mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 15:37:47 +00:00
VisualBuilder: Work on selecting a widget and moving it around.
This commit is contained in:
parent
77a77b5bf7
commit
3c8e53ef2b
6 changed files with 167 additions and 5 deletions
|
@ -1,15 +1,44 @@
|
|||
#pragma once
|
||||
|
||||
#include <SharedGraphics/Rect.h>
|
||||
#include <AK/Retainable.h>
|
||||
#include <AK/Retained.h>
|
||||
#include <AK/Weakable.h>
|
||||
|
||||
class VBWidget {
|
||||
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> {
|
||||
public:
|
||||
VBWidget();
|
||||
static Retained<VBWidget> create(VBForm& form) { return adopt(*new VBWidget(form)); }
|
||||
virtual ~VBWidget();
|
||||
|
||||
bool is_selected() const;
|
||||
|
||||
Rect rect() const { return m_rect; }
|
||||
void set_rect(const Rect& rect) { m_rect = rect; }
|
||||
|
||||
Rect grabber_rect(Direction) const;
|
||||
|
||||
void paint(GPainter&);
|
||||
|
||||
private:
|
||||
VBWidget(VBForm&);
|
||||
|
||||
VBForm& m_form;
|
||||
Rect m_rect;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue