forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HackStudio: Start fleshing out the GUI for a GUI designer :^)
I'll be reconstructing parts of the VisualBuilder application here and then we can retire VisualBuilder entirely once all the functionality is available in HackStudio.
- Loading branch information
1 parent
bce510b
commit d016d5e
Showing
9 changed files
with
136 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
main.cpp | ||
Makefile | ||
little.files | ||
test.frm |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "FormEditorWidget.h" | ||
#include "FormWidget.h" | ||
#include <LibGUI/GPainter.h> | ||
|
||
FormEditorWidget::FormEditorWidget(GWidget* parent) | ||
: GScrollableWidget(parent) | ||
{ | ||
set_fill_with_background_color(true); | ||
set_background_color(Color::White); | ||
|
||
set_frame_shape(FrameShape::Container); | ||
set_frame_shadow(FrameShadow::Sunken); | ||
set_frame_thickness(2); | ||
|
||
m_form_widget = FormWidget::construct(*this); | ||
} | ||
|
||
FormEditorWidget::~FormEditorWidget() | ||
{ | ||
} | ||
|
||
void FormEditorWidget::paint_event(GPaintEvent& event) | ||
{ | ||
GFrame::paint_event(event); | ||
|
||
GPainter painter(*this); | ||
painter.add_clip_rect(event.rect()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <LibGUI/GScrollableWidget.h> | ||
|
||
class FormWidget; | ||
|
||
class FormEditorWidget final : public GScrollableWidget { | ||
C_OBJECT(FormEditorWidget) | ||
public: | ||
virtual ~FormEditorWidget() override; | ||
|
||
private: | ||
virtual void paint_event(GPaintEvent&) override; | ||
|
||
explicit FormEditorWidget(GWidget* parent); | ||
|
||
RefPtr<FormWidget> m_form_widget; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "FormWidget.h" | ||
#include "FormEditorWidget.h" | ||
#include <LibGUI/GPainter.h> | ||
|
||
FormWidget::FormWidget(FormEditorWidget& parent) | ||
: GWidget(&parent) | ||
{ | ||
set_fill_with_background_color(true); | ||
set_background_color(Color::WarmGray); | ||
set_relative_rect(20, 20, 400, 300); | ||
} | ||
|
||
FormWidget::~FormWidget() | ||
{ | ||
} | ||
|
||
void FormWidget::paint_event(GPaintEvent& event) | ||
{ | ||
GPainter painter(*this); | ||
painter.add_clip_rect(event.rect()); | ||
|
||
for (int y = 0; y < height(); y += m_grid_size) { | ||
for (int x = 0; x < width(); x += m_grid_size) { | ||
painter.set_pixel({ x, y }, Color::from_rgb(0x404040)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <LibGUI/GWidget.h> | ||
|
||
class FormEditorWidget; | ||
|
||
class FormWidget final : public GWidget { | ||
C_OBJECT(FormWidget) | ||
public: | ||
virtual ~FormWidget() override; | ||
|
||
FormEditorWidget& editor(); | ||
const FormEditorWidget& editor() const; | ||
|
||
private: | ||
virtual void paint_event(GPaintEvent&) override; | ||
|
||
explicit FormWidget(FormEditorWidget& parent); | ||
|
||
// FIXME: This should be an app-wide preference instead. | ||
int m_grid_size { 5 }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters