mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
This commit is contained in:
parent
2d39da5405
commit
c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions
|
@ -30,13 +30,13 @@
|
|||
#include "WidgetTreeModel.h"
|
||||
#include <AK/LogStream.h>
|
||||
|
||||
void CursorTool::on_mousedown(GMouseEvent& event)
|
||||
void CursorTool::on_mousedown(GUI::MouseEvent& event)
|
||||
{
|
||||
dbg() << "CursorTool::on_mousedown";
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
auto result = form_widget.hit_test(event.position(), GWidget::ShouldRespectGreediness::No);
|
||||
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
||||
|
||||
if (event.button() == GMouseButton::Left) {
|
||||
if (event.button() == GUI::MouseButton::Left) {
|
||||
if (result.widget && result.widget != &form_widget) {
|
||||
if (event.modifiers() & Mod_Ctrl) {
|
||||
m_editor.selection().toggle(*result.widget);
|
||||
|
@ -65,12 +65,12 @@ void CursorTool::on_mousedown(GMouseEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void CursorTool::on_mouseup(GMouseEvent& event)
|
||||
void CursorTool::on_mouseup(GUI::MouseEvent& event)
|
||||
{
|
||||
dbg() << "CursorTool::on_mouseup";
|
||||
if (event.button() == GMouseButton::Left) {
|
||||
if (event.button() == GUI::MouseButton::Left) {
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
auto result = form_widget.hit_test(event.position(), GWidget::ShouldRespectGreediness::No);
|
||||
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
||||
if (!m_dragging && !(event.modifiers() & Mod_Ctrl)) {
|
||||
if (result.widget && result.widget != &form_widget) {
|
||||
m_editor.selection().set(*result.widget);
|
||||
|
@ -84,7 +84,7 @@ void CursorTool::on_mouseup(GMouseEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void CursorTool::on_mousemove(GMouseEvent& event)
|
||||
void CursorTool::on_mousemove(GUI::MouseEvent& event)
|
||||
{
|
||||
dbg() << "CursorTool::on_mousemove";
|
||||
auto& form_widget = m_editor.form_widget();
|
||||
|
@ -94,8 +94,8 @@ void CursorTool::on_mousemove(GMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!m_dragging && event.buttons() & GMouseButton::Left && event.position() != m_drag_origin) {
|
||||
auto result = form_widget.hit_test(event.position(), GWidget::ShouldRespectGreediness::No);
|
||||
if (!m_dragging && event.buttons() & GUI::MouseButton::Left && event.position() != m_drag_origin) {
|
||||
auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No);
|
||||
if (result.widget && result.widget != &form_widget) {
|
||||
if (!m_editor.selection().contains(*result.widget)) {
|
||||
m_editor.selection().set(*result.widget);
|
||||
|
@ -121,7 +121,7 @@ void CursorTool::on_mousemove(GMouseEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void CursorTool::on_keydown(GKeyEvent& event)
|
||||
void CursorTool::on_keydown(GUI::KeyEvent& event)
|
||||
{
|
||||
dbg() << "CursorTool::on_keydown";
|
||||
|
||||
|
@ -175,7 +175,7 @@ Rect CursorTool::rubber_band_rect() const
|
|||
return Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position);
|
||||
}
|
||||
|
||||
void CursorTool::on_second_paint(GPainter& painter, GPaintEvent&)
|
||||
void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&)
|
||||
{
|
||||
if (!m_rubber_banding)
|
||||
return;
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <LibDraw/Point.h>
|
||||
|
||||
class GWidget;
|
||||
namespace GUI {
|
||||
class Widget;
|
||||
}
|
||||
|
||||
class CursorTool final : public Tool {
|
||||
public:
|
||||
|
@ -42,17 +44,17 @@ public:
|
|||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "CursorTool"; }
|
||||
virtual void on_mousedown(GMouseEvent&) override;
|
||||
virtual void on_mouseup(GMouseEvent&) override;
|
||||
virtual void on_mousemove(GMouseEvent&) override;
|
||||
virtual void on_keydown(GKeyEvent&) override;
|
||||
virtual void on_second_paint(GPainter&, GPaintEvent&) override;
|
||||
virtual void on_mousedown(GUI::MouseEvent&) override;
|
||||
virtual void on_mouseup(GUI::MouseEvent&) override;
|
||||
virtual void on_mousemove(GUI::MouseEvent&) override;
|
||||
virtual void on_keydown(GUI::KeyEvent&) override;
|
||||
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) override;
|
||||
|
||||
void set_rubber_band_position(const Point&);
|
||||
Rect rubber_band_rect() const;
|
||||
|
||||
Point m_drag_origin;
|
||||
HashMap<GWidget*, Point> m_positions_before_drag;
|
||||
HashMap<GUI::Widget*, Point> m_positions_before_drag;
|
||||
bool m_dragging { false };
|
||||
|
||||
bool m_rubber_banding { false };
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
|
||||
//#define EDITOR_DEBUG
|
||||
|
||||
Editor::Editor(GWidget* parent)
|
||||
: GTextEditor(GTextEditor::MultiLine, parent)
|
||||
Editor::Editor(GUI::Widget* parent)
|
||||
: TextEditor(GUI::TextEditor::MultiLine, parent)
|
||||
{
|
||||
m_documentation_tooltip_window = GWindow::construct();
|
||||
m_documentation_tooltip_window = GUI::Window::construct();
|
||||
m_documentation_tooltip_window->set_rect(0, 0, 500, 400);
|
||||
m_documentation_tooltip_window->set_window_type(GWindowType::Tooltip);
|
||||
m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip);
|
||||
|
||||
m_documentation_html_view = HtmlView::construct(nullptr);
|
||||
m_documentation_tooltip_window->set_main_widget(m_documentation_html_view);
|
||||
|
@ -72,21 +72,21 @@ void Editor::focusin_event(Core::Event& event)
|
|||
wrapper().set_editor_has_focus({}, true);
|
||||
if (on_focus)
|
||||
on_focus();
|
||||
GTextEditor::focusin_event(event);
|
||||
GUI::TextEditor::focusin_event(event);
|
||||
}
|
||||
|
||||
void Editor::focusout_event(Core::Event& event)
|
||||
{
|
||||
wrapper().set_editor_has_focus({}, false);
|
||||
GTextEditor::focusout_event(event);
|
||||
GUI::TextEditor::focusout_event(event);
|
||||
}
|
||||
|
||||
void Editor::paint_event(GPaintEvent& event)
|
||||
void Editor::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GTextEditor::paint_event(event);
|
||||
GUI::TextEditor::paint_event(event);
|
||||
|
||||
if (is_focused()) {
|
||||
GPainter painter(*this);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
auto rect = frame_inner_rect();
|
||||
|
@ -170,16 +170,16 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token
|
|||
m_last_parsed_token = hovered_token;
|
||||
}
|
||||
|
||||
void Editor::mousemove_event(GMouseEvent& event)
|
||||
void Editor::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
GTextEditor::mousemove_event(event);
|
||||
GUI::TextEditor::mousemove_event(event);
|
||||
|
||||
if (document().spans().is_empty())
|
||||
return;
|
||||
|
||||
auto text_position = text_position_at(event.position());
|
||||
if (!text_position.is_valid()) {
|
||||
GApplication::the().hide_tooltip();
|
||||
GUI::Application::the().hide_tooltip();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ void Editor::mousemove_event(GMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
}
|
||||
GApplication::the().hide_tooltip();
|
||||
GUI::Application::the().hide_tooltip();
|
||||
}
|
||||
|
||||
void Editor::highlight_matching_token_pair()
|
||||
|
@ -222,8 +222,8 @@ void Editor::highlight_matching_token_pair()
|
|||
};
|
||||
|
||||
auto make_buddies = [&](int index0, int index1) {
|
||||
auto& buddy0 = const_cast<GTextDocumentSpan&>(document().spans()[index0]);
|
||||
auto& buddy1 = const_cast<GTextDocumentSpan&>(document().spans()[index1]);
|
||||
auto& buddy0 = const_cast<GUI::TextDocumentSpan&>(document().spans()[index0]);
|
||||
auto& buddy1 = const_cast<GUI::TextDocumentSpan&>(document().spans()[index1]);
|
||||
m_has_brace_buddies = true;
|
||||
m_brace_buddies[0].index = index0;
|
||||
m_brace_buddies[1].index = index1;
|
||||
|
@ -248,7 +248,7 @@ void Editor::highlight_matching_token_pair()
|
|||
};
|
||||
|
||||
for (int i = 0; i < document().spans().size(); ++i) {
|
||||
auto& span = const_cast<GTextDocumentSpan&>(document().spans().at(i));
|
||||
auto& span = const_cast<GUI::TextDocumentSpan&>(document().spans().at(i));
|
||||
auto token_type = (CppToken::Type)((uintptr_t)span.data);
|
||||
|
||||
for (auto& pair : pairs) {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
class EditorWrapper;
|
||||
class HtmlView;
|
||||
|
||||
class Editor final : public GTextEditor {
|
||||
class Editor final : public GUI::TextEditor {
|
||||
C_OBJECT(Editor)
|
||||
public:
|
||||
virtual ~Editor() override;
|
||||
|
@ -46,22 +46,22 @@ public:
|
|||
private:
|
||||
virtual void focusin_event(Core::Event&) override;
|
||||
virtual void focusout_event(Core::Event&) override;
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void cursor_did_change() override;
|
||||
|
||||
void show_documentation_tooltip_if_available(const String&, const Point& screen_location);
|
||||
void highlight_matching_token_pair();
|
||||
|
||||
explicit Editor(GWidget* parent);
|
||||
explicit Editor(GUI::Widget* parent);
|
||||
|
||||
RefPtr<GWindow> m_documentation_tooltip_window;
|
||||
RefPtr<GUI::Window> m_documentation_tooltip_window;
|
||||
RefPtr<HtmlView> m_documentation_html_view;
|
||||
String m_last_parsed_token;
|
||||
|
||||
struct BuddySpan {
|
||||
int index { -1 };
|
||||
GTextDocumentSpan span_backup;
|
||||
GUI::TextDocumentSpan span_backup;
|
||||
};
|
||||
|
||||
bool m_has_brace_buddies { false };
|
||||
|
|
|
@ -33,26 +33,26 @@
|
|||
|
||||
extern RefPtr<EditorWrapper> g_current_editor_wrapper;
|
||||
|
||||
EditorWrapper::EditorWrapper(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
EditorWrapper::EditorWrapper(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
{
|
||||
set_layout(make<GVBoxLayout>());
|
||||
set_layout(make<GUI::VBoxLayout>());
|
||||
|
||||
auto label_wrapper = GWidget::construct(this);
|
||||
label_wrapper->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
auto label_wrapper = GUI::Widget::construct(this);
|
||||
label_wrapper->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
label_wrapper->set_preferred_size(0, 14);
|
||||
label_wrapper->set_fill_with_background_color(true);
|
||||
label_wrapper->set_layout(make<GHBoxLayout>());
|
||||
label_wrapper->set_layout(make<GUI::HBoxLayout>());
|
||||
label_wrapper->layout()->set_margins({ 2, 0, 2, 0 });
|
||||
|
||||
m_filename_label = GLabel::construct("(Untitled)", label_wrapper);
|
||||
m_filename_label = GUI::Label::construct("(Untitled)", label_wrapper);
|
||||
m_filename_label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
m_filename_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_filename_label->set_preferred_size(0, 14);
|
||||
|
||||
m_cursor_label = GLabel::construct("(Cursor)", label_wrapper);
|
||||
m_cursor_label = GUI::Label::construct("(Cursor)", label_wrapper);
|
||||
m_cursor_label->set_text_alignment(TextAlignment::CenterRight);
|
||||
m_cursor_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_cursor_label->set_preferred_size(0, 14);
|
||||
|
||||
m_editor = Editor::construct(this);
|
||||
|
|
|
@ -28,10 +28,13 @@
|
|||
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class GLabel;
|
||||
namespace GUI {
|
||||
class Label;
|
||||
}
|
||||
|
||||
class Editor;
|
||||
|
||||
class EditorWrapper : public GWidget {
|
||||
class EditorWrapper : public GUI::Widget {
|
||||
C_OBJECT(EditorWrapper)
|
||||
public:
|
||||
virtual ~EditorWrapper() override;
|
||||
|
@ -39,15 +42,15 @@ public:
|
|||
Editor& editor() { return *m_editor; }
|
||||
const Editor& editor() const { return *m_editor; }
|
||||
|
||||
GLabel& filename_label() { return *m_filename_label; }
|
||||
GUI::Label& filename_label() { return *m_filename_label; }
|
||||
|
||||
void set_editor_has_focus(Badge<Editor>, bool);
|
||||
|
||||
private:
|
||||
explicit EditorWrapper(GWidget* parent = nullptr);
|
||||
explicit EditorWrapper(GUI::Widget* parent = nullptr);
|
||||
|
||||
RefPtr<GLabel> m_filename_label;
|
||||
RefPtr<GLabel> m_cursor_label;
|
||||
RefPtr<GUI::Label> m_filename_label;
|
||||
RefPtr<GUI::Label> m_cursor_label;
|
||||
RefPtr<Editor> m_editor;
|
||||
};
|
||||
|
||||
|
|
|
@ -32,17 +32,17 @@
|
|||
#include <LibGUI/GTableView.h>
|
||||
#include <LibGUI/GTextBox.h>
|
||||
|
||||
extern GTextEditor& current_editor();
|
||||
extern GUI::TextEditor& current_editor();
|
||||
extern void open_file(const String&);
|
||||
extern OwnPtr<Project> g_project;
|
||||
|
||||
struct Match {
|
||||
String filename;
|
||||
GTextRange range;
|
||||
GUI::TextRange range;
|
||||
String text;
|
||||
};
|
||||
|
||||
class SearchResultsModel final : public GModel {
|
||||
class SearchResultsModel final : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
Filename,
|
||||
|
@ -56,8 +56,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual int row_count(const GModelIndex& = GModelIndex()) const override { return m_matches.size(); }
|
||||
virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; }
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_matches.size(); }
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||
|
||||
virtual String column_name(int column) const override
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override
|
||||
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
|
||||
{
|
||||
if (role == Role::Display) {
|
||||
auto& match = m_matches.at(index.row());
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
}
|
||||
|
||||
virtual void update() override {}
|
||||
virtual GModelIndex index(int row, int column = 0, const GModelIndex& = GModelIndex()) const override { return create_index(row, column, &m_matches.at(row)); }
|
||||
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override { return create_index(row, column, &m_matches.at(row)); }
|
||||
|
||||
private:
|
||||
Vector<Match> m_matches;
|
||||
|
@ -127,18 +127,18 @@ static RefPtr<SearchResultsModel> find_in_files(const StringView& text)
|
|||
return adopt(*new SearchResultsModel(move(matches)));
|
||||
}
|
||||
|
||||
FindInFilesWidget::FindInFilesWidget(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
FindInFilesWidget::FindInFilesWidget(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
{
|
||||
set_layout(make<GVBoxLayout>());
|
||||
m_textbox = GTextBox::construct(this);
|
||||
m_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_layout(make<GUI::VBoxLayout>());
|
||||
m_textbox = GUI::TextBox::construct(this);
|
||||
m_textbox->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_textbox->set_preferred_size(0, 20);
|
||||
m_button = GButton::construct("Find in files", this);
|
||||
m_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_button = GUI::Button::construct("Find in files", this);
|
||||
m_button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_button->set_preferred_size(0, 20);
|
||||
|
||||
m_result_view = GTableView::construct(this);
|
||||
m_result_view = GUI::TableView::construct(this);
|
||||
m_result_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
m_result_view->on_activation = [](auto& index) {
|
||||
|
|
|
@ -28,11 +28,13 @@
|
|||
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class GButton;
|
||||
class GTableView;
|
||||
class GTextBox;
|
||||
namespace GUI {
|
||||
class Button;
|
||||
class TableView;
|
||||
class TextBox;
|
||||
}
|
||||
|
||||
class FindInFilesWidget final : public GWidget {
|
||||
class FindInFilesWidget final : public GUI::Widget {
|
||||
C_OBJECT(FindInFilesWidget)
|
||||
public:
|
||||
virtual ~FindInFilesWidget() override {}
|
||||
|
@ -40,9 +42,9 @@ public:
|
|||
void focus_textbox_and_select_all();
|
||||
|
||||
private:
|
||||
explicit FindInFilesWidget(GWidget* parent);
|
||||
explicit FindInFilesWidget(GUI::Widget* parent);
|
||||
|
||||
RefPtr<GTextBox> m_textbox;
|
||||
RefPtr<GButton> m_button;
|
||||
RefPtr<GTableView> m_result_view;
|
||||
RefPtr<GUI::TextBox> m_textbox;
|
||||
RefPtr<GUI::Button> m_button;
|
||||
RefPtr<GUI::TableView> m_result_view;
|
||||
};
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
#include "WidgetTreeModel.h"
|
||||
#include <LibGUI/GPainter.h>
|
||||
|
||||
FormEditorWidget::FormEditorWidget(GWidget* parent)
|
||||
: GScrollableWidget(parent)
|
||||
FormEditorWidget::FormEditorWidget(GUI::Widget* parent)
|
||||
: ScrollableWidget(parent)
|
||||
, m_tool(make<CursorTool>(*this))
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
|
@ -49,11 +49,11 @@ FormEditorWidget::~FormEditorWidget()
|
|||
{
|
||||
}
|
||||
|
||||
void FormEditorWidget::paint_event(GPaintEvent& event)
|
||||
void FormEditorWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GFrame::paint_event(event);
|
||||
GUI::Frame::paint_event(event);
|
||||
|
||||
GPainter painter(*this);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class FormWidget;
|
|||
class Tool;
|
||||
class WidgetTreeModel;
|
||||
|
||||
class FormEditorWidget final : public GScrollableWidget {
|
||||
class FormEditorWidget final : public GUI::ScrollableWidget {
|
||||
C_OBJECT(FormEditorWidget)
|
||||
public:
|
||||
virtual ~FormEditorWidget() override;
|
||||
|
@ -49,8 +49,8 @@ public:
|
|||
|
||||
class WidgetSelection {
|
||||
public:
|
||||
Function<void(GWidget&)> on_remove;
|
||||
Function<void(GWidget&)> on_add;
|
||||
Function<void(GUI::Widget&)> on_remove;
|
||||
Function<void(GUI::Widget&)> on_add;
|
||||
Function<void()> on_clear;
|
||||
|
||||
void enable_hooks() { m_hooks_enabled = true; }
|
||||
|
@ -61,12 +61,12 @@ public:
|
|||
return m_widgets.is_empty();
|
||||
}
|
||||
|
||||
bool contains(GWidget& widget) const
|
||||
bool contains(GUI::Widget& widget) const
|
||||
{
|
||||
return m_widgets.contains(&widget);
|
||||
}
|
||||
|
||||
void toggle(GWidget& widget)
|
||||
void toggle(GUI::Widget& widget)
|
||||
{
|
||||
if (contains(widget))
|
||||
remove(widget);
|
||||
|
@ -74,13 +74,13 @@ public:
|
|||
add(widget);
|
||||
}
|
||||
|
||||
void set(GWidget& widget)
|
||||
void set(GUI::Widget& widget)
|
||||
{
|
||||
clear();
|
||||
add(widget);
|
||||
}
|
||||
|
||||
void remove(GWidget& widget)
|
||||
void remove(GUI::Widget& widget)
|
||||
{
|
||||
ASSERT(m_widgets.contains(&widget));
|
||||
m_widgets.remove(&widget);
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
on_remove(widget);
|
||||
}
|
||||
|
||||
void add(GWidget& widget)
|
||||
void add(GUI::Widget& widget)
|
||||
{
|
||||
m_widgets.set(&widget);
|
||||
if (m_hooks_enabled && on_add)
|
||||
|
@ -114,16 +114,16 @@ public:
|
|||
WidgetSelection() {}
|
||||
|
||||
private:
|
||||
HashTable<GWidget*> m_widgets;
|
||||
HashTable<GUI::Widget*> m_widgets;
|
||||
bool m_hooks_enabled { true };
|
||||
};
|
||||
|
||||
WidgetSelection& selection() { return m_selection; }
|
||||
|
||||
private:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
|
||||
explicit FormEditorWidget(GWidget* parent);
|
||||
explicit FormEditorWidget(GUI::Widget* parent);
|
||||
|
||||
RefPtr<FormWidget> m_form_widget;
|
||||
RefPtr<WidgetTreeModel> m_widget_tree_model;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <LibGUI/GPainter.h>
|
||||
|
||||
FormWidget::FormWidget(FormEditorWidget& parent)
|
||||
: GWidget(&parent)
|
||||
: GUI::Widget(&parent)
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
set_relative_rect(5, 5, 400, 300);
|
||||
|
@ -52,9 +52,9 @@ const FormEditorWidget& FormWidget::editor() const
|
|||
return static_cast<const FormEditorWidget&>(*parent());
|
||||
}
|
||||
|
||||
void FormWidget::paint_event(GPaintEvent& event)
|
||||
void FormWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
for (int y = 0; y < height(); y += m_grid_size) {
|
||||
|
@ -64,9 +64,9 @@ void FormWidget::paint_event(GPaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void FormWidget::second_paint_event(GPaintEvent& event)
|
||||
void FormWidget::second_paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
if (!editor().selection().is_empty()) {
|
||||
|
@ -81,22 +81,22 @@ void FormWidget::second_paint_event(GPaintEvent& event)
|
|||
editor().tool().on_second_paint(painter, event);
|
||||
}
|
||||
|
||||
void FormWidget::mousedown_event(GMouseEvent& event)
|
||||
void FormWidget::mousedown_event(GUI::MouseEvent& event)
|
||||
{
|
||||
editor().tool().on_mousedown(event);
|
||||
}
|
||||
|
||||
void FormWidget::mouseup_event(GMouseEvent& event)
|
||||
void FormWidget::mouseup_event(GUI::MouseEvent& event)
|
||||
{
|
||||
editor().tool().on_mouseup(event);
|
||||
}
|
||||
|
||||
void FormWidget::mousemove_event(GMouseEvent& event)
|
||||
void FormWidget::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
editor().tool().on_mousemove(event);
|
||||
}
|
||||
|
||||
void FormWidget::keydown_event(GKeyEvent& event)
|
||||
void FormWidget::keydown_event(GUI::KeyEvent& event)
|
||||
{
|
||||
editor().tool().on_keydown(event);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
class CursorTool;
|
||||
class FormEditorWidget;
|
||||
|
||||
class FormWidget final : public GWidget {
|
||||
class FormWidget final : public GUI::Widget {
|
||||
C_OBJECT(FormWidget)
|
||||
public:
|
||||
virtual ~FormWidget() override;
|
||||
|
@ -46,12 +46,12 @@ public:
|
|||
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;
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void second_paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
|
||||
explicit FormWidget(FormEditorWidget& parent);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ static RefPtr<GraphicsBitmap> s_file_icon;
|
|||
static RefPtr<GraphicsBitmap> s_cplusplus_icon;
|
||||
static RefPtr<GraphicsBitmap> s_header_icon;
|
||||
|
||||
class LocatorSuggestionModel final : public GModel {
|
||||
class LocatorSuggestionModel final : public GUI::Model {
|
||||
public:
|
||||
explicit LocatorSuggestionModel(Vector<String>&& suggestions)
|
||||
: m_suggestions(move(suggestions))
|
||||
|
@ -49,9 +49,9 @@ public:
|
|||
Name,
|
||||
__Column_Count,
|
||||
};
|
||||
virtual int row_count(const GModelIndex& = GModelIndex()) const override { return m_suggestions.size(); }
|
||||
virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Column_Count; }
|
||||
virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_suggestions.size(); }
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Column_Count; }
|
||||
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
|
||||
{
|
||||
auto& suggestion = m_suggestions.at(index.row());
|
||||
if (role == Role::Display) {
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
Vector<String> m_suggestions;
|
||||
};
|
||||
|
||||
class LocatorTextBox final : public GTextBox {
|
||||
class LocatorTextBox final : public GUI::TextBox {
|
||||
C_OBJECT(LocatorTextBox)
|
||||
public:
|
||||
virtual ~LocatorTextBox() override {}
|
||||
|
@ -81,25 +81,25 @@ public:
|
|||
Function<void()> on_up;
|
||||
Function<void()> on_down;
|
||||
|
||||
virtual void keydown_event(GKeyEvent& event) override
|
||||
virtual void keydown_event(GUI::KeyEvent& event) override
|
||||
{
|
||||
if (event.key() == Key_Up)
|
||||
on_up();
|
||||
else if (event.key() == Key_Down)
|
||||
on_down();
|
||||
|
||||
GTextBox::keydown_event(event);
|
||||
GUI::TextBox::keydown_event(event);
|
||||
}
|
||||
|
||||
private:
|
||||
LocatorTextBox(GWidget* parent)
|
||||
: GTextBox(parent)
|
||||
LocatorTextBox(GUI::Widget* parent)
|
||||
: GUI::TextBox(parent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Locator::Locator(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
Locator::Locator(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
{
|
||||
if (!s_cplusplus_icon) {
|
||||
s_file_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
|
||||
|
@ -107,8 +107,8 @@ Locator::Locator(GWidget* parent)
|
|||
s_header_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png");
|
||||
}
|
||||
|
||||
set_layout(make<GVBoxLayout>());
|
||||
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_layout(make<GUI::VBoxLayout>());
|
||||
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
set_preferred_size(0, 20);
|
||||
m_textbox = LocatorTextBox::construct(this);
|
||||
m_textbox->on_change = [this] {
|
||||
|
@ -118,7 +118,7 @@ Locator::Locator(GWidget* parent)
|
|||
m_popup_window->hide();
|
||||
};
|
||||
m_textbox->on_up = [this] {
|
||||
GModelIndex new_index = m_suggestion_view->selection().first();
|
||||
GUI::ModelIndex new_index = m_suggestion_view->selection().first();
|
||||
if (new_index.is_valid())
|
||||
new_index = m_suggestion_view->model()->index(new_index.row() - 1);
|
||||
else
|
||||
|
@ -130,7 +130,7 @@ Locator::Locator(GWidget* parent)
|
|||
}
|
||||
};
|
||||
m_textbox->on_down = [this] {
|
||||
GModelIndex new_index = m_suggestion_view->selection().first();
|
||||
GUI::ModelIndex new_index = m_suggestion_view->selection().first();
|
||||
if (new_index.is_valid())
|
||||
new_index = m_suggestion_view->model()->index(new_index.row() + 1);
|
||||
else
|
||||
|
@ -149,12 +149,12 @@ Locator::Locator(GWidget* parent)
|
|||
open_suggestion(selected_index);
|
||||
};
|
||||
|
||||
m_popup_window = GWindow::construct();
|
||||
m_popup_window = GUI::Window::construct();
|
||||
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
|
||||
m_popup_window->set_window_type(GWindowType::Tooltip);
|
||||
m_popup_window->set_window_type(GUI::WindowType::Tooltip);
|
||||
m_popup_window->set_rect(0, 0, 500, 200);
|
||||
|
||||
m_suggestion_view = GTableView::construct(nullptr);
|
||||
m_suggestion_view = GUI::TableView::construct(nullptr);
|
||||
m_suggestion_view->set_size_columns_to_fit_content(true);
|
||||
m_suggestion_view->set_headers_visible(false);
|
||||
m_popup_window->set_main_widget(m_suggestion_view);
|
||||
|
@ -168,10 +168,10 @@ Locator::~Locator()
|
|||
{
|
||||
}
|
||||
|
||||
void Locator::open_suggestion(const GModelIndex& index)
|
||||
void Locator::open_suggestion(const GUI::ModelIndex& index)
|
||||
{
|
||||
auto filename_index = m_suggestion_view->model()->index(index.row(), LocatorSuggestionModel::Column::Name);
|
||||
auto filename = m_suggestion_view->model()->data(filename_index, GModel::Role::Display).to_string();
|
||||
auto filename = m_suggestion_view->model()->data(filename_index, GUI::Model::Role::Display).to_string();
|
||||
open_file(filename);
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -28,11 +28,14 @@
|
|||
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class LocatorTextBox;
|
||||
class GModelIndex;
|
||||
class GTableView;
|
||||
namespace GUI {
|
||||
class ModelIndex;
|
||||
class TableView;
|
||||
}
|
||||
|
||||
class Locator final : public GWidget {
|
||||
class LocatorTextBox;
|
||||
|
||||
class Locator final : public GUI::Widget {
|
||||
C_OBJECT(Locator)
|
||||
public:
|
||||
virtual ~Locator() override;
|
||||
|
@ -42,11 +45,11 @@ public:
|
|||
|
||||
private:
|
||||
void update_suggestions();
|
||||
void open_suggestion(const GModelIndex&);
|
||||
void open_suggestion(const GUI::ModelIndex&);
|
||||
|
||||
explicit Locator(GWidget* parent);
|
||||
explicit Locator(GUI::Widget* parent);
|
||||
|
||||
RefPtr<LocatorTextBox> m_textbox;
|
||||
RefPtr<GWindow> m_popup_window;
|
||||
RefPtr<GTableView> m_suggestion_view;
|
||||
RefPtr<GUI::Window> m_popup_window;
|
||||
RefPtr<GUI::TableView> m_suggestion_view;
|
||||
};
|
||||
|
|
|
@ -31,31 +31,31 @@
|
|||
#include <LibGUI/GLabel.h>
|
||||
#include <unistd.h>
|
||||
|
||||
ProcessStateWidget::ProcessStateWidget(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
ProcessStateWidget::ProcessStateWidget(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
{
|
||||
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
set_preferred_size(0, 20);
|
||||
set_visible(false);
|
||||
|
||||
set_layout(make<GHBoxLayout>());
|
||||
set_layout(make<GUI::HBoxLayout>());
|
||||
|
||||
auto pid_label_label = GLabel::construct("Process:", this);
|
||||
auto pid_label_label = GUI::Label::construct("Process:", this);
|
||||
pid_label_label->set_font(Font::default_bold_font());
|
||||
m_pid_label = GLabel::construct("", this);
|
||||
m_pid_label = GUI::Label::construct("", this);
|
||||
|
||||
auto state_label_label = GLabel::construct("State:", this);
|
||||
auto state_label_label = GUI::Label::construct("State:", this);
|
||||
state_label_label->set_font(Font::default_bold_font());
|
||||
m_state_label = GLabel::construct("", this);
|
||||
m_state_label = GUI::Label::construct("", this);
|
||||
|
||||
// FIXME: This should show CPU% instead.
|
||||
auto cpu_label_label = GLabel::construct("Times scheduled:", this);
|
||||
auto cpu_label_label = GUI::Label::construct("Times scheduled:", this);
|
||||
cpu_label_label->set_font(Font::default_bold_font());
|
||||
m_cpu_label = GLabel::construct("", this);
|
||||
m_cpu_label = GUI::Label::construct("", this);
|
||||
|
||||
auto memory_label_label = GLabel::construct("Memory (resident):", this);
|
||||
auto memory_label_label = GUI::Label::construct("Memory (resident):", this);
|
||||
memory_label_label->set_font(Font::default_bold_font());
|
||||
m_memory_label = GLabel::construct("", this);
|
||||
m_memory_label = GUI::Label::construct("", this);
|
||||
|
||||
m_timer = Core::Timer::construct(500, [this] {
|
||||
refresh();
|
||||
|
|
|
@ -31,10 +31,11 @@
|
|||
namespace Core {
|
||||
class Timer;
|
||||
}
|
||||
namespace GUI {
|
||||
class Label;
|
||||
}
|
||||
|
||||
class GLabel;
|
||||
|
||||
class ProcessStateWidget final : public GWidget {
|
||||
class ProcessStateWidget final : public GUI::Widget {
|
||||
C_OBJECT(ProcessStateWidget)
|
||||
public:
|
||||
virtual ~ProcessStateWidget() override;
|
||||
|
@ -42,14 +43,14 @@ public:
|
|||
void set_tty_fd(int);
|
||||
|
||||
private:
|
||||
explicit ProcessStateWidget(GWidget* parent);
|
||||
explicit ProcessStateWidget(GUI::Widget* parent);
|
||||
|
||||
void refresh();
|
||||
|
||||
RefPtr<GLabel> m_pid_label;
|
||||
RefPtr<GLabel> m_state_label;
|
||||
RefPtr<GLabel> m_cpu_label;
|
||||
RefPtr<GLabel> m_memory_label;
|
||||
RefPtr<GUI::Label> m_pid_label;
|
||||
RefPtr<GUI::Label> m_state_label;
|
||||
RefPtr<GUI::Label> m_cpu_label;
|
||||
RefPtr<GUI::Label> m_memory_label;
|
||||
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
|
||||
|
|
|
@ -74,14 +74,14 @@ struct Project::ProjectTreeNode : public RefCounted<ProjectTreeNode> {
|
|||
ProjectTreeNode* parent { nullptr };
|
||||
};
|
||||
|
||||
class ProjectModel final : public GModel {
|
||||
class ProjectModel final : public GUI::Model {
|
||||
public:
|
||||
explicit ProjectModel(Project& project)
|
||||
: m_project(project)
|
||||
{
|
||||
}
|
||||
|
||||
virtual int row_count(const GModelIndex& index) const override
|
||||
virtual int row_count(const GUI::ModelIndex& index) const override
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return 1;
|
||||
|
@ -89,12 +89,12 @@ public:
|
|||
return node->children.size();
|
||||
}
|
||||
|
||||
virtual int column_count(const GModelIndex&) const override
|
||||
virtual int column_count(const GUI::ModelIndex&) const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override
|
||||
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
|
||||
{
|
||||
auto* node = static_cast<Project::ProjectTreeNode*>(index.internal_data());
|
||||
if (role == Role::Display) {
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
virtual GModelIndex index(int row, int column = 0, const GModelIndex& parent = GModelIndex()) const override
|
||||
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override
|
||||
{
|
||||
if (!parent.is_valid()) {
|
||||
return create_index(row, column, &m_project.root_node());
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
return create_index(row, column, node.children.at(row).ptr());
|
||||
}
|
||||
|
||||
GModelIndex parent_index(const GModelIndex& index) const override
|
||||
GUI::ModelIndex parent_index(const GUI::ModelIndex& index) const override
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
ProjectFile* get_file(const String& filename);
|
||||
|
||||
GModel& model() { return *m_model; }
|
||||
GUI::Model& model() { return *m_model; }
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_text_file(Callback callback) const
|
||||
|
@ -67,7 +67,7 @@ private:
|
|||
|
||||
String m_name;
|
||||
String m_path;
|
||||
RefPtr<GModel> m_model;
|
||||
RefPtr<GUI::Model> m_model;
|
||||
NonnullRefPtrVector<ProjectFile> m_files;
|
||||
RefPtr<ProjectTreeNode> m_root_node;
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
#include <LibCore/CFile.h>
|
||||
#include <string.h>
|
||||
|
||||
const GTextDocument& ProjectFile::document() const
|
||||
const GUI::TextDocument& ProjectFile::document() const
|
||||
{
|
||||
if (!m_document) {
|
||||
m_document = GTextDocument::create(nullptr);
|
||||
m_document = GUI::TextDocument::create(nullptr);
|
||||
auto file = Core::File::construct(m_name);
|
||||
if (!file->open(Core::File::ReadOnly)) {
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
const String& name() const { return m_name; }
|
||||
|
||||
const GTextDocument& document() const;
|
||||
const GUI::TextDocument& document() const;
|
||||
|
||||
private:
|
||||
explicit ProjectFile(const String& name)
|
||||
|
@ -50,5 +50,5 @@ private:
|
|||
}
|
||||
|
||||
String m_name;
|
||||
mutable RefPtr<GTextDocument> m_document;
|
||||
mutable RefPtr<GUI::TextDocument> m_document;
|
||||
};
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
void TerminalWrapper::run_command(const String& command)
|
||||
{
|
||||
if (m_pid != -1) {
|
||||
GMessageBox::show(
|
||||
GUI::MessageBox::show(
|
||||
"A command is already running in this TerminalWrapper",
|
||||
"Can't run command",
|
||||
GMessageBox::Type::Error,
|
||||
GMessageBox::InputType::OK,
|
||||
GUI::MessageBox::Type::Error,
|
||||
GUI::MessageBox::InputType::OK,
|
||||
window());
|
||||
return;
|
||||
}
|
||||
|
@ -158,10 +158,10 @@ void TerminalWrapper::kill_running_command()
|
|||
(void)killpg(m_pid, SIGTERM);
|
||||
}
|
||||
|
||||
TerminalWrapper::TerminalWrapper(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
TerminalWrapper::TerminalWrapper(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
{
|
||||
set_layout(make<GVBoxLayout>());
|
||||
set_layout(make<GUI::VBoxLayout>());
|
||||
|
||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal");
|
||||
m_terminal_widget = TerminalWidget::construct(-1, false, config);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
class ProcessStateWidget;
|
||||
class TerminalWidget;
|
||||
|
||||
class TerminalWrapper final : public GWidget {
|
||||
class TerminalWrapper final : public GUI::Widget {
|
||||
C_OBJECT(TerminalWrapper)
|
||||
public:
|
||||
virtual ~TerminalWrapper() override;
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
Function<void()> on_command_exit;
|
||||
|
||||
private:
|
||||
explicit TerminalWrapper(GWidget* parent);
|
||||
explicit TerminalWrapper(GUI::Widget* parent);
|
||||
|
||||
RefPtr<ProcessStateWidget> m_process_state_widget;
|
||||
RefPtr<TerminalWidget> m_terminal_widget;
|
||||
|
|
|
@ -29,10 +29,13 @@
|
|||
#include <AK/Noncopyable.h>
|
||||
|
||||
class FormEditorWidget;
|
||||
class GKeyEvent;
|
||||
class GMouseEvent;
|
||||
class GPaintEvent;
|
||||
class GPainter;
|
||||
|
||||
namespace GUI {
|
||||
class KeyEvent;
|
||||
class MouseEvent;
|
||||
class PaintEvent;
|
||||
class Painter;
|
||||
}
|
||||
|
||||
class Tool {
|
||||
AK_MAKE_NONCOPYABLE(Tool)
|
||||
|
@ -40,11 +43,11 @@ class Tool {
|
|||
public:
|
||||
virtual ~Tool() {}
|
||||
|
||||
virtual void on_mousedown(GMouseEvent&) = 0;
|
||||
virtual void on_mouseup(GMouseEvent&) = 0;
|
||||
virtual void on_mousemove(GMouseEvent&) = 0;
|
||||
virtual void on_keydown(GKeyEvent&) = 0;
|
||||
virtual void on_second_paint(GPainter&, GPaintEvent&) {}
|
||||
virtual void on_mousedown(GUI::MouseEvent&) = 0;
|
||||
virtual void on_mouseup(GUI::MouseEvent&) = 0;
|
||||
virtual void on_mousemove(GUI::MouseEvent&) = 0;
|
||||
virtual void on_keydown(GUI::KeyEvent&) = 0;
|
||||
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) {}
|
||||
|
||||
virtual const char* class_name() const = 0;
|
||||
|
||||
|
|
|
@ -27,25 +27,25 @@
|
|||
#include "WidgetTool.h"
|
||||
#include <AK/LogStream.h>
|
||||
|
||||
void WidgetTool::on_mousedown(GMouseEvent& event)
|
||||
void WidgetTool::on_mousedown(GUI::MouseEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
dbg() << "WidgetTool::on_mousedown";
|
||||
}
|
||||
|
||||
void WidgetTool::on_mouseup(GMouseEvent& event)
|
||||
void WidgetTool::on_mouseup(GUI::MouseEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
dbg() << "WidgetTool::on_mouseup";
|
||||
}
|
||||
|
||||
void WidgetTool::on_mousemove(GMouseEvent& event)
|
||||
void WidgetTool::on_mousemove(GUI::MouseEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
dbg() << "WidgetTool::on_mousemove";
|
||||
}
|
||||
|
||||
void WidgetTool::on_keydown(GKeyEvent& event)
|
||||
void WidgetTool::on_keydown(GUI::KeyEvent& event)
|
||||
{
|
||||
(void)event;
|
||||
dbg() << "WidgetTool::on_keydown";
|
||||
|
|
|
@ -28,11 +28,13 @@
|
|||
|
||||
#include "Tool.h"
|
||||
|
||||
class GWidgetClassRegistration;
|
||||
namespace GUI {
|
||||
class WidgetClassRegistration;
|
||||
}
|
||||
|
||||
class WidgetTool final : public Tool {
|
||||
public:
|
||||
explicit WidgetTool(FormEditorWidget& editor, const GWidgetClassRegistration& meta_class)
|
||||
explicit WidgetTool(FormEditorWidget& editor, const GUI::WidgetClassRegistration& meta_class)
|
||||
: Tool(editor)
|
||||
, m_meta_class(meta_class)
|
||||
{
|
||||
|
@ -41,10 +43,10 @@ public:
|
|||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "WidgetTool"; }
|
||||
virtual void on_mousedown(GMouseEvent&) override;
|
||||
virtual void on_mouseup(GMouseEvent&) override;
|
||||
virtual void on_mousemove(GMouseEvent&) override;
|
||||
virtual void on_keydown(GKeyEvent&) override;
|
||||
virtual void on_mousedown(GUI::MouseEvent&) override;
|
||||
virtual void on_mouseup(GUI::MouseEvent&) override;
|
||||
virtual void on_mousemove(GUI::MouseEvent&) override;
|
||||
virtual void on_keydown(GUI::KeyEvent&) override;
|
||||
|
||||
const GWidgetClassRegistration& m_meta_class;
|
||||
const GUI::WidgetClassRegistration& m_meta_class;
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <LibGUI/GWidget.h>
|
||||
#include <stdio.h>
|
||||
|
||||
WidgetTreeModel::WidgetTreeModel(GWidget& root)
|
||||
WidgetTreeModel::WidgetTreeModel(GUI::Widget& root)
|
||||
: m_root(root)
|
||||
{
|
||||
m_widget_icon.set_bitmap_for_size(16, GraphicsBitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
|
||||
|
@ -39,20 +39,20 @@ WidgetTreeModel::~WidgetTreeModel()
|
|||
{
|
||||
}
|
||||
|
||||
GModelIndex WidgetTreeModel::index(int row, int column, const GModelIndex& parent) const
|
||||
GUI::ModelIndex WidgetTreeModel::index(int row, int column, const GUI::ModelIndex& parent) const
|
||||
{
|
||||
if (!parent.is_valid()) {
|
||||
return create_index(row, column, m_root.ptr());
|
||||
}
|
||||
auto& parent_node = *static_cast<GWidget*>(parent.internal_data());
|
||||
auto& parent_node = *static_cast<GUI::Widget*>(parent.internal_data());
|
||||
return create_index(row, column, parent_node.child_widgets().at(row));
|
||||
}
|
||||
|
||||
GModelIndex WidgetTreeModel::parent_index(const GModelIndex& index) const
|
||||
GUI::ModelIndex WidgetTreeModel::parent_index(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return {};
|
||||
auto& widget = *static_cast<GWidget*>(index.internal_data());
|
||||
auto& widget = *static_cast<GUI::Widget*>(index.internal_data());
|
||||
if (&widget == m_root.ptr())
|
||||
return {};
|
||||
|
||||
|
@ -60,7 +60,7 @@ GModelIndex WidgetTreeModel::parent_index(const GModelIndex& index) const
|
|||
return create_index(0, 0, m_root.ptr());
|
||||
|
||||
// Walk the grandparent's children to find the index of widget's parent in its parent.
|
||||
// (This is needed to produce the row number of the GModelIndex corresponding to widget's parent.)
|
||||
// (This is needed to produce the row number of the GUI::ModelIndex corresponding to widget's parent.)
|
||||
int grandparent_child_index = 0;
|
||||
for (auto& grandparent_child : widget.parent_widget()->parent_widget()->child_widgets()) {
|
||||
if (grandparent_child == widget.parent_widget())
|
||||
|
@ -72,22 +72,22 @@ GModelIndex WidgetTreeModel::parent_index(const GModelIndex& index) const
|
|||
return {};
|
||||
}
|
||||
|
||||
int WidgetTreeModel::row_count(const GModelIndex& index) const
|
||||
int WidgetTreeModel::row_count(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return 1;
|
||||
auto& widget = *static_cast<GWidget*>(index.internal_data());
|
||||
auto& widget = *static_cast<GUI::Widget*>(index.internal_data());
|
||||
return widget.child_widgets().size();
|
||||
}
|
||||
|
||||
int WidgetTreeModel::column_count(const GModelIndex&) const
|
||||
int WidgetTreeModel::column_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
GVariant WidgetTreeModel::data(const GModelIndex& index, Role role) const
|
||||
GUI::Variant WidgetTreeModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
auto* widget = static_cast<GWidget*>(index.internal_data());
|
||||
auto* widget = static_cast<GUI::Widget*>(index.internal_data());
|
||||
if (role == Role::Icon) {
|
||||
return m_widget_icon;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ void WidgetTreeModel::update()
|
|||
did_update();
|
||||
}
|
||||
|
||||
GModelIndex WidgetTreeModel::index_for_widget(GWidget& widget) const
|
||||
GUI::ModelIndex WidgetTreeModel::index_for_widget(GUI::Widget& widget) const
|
||||
{
|
||||
int parent_child_index = 0;
|
||||
for (auto& parent_child : widget.parent_widget()->child_widgets()) {
|
||||
|
|
|
@ -29,23 +29,23 @@
|
|||
#include <LibGUI/GModel.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
|
||||
class WidgetTreeModel final : public GModel {
|
||||
class WidgetTreeModel final : public GUI::Model {
|
||||
public:
|
||||
static NonnullRefPtr<WidgetTreeModel> create(GWidget& root) { return adopt(*new WidgetTreeModel(root)); }
|
||||
static NonnullRefPtr<WidgetTreeModel> create(GUI::Widget& root) { return adopt(*new WidgetTreeModel(root)); }
|
||||
virtual ~WidgetTreeModel() override;
|
||||
|
||||
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
|
||||
virtual int column_count(const GModelIndex& = GModelIndex()) const override;
|
||||
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
|
||||
virtual GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override;
|
||||
virtual GModelIndex parent_index(const GModelIndex&) const override;
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
||||
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override;
|
||||
virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override;
|
||||
virtual void update() override;
|
||||
|
||||
GModelIndex index_for_widget(GWidget&) const;
|
||||
GUI::ModelIndex index_for_widget(GUI::Widget&) const;
|
||||
|
||||
private:
|
||||
explicit WidgetTreeModel(GWidget&);
|
||||
explicit WidgetTreeModel(GUI::Widget&);
|
||||
|
||||
NonnullRefPtr<GWidget> m_root;
|
||||
NonnullRefPtr<GUI::Widget> m_root;
|
||||
GIcon m_widget_icon;
|
||||
};
|
||||
|
|
|
@ -69,16 +69,16 @@ RefPtr<EditorWrapper> g_current_editor_wrapper;
|
|||
|
||||
String g_currently_open_file;
|
||||
OwnPtr<Project> g_project;
|
||||
RefPtr<GWindow> g_window;
|
||||
RefPtr<GTreeView> g_project_tree_view;
|
||||
RefPtr<GStackWidget> g_right_hand_stack;
|
||||
RefPtr<GSplitter> g_text_inner_splitter;
|
||||
RefPtr<GWidget> g_form_inner_container;
|
||||
RefPtr<GUI::Window> g_window;
|
||||
RefPtr<GUI::TreeView> g_project_tree_view;
|
||||
RefPtr<GUI::StackWidget> g_right_hand_stack;
|
||||
RefPtr<GUI::Splitter> g_text_inner_splitter;
|
||||
RefPtr<GUI::Widget> g_form_inner_container;
|
||||
RefPtr<FormEditorWidget> g_form_editor_widget;
|
||||
|
||||
static RefPtr<GTabWidget> s_action_tab_widget;
|
||||
static RefPtr<GUI::TabWidget> s_action_tab_widget;
|
||||
|
||||
void add_new_editor(GWidget& parent)
|
||||
void add_new_editor(GUI::Widget& parent)
|
||||
{
|
||||
auto wrapper = EditorWrapper::construct(nullptr);
|
||||
if (s_action_tab_widget) {
|
||||
|
@ -128,7 +128,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
GApplication app(argc, argv);
|
||||
GUI::Application app(argc, argv);
|
||||
|
||||
if (pledge("stdio tty accept rpath cpath wpath shared_buffer proc exec fattr", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
|
@ -137,15 +137,15 @@ int main(int argc, char** argv)
|
|||
|
||||
Function<void()> update_actions;
|
||||
|
||||
g_window = GWindow::construct();
|
||||
g_window = GUI::Window::construct();
|
||||
g_window->set_rect(90, 90, 840, 600);
|
||||
g_window->set_title("HackStudio");
|
||||
|
||||
auto widget = GWidget::construct();
|
||||
auto widget = GUI::Widget::construct();
|
||||
g_window->set_main_widget(widget);
|
||||
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GVBoxLayout>());
|
||||
widget->set_layout(make<GUI::VBoxLayout>());
|
||||
widget->layout()->set_spacing(0);
|
||||
|
||||
StringBuilder path;
|
||||
|
@ -156,7 +156,7 @@ int main(int argc, char** argv)
|
|||
setenv("PATH", path.to_string().characters(), true);
|
||||
|
||||
if (!make_is_available())
|
||||
GMessageBox::show("The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window);
|
||||
GUI::MessageBox::show("The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window);
|
||||
|
||||
if (chdir("/home/anon/little") < 0) {
|
||||
perror("chdir");
|
||||
|
@ -165,47 +165,47 @@ int main(int argc, char** argv)
|
|||
g_project = Project::load_from_file("little.files");
|
||||
ASSERT(g_project);
|
||||
|
||||
auto toolbar = GToolBar::construct(widget);
|
||||
auto toolbar = GUI::ToolBar::construct(widget);
|
||||
|
||||
auto selected_file_names = [&] {
|
||||
Vector<String> files;
|
||||
g_project_tree_view->selection().for_each_index([&](const GModelIndex& index) {
|
||||
g_project_tree_view->selection().for_each_index([&](const GUI::ModelIndex& index) {
|
||||
files.append(g_project->model().data(index).as_string());
|
||||
});
|
||||
return files;
|
||||
};
|
||||
|
||||
auto new_action = GAction::create("Add new file to project...", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GAction&) {
|
||||
auto input_box = GInputBox::construct("Enter name of new file:", "Add new file to project", g_window);
|
||||
if (input_box->exec() == GInputBox::ExecCancel)
|
||||
auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) {
|
||||
auto input_box = GUI::InputBox::construct("Enter name of new file:", "Add new file to project", g_window);
|
||||
if (input_box->exec() == GUI::InputBox::ExecCancel)
|
||||
return;
|
||||
auto filename = input_box->text_value();
|
||||
auto file = Core::File::construct(filename);
|
||||
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
||||
GMessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window);
|
||||
GUI::MessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window);
|
||||
return;
|
||||
}
|
||||
if (!g_project->add_file(filename)) {
|
||||
GMessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window);
|
||||
GUI::MessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window);
|
||||
// FIXME: Should we unlink the file here maybe?
|
||||
return;
|
||||
}
|
||||
open_file(filename);
|
||||
});
|
||||
|
||||
auto add_existing_file_action = GAction::create("Add existing file to project...", GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
|
||||
auto result = GFilePicker::get_open_filepath("Add existing file to project");
|
||||
auto add_existing_file_action = GUI::Action::create("Add existing file to project...", GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
|
||||
auto result = GUI::FilePicker::get_open_filepath("Add existing file to project");
|
||||
if (!result.has_value())
|
||||
return;
|
||||
auto& filename = result.value();
|
||||
if (!g_project->add_file(filename)) {
|
||||
GMessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window);
|
||||
GUI::MessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window);
|
||||
return;
|
||||
}
|
||||
open_file(filename);
|
||||
});
|
||||
|
||||
auto delete_action = GCommonActions::make_delete_action([&](const GAction& action) {
|
||||
auto delete_action = GUI::CommonActions::make_delete_action([&](const GUI::Action& action) {
|
||||
(void)action;
|
||||
|
||||
auto files = selected_file_names();
|
||||
|
@ -219,22 +219,22 @@ int main(int argc, char** argv)
|
|||
message = String::format("Really remove %d files from the project?", files.size());
|
||||
}
|
||||
|
||||
auto result = GMessageBox::show(
|
||||
auto result = GUI::MessageBox::show(
|
||||
message,
|
||||
"Confirm deletion",
|
||||
GMessageBox::Type::Warning,
|
||||
GMessageBox::InputType::OKCancel,
|
||||
GUI::MessageBox::Type::Warning,
|
||||
GUI::MessageBox::InputType::OKCancel,
|
||||
g_window);
|
||||
if (result == GMessageBox::ExecCancel)
|
||||
if (result == GUI::MessageBox::ExecCancel)
|
||||
return;
|
||||
|
||||
for (auto& file : files) {
|
||||
if (!g_project->remove_file(file)) {
|
||||
GMessageBox::show(
|
||||
GUI::MessageBox::show(
|
||||
String::format("Removing file %s from the project failed.", file.characters()),
|
||||
"Removal failed",
|
||||
GMessageBox::Type::Error,
|
||||
GMessageBox::InputType::OK,
|
||||
GUI::MessageBox::Type::Error,
|
||||
GUI::MessageBox::InputType::OK,
|
||||
g_window);
|
||||
break;
|
||||
}
|
||||
|
@ -242,18 +242,18 @@ int main(int argc, char** argv)
|
|||
});
|
||||
delete_action->set_enabled(false);
|
||||
|
||||
auto project_tree_view_context_menu = GMenu::construct("Project Files");
|
||||
auto project_tree_view_context_menu = GUI::Menu::construct("Project Files");
|
||||
project_tree_view_context_menu->add_action(new_action);
|
||||
project_tree_view_context_menu->add_action(add_existing_file_action);
|
||||
project_tree_view_context_menu->add_action(delete_action);
|
||||
|
||||
auto outer_splitter = GSplitter::construct(Orientation::Horizontal, widget);
|
||||
g_project_tree_view = GTreeView::construct(outer_splitter);
|
||||
auto outer_splitter = GUI::Splitter::construct(Orientation::Horizontal, widget);
|
||||
g_project_tree_view = GUI::TreeView::construct(outer_splitter);
|
||||
g_project_tree_view->set_model(g_project->model());
|
||||
g_project_tree_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
g_project_tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
g_project_tree_view->set_preferred_size(140, 0);
|
||||
|
||||
g_project_tree_view->on_context_menu_request = [&](const GModelIndex& index, const GContextMenuEvent& event) {
|
||||
g_project_tree_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
|
||||
if (index.is_valid()) {
|
||||
project_tree_view_context_menu->popup(event.screen_position());
|
||||
}
|
||||
|
@ -263,17 +263,17 @@ int main(int argc, char** argv)
|
|||
delete_action->set_enabled(!g_project_tree_view->selection().is_empty());
|
||||
};
|
||||
|
||||
g_right_hand_stack = GStackWidget::construct(outer_splitter);
|
||||
g_right_hand_stack = GUI::StackWidget::construct(outer_splitter);
|
||||
|
||||
g_form_inner_container = GWidget::construct(g_right_hand_stack);
|
||||
g_form_inner_container->set_layout(make<GHBoxLayout>());
|
||||
auto form_widgets_toolbar = GToolBar::construct(Orientation::Vertical, 26, g_form_inner_container);
|
||||
g_form_inner_container = GUI::Widget::construct(g_right_hand_stack);
|
||||
g_form_inner_container->set_layout(make<GUI::HBoxLayout>());
|
||||
auto form_widgets_toolbar = GUI::ToolBar::construct(Orientation::Vertical, 26, g_form_inner_container);
|
||||
form_widgets_toolbar->set_preferred_size(38, 0);
|
||||
|
||||
GActionGroup tool_actions;
|
||||
GUI::ActionGroup tool_actions;
|
||||
tool_actions.set_exclusive(true);
|
||||
|
||||
auto cursor_tool_action = GAction::create("Cursor", GraphicsBitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) {
|
||||
auto cursor_tool_action = GUI::Action::create("Cursor", GraphicsBitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) {
|
||||
g_form_editor_widget->set_tool(make<CursorTool>(*g_form_editor_widget));
|
||||
});
|
||||
cursor_tool_action->set_checkable(true);
|
||||
|
@ -282,9 +282,9 @@ int main(int argc, char** argv)
|
|||
|
||||
form_widgets_toolbar->add_action(cursor_tool_action);
|
||||
|
||||
GWidgetClassRegistration::for_each([&](const GWidgetClassRegistration& reg) {
|
||||
GUI::WidgetClassRegistration::for_each([&](const GUI::WidgetClassRegistration& reg) {
|
||||
auto icon_path = String::format("/res/icons/widgets/%s.png", reg.class_name().characters());
|
||||
auto action = GAction::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [®](auto&) {
|
||||
auto action = GUI::Action::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [®](auto&) {
|
||||
g_form_editor_widget->set_tool(make<WidgetTool>(*g_form_editor_widget, reg));
|
||||
auto widget = reg.construct(&g_form_editor_widget->form_widget());
|
||||
widget->set_relative_rect(30, 30, 30, 30);
|
||||
|
@ -296,28 +296,28 @@ int main(int argc, char** argv)
|
|||
form_widgets_toolbar->add_action(move(action));
|
||||
});
|
||||
|
||||
auto form_editor_inner_splitter = GSplitter::construct(Orientation::Horizontal, g_form_inner_container);
|
||||
auto form_editor_inner_splitter = GUI::Splitter::construct(Orientation::Horizontal, g_form_inner_container);
|
||||
|
||||
g_form_editor_widget = FormEditorWidget::construct(form_editor_inner_splitter);
|
||||
|
||||
auto form_editing_pane_container = GSplitter::construct(Orientation::Vertical, form_editor_inner_splitter);
|
||||
form_editing_pane_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
auto form_editing_pane_container = GUI::Splitter::construct(Orientation::Vertical, form_editor_inner_splitter);
|
||||
form_editing_pane_container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
form_editing_pane_container->set_preferred_size(190, 0);
|
||||
form_editing_pane_container->set_layout(make<GVBoxLayout>());
|
||||
form_editing_pane_container->set_layout(make<GUI::VBoxLayout>());
|
||||
|
||||
auto add_properties_pane = [&](auto& text, auto pane_widget) {
|
||||
auto wrapper = GWidget::construct(form_editing_pane_container.ptr());
|
||||
wrapper->set_layout(make<GVBoxLayout>());
|
||||
auto label = GLabel::construct(text, wrapper);
|
||||
auto wrapper = GUI::Widget::construct(form_editing_pane_container.ptr());
|
||||
wrapper->set_layout(make<GUI::VBoxLayout>());
|
||||
auto label = GUI::Label::construct(text, wrapper);
|
||||
label->set_fill_with_background_color(true);
|
||||
label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
label->set_font(Font::default_bold_font());
|
||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
label->set_preferred_size(0, 16);
|
||||
wrapper->add_child(pane_widget);
|
||||
};
|
||||
|
||||
auto form_widget_tree_view = GTreeView::construct(nullptr);
|
||||
auto form_widget_tree_view = GUI::TreeView::construct(nullptr);
|
||||
form_widget_tree_view->set_model(g_form_editor_widget->model());
|
||||
form_widget_tree_view->on_selection_change = [&] {
|
||||
g_form_editor_widget->selection().disable_hooks();
|
||||
|
@ -326,7 +326,7 @@ int main(int argc, char** argv)
|
|||
// NOTE: Make sure we don't add the FormWidget itself to the selection,
|
||||
// since that would allow you to drag-move the FormWidget.
|
||||
if (index.internal_data() != &g_form_editor_widget->form_widget())
|
||||
g_form_editor_widget->selection().add(*(GWidget*)index.internal_data());
|
||||
g_form_editor_widget->selection().add(*(GUI::Widget*)index.internal_data());
|
||||
});
|
||||
g_form_editor_widget->update();
|
||||
g_form_editor_widget->selection().enable_hooks();
|
||||
|
@ -343,13 +343,13 @@ int main(int argc, char** argv)
|
|||
};
|
||||
|
||||
add_properties_pane("Form widget tree:", form_widget_tree_view);
|
||||
add_properties_pane("Widget properties:", GTableView::construct(nullptr));
|
||||
add_properties_pane("Widget properties:", GUI::TableView::construct(nullptr));
|
||||
|
||||
g_text_inner_splitter = GSplitter::construct(Orientation::Vertical, g_right_hand_stack);
|
||||
g_text_inner_splitter = GUI::Splitter::construct(Orientation::Vertical, g_right_hand_stack);
|
||||
g_text_inner_splitter->layout()->set_margins({ 0, 3, 0, 0 });
|
||||
add_new_editor(*g_text_inner_splitter);
|
||||
|
||||
auto switch_to_next_editor = GAction::create("Switch to next editor", { Mod_Ctrl, Key_E }, [&](auto&) {
|
||||
auto switch_to_next_editor = GUI::Action::create("Switch to next editor", { Mod_Ctrl, Key_E }, [&](auto&) {
|
||||
if (g_all_editor_wrappers.size() <= 1)
|
||||
return;
|
||||
Vector<EditorWrapper*> wrappers;
|
||||
|
@ -367,7 +367,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
});
|
||||
|
||||
auto switch_to_previous_editor = GAction::create("Switch to previous editor", { Mod_Ctrl | Mod_Shift, Key_E }, [&](auto&) {
|
||||
auto switch_to_previous_editor = GUI::Action::create("Switch to previous editor", { Mod_Ctrl | Mod_Shift, Key_E }, [&](auto&) {
|
||||
if (g_all_editor_wrappers.size() <= 1)
|
||||
return;
|
||||
Vector<EditorWrapper*> wrappers;
|
||||
|
@ -385,7 +385,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
});
|
||||
|
||||
auto remove_current_editor_action = GAction::create("Remove current editor", { Mod_Alt | Mod_Shift, Key_E }, [&](auto&) {
|
||||
auto remove_current_editor_action = GUI::Action::create("Remove current editor", { Mod_Alt | Mod_Shift, Key_E }, [&](auto&) {
|
||||
if (g_all_editor_wrappers.size() <= 1)
|
||||
return;
|
||||
auto wrapper = g_current_editor_wrapper;
|
||||
|
@ -395,7 +395,7 @@ int main(int argc, char** argv)
|
|||
update_actions();
|
||||
});
|
||||
|
||||
auto save_action = GAction::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) {
|
||||
auto save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) {
|
||||
if (g_currently_open_file.is_empty())
|
||||
return;
|
||||
current_editor().write_to_file(g_currently_open_file);
|
||||
|
@ -407,22 +407,22 @@ int main(int argc, char** argv)
|
|||
toolbar->add_action(delete_action);
|
||||
toolbar->add_separator();
|
||||
|
||||
toolbar->add_action(GCommonActions::make_cut_action([&](auto&) { current_editor().cut_action().activate(); }));
|
||||
toolbar->add_action(GCommonActions::make_copy_action([&](auto&) { current_editor().copy_action().activate(); }));
|
||||
toolbar->add_action(GCommonActions::make_paste_action([&](auto&) { current_editor().paste_action().activate(); }));
|
||||
toolbar->add_action(GUI::CommonActions::make_cut_action([&](auto&) { current_editor().cut_action().activate(); }));
|
||||
toolbar->add_action(GUI::CommonActions::make_copy_action([&](auto&) { current_editor().copy_action().activate(); }));
|
||||
toolbar->add_action(GUI::CommonActions::make_paste_action([&](auto&) { current_editor().paste_action().activate(); }));
|
||||
toolbar->add_separator();
|
||||
toolbar->add_action(GCommonActions::make_undo_action([&](auto&) { current_editor().undo_action().activate(); }));
|
||||
toolbar->add_action(GCommonActions::make_redo_action([&](auto&) { current_editor().redo_action().activate(); }));
|
||||
toolbar->add_action(GUI::CommonActions::make_undo_action([&](auto&) { current_editor().undo_action().activate(); }));
|
||||
toolbar->add_action(GUI::CommonActions::make_redo_action([&](auto&) { current_editor().redo_action().activate(); }));
|
||||
toolbar->add_separator();
|
||||
|
||||
g_project_tree_view->on_activation = [&](auto& index) {
|
||||
auto filename = g_project_tree_view->model()->data(index, GModel::Role::Custom).to_string();
|
||||
auto filename = g_project_tree_view->model()->data(index, GUI::Model::Role::Custom).to_string();
|
||||
open_file(filename);
|
||||
};
|
||||
|
||||
s_action_tab_widget = GTabWidget::construct(g_text_inner_splitter);
|
||||
s_action_tab_widget = GUI::TabWidget::construct(g_text_inner_splitter);
|
||||
|
||||
s_action_tab_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
s_action_tab_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
s_action_tab_widget->set_preferred_size(0, 24);
|
||||
|
||||
auto reveal_action_tab = [&](auto& widget) {
|
||||
|
@ -435,11 +435,11 @@ int main(int argc, char** argv)
|
|||
s_action_tab_widget->set_preferred_size(0, 24);
|
||||
};
|
||||
|
||||
auto hide_action_tabs_action = GAction::create("Hide action tabs", { Mod_Ctrl | Mod_Shift, Key_X }, [&](auto&) {
|
||||
auto hide_action_tabs_action = GUI::Action::create("Hide action tabs", { Mod_Ctrl | Mod_Shift, Key_X }, [&](auto&) {
|
||||
hide_action_tabs();
|
||||
});
|
||||
|
||||
auto add_editor_action = GAction::create("Add new editor", { Mod_Ctrl | Mod_Alt, Key_E }, [&](auto&) {
|
||||
auto add_editor_action = GUI::Action::create("Add new editor", { Mod_Ctrl | Mod_Alt, Key_E }, [&](auto&) {
|
||||
add_new_editor(*g_text_inner_splitter);
|
||||
update_actions();
|
||||
});
|
||||
|
@ -452,31 +452,31 @@ int main(int argc, char** argv)
|
|||
|
||||
auto locator = Locator::construct(widget);
|
||||
|
||||
auto open_locator_action = GAction::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) {
|
||||
auto open_locator_action = GUI::Action::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) {
|
||||
locator->open();
|
||||
});
|
||||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = GMenu::construct("HackStudio");
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
auto app_menu = GUI::Menu::construct("HackStudio");
|
||||
app_menu->add_action(save_action);
|
||||
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) {
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
app.quit();
|
||||
}));
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto project_menu = GMenu::construct("Project");
|
||||
auto project_menu = GUI::Menu::construct("Project");
|
||||
project_menu->add_action(new_action);
|
||||
project_menu->add_action(add_existing_file_action);
|
||||
menubar->add_menu(move(project_menu));
|
||||
|
||||
auto edit_menu = GMenu::construct("Edit");
|
||||
edit_menu->add_action(GAction::create("Find in files...", { Mod_Ctrl | Mod_Shift, Key_F }, [&](auto&) {
|
||||
auto edit_menu = GUI::Menu::construct("Edit");
|
||||
edit_menu->add_action(GUI::Action::create("Find in files...", { Mod_Ctrl | Mod_Shift, Key_F }, [&](auto&) {
|
||||
reveal_action_tab(find_in_files_widget);
|
||||
find_in_files_widget->focus_textbox_and_select_all();
|
||||
}));
|
||||
menubar->add_menu(move(edit_menu));
|
||||
|
||||
auto stop_action = GAction::create("Stop", GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) {
|
||||
auto stop_action = GUI::Action::create("Stop", GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) {
|
||||
terminal_wrapper->kill_running_command();
|
||||
});
|
||||
|
||||
|
@ -485,14 +485,14 @@ int main(int argc, char** argv)
|
|||
stop_action->set_enabled(false);
|
||||
};
|
||||
|
||||
auto build_action = GAction::create("Build", { Mod_Ctrl, Key_B }, GraphicsBitmap::load_from_file("/res/icons/16x16/build.png"), [&](auto&) {
|
||||
auto build_action = GUI::Action::create("Build", { Mod_Ctrl, Key_B }, GraphicsBitmap::load_from_file("/res/icons/16x16/build.png"), [&](auto&) {
|
||||
reveal_action_tab(terminal_wrapper);
|
||||
build(terminal_wrapper);
|
||||
stop_action->set_enabled(true);
|
||||
});
|
||||
toolbar->add_action(build_action);
|
||||
|
||||
auto run_action = GAction::create("Run", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) {
|
||||
auto run_action = GUI::Action::create("Run", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) {
|
||||
reveal_action_tab(terminal_wrapper);
|
||||
run(terminal_wrapper);
|
||||
stop_action->set_enabled(true);
|
||||
|
@ -500,13 +500,13 @@ int main(int argc, char** argv)
|
|||
toolbar->add_action(run_action);
|
||||
toolbar->add_action(stop_action);
|
||||
|
||||
auto build_menu = GMenu::construct("Build");
|
||||
auto build_menu = GUI::Menu::construct("Build");
|
||||
build_menu->add_action(build_action);
|
||||
build_menu->add_action(run_action);
|
||||
build_menu->add_action(stop_action);
|
||||
menubar->add_menu(move(build_menu));
|
||||
|
||||
auto view_menu = GMenu::construct("View");
|
||||
auto view_menu = GUI::Menu::construct("View");
|
||||
view_menu->add_action(hide_action_tabs_action);
|
||||
view_menu->add_action(open_locator_action);
|
||||
view_menu->add_separator();
|
||||
|
@ -516,9 +516,9 @@ int main(int argc, char** argv)
|
|||
|
||||
auto small_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png");
|
||||
|
||||
auto help_menu = GMenu::construct("Help");
|
||||
help_menu->add_action(GAction::create("About", [&](auto&) {
|
||||
GAboutDialog::show("HackStudio", small_icon, g_window);
|
||||
auto help_menu = GUI::Menu::construct("Help");
|
||||
help_menu->add_action(GUI::Action::create("About", [&](auto&) {
|
||||
GUI::AboutDialog::show("HackStudio", small_icon, g_window);
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
||||
|
@ -581,12 +581,12 @@ static void rehighlight()
|
|||
CppLexer lexer(text);
|
||||
auto tokens = lexer.lex();
|
||||
|
||||
Vector<GTextDocumentSpan> spans;
|
||||
Vector<GUI::TextDocumentSpan> spans;
|
||||
for (auto& token : tokens) {
|
||||
#ifdef DEBUG_SYNTAX_HIGHLIGHTING
|
||||
dbg() << token.to_string() << " @ " << token.m_start.line << ":" << token.m_start.column << " - " << token.m_end.line << ":" << token.m_end.column;
|
||||
#endif
|
||||
GTextDocumentSpan span;
|
||||
GUI::TextDocumentSpan span;
|
||||
span.range.set_start({ token.m_start.line, token.m_start.column });
|
||||
span.range.set_end({ token.m_end.line, token.m_end.column });
|
||||
auto style = style_for_token_type(token.m_type);
|
||||
|
@ -604,7 +604,7 @@ static void rehighlight()
|
|||
void open_file(const String& filename)
|
||||
{
|
||||
auto file = g_project->get_file(filename);
|
||||
current_editor().set_document(const_cast<GTextDocument&>(file->document()));
|
||||
current_editor().set_document(const_cast<GUI::TextDocument&>(file->document()));
|
||||
|
||||
if (filename.ends_with(".cpp") || filename.ends_with(".h")) {
|
||||
current_editor().on_change = [] { rehighlight(); };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue