2019-04-11 01:05:47 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <SharedGraphics/Rect.h>
|
2019-04-11 02:59:07 +03:00
|
|
|
#include <AK/Retainable.h>
|
|
|
|
#include <AK/Retained.h>
|
|
|
|
#include <AK/Weakable.h>
|
2019-04-11 01:05:47 +03:00
|
|
|
|
2019-04-11 02:59:07 +03:00
|
|
|
class GPainter;
|
|
|
|
class VBForm;
|
|
|
|
|
|
|
|
enum class Direction { None, Left, UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft };
|
|
|
|
template<typename Callback>
|
|
|
|
inline void for_each_direction(Callback callback)
|
|
|
|
{
|
|
|
|
callback(Direction::Left);
|
|
|
|
callback(Direction::UpLeft);
|
|
|
|
callback(Direction::Up);
|
|
|
|
callback(Direction::UpRight);
|
|
|
|
callback(Direction::Right);
|
|
|
|
callback(Direction::DownRight);
|
|
|
|
callback(Direction::Down);
|
|
|
|
callback(Direction::DownLeft);
|
|
|
|
}
|
|
|
|
|
|
|
|
class VBWidget : public Retainable<VBWidget>, public Weakable<VBWidget> {
|
2019-04-11 01:05:47 +03:00
|
|
|
public:
|
2019-04-11 02:59:07 +03:00
|
|
|
static Retained<VBWidget> create(VBForm& form) { return adopt(*new VBWidget(form)); }
|
2019-04-11 01:05:47 +03:00
|
|
|
virtual ~VBWidget();
|
|
|
|
|
2019-04-11 02:59:07 +03:00
|
|
|
bool is_selected() const;
|
|
|
|
|
2019-04-11 01:05:47 +03:00
|
|
|
Rect rect() const { return m_rect; }
|
|
|
|
void set_rect(const Rect& rect) { m_rect = rect; }
|
|
|
|
|
2019-04-11 02:59:07 +03:00
|
|
|
Rect grabber_rect(Direction) const;
|
|
|
|
|
|
|
|
void paint(GPainter&);
|
|
|
|
|
2019-04-11 01:05:47 +03:00
|
|
|
private:
|
2019-04-11 02:59:07 +03:00
|
|
|
VBWidget(VBForm&);
|
|
|
|
|
|
|
|
VBForm& m_form;
|
2019-04-11 01:05:47 +03:00
|
|
|
Rect m_rect;
|
|
|
|
};
|