summaryrefslogtreecommitdiff
path: root/DevTools/HackStudio/FormWidget.h
blob: f9b41bccee3d3a40fdadcd0fbec6f7679cea89bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include <AK/Badge.h>
#include <LibGUI/GWidget.h>

class CursorTool;
class FormEditorWidget;

class FormWidget final : public GWidget {
    C_OBJECT(FormWidget)
public:
    virtual ~FormWidget() override;

    FormEditorWidget& editor();
    const FormEditorWidget& editor() const;

    // FIXME: This should be an app-wide preference instead.
    int grid_size() const { return m_grid_size; }

    bool is_rubber_banding(Badge<CursorTool>) const { return m_rubber_banding; }
    void set_rubber_banding(Badge<CursorTool>, bool);
    void set_rubber_band_position(Badge<CursorTool>, const Point&);
    void set_rubber_band_origin(Badge<CursorTool>, const Point&);

private:
    virtual bool accepts_focus() const override { return true; }

    virtual void paint_event(GPaintEvent&) override;
    virtual void second_paint_event(GPaintEvent&) override;
    virtual void mousedown_event(GMouseEvent&) override;
    virtual void mouseup_event(GMouseEvent&) override;
    virtual void mousemove_event(GMouseEvent&) override;
    virtual void keydown_event(GKeyEvent&) override;

    explicit FormWidget(FormEditorWidget& parent);

    Rect rubber_band_rect() const;

    int m_grid_size { 5 };

    bool m_rubber_banding { false };
    Point m_rubber_band_origin;
    Point m_rubber_band_position;
};