mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 19:35:06 +00:00
LibDraw: Put all classes in the Gfx namespace
I started adding things to a Draw namespace, but it somehow felt really wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename the library to LibGfx. :^)
This commit is contained in:
parent
939a605334
commit
11580babbf
269 changed files with 1513 additions and 1315 deletions
|
@ -69,12 +69,12 @@ int main(int argc, char** argv)
|
||||||
widget->layout()->set_spacing(8);
|
widget->layout()->set_spacing(8);
|
||||||
|
|
||||||
auto icon_label = GUI::Label::construct(widget);
|
auto icon_label = GUI::Label::construct(widget);
|
||||||
icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/serenity.png"));
|
icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/serenity.png"));
|
||||||
icon_label->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
icon_label->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
icon_label->set_preferred_size(icon_label->icon()->size());
|
icon_label->set_preferred_size(icon_label->icon()->size());
|
||||||
|
|
||||||
auto label = GUI::Label::construct(widget);
|
auto label = GUI::Label::construct(widget);
|
||||||
label->set_font(Font::default_bold_font());
|
label->set_font(Gfx::Font::default_bold_font());
|
||||||
label->set_text("SerenityOS");
|
label->set_text("SerenityOS");
|
||||||
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
label->set_preferred_size(0, 11);
|
label->set_preferred_size(0, 11);
|
||||||
|
|
|
@ -235,13 +235,13 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Browser", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
|
GUI::AboutDialog::show("Browser", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
app.set_menubar(move(menubar));
|
app.set_menubar(move(menubar));
|
||||||
|
|
||||||
window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-html.png"));
|
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"));
|
||||||
|
|
||||||
window->set_title("Browser");
|
window->set_title("Browser");
|
||||||
window->set_main_widget(widget);
|
window->set_main_widget(widget);
|
||||||
|
|
|
@ -37,13 +37,13 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent)
|
||||||
|
|
||||||
m_entry = GUI::TextBox::construct(this);
|
m_entry = GUI::TextBox::construct(this);
|
||||||
m_entry->set_relative_rect(5, 5, 244, 26);
|
m_entry->set_relative_rect(5, 5, 244, 26);
|
||||||
m_entry->set_text_alignment(TextAlignment::CenterRight);
|
m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
|
|
||||||
m_label = GUI::Label::construct(this);
|
m_label = GUI::Label::construct(this);
|
||||||
m_label->set_relative_rect(12, 42, 27, 27);
|
m_label->set_relative_rect(12, 42, 27, 27);
|
||||||
m_label->set_foreground_color(Color::NamedColor::Red);
|
m_label->set_foreground_color(Color::NamedColor::Red);
|
||||||
m_label->set_frame_shadow(FrameShadow::Sunken);
|
m_label->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
m_label->set_frame_shape(FrameShape::Container);
|
m_label->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
m_label->set_frame_thickness(2);
|
m_label->set_frame_thickness(2);
|
||||||
|
|
||||||
update_display();
|
update_display();
|
||||||
|
|
|
@ -63,7 +63,7 @@ int main(int argc, char** argv)
|
||||||
window->set_main_widget(calc_widget);
|
window->set_main_widget(calc_widget);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-calculator.png"));
|
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calculator.png"));
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Calculator", load_png("/res/icons/16x16/app-calculator.png"), window);
|
GUI::AboutDialog::show("Calculator", Gfx::load_png("/res/icons/16x16/app-calculator.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -129,17 +129,17 @@ GUI::Model::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::ThreadNumber:
|
case Column::ThreadNumber:
|
||||||
return { 70, TextAlignment::CenterRight };
|
return { 70, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::Subject:
|
case Column::Subject:
|
||||||
return { 170, TextAlignment::CenterLeft };
|
return { 170, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::Text:
|
case Column::Text:
|
||||||
return { 270, TextAlignment::CenterLeft };
|
return { 270, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::ReplyCount:
|
case Column::ReplyCount:
|
||||||
return { 45, TextAlignment::CenterRight };
|
return { 45, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::ImageCount:
|
case Column::ImageCount:
|
||||||
return { 40, TextAlignment::CenterRight };
|
return { 40, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::PostTime:
|
case Column::PostTime:
|
||||||
return { 120, TextAlignment::CenterLeft };
|
return { 120, Gfx::TextAlignment::CenterLeft };
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ int main(int argc, char** argv)
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
window->set_title("ChanViewer");
|
window->set_title("ChanViewer");
|
||||||
window->set_rect(100, 100, 800, 500);
|
window->set_rect(100, 100, 800, 500);
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-chanviewer.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-chanviewer.png"));
|
||||||
|
|
||||||
auto widget = GUI::Widget::construct();
|
auto widget = GUI::Widget::construct();
|
||||||
window->set_main_widget(widget);
|
window->set_main_widget(widget);
|
||||||
|
@ -104,7 +104,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("ChanViewer", load_png("/res/icons/32x32/app-chanviewer.png"), window);
|
GUI::AboutDialog::show("ChanViewer", Gfx::load_png("/res/icons/32x32/app-chanviewer.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ void DisplayPropertiesWidget::create_frame()
|
||||||
m_selected_wallpaper = m_wallpapers.at(index.row());
|
m_selected_wallpaper = m_wallpapers.at(index.row());
|
||||||
builder.append("/res/wallpapers/");
|
builder.append("/res/wallpapers/");
|
||||||
builder.append(m_selected_wallpaper);
|
builder.append(m_selected_wallpaper);
|
||||||
m_wallpaper_preview->set_icon(load_png(builder.to_string()));
|
m_wallpaper_preview->set_icon(Gfx::load_png(builder.to_string()));
|
||||||
m_wallpaper_preview->set_should_stretch_icon(true);
|
m_wallpaper_preview->set_should_stretch_icon(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,6 @@ private:
|
||||||
Vector<String> m_wallpapers;
|
Vector<String> m_wallpapers;
|
||||||
RefPtr<GUI::Label> m_wallpaper_preview;
|
RefPtr<GUI::Label> m_wallpaper_preview;
|
||||||
|
|
||||||
Size m_selected_resolution;
|
Gfx::Size m_selected_resolution;
|
||||||
String m_selected_wallpaper;
|
String m_selected_wallpaper;
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
|
|
||||||
virtual ColumnMetadata column_metadata(int) const override
|
virtual ColumnMetadata column_metadata(int) const override
|
||||||
{
|
{
|
||||||
return { 70, TextAlignment::CenterLeft };
|
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
|
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override
|
||||||
|
|
|
@ -58,7 +58,7 @@ int main(int argc, char** argv)
|
||||||
window->resize(400, 448);
|
window->resize(400, 448);
|
||||||
window->set_resizable(false);
|
window->set_resizable(false);
|
||||||
window->set_main_widget(instance.root_widget());
|
window->set_main_widget(instance.root_widget());
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-display-properties.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-display-properties.png"));
|
||||||
|
|
||||||
// Let's create the menubar first
|
// Let's create the menubar first
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
|
@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Display Properties", load_png("/res/icons/32x32/app-display-properties.png"), window);
|
GUI::AboutDialog::show("Display Properties", Gfx::load_png("/res/icons/32x32/app-display-properties.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"));
|
set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"));
|
||||||
make_divider(general_tab);
|
make_divider(general_tab);
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -154,7 +154,7 @@ PropertiesDialog::~PropertiesDialog() {}
|
||||||
|
|
||||||
void PropertiesDialog::update()
|
void PropertiesDialog::update()
|
||||||
{
|
{
|
||||||
m_icon->set_icon(const_cast<GraphicsBitmap*>(m_model.icon_for_file(m_mode, m_name).bitmap_for_size(32)));
|
m_icon->set_icon(const_cast<Gfx::Bitmap*>(m_model.icon_for_file(m_mode, m_name).bitmap_for_size(32)));
|
||||||
set_title(String::format("Properties of \"%s\"", m_name.characters()));
|
set_title(String::format("Properties of \"%s\"", m_name.characters()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& pa
|
||||||
widget->layout()->set_spacing(10);
|
widget->layout()->set_spacing(10);
|
||||||
|
|
||||||
auto label = GUI::Label::construct(label_string, widget);
|
auto label = GUI::Label::construct(label_string, widget);
|
||||||
label->set_text_alignment(TextAlignment::CenterLeft);
|
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
|
|
||||||
auto box_read = GUI::CheckBox::construct("Read", widget);
|
auto box_read = GUI::CheckBox::construct("Read", widget);
|
||||||
box_read->set_checked(mode & masks.read);
|
box_read->set_checked(mode & masks.read);
|
||||||
|
@ -248,10 +248,10 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>
|
||||||
label_container->layout()->set_spacing(12);
|
label_container->layout()->set_spacing(12);
|
||||||
|
|
||||||
auto label_property = GUI::Label::construct(pair.property, label_container);
|
auto label_property = GUI::Label::construct(pair.property, label_container);
|
||||||
label_property->set_text_alignment(TextAlignment::CenterLeft);
|
label_property->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
label_property->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
label_property->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
|
|
||||||
GUI::Label::construct(pair.value, label_container)->set_text_alignment(TextAlignment::CenterLeft);
|
GUI::Label::construct(pair.value, label_container)->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
|
|
||||||
max_width = max(max_width, label_property->font().width(pair.property));
|
max_width = max(max_width, label_property->font().width(pair.property));
|
||||||
property_labels.append(label_property);
|
property_labels.append(label_property);
|
||||||
|
@ -276,8 +276,8 @@ void PropertiesDialog::make_divider(NonnullRefPtr<GUI::Widget>& parent)
|
||||||
auto divider = GUI::Frame::construct(parent.ptr());
|
auto divider = GUI::Frame::construct(parent.ptr());
|
||||||
divider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
divider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
divider->set_preferred_size({ 0, 2 });
|
divider->set_preferred_size({ 0, 2 });
|
||||||
divider->set_frame_shape(FrameShape::HorizontalLine);
|
divider->set_frame_shape(Gfx::FrameShape::HorizontalLine);
|
||||||
divider->set_frame_shadow(FrameShadow::Sunken);
|
divider->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
divider->set_frame_thickness(2);
|
divider->set_frame_thickness(2);
|
||||||
|
|
||||||
parent->layout()->add_spacer();
|
parent->layout()->add_spacer();
|
||||||
|
|
|
@ -126,8 +126,8 @@ int main(int argc, char** argv)
|
||||||
progressbar->set_caption("Generating thumbnails: ");
|
progressbar->set_caption("Generating thumbnails: ");
|
||||||
progressbar->set_format(GUI::ProgressBar::Format::ValueSlashMax);
|
progressbar->set_format(GUI::ProgressBar::Format::ValueSlashMax);
|
||||||
progressbar->set_visible(false);
|
progressbar->set_visible(false);
|
||||||
progressbar->set_frame_shape(FrameShape::Panel);
|
progressbar->set_frame_shape(Gfx::FrameShape::Panel);
|
||||||
progressbar->set_frame_shadow(FrameShadow::Sunken);
|
progressbar->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
progressbar->set_frame_thickness(1);
|
progressbar->set_frame_thickness(1);
|
||||||
|
|
||||||
location_textbox->on_return_pressed = [&] {
|
location_textbox->on_return_pressed = [&] {
|
||||||
|
@ -164,11 +164,11 @@ int main(int argc, char** argv)
|
||||||
auto tree_view_directory_context_menu = GUI::Menu::construct("Tree View Directory");
|
auto tree_view_directory_context_menu = GUI::Menu::construct("Tree View Directory");
|
||||||
auto tree_view_context_menu = GUI::Menu::construct("Tree View");
|
auto tree_view_context_menu = GUI::Menu::construct("Tree View");
|
||||||
|
|
||||||
auto open_parent_directory_action = GUI::Action::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) {
|
auto open_parent_directory_action = GUI::Action::create("Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) {
|
||||||
directory_view->open_parent_directory();
|
directory_view->open_parent_directory();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
|
auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) {
|
||||||
auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window);
|
auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window);
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
||||||
auto new_dir_path = canonicalized_path(
|
auto new_dir_path = canonicalized_path(
|
||||||
|
@ -188,7 +188,7 @@ int main(int argc, char** argv)
|
||||||
RefPtr<GUI::Action> view_as_icons_action;
|
RefPtr<GUI::Action> view_as_icons_action;
|
||||||
RefPtr<GUI::Action> view_as_columns_action;
|
RefPtr<GUI::Action> view_as_columns_action;
|
||||||
|
|
||||||
view_as_table_action = GUI::Action::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
|
view_as_table_action = GUI::Action::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::List);
|
directory_view->set_view_mode(DirectoryView::ViewMode::List);
|
||||||
view_as_table_action->set_checked(true);
|
view_as_table_action->set_checked(true);
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ int main(int argc, char** argv)
|
||||||
}, window);
|
}, window);
|
||||||
view_as_table_action->set_checkable(true);
|
view_as_table_action->set_checkable(true);
|
||||||
|
|
||||||
view_as_icons_action = GUI::Action::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, GraphicsBitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) {
|
view_as_icons_action = GUI::Action::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, Gfx::Bitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::Icon);
|
directory_view->set_view_mode(DirectoryView::ViewMode::Icon);
|
||||||
view_as_icons_action->set_checked(true);
|
view_as_icons_action->set_checked(true);
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ int main(int argc, char** argv)
|
||||||
}, window);
|
}, window);
|
||||||
view_as_icons_action->set_checkable(true);
|
view_as_icons_action->set_checkable(true);
|
||||||
|
|
||||||
view_as_columns_action = GUI::Action::create("Columns view", GraphicsBitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) {
|
view_as_columns_action = GUI::Action::create("Columns view", Gfx::Bitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) {
|
||||||
directory_view->set_view_mode(DirectoryView::ViewMode::Columns);
|
directory_view->set_view_mode(DirectoryView::ViewMode::Columns);
|
||||||
view_as_columns_action->set_checked(true);
|
view_as_columns_action->set_checked(true);
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ int main(int argc, char** argv)
|
||||||
};
|
};
|
||||||
|
|
||||||
auto properties_action
|
auto properties_action
|
||||||
= GUI::Action::create("Properties...", { Mod_Alt, Key_Return }, GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
|
= GUI::Action::create("Properties...", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) {
|
||||||
auto& model = directory_view->model();
|
auto& model = directory_view->model();
|
||||||
String path;
|
String path;
|
||||||
Vector<String> selected;
|
Vector<String> selected;
|
||||||
|
@ -445,7 +445,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("File Manager", load_png("/res/icons/32x32/filetype-folder.png"), window);
|
GUI::AboutDialog::show("File Manager", Gfx::load_png("/res/icons/32x32/filetype-folder.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ int main(int argc, char** argv)
|
||||||
delete_action->set_enabled(!view.selection().is_empty());
|
delete_action->set_enabled(!view.selection().is_empty());
|
||||||
};
|
};
|
||||||
|
|
||||||
auto open_in_text_editor_action = GUI::Action::create("Open in TextEditor...", GraphicsBitmap::load_from_file("/res/icons/TextEditor16.png"), [&](auto&) {
|
auto open_in_text_editor_action = GUI::Action::create("Open in TextEditor...", Gfx::Bitmap::load_from_file("/res/icons/TextEditor16.png"), [&](auto&) {
|
||||||
for (auto& path : selected_file_paths()) {
|
for (auto& path : selected_file_paths()) {
|
||||||
if (!fork()) {
|
if (!fork()) {
|
||||||
int rc = execl("/bin/TextEditor", "TextEditor", path.characters(), nullptr);
|
int rc = execl("/bin/TextEditor", "TextEditor", path.characters(), nullptr);
|
||||||
|
@ -587,7 +587,7 @@ int main(int argc, char** argv)
|
||||||
window->set_main_widget(widget);
|
window->set_main_widget(widget);
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
window->set_icon(load_png("/res/icons/16x16/filetype-folder.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/filetype-folder.png"));
|
||||||
|
|
||||||
// Read direcory read mode from config.
|
// Read direcory read mode from config.
|
||||||
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
auto dir_view_mode = config->read_entry("DirectoryView", "ViewMode", "Icon");
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include <LibGUI/GTextBox.h>
|
#include <LibGUI/GTextBox.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& edited_font, GUI::Widget* parent)
|
FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edited_font, GUI::Widget* parent)
|
||||||
: GUI::Widget(parent)
|
: GUI::Widget(parent)
|
||||||
, m_edited_font(move(edited_font))
|
, m_edited_font(move(edited_font))
|
||||||
{
|
{
|
||||||
|
@ -85,7 +85,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& edited_fon
|
||||||
exit(0);
|
exit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_ui->info_label->set_text_alignment(TextAlignment::CenterLeft);
|
m_ui->info_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
|
|
||||||
m_ui->demo_label_1->set_font(m_edited_font);
|
m_ui->demo_label_1->set_font(m_edited_font);
|
||||||
m_ui->demo_label_1->set_text("quick fox jumps nightly above wizard.");
|
m_ui->demo_label_1->set_text("quick fox jumps nightly above wizard.");
|
||||||
|
|
|
@ -40,8 +40,8 @@ public:
|
||||||
virtual ~FontEditorWidget() override;
|
virtual ~FontEditorWidget() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FontEditorWidget(const String& path, RefPtr<Font>&&, GUI::Widget* parent = nullptr);
|
FontEditorWidget(const String& path, RefPtr<Gfx::Font>&&, GUI::Widget* parent = nullptr);
|
||||||
RefPtr<Font> m_edited_font;
|
RefPtr<Gfx::Font> m_edited_font;
|
||||||
|
|
||||||
GlyphMapWidget* m_glyph_map_widget { nullptr };
|
GlyphMapWidget* m_glyph_map_widget { nullptr };
|
||||||
GlyphEditorWidget* m_glyph_editor_widget { nullptr };
|
GlyphEditorWidget* m_glyph_editor_widget { nullptr };
|
||||||
|
|
|
@ -27,13 +27,13 @@
|
||||||
#include "GlyphEditorWidget.h"
|
#include "GlyphEditorWidget.h"
|
||||||
#include <LibGUI/GPainter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
GlyphEditorWidget::GlyphEditorWidget(Font& mutable_font, GUI::Widget* parent)
|
GlyphEditorWidget::GlyphEditorWidget(Gfx::Font& mutable_font, GUI::Widget* parent)
|
||||||
: GUI::Frame(parent)
|
: GUI::Frame(parent)
|
||||||
, m_font(mutable_font)
|
, m_font(mutable_font)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_relative_rect({ 0, 0, preferred_width(), preferred_height() });
|
set_relative_rect({ 0, 0, preferred_width(), preferred_height() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,20 +38,20 @@ public:
|
||||||
int preferred_width() const;
|
int preferred_width() const;
|
||||||
int preferred_height() const;
|
int preferred_height() const;
|
||||||
|
|
||||||
Font& font() { return *m_font; }
|
Gfx::Font& font() { return *m_font; }
|
||||||
const Font& font() const { return *m_font; }
|
const Gfx::Font& font() const { return *m_font; }
|
||||||
|
|
||||||
Function<void(u8)> on_glyph_altered;
|
Function<void(u8)> on_glyph_altered;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlyphEditorWidget(Font&, GUI::Widget* parent);
|
GlyphEditorWidget(Gfx::Font&, GUI::Widget* parent);
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||||
|
|
||||||
void draw_at_mouse(const GUI::MouseEvent&);
|
void draw_at_mouse(const GUI::MouseEvent&);
|
||||||
|
|
||||||
RefPtr<Font> m_font;
|
RefPtr<Gfx::Font> m_font;
|
||||||
u8 m_glyph { 0 };
|
u8 m_glyph { 0 };
|
||||||
int m_scale { 10 };
|
int m_scale { 10 };
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,13 +28,13 @@
|
||||||
#include <LibDraw/Palette.h>
|
#include <LibDraw/Palette.h>
|
||||||
#include <LibGUI/GPainter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
|
|
||||||
GlyphMapWidget::GlyphMapWidget(Font& mutable_font, GUI::Widget* parent)
|
GlyphMapWidget::GlyphMapWidget(Gfx::Font& mutable_font, GUI::Widget* parent)
|
||||||
: GUI::Frame(parent)
|
: GUI::Frame(parent)
|
||||||
, m_font(mutable_font)
|
, m_font(mutable_font)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_relative_rect({ 0, 0, preferred_width(), preferred_height() });
|
set_relative_rect({ 0, 0, preferred_width(), preferred_height() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,21 +43,21 @@ public:
|
||||||
int preferred_width() const;
|
int preferred_width() const;
|
||||||
int preferred_height() const;
|
int preferred_height() const;
|
||||||
|
|
||||||
Font& font() { return *m_font; }
|
Gfx::Font& font() { return *m_font; }
|
||||||
const Font& font() const { return *m_font; }
|
const Gfx::Font& font() const { return *m_font; }
|
||||||
|
|
||||||
void update_glyph(u8);
|
void update_glyph(u8);
|
||||||
|
|
||||||
Function<void(u8)> on_glyph_selected;
|
Function<void(u8)> on_glyph_selected;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlyphMapWidget(Font&, GUI::Widget* parent);
|
GlyphMapWidget(Gfx::Font&, GUI::Widget* parent);
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||||
|
|
||||||
Rect get_outer_rect(u8 glyph) const;
|
Rect get_outer_rect(u8 glyph) const;
|
||||||
|
|
||||||
RefPtr<Font> m_font;
|
RefPtr<Gfx::Font> m_font;
|
||||||
int m_rows { 8 };
|
int m_rows { 8 };
|
||||||
int m_horizontal_spacing { 2 };
|
int m_horizontal_spacing { 2 };
|
||||||
int m_vertical_spacing { 2 };
|
int m_vertical_spacing { 2 };
|
||||||
|
|
|
@ -47,12 +47,12 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<Font> edited_font;
|
RefPtr<Gfx::Font> edited_font;
|
||||||
String path;
|
String path;
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
path = argv[1];
|
path = argv[1];
|
||||||
edited_font = Font::load_from_file(path);
|
edited_font = Gfx::Font::load_from_file(path);
|
||||||
if (!edited_font) {
|
if (!edited_font) {
|
||||||
fprintf(stderr, "Couldn't load font: %s\n", path.characters());
|
fprintf(stderr, "Couldn't load font: %s\n", path.characters());
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -62,7 +62,7 @@ int main(int argc, char** argv)
|
||||||
if (edited_font)
|
if (edited_font)
|
||||||
edited_font = edited_font->clone();
|
edited_font = edited_font->clone();
|
||||||
else
|
else
|
||||||
edited_font = Font::default_font().clone();
|
edited_font = Gfx::Font::default_font().clone();
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
window->set_title("Font Editor");
|
window->set_title("Font Editor");
|
||||||
|
@ -71,7 +71,7 @@ int main(int argc, char** argv)
|
||||||
auto font_editor = FontEditorWidget::construct(path, move(edited_font));
|
auto font_editor = FontEditorWidget::construct(path, move(edited_font));
|
||||||
window->set_main_widget(font_editor);
|
window->set_main_widget(font_editor);
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-font-editor.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-font-editor.png"));
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Font Editor", load_png("/res/icons/FontEditor.png"), window);
|
GUI::AboutDialog::show("Font Editor", Gfx::load_png("/res/icons/FontEditor.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ static ManualSectionNode s_sections[] = {
|
||||||
ManualModel::ManualModel()
|
ManualModel::ManualModel()
|
||||||
{
|
{
|
||||||
// FIXME: need some help from the icon fairy ^)
|
// FIXME: need some help from the icon fairy ^)
|
||||||
m_section_icon.set_bitmap_for_size(16, load_png("/res/icons/16x16/book.png"));
|
m_section_icon.set_bitmap_for_size(16, Gfx::load_png("/res/icons/16x16/book.png"));
|
||||||
m_page_icon.set_bitmap_for_size(16, load_png("/res/icons/16x16/filetype-unknown.png"));
|
m_page_icon.set_bitmap_for_size(16, Gfx::load_png("/res/icons/16x16/filetype-unknown.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String ManualModel::page_path(const GUI::ModelIndex& index) const
|
String ManualModel::page_path(const GUI::ModelIndex& index) const
|
||||||
|
|
|
@ -180,7 +180,7 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
auto app_menu = GUI::Menu::construct("Help");
|
auto app_menu = GUI::Menu::construct("Help");
|
||||||
app_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
app_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Help", load_png("/res/icons/16x16/book.png"), window);
|
GUI::AboutDialog::show("Help", Gfx::load_png("/res/icons/16x16/book.png"), window);
|
||||||
}));
|
}));
|
||||||
app_menu->add_separator();
|
app_menu->add_separator();
|
||||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||||
|
@ -199,7 +199,7 @@ int main(int argc, char* argv[])
|
||||||
window->set_focused_widget(tree_view);
|
window->set_focused_widget(tree_view);
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
window->set_icon(load_png("/res/icons/16x16/book.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/book.png"));
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
HexEditor::HexEditor(GUI::Widget* parent)
|
HexEditor::HexEditor(GUI::Widget* parent)
|
||||||
: ScrollableWidget(parent)
|
: ScrollableWidget(parent)
|
||||||
{
|
{
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_scrollbars_enabled(true);
|
set_scrollbars_enabled(true);
|
||||||
set_font(GFontDatabase::the().get_by_name("Csilla Thin"));
|
set_font(GFontDatabase::the().get_by_name("Csilla Thin"));
|
||||||
|
@ -544,7 +544,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto line = String::format("%02X", m_buffer[byte_position]);
|
auto line = String::format("%02X", m_buffer[byte_position]);
|
||||||
painter.draw_text(hex_display_rect, line, TextAlignment::TopLeft, text_color);
|
painter.draw_text(hex_display_rect, line, Gfx::TextAlignment::TopLeft, text_color);
|
||||||
|
|
||||||
Rect text_display_rect {
|
Rect text_display_rect {
|
||||||
frame_thickness() + offset_margin_width() + (bytes_per_row() * (character_width() * 3)) + (j * character_width()) + 20,
|
frame_thickness() + offset_margin_width() + (bytes_per_row() * (character_width() * 3)) + (j * character_width()) + 20,
|
||||||
|
@ -559,7 +559,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
||||||
painter.fill_rect(text_display_rect, Color::from_rgb(0xCCCCCC));
|
painter.fill_rect(text_display_rect, Color::from_rgb(0xCCCCCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
painter.draw_text(text_display_rect, String::format("%c", isprint(m_buffer[byte_position]) ? m_buffer[byte_position] : '.'), TextAlignment::TopLeft, text_color);
|
painter.draw_text(text_display_rect, String::format("%c", isprint(m_buffer[byte_position]) ? m_buffer[byte_position] : '.'), Gfx::TextAlignment::TopLeft, text_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ HexEditorWidget::HexEditorWidget()
|
||||||
|
|
||||||
m_statusbar = GUI::StatusBar::construct(5, this);
|
m_statusbar = GUI::StatusBar::construct(5, this);
|
||||||
|
|
||||||
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
|
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
|
||||||
if (m_document_dirty) {
|
if (m_document_dirty) {
|
||||||
auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window());
|
auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window());
|
||||||
auto save_document_first_result = save_document_first_box->exec();
|
auto save_document_first_result = save_document_first_box->exec();
|
||||||
|
@ -102,7 +102,7 @@ HexEditorWidget::HexEditorWidget()
|
||||||
open_file(open_path.value());
|
open_file(open_path.value());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GUI::Action&) {
|
m_save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GUI::Action&) {
|
||||||
if (!m_path.is_empty()) {
|
if (!m_path.is_empty()) {
|
||||||
if (!m_editor->write_to_file(m_path)) {
|
if (!m_editor->write_to_file(m_path)) {
|
||||||
GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||||
|
@ -116,7 +116,7 @@ HexEditorWidget::HexEditorWidget()
|
||||||
m_save_as_action->activate();
|
m_save_as_action->activate();
|
||||||
});
|
});
|
||||||
|
|
||||||
m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) {
|
m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) {
|
||||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "bin" : m_extension);
|
Optional<String> save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "bin" : m_extension);
|
||||||
if (!save_path.has_value())
|
if (!save_path.has_value())
|
||||||
return;
|
return;
|
||||||
|
@ -153,7 +153,7 @@ HexEditorWidget::HexEditorWidget()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_goto_decimal_offset_action = GUI::Action::create("Go To Offset (Decimal)...", { Mod_Ctrl | Mod_Shift, Key_G }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) {
|
m_goto_decimal_offset_action = GUI::Action::create("Go To Offset (Decimal)...", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) {
|
||||||
auto input_box = GUI::InputBox::construct("Enter Decimal offset:", "Go To", this);
|
auto input_box = GUI::InputBox::construct("Enter Decimal offset:", "Go To", this);
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
||||||
auto valid = false;
|
auto valid = false;
|
||||||
|
@ -164,7 +164,7 @@ HexEditorWidget::HexEditorWidget()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_goto_hex_offset_action = GUI::Action::create("Go To Offset (Hex)...", { Mod_Ctrl, Key_G }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) {
|
m_goto_hex_offset_action = GUI::Action::create("Go To Offset (Hex)...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) {
|
||||||
auto input_box = GUI::InputBox::construct("Enter Hex offset:", "Go To", this);
|
auto input_box = GUI::InputBox::construct("Enter Hex offset:", "Go To", this);
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
||||||
auto new_offset = strtol(input_box->text_value().characters(), nullptr, 16);
|
auto new_offset = strtol(input_box->text_value().characters(), nullptr, 16);
|
||||||
|
@ -202,7 +202,7 @@ HexEditorWidget::HexEditorWidget()
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Hex Editor", load_png("/res/icons/32x32/app-hexeditor.png"), window());
|
GUI::AboutDialog::show("Hex Editor", Gfx::load_png("/res/icons/32x32/app-hexeditor.png"), window());
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ int main(int argc, char** argv)
|
||||||
};
|
};
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-hexeditor.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-hexeditor.png"));
|
||||||
|
|
||||||
if (argc >= 2)
|
if (argc >= 2)
|
||||||
hex_editor_widget->open_file(argv[1]);
|
hex_editor_widget->open_file(argv[1]);
|
||||||
|
|
|
@ -55,7 +55,7 @@ IRCAppWindow::IRCAppWindow()
|
||||||
ASSERT(!s_the);
|
ASSERT(!s_the);
|
||||||
s_the = this;
|
s_the = this;
|
||||||
|
|
||||||
set_icon(load_png("/res/icons/16x16/app-irc-client.png"));
|
set_icon(Gfx::load_png("/res/icons/16x16/app-irc-client.png"));
|
||||||
|
|
||||||
update_title();
|
update_title();
|
||||||
set_rect(200, 200, 600, 400);
|
set_rect(200, 200, 600, 400);
|
||||||
|
@ -108,13 +108,13 @@ void IRCAppWindow::setup_client()
|
||||||
|
|
||||||
void IRCAppWindow::setup_actions()
|
void IRCAppWindow::setup_actions()
|
||||||
{
|
{
|
||||||
m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
|
m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
|
||||||
auto input_box = GUI::InputBox::construct("Enter channel name:", "Join channel", this);
|
auto input_box = GUI::InputBox::construct("Enter channel name:", "Join channel", this);
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
m_client.handle_join_action(input_box->text_value());
|
m_client.handle_join_action(input_box->text_value());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_part_action = GUI::Action::create("Part from channel", { Mod_Ctrl, Key_P }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) {
|
m_part_action = GUI::Action::create("Part from channel", { Mod_Ctrl, Key_P }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) {
|
||||||
auto* window = m_client.current_window();
|
auto* window = m_client.current_window();
|
||||||
if (!window || window->type() != IRCWindow::Type::Channel) {
|
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||||
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||||
|
@ -123,23 +123,23 @@ void IRCAppWindow::setup_actions()
|
||||||
m_client.handle_part_action(window->channel().name());
|
m_client.handle_part_action(window->channel().name());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_whois_action = GUI::Action::create("Whois user", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) {
|
m_whois_action = GUI::Action::create("Whois user", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) {
|
||||||
auto input_box = GUI::InputBox::construct("Enter nickname:", "IRC WHOIS lookup", this);
|
auto input_box = GUI::InputBox::construct("Enter nickname:", "IRC WHOIS lookup", this);
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
m_client.handle_whois_action(input_box->text_value());
|
m_client.handle_whois_action(input_box->text_value());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_open_query_action = GUI::Action::create("Open query", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) {
|
m_open_query_action = GUI::Action::create("Open query", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) {
|
||||||
auto input_box = GUI::InputBox::construct("Enter nickname:", "Open IRC query with...", this);
|
auto input_box = GUI::InputBox::construct("Enter nickname:", "Open IRC query with...", this);
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
m_client.handle_open_query_action(input_box->text_value());
|
m_client.handle_open_query_action(input_box->text_value());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_close_query_action = GUI::Action::create("Close query", { Mod_Ctrl, Key_D }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) {
|
m_close_query_action = GUI::Action::create("Close query", { Mod_Ctrl, Key_D }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) {
|
||||||
printf("FIXME: Implement close-query action\n");
|
printf("FIXME: Implement close-query action\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
m_change_nick_action = GUI::Action::create("Change nickname", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) {
|
m_change_nick_action = GUI::Action::create("Change nickname", Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) {
|
||||||
auto input_box = GUI::InputBox::construct("Enter nickname:", "Change nickname", this);
|
auto input_box = GUI::InputBox::construct("Enter nickname:", "Change nickname", this);
|
||||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||||
m_client.handle_change_nick_action(input_box->text_value());
|
m_client.handle_change_nick_action(input_box->text_value());
|
||||||
|
@ -170,7 +170,7 @@ void IRCAppWindow::setup_menus()
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [this](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [this](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("IRC Client", load_png("/res/icons/32x32/app-irc-client.png"), this);
|
GUI::AboutDialog::show("IRC Client", Gfx::load_png("/res/icons/32x32/app-irc-client.png"), this);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ GUI::Model::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::Name:
|
case Column::Name:
|
||||||
return { 70, TextAlignment::CenterLeft };
|
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ GUI::Model::ColumnMetadata IRCWindowListModel::column_metadata(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::Name:
|
case Column::Name:
|
||||||
return { 70, TextAlignment::CenterLeft };
|
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||||
}
|
}
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ BucketTool::~BucketTool()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flood_fill(GraphicsBitmap& bitmap, const Point& start_position, Color target_color, Color fill_color)
|
static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Color target_color, Color fill_color)
|
||||||
{
|
{
|
||||||
ASSERT(bitmap.bpp() == 32);
|
ASSERT(bitmap.bpp() == 32);
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ static void flood_fill(GraphicsBitmap& bitmap, const Point& start_position, Colo
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Queue<Point> queue;
|
Queue<Point> queue;
|
||||||
queue.enqueue(Point(start_position));
|
queue.enqueue(start_position);
|
||||||
while (!queue.is_empty()) {
|
while (!queue.is_empty()) {
|
||||||
auto position = queue.dequeue();
|
auto position = queue.dequeue();
|
||||||
|
|
||||||
if (bitmap.get_pixel<GraphicsBitmap::Format::RGB32>(position.x(), position.y()) != target_color)
|
if (bitmap.get_pixel<Gfx::Bitmap::Format::RGB32>(position.x(), position.y()) != target_color)
|
||||||
continue;
|
continue;
|
||||||
bitmap.set_pixel<GraphicsBitmap::Format::RGB32>(position.x(), position.y(), fill_color);
|
bitmap.set_pixel<Gfx::Bitmap::Format::RGB32>(position.x(), position.y(), fill_color);
|
||||||
|
|
||||||
if (position.x() != 0)
|
if (position.x() != 0)
|
||||||
queue.enqueue(position.translated(-1, 0));
|
queue.enqueue(position.translated(-1, 0));
|
||||||
|
|
|
@ -57,8 +57,8 @@ private:
|
||||||
void draw_using(GUI::Painter& painter);
|
void draw_using(GUI::Painter& painter);
|
||||||
|
|
||||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||||
Point m_ellipse_start_position;
|
Gfx::Point m_ellipse_start_position;
|
||||||
Point m_ellipse_end_position;
|
Gfx::Point m_ellipse_end_position;
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
int m_thickness { 1 };
|
int m_thickness { 1 };
|
||||||
GUI::ActionGroup m_thickness_actions;
|
GUI::ActionGroup m_thickness_actions;
|
||||||
|
|
|
@ -38,7 +38,7 @@ EraseTool::~EraseTool()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect EraseTool::build_rect(const Point& pos, const Rect& widget_rect)
|
Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect)
|
||||||
{
|
{
|
||||||
const int base_eraser_size = 10;
|
const int base_eraser_size = 10;
|
||||||
const int eraser_size = (base_eraser_size * m_thickness);
|
const int eraser_size = (base_eraser_size * m_thickness);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Color get_color() const;
|
Color get_color() const;
|
||||||
virtual const char* class_name() const override { return "EraseTool"; }
|
virtual const char* class_name() const override { return "EraseTool"; }
|
||||||
Rect build_rect(const Point& pos, const Rect& widget_rect);
|
Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect);
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
|
|
||||||
bool m_use_secondary_color { true };
|
bool m_use_secondary_color { true };
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <LibGUI/GPainter.h>
|
#include <LibGUI/GPainter.h>
|
||||||
#include <LibM/math.h>
|
#include <LibM/math.h>
|
||||||
|
|
||||||
Point constrain_line_angle(const Point& start_pos, const Point& end_pos, float angle_increment)
|
Point constrain_line_angle(const Gfx::Point& start_pos, const Gfx::Point& end_pos, float angle_increment)
|
||||||
{
|
{
|
||||||
float current_angle = atan2(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + M_PI * 2.;
|
float current_angle = atan2(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + M_PI * 2.;
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,8 @@ private:
|
||||||
virtual const char* class_name() const override { return "LineTool"; }
|
virtual const char* class_name() const override { return "LineTool"; }
|
||||||
|
|
||||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||||
Point m_line_start_position;
|
Gfx::Point m_line_start_position;
|
||||||
Point m_line_end_position;
|
Gfx::Point m_line_end_position;
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
GUI::ActionGroup m_thickness_actions;
|
GUI::ActionGroup m_thickness_actions;
|
||||||
int m_thickness { 1 };
|
int m_thickness { 1 };
|
||||||
|
|
|
@ -47,7 +47,7 @@ PaintableWidget::PaintableWidget(GUI::Widget* parent)
|
||||||
pal.set_color(ColorRole::Window, Color::MidGray);
|
pal.set_color(ColorRole::Window, Color::MidGray);
|
||||||
set_palette(pal);
|
set_palette(pal);
|
||||||
set_background_color(Color::MidGray);
|
set_background_color(Color::MidGray);
|
||||||
m_bitmap = GraphicsBitmap::create(GraphicsBitmap::Format::RGB32, { 600, 400 });
|
m_bitmap = Gfx::Bitmap::create(Gfx::Bitmap::Format::RGB32, { 600, 400 });
|
||||||
m_bitmap->fill(Color::White);
|
m_bitmap->fill(Color::White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void PaintableWidget::set_secondary_color(Color color)
|
||||||
on_secondary_color_change(color);
|
on_secondary_color_change(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintableWidget::set_bitmap(const GraphicsBitmap& bitmap)
|
void PaintableWidget::set_bitmap(const Gfx::Bitmap& bitmap)
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmap = bitmap;
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -49,10 +49,10 @@ public:
|
||||||
Color color_for(const GUI::MouseEvent&) const;
|
Color color_for(const GUI::MouseEvent&) const;
|
||||||
Color color_for(GUI::MouseButton) const;
|
Color color_for(GUI::MouseButton) const;
|
||||||
|
|
||||||
void set_bitmap(const GraphicsBitmap&);
|
void set_bitmap(const Gfx::Bitmap&);
|
||||||
|
|
||||||
GraphicsBitmap& bitmap() { return *m_bitmap; }
|
Gfx::Bitmap& bitmap() { return *m_bitmap; }
|
||||||
const GraphicsBitmap& bitmap() const { return *m_bitmap; }
|
const Gfx::Bitmap& bitmap() const { return *m_bitmap; }
|
||||||
|
|
||||||
Function<void(Color)> on_primary_color_change;
|
Function<void(Color)> on_primary_color_change;
|
||||||
Function<void(Color)> on_secondary_color_change;
|
Function<void(Color)> on_secondary_color_change;
|
||||||
|
@ -67,7 +67,7 @@ private:
|
||||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||||
virtual void keyup_event(GUI::KeyEvent&) override;
|
virtual void keyup_event(GUI::KeyEvent&) override;
|
||||||
|
|
||||||
RefPtr<GraphicsBitmap> m_bitmap;
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||||
|
|
||||||
Color m_primary_color { Color::Black };
|
Color m_primary_color { Color::Black };
|
||||||
Color m_secondary_color { Color::White };
|
Color m_secondary_color { Color::White };
|
||||||
|
|
|
@ -38,8 +38,8 @@ public:
|
||||||
, m_color(color)
|
, m_color(color)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ColorWidget() override
|
virtual ~ColorWidget() override
|
||||||
|
@ -75,8 +75,8 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* par
|
||||||
: GUI::Frame(parent)
|
: GUI::Frame(parent)
|
||||||
, m_paintable_widget(paintable_widget)
|
, m_paintable_widget(paintable_widget)
|
||||||
{
|
{
|
||||||
set_frame_shape(FrameShape::Panel);
|
set_frame_shape(Gfx::FrameShape::Panel);
|
||||||
set_frame_shadow(FrameShadow::Raised);
|
set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||||
set_frame_thickness(0);
|
set_frame_thickness(0);
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
|
|
||||||
|
@ -85,16 +85,16 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* par
|
||||||
|
|
||||||
m_secondary_color_widget = GUI::Frame::construct(this);
|
m_secondary_color_widget = GUI::Frame::construct(this);
|
||||||
m_secondary_color_widget->set_frame_thickness(2);
|
m_secondary_color_widget->set_frame_thickness(2);
|
||||||
m_secondary_color_widget->set_frame_shape(FrameShape::Container);
|
m_secondary_color_widget->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
m_secondary_color_widget->set_frame_shadow(FrameShadow::Sunken);
|
m_secondary_color_widget->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
m_secondary_color_widget->set_relative_rect({ 2, 2, 60, 31 });
|
m_secondary_color_widget->set_relative_rect({ 2, 2, 60, 31 });
|
||||||
m_secondary_color_widget->set_fill_with_background_color(true);
|
m_secondary_color_widget->set_fill_with_background_color(true);
|
||||||
set_secondary_color(paintable_widget.secondary_color());
|
set_secondary_color(paintable_widget.secondary_color());
|
||||||
|
|
||||||
m_primary_color_widget = GUI::Frame::construct(this);
|
m_primary_color_widget = GUI::Frame::construct(this);
|
||||||
m_primary_color_widget->set_frame_thickness(2);
|
m_primary_color_widget->set_frame_thickness(2);
|
||||||
m_primary_color_widget->set_frame_shape(FrameShape::Container);
|
m_primary_color_widget->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
m_primary_color_widget->set_frame_shadow(FrameShadow::Sunken);
|
m_primary_color_widget->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
Rect rect { 0, 0, 38, 15 };
|
Rect rect { 0, 0, 38, 15 };
|
||||||
rect.center_within(m_secondary_color_widget->relative_rect());
|
rect.center_within(m_secondary_color_widget->relative_rect());
|
||||||
m_primary_color_widget->set_relative_rect(rect);
|
m_primary_color_widget->set_relative_rect(rect);
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
private:
|
private:
|
||||||
virtual const char* class_name() const override { return "PenTool"; }
|
virtual const char* class_name() const override { return "PenTool"; }
|
||||||
|
|
||||||
Point m_last_drawing_event_position { -1, -1 };
|
Gfx::Point m_last_drawing_event_position { -1, -1 };
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
int m_thickness { 1 };
|
int m_thickness { 1 };
|
||||||
GUI::ActionGroup m_thickness_actions;
|
GUI::ActionGroup m_thickness_actions;
|
||||||
|
|
|
@ -57,8 +57,8 @@ private:
|
||||||
void draw_using(GUI::Painter& painter);
|
void draw_using(GUI::Painter& painter);
|
||||||
|
|
||||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||||
Point m_rectangle_start_position;
|
Gfx::Point m_rectangle_start_position;
|
||||||
Point m_rectangle_end_position;
|
Gfx::Point m_rectangle_end_position;
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
Mode m_mode { Mode::Outline };
|
Mode m_mode { Mode::Outline };
|
||||||
};
|
};
|
||||||
|
|
|
@ -70,7 +70,7 @@ void SprayTool::paint_it()
|
||||||
continue;
|
continue;
|
||||||
if (ypos < 0 || ypos >= bitmap.height())
|
if (ypos < 0 || ypos >= bitmap.height())
|
||||||
continue;
|
continue;
|
||||||
bitmap.set_pixel<GraphicsBitmap::Format::RGB32>(xpos, ypos, m_color);
|
bitmap.set_pixel<Gfx::Bitmap::Format::RGB32>(xpos, ypos, m_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ private:
|
||||||
virtual const char* class_name() const override { return "SprayTool"; }
|
virtual const char* class_name() const override { return "SprayTool"; }
|
||||||
void paint_it();
|
void paint_it();
|
||||||
RefPtr<Core::Timer> m_timer;
|
RefPtr<Core::Timer> m_timer;
|
||||||
Point m_last_pos;
|
Gfx::Point m_last_pos;
|
||||||
Color m_color;
|
Color m_color;
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
GUI::ActionGroup m_thickness_actions;
|
GUI::ActionGroup m_thickness_actions;
|
||||||
|
|
|
@ -67,8 +67,8 @@ ToolboxWidget::ToolboxWidget(GUI::Widget* parent)
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
|
|
||||||
set_frame_thickness(1);
|
set_frame_thickness(1);
|
||||||
set_frame_shape(FrameShape::Panel);
|
set_frame_shape(Gfx::FrameShape::Panel);
|
||||||
set_frame_shadow(FrameShadow::Raised);
|
set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||||
|
|
||||||
set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
set_preferred_size(48, 0);
|
set_preferred_size(48, 0);
|
||||||
|
@ -83,7 +83,7 @@ ToolboxWidget::ToolboxWidget(GUI::Widget* parent)
|
||||||
button->set_checkable(true);
|
button->set_checkable(true);
|
||||||
button->set_exclusive(true);
|
button->set_exclusive(true);
|
||||||
|
|
||||||
button->set_icon(load_png(String::format("/res/icons/paintbrush/%s.png", String(icon_name).characters())));
|
button->set_icon(Gfx::load_png(String::format("/res/icons/paintbrush/%s.png", String(icon_name).characters())));
|
||||||
|
|
||||||
button->on_checked = [button = button.ptr()](auto checked) {
|
button->on_checked = [button = button.ptr()](auto checked) {
|
||||||
if (checked)
|
if (checked)
|
||||||
|
|
|
@ -56,7 +56,7 @@ int main(int argc, char** argv)
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
window->set_title("PaintBrush");
|
window->set_title("PaintBrush");
|
||||||
window->set_rect(100, 100, 640, 480);
|
window->set_rect(100, 100, 640, 480);
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-paintbrush.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-paintbrush.png"));
|
||||||
|
|
||||||
auto horizontal_container = GUI::Widget::construct();
|
auto horizontal_container = GUI::Widget::construct();
|
||||||
window->set_main_widget(horizontal_container);
|
window->set_main_widget(horizontal_container);
|
||||||
|
@ -84,7 +84,7 @@ int main(int argc, char** argv)
|
||||||
if (!open_path.has_value())
|
if (!open_path.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto bitmap = load_png(open_path.value());
|
auto bitmap = Gfx::load_png(open_path.value());
|
||||||
if (!bitmap) {
|
if (!bitmap) {
|
||||||
GUI::MessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
|
GUI::MessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window);
|
||||||
return;
|
return;
|
||||||
|
@ -104,7 +104,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](auto&) {
|
help_menu->add_action(GUI::Action::create("About", [&](auto&) {
|
||||||
GUI::AboutDialog::show("PaintBrush", load_png("/res/icons/32x32/app-paintbrush.png"), window);
|
GUI::AboutDialog::show("PaintBrush", Gfx::load_png("/res/icons/32x32/app-paintbrush.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ KeysWidget::KeysWidget(GUI::Widget* parent, AudioEngine& audio_engine)
|
||||||
, m_audio_engine(audio_engine)
|
, m_audio_engine(audio_engine)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
|
||||||
painter.draw_rect(rect, Color::Black);
|
painter.draw_rect(rect, Color::Black);
|
||||||
if (i < white_key_labels_count) {
|
if (i < white_key_labels_count) {
|
||||||
rect.set_height(rect.height() * 1.5);
|
rect.set_height(rect.height() * 1.5);
|
||||||
painter.draw_text(rect, StringView(&white_key_labels[i], 1), TextAlignment::Center, Color::Black);
|
painter.draw_text(rect, StringView(&white_key_labels[i], 1), Gfx::TextAlignment::Center, Color::Black);
|
||||||
}
|
}
|
||||||
|
|
||||||
note += white_key_note_accumulator[i % white_keys_per_octave];
|
note += white_key_note_accumulator[i % white_keys_per_octave];
|
||||||
|
@ -210,7 +210,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
|
||||||
painter.draw_rect(rect, Color::Black);
|
painter.draw_rect(rect, Color::Black);
|
||||||
if (i < black_key_labels_count) {
|
if (i < black_key_labels_count) {
|
||||||
rect.set_height(rect.height() * 1.5);
|
rect.set_height(rect.height() * 1.5);
|
||||||
painter.draw_text(rect, StringView(&black_key_labels[i], 1), TextAlignment::Center, Color::White);
|
painter.draw_text(rect, StringView(&black_key_labels[i], 1), Gfx::TextAlignment::Center, Color::White);
|
||||||
}
|
}
|
||||||
|
|
||||||
note += black_key_note_accumulator[i % black_keys_per_octave];
|
note += black_key_note_accumulator[i % black_keys_per_octave];
|
||||||
|
@ -249,11 +249,12 @@ static inline int note_from_white_keys(int white_keys)
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KeysWidget::note_for_event_position(Point point) const
|
int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const
|
||||||
{
|
{
|
||||||
if (!frame_inner_rect().contains(point))
|
if (!frame_inner_rect().contains(a_point))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
auto point = a_point;
|
||||||
point.move_by(-frame_thickness(), -frame_thickness());
|
point.move_by(-frame_thickness(), -frame_thickness());
|
||||||
|
|
||||||
int white_keys = point.x() / white_key_width;
|
int white_keys = point.x() / white_key_width;
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||||
|
|
||||||
int note_for_event_position(Point) const;
|
int note_for_event_position(const Gfx::Point&) const;
|
||||||
|
|
||||||
AudioEngine& m_audio_engine;
|
AudioEngine& m_audio_engine;
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid
|
||||||
, m_main_widget(main_widget)
|
, m_main_widget(main_widget)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_layout(make<GUI::VBoxLayout>());
|
set_layout(make<GUI::VBoxLayout>());
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@ RollWidget::RollWidget(GUI::Widget* parent, AudioEngine& audio_engine)
|
||||||
, m_audio_engine(audio_engine)
|
, m_audio_engine(audio_engine)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
|
|
||||||
set_should_hide_unnecessary_scrollbars(true);
|
set_should_hide_unnecessary_scrollbars(true);
|
||||||
set_content_size({ 0, roll_height });
|
set_content_size({ 0, roll_height });
|
||||||
|
|
|
@ -35,8 +35,8 @@ WaveWidget::WaveWidget(GUI::Widget* parent, AudioEngine& audio_engine)
|
||||||
, m_audio_engine(audio_engine)
|
, m_audio_engine(audio_engine)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveWidget::~WaveWidget()
|
WaveWidget::~WaveWidget()
|
||||||
|
|
|
@ -51,7 +51,7 @@ int main(int argc, char** argv)
|
||||||
window->set_main_widget(main_widget);
|
window->set_main_widget(main_widget);
|
||||||
window->set_title("Piano");
|
window->set_title("Piano");
|
||||||
window->set_rect(90, 90, 840, 600);
|
window->set_rect(90, 90, 840, 600);
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-piano.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-piano.png"));
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
LibThread::Thread audio_thread([&] {
|
LibThread::Thread audio_thread([&] {
|
||||||
|
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Piano", load_png("/res/icons/32x32/app-piano.png"), window);
|
GUI::AboutDialog::show("Piano", Gfx::load_png("/res/icons/32x32/app-piano.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
QSWidget::QSWidget(GUI::Widget* parent)
|
QSWidget::QSWidget(GUI::Widget* parent)
|
||||||
: GUI::Frame(parent)
|
: GUI::Frame(parent)
|
||||||
{
|
{
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
|
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
|
@ -46,7 +46,7 @@ QSWidget::~QSWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSWidget::set_bitmap(NonnullRefPtr<GraphicsBitmap> bitmap)
|
void QSWidget::set_bitmap(NonnullRefPtr<Gfx::Bitmap> bitmap)
|
||||||
{
|
{
|
||||||
m_bitmap = move(bitmap);
|
m_bitmap = move(bitmap);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ void QSWidget::drop_event(GUI::DropEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
URL url(lines[0]);
|
URL url(lines[0]);
|
||||||
auto bitmap = GraphicsBitmap::load_from_file(url.path());
|
auto bitmap = Gfx::Bitmap::load_from_file(url.path());
|
||||||
if (!bitmap) {
|
if (!bitmap) {
|
||||||
GUI::MessageBox::show(String::format("Failed to open %s", url.to_string().characters()), "Cannot open image", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
GUI::MessageBox::show(String::format("Failed to open %s", url.to_string().characters()), "Cannot open image", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -35,8 +35,8 @@ class QSWidget final : public GUI::Frame {
|
||||||
public:
|
public:
|
||||||
virtual ~QSWidget() override;
|
virtual ~QSWidget() override;
|
||||||
|
|
||||||
void set_bitmap(NonnullRefPtr<GraphicsBitmap>);
|
void set_bitmap(NonnullRefPtr<Gfx::Bitmap>);
|
||||||
const GraphicsBitmap* bitmap() const { return m_bitmap.ptr(); }
|
const Gfx::Bitmap* bitmap() const { return m_bitmap.ptr(); }
|
||||||
|
|
||||||
void set_path(const String&);
|
void set_path(const String&);
|
||||||
const String& path() const { return m_path; }
|
const String& path() const { return m_path; }
|
||||||
|
@ -55,10 +55,10 @@ private:
|
||||||
|
|
||||||
void relayout();
|
void relayout();
|
||||||
|
|
||||||
RefPtr<GraphicsBitmap> m_bitmap;
|
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||||
Rect m_bitmap_rect;
|
Gfx::Rect m_bitmap_rect;
|
||||||
int m_scale { 100 };
|
int m_scale { 100 };
|
||||||
Point m_pan_origin;
|
Gfx::Point m_pan_origin;
|
||||||
Point m_pan_bitmap_origin;
|
Gfx::Point m_pan_bitmap_origin;
|
||||||
String m_path;
|
String m_path;
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,7 +80,7 @@ int main(int argc, char** argv)
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
path = argv[1];
|
path = argv[1];
|
||||||
|
|
||||||
auto bitmap = GraphicsBitmap::load_from_file(path);
|
auto bitmap = Gfx::Bitmap::load_from_file(path);
|
||||||
if (!bitmap) {
|
if (!bitmap) {
|
||||||
fprintf(stderr, "Failed to load %s\n", path);
|
fprintf(stderr, "Failed to load %s\n", path);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
SampleWidget::SampleWidget(GUI::Widget* parent)
|
SampleWidget::SampleWidget(GUI::Widget* parent)
|
||||||
: GUI::Frame(parent)
|
: GUI::Frame(parent)
|
||||||
{
|
{
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C
|
||||||
status_widget->set_layout(make<GUI::HBoxLayout>());
|
status_widget->set_layout(make<GUI::HBoxLayout>());
|
||||||
|
|
||||||
m_elapsed = GUI::Label::construct(status_widget);
|
m_elapsed = GUI::Label::construct(status_widget);
|
||||||
m_elapsed->set_frame_shape(FrameShape::Container);
|
m_elapsed->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
m_elapsed->set_frame_shadow(FrameShadow::Sunken);
|
m_elapsed->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
m_elapsed->set_frame_thickness(2);
|
m_elapsed->set_frame_thickness(2);
|
||||||
m_elapsed->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
m_elapsed->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
m_elapsed->set_preferred_size(80, 0);
|
m_elapsed->set_preferred_size(80, 0);
|
||||||
|
@ -59,8 +59,8 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C
|
||||||
m_sample_widget = SampleWidget::construct(sample_widget_container);
|
m_sample_widget = SampleWidget::construct(sample_widget_container);
|
||||||
|
|
||||||
m_remaining = GUI::Label::construct(status_widget);
|
m_remaining = GUI::Label::construct(status_widget);
|
||||||
m_remaining->set_frame_shape(FrameShape::Container);
|
m_remaining->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
m_remaining->set_frame_shadow(FrameShadow::Sunken);
|
m_remaining->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
m_remaining->set_frame_thickness(2);
|
m_remaining->set_frame_thickness(2);
|
||||||
m_remaining->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
m_remaining->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
m_remaining->set_preferred_size(80, 0);
|
m_remaining->set_preferred_size(80, 0);
|
||||||
|
@ -87,14 +87,14 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C
|
||||||
|
|
||||||
m_stop = GUI::Button::construct(control_widget);
|
m_stop = GUI::Button::construct(control_widget);
|
||||||
m_stop->set_enabled(false);
|
m_stop->set_enabled(false);
|
||||||
m_stop->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png"));
|
m_stop->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png"));
|
||||||
m_stop->on_click = [&](GUI::Button&) { m_manager.stop(); };
|
m_stop->on_click = [&](GUI::Button&) { m_manager.stop(); };
|
||||||
|
|
||||||
m_status = GUI::Label::construct(this);
|
m_status = GUI::Label::construct(this);
|
||||||
m_status->set_frame_shape(FrameShape::Box);
|
m_status->set_frame_shape(Gfx::FrameShape::Box);
|
||||||
m_status->set_frame_shadow(FrameShadow::Raised);
|
m_status->set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||||
m_status->set_frame_thickness(4);
|
m_status->set_frame_thickness(4);
|
||||||
m_status->set_text_alignment(TextAlignment::CenterLeft);
|
m_status->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
m_status->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
m_status->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
m_status->set_preferred_size(0, 18);
|
m_status->set_preferred_size(0, 18);
|
||||||
m_status->set_text("No file open!");
|
m_status->set_text("No file open!");
|
||||||
|
|
|
@ -85,8 +85,8 @@ private:
|
||||||
RefPtr<GUI::Label> m_remaining;
|
RefPtr<GUI::Label> m_remaining;
|
||||||
RefPtr<Slider> m_slider;
|
RefPtr<Slider> m_slider;
|
||||||
RefPtr<SampleWidget> m_sample_widget;
|
RefPtr<SampleWidget> m_sample_widget;
|
||||||
RefPtr<GraphicsBitmap> m_play_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/play.png") };
|
RefPtr<Gfx::Bitmap> m_play_icon { Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png") };
|
||||||
RefPtr<GraphicsBitmap> m_pause_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/pause.png") };
|
RefPtr<Gfx::Bitmap> m_pause_icon { Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png") };
|
||||||
RefPtr<GUI::Button> m_play;
|
RefPtr<GUI::Button> m_play;
|
||||||
RefPtr<GUI::Button> m_stop;
|
RefPtr<GUI::Button> m_stop;
|
||||||
};
|
};
|
||||||
|
|
|
@ -62,7 +62,7 @@ int main(int argc, char** argv)
|
||||||
window->set_title("SoundPlayer");
|
window->set_title("SoundPlayer");
|
||||||
window->set_resizable(false);
|
window->set_resizable(false);
|
||||||
window->set_rect(300, 300, 350, 140);
|
window->set_rect(300, 300, 350, 140);
|
||||||
window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-sound-player.png"));
|
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-sound-player.png"));
|
||||||
|
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
auto app_menu = GUI::Menu::construct("SoundPlayer");
|
auto app_menu = GUI::Menu::construct("SoundPlayer");
|
||||||
|
@ -94,7 +94,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [](auto&) {
|
help_menu->add_action(GUI::Action::create("About", [](auto&) {
|
||||||
GUI::AboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png"));
|
GUI::AboutDialog::show("SoundPlayer", Gfx::Bitmap::load_from_file("/res/icons/32x32/app-sound-player.png"));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
menubar->add_menu(move(app_menu));
|
menubar->add_menu(move(app_menu));
|
||||||
|
|
|
@ -77,15 +77,15 @@ GUI::Model::ColumnMetadata DevicesModel::column_metadata(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::Device:
|
case Column::Device:
|
||||||
return { 70, TextAlignment::CenterLeft };
|
return { 70, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::Major:
|
case Column::Major:
|
||||||
return { 32, TextAlignment::CenterRight };
|
return { 32, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::Minor:
|
case Column::Minor:
|
||||||
return { 32, TextAlignment::CenterRight };
|
return { 32, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::ClassName:
|
case Column::ClassName:
|
||||||
return { 120, TextAlignment::CenterLeft };
|
return { 120, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::Type:
|
case Column::Type:
|
||||||
return { 120, TextAlignment::CenterLeft };
|
return { 120, Gfx::TextAlignment::CenterLeft };
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ GraphWidget::GraphWidget(GUI::Widget* parent)
|
||||||
: GUI::Frame(parent)
|
: GUI::Frame(parent)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphWidget::~GraphWidget()
|
GraphWidget::~GraphWidget()
|
||||||
|
@ -72,7 +72,7 @@ void GraphWidget::paint_event(GUI::PaintEvent& event)
|
||||||
Rect text_rect = inner_rect.shrunken(8, 8);
|
Rect text_rect = inner_rect.shrunken(8, 8);
|
||||||
text_rect.set_height(font().glyph_height());
|
text_rect.set_height(font().glyph_height());
|
||||||
auto text = text_formatter(m_values.last(), m_max);
|
auto text = text_formatter(m_values.last(), m_max);
|
||||||
painter.draw_text(text_rect.translated(1, 1), text.characters(), TextAlignment::CenterRight, Color::Black);
|
painter.draw_text(text_rect.translated(1, 1), text.characters(), Gfx::TextAlignment::CenterRight, Color::Black);
|
||||||
painter.draw_text(text_rect, text.characters(), TextAlignment::CenterRight, m_text_color);
|
painter.draw_text(text_rect, text.characters(), Gfx::TextAlignment::CenterRight, m_text_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,10 +62,10 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GUI::Widget* parent)
|
||||||
container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
container->set_preferred_size(275, 12);
|
container->set_preferred_size(275, 12);
|
||||||
auto description_label = GUI::Label::construct(description, container);
|
auto description_label = GUI::Label::construct(description, container);
|
||||||
description_label->set_font(Font::default_bold_font());
|
description_label->set_font(Gfx::Font::default_bold_font());
|
||||||
description_label->set_text_alignment(TextAlignment::CenterLeft);
|
description_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
auto label = GUI::Label::construct(container);
|
auto label = GUI::Label::construct(container);
|
||||||
label->set_text_alignment(TextAlignment::CenterRight);
|
label->set_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
return label;
|
return label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,14 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent)
|
||||||
m_adapter_table_view->set_size_columns_to_fit_content(true);
|
m_adapter_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> net_adapters_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> net_adapters_fields;
|
||||||
net_adapters_fields.empend("name", "Name", TextAlignment::CenterLeft);
|
net_adapters_fields.empend("name", "Name", Gfx::TextAlignment::CenterLeft);
|
||||||
net_adapters_fields.empend("class_name", "Class", TextAlignment::CenterLeft);
|
net_adapters_fields.empend("class_name", "Class", Gfx::TextAlignment::CenterLeft);
|
||||||
net_adapters_fields.empend("mac_address", "MAC", TextAlignment::CenterLeft);
|
net_adapters_fields.empend("mac_address", "MAC", Gfx::TextAlignment::CenterLeft);
|
||||||
net_adapters_fields.empend("ipv4_address", "IPv4", TextAlignment::CenterLeft);
|
net_adapters_fields.empend("ipv4_address", "IPv4", Gfx::TextAlignment::CenterLeft);
|
||||||
net_adapters_fields.empend("packets_in", "Pkt In", TextAlignment::CenterRight);
|
net_adapters_fields.empend("packets_in", "Pkt In", Gfx::TextAlignment::CenterRight);
|
||||||
net_adapters_fields.empend("packets_out", "Pkt Out", TextAlignment::CenterRight);
|
net_adapters_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight);
|
||||||
net_adapters_fields.empend("bytes_in", "Bytes In", TextAlignment::CenterRight);
|
net_adapters_fields.empend("bytes_in", "Bytes In", Gfx::TextAlignment::CenterRight);
|
||||||
net_adapters_fields.empend("bytes_out", "Bytes Out", TextAlignment::CenterRight);
|
net_adapters_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight);
|
||||||
m_adapter_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)));
|
m_adapter_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)));
|
||||||
|
|
||||||
auto sockets_group_box = GUI::GroupBox::construct("Sockets", this);
|
auto sockets_group_box = GUI::GroupBox::construct("Sockets", this);
|
||||||
|
@ -68,17 +68,17 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent)
|
||||||
m_socket_table_view->set_size_columns_to_fit_content(true);
|
m_socket_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> net_tcp_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> net_tcp_fields;
|
||||||
net_tcp_fields.empend("peer_address", "Peer", TextAlignment::CenterLeft);
|
net_tcp_fields.empend("peer_address", "Peer", Gfx::TextAlignment::CenterLeft);
|
||||||
net_tcp_fields.empend("peer_port", "Port", TextAlignment::CenterRight);
|
net_tcp_fields.empend("peer_port", "Port", Gfx::TextAlignment::CenterRight);
|
||||||
net_tcp_fields.empend("local_address", "Local", TextAlignment::CenterLeft);
|
net_tcp_fields.empend("local_address", "Local", Gfx::TextAlignment::CenterLeft);
|
||||||
net_tcp_fields.empend("local_port", "Port", TextAlignment::CenterRight);
|
net_tcp_fields.empend("local_port", "Port", Gfx::TextAlignment::CenterRight);
|
||||||
net_tcp_fields.empend("state", "State", TextAlignment::CenterLeft);
|
net_tcp_fields.empend("state", "State", Gfx::TextAlignment::CenterLeft);
|
||||||
net_tcp_fields.empend("ack_number", "Ack#", TextAlignment::CenterRight);
|
net_tcp_fields.empend("ack_number", "Ack#", Gfx::TextAlignment::CenterRight);
|
||||||
net_tcp_fields.empend("sequence_number", "Seq#", TextAlignment::CenterRight);
|
net_tcp_fields.empend("sequence_number", "Seq#", Gfx::TextAlignment::CenterRight);
|
||||||
net_tcp_fields.empend("packets_in", "Pkt In", TextAlignment::CenterRight);
|
net_tcp_fields.empend("packets_in", "Pkt In", Gfx::TextAlignment::CenterRight);
|
||||||
net_tcp_fields.empend("packets_out", "Pkt Out", TextAlignment::CenterRight);
|
net_tcp_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight);
|
||||||
net_tcp_fields.empend("bytes_in", "Bytes In", TextAlignment::CenterRight);
|
net_tcp_fields.empend("bytes_in", "Bytes In", Gfx::TextAlignment::CenterRight);
|
||||||
net_tcp_fields.empend("bytes_out", "Bytes Out", TextAlignment::CenterRight);
|
net_tcp_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight);
|
||||||
m_socket_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields)));
|
m_socket_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields)));
|
||||||
|
|
||||||
m_update_timer = Core::Timer::construct(
|
m_update_timer = Core::Timer::construct(
|
||||||
|
|
|
@ -38,23 +38,23 @@ ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GUI::Widget* pare
|
||||||
m_table_view->set_size_columns_to_fit_content(true);
|
m_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_fds_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> pid_fds_fields;
|
||||||
pid_fds_fields.empend("fd", "FD", TextAlignment::CenterRight);
|
pid_fds_fields.empend("fd", "FD", Gfx::TextAlignment::CenterRight);
|
||||||
pid_fds_fields.empend("class", "Class", TextAlignment::CenterLeft);
|
pid_fds_fields.empend("class", "Class", Gfx::TextAlignment::CenterLeft);
|
||||||
pid_fds_fields.empend("offset", "Offset", TextAlignment::CenterRight);
|
pid_fds_fields.empend("offset", "Offset", Gfx::TextAlignment::CenterRight);
|
||||||
pid_fds_fields.empend("absolute_path", "Path", TextAlignment::CenterLeft);
|
pid_fds_fields.empend("absolute_path", "Path", Gfx::TextAlignment::CenterLeft);
|
||||||
pid_fds_fields.empend("Access", TextAlignment::CenterLeft, [](auto& object) {
|
pid_fds_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
return object.get("seekable").to_bool() ? "Seekable" : "Sequential";
|
return object.get("seekable").to_bool() ? "Seekable" : "Sequential";
|
||||||
});
|
});
|
||||||
pid_fds_fields.empend("Blocking", TextAlignment::CenterLeft, [](auto& object) {
|
pid_fds_fields.empend("Blocking", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
return object.get("blocking").to_bool() ? "Blocking" : "Nonblocking";
|
return object.get("blocking").to_bool() ? "Blocking" : "Nonblocking";
|
||||||
});
|
});
|
||||||
pid_fds_fields.empend("On exec", TextAlignment::CenterLeft, [](auto& object) {
|
pid_fds_fields.empend("On exec", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
return object.get("cloexec").to_bool() ? "Close" : "Keep";
|
return object.get("cloexec").to_bool() ? "Close" : "Keep";
|
||||||
});
|
});
|
||||||
pid_fds_fields.empend("Can read", TextAlignment::CenterLeft, [](auto& object) {
|
pid_fds_fields.empend("Can read", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
return object.get("can_read").to_bool() ? "Yes" : "No";
|
return object.get("can_read").to_bool() ? "Yes" : "No";
|
||||||
});
|
});
|
||||||
pid_fds_fields.empend("Can write", TextAlignment::CenterLeft, [](auto& object) {
|
pid_fds_fields.empend("Can write", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
return object.get("can_write").to_bool() ? "Yes" : "No";
|
return object.get("can_write").to_bool() ? "Yes" : "No";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,13 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GUI::Widget* parent)
|
||||||
m_table_view = GUI::TableView::construct(this);
|
m_table_view = GUI::TableView::construct(this);
|
||||||
m_table_view->set_size_columns_to_fit_content(true);
|
m_table_view->set_size_columns_to_fit_content(true);
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields;
|
||||||
pid_vm_fields.empend("Address", TextAlignment::CenterLeft, [](auto& object) {
|
pid_vm_fields.empend("Address", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
return String::format("%#x", object.get("address").to_u32());
|
return String::format("%#x", object.get("address").to_u32());
|
||||||
});
|
});
|
||||||
pid_vm_fields.empend("size", "Size", TextAlignment::CenterRight);
|
pid_vm_fields.empend("size", "Size", Gfx::TextAlignment::CenterRight);
|
||||||
pid_vm_fields.empend("amount_resident", "Resident", TextAlignment::CenterRight);
|
pid_vm_fields.empend("amount_resident", "Resident", Gfx::TextAlignment::CenterRight);
|
||||||
pid_vm_fields.empend("amount_dirty", "Dirty", TextAlignment::CenterRight);
|
pid_vm_fields.empend("amount_dirty", "Dirty", Gfx::TextAlignment::CenterRight);
|
||||||
pid_vm_fields.empend("Access", TextAlignment::CenterLeft, [](auto& object) {
|
pid_vm_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
if (!object.get("user_accessible").to_bool())
|
if (!object.get("user_accessible").to_bool())
|
||||||
builder.append('K');
|
builder.append('K');
|
||||||
|
@ -61,15 +61,15 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GUI::Widget* parent)
|
||||||
builder.append('T');
|
builder.append('T');
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
});
|
});
|
||||||
pid_vm_fields.empend("Purgeable", TextAlignment::CenterLeft, [](auto& object) {
|
pid_vm_fields.empend("Purgeable", Gfx::TextAlignment::CenterLeft, [](auto& object) {
|
||||||
if (!object.get("purgeable").to_bool())
|
if (!object.get("purgeable").to_bool())
|
||||||
return "";
|
return "";
|
||||||
if (object.get("volatile").to_bool())
|
if (object.get("volatile").to_bool())
|
||||||
return "Volatile";
|
return "Volatile";
|
||||||
return "Non-volatile";
|
return "Non-volatile";
|
||||||
});
|
});
|
||||||
pid_vm_fields.empend("cow_pages", "# CoW", TextAlignment::CenterRight);
|
pid_vm_fields.empend("cow_pages", "# CoW", Gfx::TextAlignment::CenterRight);
|
||||||
pid_vm_fields.empend("name", "Name", TextAlignment::CenterLeft);
|
pid_vm_fields.empend("name", "Name", Gfx::TextAlignment::CenterLeft);
|
||||||
m_json_model = GUI::JsonArrayModel::create({}, move(pid_vm_fields));
|
m_json_model = GUI::JsonArrayModel::create({}, move(pid_vm_fields));
|
||||||
m_table_view->set_model(GUI::SortingProxyModel::create(*m_json_model));
|
m_table_view->set_model(GUI::SortingProxyModel::create(*m_json_model));
|
||||||
m_table_view->model()->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending);
|
m_table_view->model()->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending);
|
||||||
|
|
|
@ -46,10 +46,10 @@ ProcessModel::ProcessModel()
|
||||||
{
|
{
|
||||||
ASSERT(!s_the);
|
ASSERT(!s_the);
|
||||||
s_the = this;
|
s_the = this;
|
||||||
m_generic_process_icon = GraphicsBitmap::load_from_file("/res/icons/gear16.png");
|
m_generic_process_icon = Gfx::Bitmap::load_from_file("/res/icons/gear16.png");
|
||||||
m_high_priority_icon = GraphicsBitmap::load_from_file("/res/icons/highpriority16.png");
|
m_high_priority_icon = Gfx::Bitmap::load_from_file("/res/icons/highpriority16.png");
|
||||||
m_low_priority_icon = GraphicsBitmap::load_from_file("/res/icons/lowpriority16.png");
|
m_low_priority_icon = Gfx::Bitmap::load_from_file("/res/icons/lowpriority16.png");
|
||||||
m_normal_priority_icon = GraphicsBitmap::load_from_file("/res/icons/normalpriority16.png");
|
m_normal_priority_icon = Gfx::Bitmap::load_from_file("/res/icons/normalpriority16.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessModel::~ProcessModel()
|
ProcessModel::~ProcessModel()
|
||||||
|
@ -132,59 +132,59 @@ GUI::Model::ColumnMetadata ProcessModel::column_metadata(int column) const
|
||||||
{
|
{
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case Column::Icon:
|
case Column::Icon:
|
||||||
return { 16, TextAlignment::CenterLeft };
|
return { 16, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::PID:
|
case Column::PID:
|
||||||
return { 32, TextAlignment::CenterRight };
|
return { 32, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::TID:
|
case Column::TID:
|
||||||
return { 32, TextAlignment::CenterRight };
|
return { 32, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::State:
|
case Column::State:
|
||||||
return { 75, TextAlignment::CenterLeft };
|
return { 75, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::Priority:
|
case Column::Priority:
|
||||||
return { 16, TextAlignment::CenterRight };
|
return { 16, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::EffectivePriority:
|
case Column::EffectivePriority:
|
||||||
return { 16, TextAlignment::CenterRight };
|
return { 16, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::User:
|
case Column::User:
|
||||||
return { 50, TextAlignment::CenterLeft };
|
return { 50, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::Virtual:
|
case Column::Virtual:
|
||||||
return { 65, TextAlignment::CenterRight };
|
return { 65, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::Physical:
|
case Column::Physical:
|
||||||
return { 65, TextAlignment::CenterRight };
|
return { 65, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::DirtyPrivate:
|
case Column::DirtyPrivate:
|
||||||
return { 65, TextAlignment::CenterRight };
|
return { 65, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::CleanInode:
|
case Column::CleanInode:
|
||||||
return { 65, TextAlignment::CenterRight };
|
return { 65, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::PurgeableVolatile:
|
case Column::PurgeableVolatile:
|
||||||
return { 65, TextAlignment::CenterRight };
|
return { 65, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::PurgeableNonvolatile:
|
case Column::PurgeableNonvolatile:
|
||||||
return { 65, TextAlignment::CenterRight };
|
return { 65, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::CPU:
|
case Column::CPU:
|
||||||
return { 32, TextAlignment::CenterRight };
|
return { 32, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::Name:
|
case Column::Name:
|
||||||
return { 140, TextAlignment::CenterLeft };
|
return { 140, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::Syscalls:
|
case Column::Syscalls:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::InodeFaults:
|
case Column::InodeFaults:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::ZeroFaults:
|
case Column::ZeroFaults:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::CowFaults:
|
case Column::CowFaults:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::FileReadBytes:
|
case Column::FileReadBytes:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::FileWriteBytes:
|
case Column::FileWriteBytes:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::UnixSocketReadBytes:
|
case Column::UnixSocketReadBytes:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::UnixSocketWriteBytes:
|
case Column::UnixSocketWriteBytes:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::IPv4SocketReadBytes:
|
case Column::IPv4SocketReadBytes:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::IPv4SocketWriteBytes:
|
case Column::IPv4SocketWriteBytes:
|
||||||
return { 60, TextAlignment::CenterRight };
|
return { 60, Gfx::TextAlignment::CenterRight };
|
||||||
case Column::Pledge:
|
case Column::Pledge:
|
||||||
return { 60, TextAlignment::CenterLeft };
|
return { 60, Gfx::TextAlignment::CenterLeft };
|
||||||
case Column::Veil:
|
case Column::Veil:
|
||||||
return { 60, TextAlignment::CenterLeft };
|
return { 60, Gfx::TextAlignment::CenterLeft };
|
||||||
default:
|
default:
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const
|
||||||
if (thread.current_state.icon_id != -1) {
|
if (thread.current_state.icon_id != -1) {
|
||||||
auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(thread.current_state.icon_id);
|
auto icon_buffer = SharedBuffer::create_from_shared_buffer_id(thread.current_state.icon_id);
|
||||||
if (icon_buffer) {
|
if (icon_buffer) {
|
||||||
auto icon_bitmap = GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, *icon_buffer, { 16, 16 });
|
auto icon_bitmap = Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *icon_buffer, { 16, 16 });
|
||||||
if (icon_bitmap)
|
if (icon_bitmap)
|
||||||
return *icon_bitmap;
|
return *icon_bitmap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,10 +132,10 @@ private:
|
||||||
HashMap<uid_t, String> m_usernames;
|
HashMap<uid_t, String> m_usernames;
|
||||||
HashMap<PidAndTid, NonnullOwnPtr<Thread>> m_threads;
|
HashMap<PidAndTid, NonnullOwnPtr<Thread>> m_threads;
|
||||||
Vector<PidAndTid> m_pids;
|
Vector<PidAndTid> m_pids;
|
||||||
RefPtr<GraphicsBitmap> m_generic_process_icon;
|
RefPtr<Gfx::Bitmap> m_generic_process_icon;
|
||||||
RefPtr<GraphicsBitmap> m_high_priority_icon;
|
RefPtr<Gfx::Bitmap> m_high_priority_icon;
|
||||||
RefPtr<GraphicsBitmap> m_low_priority_icon;
|
RefPtr<Gfx::Bitmap> m_low_priority_icon;
|
||||||
RefPtr<GraphicsBitmap> m_normal_priority_icon;
|
RefPtr<Gfx::Bitmap> m_normal_priority_icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
|
@ -38,8 +38,8 @@ ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget(GUI::Widget* parent)
|
||||||
m_table_view->set_size_columns_to_fit_content(true);
|
m_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;
|
||||||
pid_unveil_fields.empend("path", "Path", TextAlignment::CenterLeft);
|
pid_unveil_fields.empend("path", "Path", Gfx::TextAlignment::CenterLeft);
|
||||||
pid_unveil_fields.empend("permissions", "Permissions", TextAlignment::CenterLeft);
|
pid_unveil_fields.empend("permissions", "Permissions", Gfx::TextAlignment::CenterLeft);
|
||||||
m_table_view->set_model(GUI::JsonArrayModel::create({}, move(pid_unveil_fields)));
|
m_table_view->set_model(GUI::JsonArrayModel::create({}, move(pid_unveil_fields)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,19 +152,19 @@ int main(int argc, char** argv)
|
||||||
memory_stats_widget->refresh();
|
memory_stats_widget->refresh();
|
||||||
}, window);
|
}, window);
|
||||||
|
|
||||||
auto kill_action = GUI::Action::create("Kill process", { Mod_Ctrl, Key_K }, GraphicsBitmap::load_from_file("/res/icons/kill16.png"), [process_table_view](const GUI::Action&) {
|
auto kill_action = GUI::Action::create("Kill process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::load_from_file("/res/icons/kill16.png"), [process_table_view](const GUI::Action&) {
|
||||||
pid_t pid = process_table_view->selected_pid();
|
pid_t pid = process_table_view->selected_pid();
|
||||||
if (pid != -1)
|
if (pid != -1)
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto stop_action = GUI::Action::create("Stop process", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/stop16.png"), [process_table_view](const GUI::Action&) {
|
auto stop_action = GUI::Action::create("Stop process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/stop16.png"), [process_table_view](const GUI::Action&) {
|
||||||
pid_t pid = process_table_view->selected_pid();
|
pid_t pid = process_table_view->selected_pid();
|
||||||
if (pid != -1)
|
if (pid != -1)
|
||||||
kill(pid, SIGSTOP);
|
kill(pid, SIGSTOP);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto continue_action = GUI::Action::create("Continue process", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/continue16.png"), [process_table_view](const GUI::Action&) {
|
auto continue_action = GUI::Action::create("Continue process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/continue16.png"), [process_table_view](const GUI::Action&) {
|
||||||
pid_t pid = process_table_view->selected_pid();
|
pid_t pid = process_table_view->selected_pid();
|
||||||
if (pid != -1)
|
if (pid != -1)
|
||||||
kill(pid, SIGCONT);
|
kill(pid, SIGCONT);
|
||||||
|
@ -222,7 +222,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("System Monitor", load_png("/res/icons/32x32/app-system-monitor.png"), window);
|
GUI::AboutDialog::show("System Monitor", Gfx::load_png("/res/icons/32x32/app-system-monitor.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-system-monitor.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-system-monitor.png"));
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate
|
||||||
public:
|
public:
|
||||||
virtual ~ProgressBarPaintingDelegate() override {}
|
virtual ~ProgressBarPaintingDelegate() override {}
|
||||||
|
|
||||||
virtual void paint(GUI::Painter& painter, const Rect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override
|
virtual void paint(GUI::Painter& painter, const Gfx::Rect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override
|
||||||
{
|
{
|
||||||
auto rect = a_rect.shrunken(2, 2);
|
auto rect = a_rect.shrunken(2, 2);
|
||||||
auto percentage = model.data(index, GUI::Model::Role::Custom).to_i32();
|
auto percentage = model.data(index, GUI::Model::Role::Custom).to_i32();
|
||||||
|
@ -269,7 +269,7 @@ public:
|
||||||
String text;
|
String text;
|
||||||
if (data.is_string())
|
if (data.is_string())
|
||||||
text = data.as_string();
|
text = data.as_string();
|
||||||
StylePainter::paint_progress_bar(painter, rect, palette, 0, 100, percentage, text);
|
Gfx::StylePainter::paint_progress_bar(painter, rect, palette, 0, 100, percentage, text);
|
||||||
painter.draw_rect(rect, Color::Black);
|
painter.draw_rect(rect, Color::Black);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -285,11 +285,11 @@ RefPtr<GUI::Widget> build_file_systems_tab()
|
||||||
fs_table_view->set_size_columns_to_fit_content(true);
|
fs_table_view->set_size_columns_to_fit_content(true);
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> df_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> df_fields;
|
||||||
df_fields.empend("mount_point", "Mount point", TextAlignment::CenterLeft);
|
df_fields.empend("mount_point", "Mount point", Gfx::TextAlignment::CenterLeft);
|
||||||
df_fields.empend("class_name", "Class", TextAlignment::CenterLeft);
|
df_fields.empend("class_name", "Class", Gfx::TextAlignment::CenterLeft);
|
||||||
df_fields.empend("device", "Device", TextAlignment::CenterLeft);
|
df_fields.empend("device", "Device", Gfx::TextAlignment::CenterLeft);
|
||||||
df_fields.empend(
|
df_fields.empend(
|
||||||
"Size", TextAlignment::CenterRight,
|
"Size", Gfx::TextAlignment::CenterRight,
|
||||||
[](const JsonObject& object) {
|
[](const JsonObject& object) {
|
||||||
return human_readable_size(object.get("total_block_count").to_u32() * object.get("block_size").to_u32());
|
return human_readable_size(object.get("total_block_count").to_u32() * object.get("block_size").to_u32());
|
||||||
},
|
},
|
||||||
|
@ -297,7 +297,7 @@ RefPtr<GUI::Widget> build_file_systems_tab()
|
||||||
return object.get("total_block_count").to_u32() * object.get("block_size").to_u32();
|
return object.get("total_block_count").to_u32() * object.get("block_size").to_u32();
|
||||||
});
|
});
|
||||||
df_fields.empend(
|
df_fields.empend(
|
||||||
"Used", TextAlignment::CenterRight,
|
"Used", Gfx::TextAlignment::CenterRight,
|
||||||
[](const JsonObject& object) {
|
[](const JsonObject& object) {
|
||||||
auto total_blocks = object.get("total_block_count").to_u32();
|
auto total_blocks = object.get("total_block_count").to_u32();
|
||||||
auto free_blocks = object.get("free_block_count").to_u32();
|
auto free_blocks = object.get("free_block_count").to_u32();
|
||||||
|
@ -319,17 +319,17 @@ RefPtr<GUI::Widget> build_file_systems_tab()
|
||||||
return percentage;
|
return percentage;
|
||||||
});
|
});
|
||||||
df_fields.empend(
|
df_fields.empend(
|
||||||
"Available", TextAlignment::CenterRight,
|
"Available", Gfx::TextAlignment::CenterRight,
|
||||||
[](const JsonObject& object) {
|
[](const JsonObject& object) {
|
||||||
return human_readable_size(object.get("free_block_count").to_u32() * object.get("block_size").to_u32());
|
return human_readable_size(object.get("free_block_count").to_u32() * object.get("block_size").to_u32());
|
||||||
},
|
},
|
||||||
[](const JsonObject& object) {
|
[](const JsonObject& object) {
|
||||||
return object.get("free_block_count").to_u32() * object.get("block_size").to_u32();
|
return object.get("free_block_count").to_u32() * object.get("block_size").to_u32();
|
||||||
});
|
});
|
||||||
df_fields.empend("Access", TextAlignment::CenterLeft, [](const JsonObject& object) {
|
df_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) {
|
||||||
return object.get("readonly").to_bool() ? "Read-only" : "Read/Write";
|
return object.get("readonly").to_bool() ? "Read-only" : "Read/Write";
|
||||||
});
|
});
|
||||||
df_fields.empend("Mount flags", TextAlignment::CenterLeft, [](const JsonObject& object) {
|
df_fields.empend("Mount flags", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) {
|
||||||
int mount_flags = object.get("mount_flags").to_int();
|
int mount_flags = object.get("mount_flags").to_int();
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -349,11 +349,11 @@ RefPtr<GUI::Widget> build_file_systems_tab()
|
||||||
return String("defaults");
|
return String("defaults");
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
});
|
});
|
||||||
df_fields.empend("free_block_count", "Free blocks", TextAlignment::CenterRight);
|
df_fields.empend("free_block_count", "Free blocks", Gfx::TextAlignment::CenterRight);
|
||||||
df_fields.empend("total_block_count", "Total blocks", TextAlignment::CenterRight);
|
df_fields.empend("total_block_count", "Total blocks", Gfx::TextAlignment::CenterRight);
|
||||||
df_fields.empend("free_inode_count", "Free inodes", TextAlignment::CenterRight);
|
df_fields.empend("free_inode_count", "Free inodes", Gfx::TextAlignment::CenterRight);
|
||||||
df_fields.empend("total_inode_count", "Total inodes", TextAlignment::CenterRight);
|
df_fields.empend("total_inode_count", "Total inodes", Gfx::TextAlignment::CenterRight);
|
||||||
df_fields.empend("block_size", "Block size", TextAlignment::CenterRight);
|
df_fields.empend("block_size", "Block size", Gfx::TextAlignment::CenterRight);
|
||||||
fs_table_view->set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/df", move(df_fields))));
|
fs_table_view->set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/df", move(df_fields))));
|
||||||
|
|
||||||
fs_table_view->set_cell_painting_delegate(3, make<ProgressBarPaintingDelegate>());
|
fs_table_view->set_cell_painting_delegate(3, make<ProgressBarPaintingDelegate>());
|
||||||
|
@ -377,7 +377,7 @@ RefPtr<GUI::Widget> build_pci_devices_tab()
|
||||||
|
|
||||||
Vector<GUI::JsonArrayModel::FieldSpec> pci_fields;
|
Vector<GUI::JsonArrayModel::FieldSpec> pci_fields;
|
||||||
pci_fields.empend(
|
pci_fields.empend(
|
||||||
"Address", TextAlignment::CenterLeft,
|
"Address", Gfx::TextAlignment::CenterLeft,
|
||||||
[](const JsonObject& object) {
|
[](const JsonObject& object) {
|
||||||
auto seg = object.get("seg").to_u32();
|
auto seg = object.get("seg").to_u32();
|
||||||
auto bus = object.get("bus").to_u32();
|
auto bus = object.get("bus").to_u32();
|
||||||
|
@ -386,21 +386,21 @@ RefPtr<GUI::Widget> build_pci_devices_tab()
|
||||||
return String::format("%04x:%02x:%02x.%d", seg, bus, slot, function);
|
return String::format("%04x:%02x:%02x.%d", seg, bus, slot, function);
|
||||||
});
|
});
|
||||||
pci_fields.empend(
|
pci_fields.empend(
|
||||||
"Class", TextAlignment::CenterLeft,
|
"Class", Gfx::TextAlignment::CenterLeft,
|
||||||
[db](const JsonObject& object) {
|
[db](const JsonObject& object) {
|
||||||
auto class_id = object.get("class").to_u32();
|
auto class_id = object.get("class").to_u32();
|
||||||
String class_name = db->get_class(class_id);
|
String class_name = db->get_class(class_id);
|
||||||
return class_name == "" ? String::format("%04x", class_id) : class_name;
|
return class_name == "" ? String::format("%04x", class_id) : class_name;
|
||||||
});
|
});
|
||||||
pci_fields.empend(
|
pci_fields.empend(
|
||||||
"Vendor", TextAlignment::CenterLeft,
|
"Vendor", Gfx::TextAlignment::CenterLeft,
|
||||||
[db](const JsonObject& object) {
|
[db](const JsonObject& object) {
|
||||||
auto vendor_id = object.get("vendor_id").to_u32();
|
auto vendor_id = object.get("vendor_id").to_u32();
|
||||||
String vendor_name = db->get_vendor(vendor_id);
|
String vendor_name = db->get_vendor(vendor_id);
|
||||||
return vendor_name == "" ? String::format("%02x", vendor_id) : vendor_name;
|
return vendor_name == "" ? String::format("%02x", vendor_id) : vendor_name;
|
||||||
});
|
});
|
||||||
pci_fields.empend(
|
pci_fields.empend(
|
||||||
"Device", TextAlignment::CenterLeft,
|
"Device", Gfx::TextAlignment::CenterLeft,
|
||||||
[db](const JsonObject& object) {
|
[db](const JsonObject& object) {
|
||||||
auto vendor_id = object.get("vendor_id").to_u32();
|
auto vendor_id = object.get("vendor_id").to_u32();
|
||||||
auto device_id = object.get("device_id").to_u32();
|
auto device_id = object.get("device_id").to_u32();
|
||||||
|
@ -408,7 +408,7 @@ RefPtr<GUI::Widget> build_pci_devices_tab()
|
||||||
return device_name == "" ? String::format("%02x", device_id) : device_name;
|
return device_name == "" ? String::format("%02x", device_id) : device_name;
|
||||||
});
|
});
|
||||||
pci_fields.empend(
|
pci_fields.empend(
|
||||||
"Revision", TextAlignment::CenterRight,
|
"Revision", Gfx::TextAlignment::CenterRight,
|
||||||
[](const JsonObject& object) {
|
[](const JsonObject& object) {
|
||||||
auto revision_id = object.get("revision_id").to_u32();
|
auto revision_id = object.get("revision_id").to_u32();
|
||||||
return String::format("%02x", revision_id);
|
return String::format("%02x", revision_id);
|
||||||
|
|
|
@ -44,7 +44,7 @@ TaskbarWindow::TaskbarWindow()
|
||||||
|
|
||||||
on_screen_rect_change(GUI::Desktop::the().rect());
|
on_screen_rect_change(GUI::Desktop::the().rect());
|
||||||
|
|
||||||
GUI::Desktop::the().on_rect_change = [this](const Rect& rect) { on_screen_rect_change(rect); };
|
GUI::Desktop::the().on_rect_change = [this](const Gfx::Rect& rect) { on_screen_rect_change(rect); };
|
||||||
|
|
||||||
auto widget = GUI::Frame::construct();
|
auto widget = GUI::Frame::construct();
|
||||||
widget->set_fill_with_background_color(true);
|
widget->set_fill_with_background_color(true);
|
||||||
|
@ -52,8 +52,8 @@ TaskbarWindow::TaskbarWindow()
|
||||||
widget->layout()->set_margins({ 3, 2, 3, 2 });
|
widget->layout()->set_margins({ 3, 2, 3, 2 });
|
||||||
widget->layout()->set_spacing(3);
|
widget->layout()->set_spacing(3);
|
||||||
widget->set_frame_thickness(1);
|
widget->set_frame_thickness(1);
|
||||||
widget->set_frame_shape(FrameShape::Panel);
|
widget->set_frame_shape(Gfx::FrameShape::Panel);
|
||||||
widget->set_frame_shadow(FrameShadow::Raised);
|
widget->set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||||
set_main_widget(widget);
|
set_main_widget(widget);
|
||||||
|
|
||||||
WindowList::the().aid_create_button = [this](auto& identifier) {
|
WindowList::the().aid_create_button = [this](auto& identifier) {
|
||||||
|
@ -75,8 +75,8 @@ void TaskbarWindow::create_quick_launch_bar()
|
||||||
quick_launch_bar->layout()->set_spacing(3);
|
quick_launch_bar->layout()->set_spacing(3);
|
||||||
quick_launch_bar->layout()->set_margins({ 3, 0, 3, 0 });
|
quick_launch_bar->layout()->set_margins({ 3, 0, 3, 0 });
|
||||||
quick_launch_bar->set_frame_thickness(1);
|
quick_launch_bar->set_frame_thickness(1);
|
||||||
quick_launch_bar->set_frame_shape(FrameShape::Container);
|
quick_launch_bar->set_frame_shape(Gfx::FrameShape::Container);
|
||||||
quick_launch_bar->set_frame_shadow(FrameShadow::Raised);
|
quick_launch_bar->set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||||
|
|
||||||
int total_width = 6;
|
int total_width = 6;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -96,9 +96,9 @@ void TaskbarWindow::create_quick_launch_bar()
|
||||||
auto button = GUI::Button::construct(quick_launch_bar);
|
auto button = GUI::Button::construct(quick_launch_bar);
|
||||||
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
button->set_preferred_size(22, 22);
|
button->set_preferred_size(22, 22);
|
||||||
button->set_button_style(ButtonStyle::CoolBar);
|
button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
|
|
||||||
button->set_icon(GraphicsBitmap::load_from_file(app_icon_path));
|
button->set_icon(Gfx::Bitmap::load_from_file(app_icon_path));
|
||||||
// FIXME: the tooltip ends up outside the screen rect.
|
// FIXME: the tooltip ends up outside the screen rect.
|
||||||
button->set_tooltip(name);
|
button->set_tooltip(name);
|
||||||
button->on_click = [app_executable](auto&) {
|
button->on_click = [app_executable](auto&) {
|
||||||
|
@ -121,7 +121,7 @@ void TaskbarWindow::create_quick_launch_bar()
|
||||||
quick_launch_bar->set_preferred_size(total_width, 22);
|
quick_launch_bar->set_preferred_size(total_width, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskbarWindow::on_screen_rect_change(const Rect& rect)
|
void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect)
|
||||||
{
|
{
|
||||||
Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() };
|
Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() };
|
||||||
set_rect(new_rect);
|
set_rect(new_rect);
|
||||||
|
@ -133,7 +133,7 @@ NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier&
|
||||||
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||||
button->set_preferred_size(140, 22);
|
button->set_preferred_size(140, 22);
|
||||||
button->set_checkable(true);
|
button->set_checkable(true);
|
||||||
button->set_text_alignment(TextAlignment::CenterLeft);
|
button->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
|
||||||
if (auto* window = WindowList::the().window(identifier)) {
|
if (auto* window = WindowList::the().window(identifier)) {
|
||||||
auto buffer = SharedBuffer::create_from_shared_buffer_id(changed_event.icon_buffer_id());
|
auto buffer = SharedBuffer::create_from_shared_buffer_id(changed_event.icon_buffer_id());
|
||||||
ASSERT(buffer);
|
ASSERT(buffer);
|
||||||
window->button()->set_icon(GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, *buffer, changed_event.icon_size()));
|
window->button()->set_icon(Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *buffer, changed_event.icon_size()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create_quick_launch_bar();
|
void create_quick_launch_bar();
|
||||||
void on_screen_rect_change(const Rect&);
|
void on_screen_rect_change(const Gfx::Rect&);
|
||||||
NonnullRefPtr<GUI::Button> create_button(const WindowIdentifier&);
|
NonnullRefPtr<GUI::Button> create_button(const WindowIdentifier&);
|
||||||
|
|
||||||
virtual void wm_event(GUI::WMEvent&) override;
|
virtual void wm_event(GUI::WMEvent&) override;
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
void set_title(const String& title) { m_title = title; }
|
void set_title(const String& title) { m_title = title; }
|
||||||
|
|
||||||
Rect rect() const { return m_rect; }
|
Rect rect() const { return m_rect; }
|
||||||
void set_rect(const Rect& rect) { m_rect = rect; }
|
void set_rect(const Gfx::Rect& rect) { m_rect = rect; }
|
||||||
|
|
||||||
GUI::Button* button() { return m_button; }
|
GUI::Button* button() { return m_button; }
|
||||||
void set_button(GUI::Button* button) { m_button = button; }
|
void set_button(GUI::Button* button) { m_button = button; }
|
||||||
|
@ -62,14 +62,14 @@ public:
|
||||||
void set_minimized(bool minimized) { m_minimized = minimized; }
|
void set_minimized(bool minimized) { m_minimized = minimized; }
|
||||||
bool is_minimized() const { return m_minimized; }
|
bool is_minimized() const { return m_minimized; }
|
||||||
|
|
||||||
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowIdentifier m_identifier;
|
WindowIdentifier m_identifier;
|
||||||
String m_title;
|
String m_title;
|
||||||
Rect m_rect;
|
Gfx::Rect m_rect;
|
||||||
RefPtr<GUI::Button> m_button;
|
RefPtr<GUI::Button> m_button;
|
||||||
RefPtr<GraphicsBitmap> m_icon;
|
RefPtr<Gfx::Bitmap> m_icon;
|
||||||
bool m_active { false };
|
bool m_active { false };
|
||||||
bool m_minimized { false };
|
bool m_minimized { false };
|
||||||
};
|
};
|
||||||
|
|
|
@ -235,7 +235,7 @@ int main(int argc, char** argv)
|
||||||
window->move_to(300, 300);
|
window->move_to(300, 300);
|
||||||
terminal->apply_size_increments_to_window(*window);
|
terminal->apply_size_increments_to_window(*window);
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-terminal.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-terminal.png"));
|
||||||
terminal->set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
terminal->set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
||||||
|
|
||||||
RefPtr<GUI::Window> settings_window;
|
RefPtr<GUI::Window> settings_window;
|
||||||
|
@ -247,13 +247,13 @@ int main(int argc, char** argv)
|
||||||
auto menubar = make<GUI::MenuBar>();
|
auto menubar = make<GUI::MenuBar>();
|
||||||
|
|
||||||
auto app_menu = GUI::Menu::construct("Terminal");
|
auto app_menu = GUI::Menu::construct("Terminal");
|
||||||
app_menu->add_action(GUI::Action::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) {
|
app_menu->add_action(GUI::Action::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) {
|
||||||
if (!fork()) {
|
if (!fork()) {
|
||||||
execl("/bin/Terminal", "Terminal", nullptr);
|
execl("/bin/Terminal", "Terminal", nullptr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
app_menu->add_action(GUI::Action::create("Settings...", load_png("/res/icons/gear16.png"),
|
app_menu->add_action(GUI::Action::create("Settings...", Gfx::load_png("/res/icons/gear16.png"),
|
||||||
[&](const GUI::Action&) {
|
[&](const GUI::Action&) {
|
||||||
if (!settings_window) {
|
if (!settings_window) {
|
||||||
settings_window = create_settings_window(*terminal);
|
settings_window = create_settings_window(*terminal);
|
||||||
|
@ -300,7 +300,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Terminal", load_png("/res/icons/32x32/app-terminal.png"), window);
|
GUI::AboutDialog::show("Terminal", Gfx::load_png("/res/icons/32x32/app-terminal.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
m_editor->set_focus(true);
|
m_editor->set_focus(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
m_find_replace_action = GUI::Action::create("Find/Replace...", { Mod_Ctrl, Key_F }, load_png("/res/icons/16x16/find.png"), [this](auto&) {
|
m_find_replace_action = GUI::Action::create("Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::load_png("/res/icons/16x16/find.png"), [this](auto&) {
|
||||||
m_find_replace_widget->set_visible(true);
|
m_find_replace_widget->set_visible(true);
|
||||||
m_find_widget->set_visible(true);
|
m_find_widget->set_visible(true);
|
||||||
m_replace_widget->set_visible(true);
|
m_replace_widget->set_visible(true);
|
||||||
|
@ -268,7 +268,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
m_statusbar->set_text(builder.to_string());
|
m_statusbar->set_text(builder.to_string());
|
||||||
};
|
};
|
||||||
|
|
||||||
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
|
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
|
||||||
if (m_document_dirty) {
|
if (m_document_dirty) {
|
||||||
auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window());
|
auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window());
|
||||||
auto save_document_first_result = save_document_first_box->exec();
|
auto save_document_first_result = save_document_first_box->exec();
|
||||||
|
@ -301,7 +301,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
open_sesame(open_path.value());
|
open_sesame(open_path.value());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) {
|
m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) {
|
||||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "txt" : m_extension);
|
Optional<String> save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "txt" : m_extension);
|
||||||
if (!save_path.has_value())
|
if (!save_path.has_value())
|
||||||
return;
|
return;
|
||||||
|
@ -316,7 +316,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
dbg() << "Wrote document to " << save_path.value();
|
dbg() << "Wrote document to " << save_path.value();
|
||||||
});
|
});
|
||||||
|
|
||||||
m_save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GUI::Action&) {
|
m_save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GUI::Action&) {
|
||||||
if (!m_path.is_empty()) {
|
if (!m_path.is_empty()) {
|
||||||
if (!m_editor->write_to_file(m_path)) {
|
if (!m_editor->write_to_file(m_path)) {
|
||||||
GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||||
|
@ -384,7 +384,7 @@ TextEditorWidget::TextEditorWidget()
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Text Editor", load_png("/res/icons/32x32/app-texteditor.png"), window());
|
GUI::AboutDialog::show("Text Editor", Gfx::load_png("/res/icons/32x32/app-texteditor.png"), window());
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ int main(int argc, char** argv)
|
||||||
text_widget->open_sesame(argv[1]);
|
text_widget->open_sesame(argv[1]);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(load_png("/res/icons/TextEditor16.png"));
|
window->set_icon(Gfx::load_png("/res/icons/TextEditor16.png"));
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,10 @@ void TextWidget::paint_event(GUI::PaintEvent& event)
|
||||||
text_rect.set_width(text_rect.width() - indent * 2);
|
text_rect.set_width(text_rect.width() - indent * 2);
|
||||||
|
|
||||||
if (is_enabled()) {
|
if (is_enabled()) {
|
||||||
painter.draw_text(text_rect, line, m_text_alignment, palette().color(foreground_role()), TextElision::None);
|
painter.draw_text(text_rect, line, m_text_alignment, palette().color(foreground_role()), Gfx::TextElision::None);
|
||||||
} else {
|
} else {
|
||||||
painter.draw_text(text_rect.translated(1, 1), line, font(), text_alignment(), Color::White, TextElision::Right);
|
painter.draw_text(text_rect.translated(1, 1), line, font(), text_alignment(), Color::White, Gfx::TextElision::Right);
|
||||||
painter.draw_text(text_rect, line, font(), text_alignment(), Color::from_rgb(0x808080), TextElision::Right);
|
painter.draw_text(text_rect, line, font(), text_alignment(), Color::from_rgb(0x808080), Gfx::TextElision::Right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ public:
|
||||||
String text() const { return m_text; }
|
String text() const { return m_text; }
|
||||||
void set_text(const StringView&);
|
void set_text(const StringView&);
|
||||||
|
|
||||||
TextAlignment text_alignment() const { return m_text_alignment; }
|
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||||
void set_text_alignment(TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||||
|
|
||||||
bool should_wrap() const { return m_should_wrap; }
|
bool should_wrap() const { return m_should_wrap; }
|
||||||
void set_should_wrap(bool should_wrap) { m_should_wrap = should_wrap; }
|
void set_should_wrap(bool should_wrap) { m_should_wrap = should_wrap; }
|
||||||
|
@ -58,7 +58,7 @@ private:
|
||||||
|
|
||||||
String m_text;
|
String m_text;
|
||||||
Vector<String> m_lines;
|
Vector<String> m_lines;
|
||||||
TextAlignment m_text_alignment { TextAlignment::Center };
|
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||||
bool m_should_wrap { false };
|
bool m_should_wrap { false };
|
||||||
int m_line_height { 0 };
|
int m_line_height { 0 };
|
||||||
};
|
};
|
||||||
|
|
|
@ -101,7 +101,7 @@ int main(int argc, char** argv)
|
||||||
background->set_layout(make<GUI::VBoxLayout>());
|
background->set_layout(make<GUI::VBoxLayout>());
|
||||||
background->layout()->set_margins({ 8, 8, 8, 8 });
|
background->layout()->set_margins({ 8, 8, 8, 8 });
|
||||||
background->layout()->set_spacing(8);
|
background->layout()->set_spacing(8);
|
||||||
background->set_icon(load_png_from_memory((const u8*)&_binary_background_png_start, (size_t)&_binary_background_png_size));
|
background->set_icon(Gfx::load_png_from_memory((const u8*)&_binary_background_png_start, (size_t)&_binary_background_png_size));
|
||||||
background->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
background->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||||
background->set_preferred_size(background->icon()->size());
|
background->set_preferred_size(background->icon()->size());
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ int main(int argc, char** argv)
|
||||||
//
|
//
|
||||||
|
|
||||||
auto header = GUI::Label::construct(background.ptr());
|
auto header = GUI::Label::construct(background.ptr());
|
||||||
header->set_font(Font::default_bold_font());
|
header->set_font(Gfx::Font::default_bold_font());
|
||||||
header->set_text("Welcome to Serenity");
|
header->set_text("Welcome to Serenity");
|
||||||
header->set_text_alignment(TextAlignment::CenterLeft);
|
header->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
header->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
header->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
header->set_preferred_size(0, 30);
|
header->set_preferred_size(0, 30);
|
||||||
|
|
||||||
|
@ -144,25 +144,25 @@ int main(int argc, char** argv)
|
||||||
content->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
content->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||||
|
|
||||||
auto content_title = GUI::Label::construct(content);
|
auto content_title = GUI::Label::construct(content);
|
||||||
content_title->set_font(Font::default_bold_font());
|
content_title->set_font(Gfx::Font::default_bold_font());
|
||||||
content_title->set_text(page.title);
|
content_title->set_text(page.title);
|
||||||
content_title->set_text_alignment(TextAlignment::CenterLeft);
|
content_title->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
content_title->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
content_title->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
content_title->set_preferred_size(0, 10);
|
content_title->set_preferred_size(0, 10);
|
||||||
|
|
||||||
for (auto& paragraph : page.content) {
|
for (auto& paragraph : page.content) {
|
||||||
auto content_text = TextWidget::construct(content);
|
auto content_text = TextWidget::construct(content);
|
||||||
content_text->set_font(Font::default_font());
|
content_text->set_font(Gfx::Font::default_font());
|
||||||
content_text->set_text(paragraph);
|
content_text->set_text(paragraph);
|
||||||
content_text->set_text_alignment(TextAlignment::TopLeft);
|
content_text->set_text_alignment(Gfx::TextAlignment::TopLeft);
|
||||||
content_text->set_line_height(12);
|
content_text->set_line_height(12);
|
||||||
content_text->wrap_and_set_height();
|
content_text->wrap_and_set_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto menu_option = GUI::Button::construct(menu);
|
auto menu_option = GUI::Button::construct(menu);
|
||||||
menu_option->set_font(Font::default_font());
|
menu_option->set_font(Gfx::Font::default_font());
|
||||||
menu_option->set_text(page.menu_name);
|
menu_option->set_text(page.menu_name);
|
||||||
menu_option->set_text_alignment(TextAlignment::CenterLeft);
|
menu_option->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
menu_option->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
menu_option->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
menu_option->set_preferred_size(0, 20);
|
menu_option->set_preferred_size(0, 20);
|
||||||
menu_option->on_click = [content = content.ptr(), &stack](auto&) {
|
menu_option->on_click = [content = content.ptr(), &stack](auto&) {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Fire(GUI::Widget* parent = nullptr);
|
explicit Fire(GUI::Widget* parent = nullptr);
|
||||||
RefPtr<GraphicsBitmap> bitmap;
|
RefPtr<Gfx::Bitmap> bitmap;
|
||||||
RefPtr<GUI::Label> stats;
|
RefPtr<GUI::Label> stats;
|
||||||
|
|
||||||
virtual void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
|
@ -115,7 +115,7 @@ private:
|
||||||
Fire::Fire(GUI::Widget* parent)
|
Fire::Fire(GUI::Widget* parent)
|
||||||
: GUI::Widget(parent)
|
: GUI::Widget(parent)
|
||||||
{
|
{
|
||||||
bitmap = GraphicsBitmap::create(GraphicsBitmap::Format::Indexed8, { 320, 200 });
|
bitmap = Gfx::Bitmap::create(Gfx::Bitmap::Format::Indexed8, { 320, 200 });
|
||||||
|
|
||||||
/* Initialize fire palette */
|
/* Initialize fire palette */
|
||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 30; i++)
|
||||||
|
@ -257,7 +257,7 @@ int main(int argc, char** argv)
|
||||||
fire->set_stat_label(time);
|
fire->set_stat_label(time);
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(load_png("/res/icons/16x16/app-demo.png"));
|
window->set_icon(Gfx::load_png("/res/icons/16x16/app-demo.png"));
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ void CursorTool::on_keydown(GUI::KeyEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CursorTool::set_rubber_band_position(const Point& position)
|
void CursorTool::set_rubber_band_position(const Gfx::Point& position)
|
||||||
{
|
{
|
||||||
if (m_rubber_band_position == position)
|
if (m_rubber_band_position == position)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -50,14 +50,14 @@ private:
|
||||||
virtual void on_keydown(GUI::KeyEvent&) override;
|
virtual void on_keydown(GUI::KeyEvent&) override;
|
||||||
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) override;
|
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) override;
|
||||||
|
|
||||||
void set_rubber_band_position(const Point&);
|
void set_rubber_band_position(const Gfx::Point&);
|
||||||
Rect rubber_band_rect() const;
|
Gfx::Rect rubber_band_rect() const;
|
||||||
|
|
||||||
Point m_drag_origin;
|
Gfx::Point m_drag_origin;
|
||||||
HashMap<GUI::Widget*, Point> m_positions_before_drag;
|
HashMap<GUI::Widget*, Point> m_positions_before_drag;
|
||||||
bool m_dragging { false };
|
bool m_dragging { false };
|
||||||
|
|
||||||
bool m_rubber_banding { false };
|
bool m_rubber_banding { false };
|
||||||
Point m_rubber_band_origin;
|
Gfx::Point m_rubber_band_origin;
|
||||||
Point m_rubber_band_position;
|
Gfx::Point m_rubber_band_position;
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,7 +114,7 @@ static HashMap<String, String>& man_paths()
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Point& screen_location)
|
void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::Point& screen_location)
|
||||||
{
|
{
|
||||||
auto it = man_paths().find(hovered_token);
|
auto it = man_paths().find(hovered_token);
|
||||||
if (it == man_paths().end()) {
|
if (it == man_paths().end()) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||||
virtual void cursor_did_change() override;
|
virtual void cursor_did_change() override;
|
||||||
|
|
||||||
void show_documentation_tooltip_if_available(const String&, const Point& screen_location);
|
void show_documentation_tooltip_if_available(const String&, const Gfx::Point& screen_location);
|
||||||
void highlight_matching_token_pair();
|
void highlight_matching_token_pair();
|
||||||
|
|
||||||
explicit Editor(GUI::Widget* parent);
|
explicit Editor(GUI::Widget* parent);
|
||||||
|
|
|
@ -46,12 +46,12 @@ EditorWrapper::EditorWrapper(GUI::Widget* parent)
|
||||||
label_wrapper->layout()->set_margins({ 2, 0, 2, 0 });
|
label_wrapper->layout()->set_margins({ 2, 0, 2, 0 });
|
||||||
|
|
||||||
m_filename_label = GUI::Label::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_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
m_filename_label->set_preferred_size(0, 14);
|
m_filename_label->set_preferred_size(0, 14);
|
||||||
|
|
||||||
m_cursor_label = GUI::Label::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_text_alignment(Gfx::TextAlignment::CenterRight);
|
||||||
m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
m_cursor_label->set_preferred_size(0, 14);
|
m_cursor_label->set_preferred_size(0, 14);
|
||||||
|
|
||||||
|
@ -75,5 +75,5 @@ EditorWrapper::~EditorWrapper()
|
||||||
|
|
||||||
void EditorWrapper::set_editor_has_focus(Badge<Editor>, bool focus)
|
void EditorWrapper::set_editor_has_focus(Badge<Editor>, bool focus)
|
||||||
{
|
{
|
||||||
m_filename_label->set_font(focus ? Font::default_bold_font() : Font::default_font());
|
m_filename_label->set_font(focus ? Gfx::Font::default_bold_font() : Gfx::Font::default_font());
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
virtual ColumnMetadata column_metadata(int column) const override
|
virtual ColumnMetadata column_metadata(int column) const override
|
||||||
{
|
{
|
||||||
if (column == Column::MatchedText) {
|
if (column == Column::MatchedText) {
|
||||||
return { 0, TextAlignment::CenterLeft, &Font::default_fixed_width_font() };
|
return { 0, Gfx::TextAlignment::CenterLeft, &Gfx::Font::default_fixed_width_font() };
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ FormEditorWidget::FormEditorWidget(GUI::Widget* parent)
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
set_background_color(Color::MidGray);
|
set_background_color(Color::MidGray);
|
||||||
|
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
|
|
||||||
m_form_widget = FormWidget::construct(*this);
|
m_form_widget = FormWidget::construct(*this);
|
||||||
|
|
|
@ -33,9 +33,9 @@
|
||||||
|
|
||||||
extern RefPtr<Project> g_project;
|
extern RefPtr<Project> g_project;
|
||||||
extern void open_file(const String&);
|
extern void open_file(const String&);
|
||||||
static RefPtr<GraphicsBitmap> s_file_icon;
|
static RefPtr<Gfx::Bitmap> s_file_icon;
|
||||||
static RefPtr<GraphicsBitmap> s_cplusplus_icon;
|
static RefPtr<Gfx::Bitmap> s_cplusplus_icon;
|
||||||
static RefPtr<GraphicsBitmap> s_header_icon;
|
static RefPtr<Gfx::Bitmap> s_header_icon;
|
||||||
|
|
||||||
class LocatorSuggestionModel final : public GUI::Model {
|
class LocatorSuggestionModel final : public GUI::Model {
|
||||||
public:
|
public:
|
||||||
|
@ -102,9 +102,9 @@ Locator::Locator(GUI::Widget* parent)
|
||||||
: GUI::Widget(parent)
|
: GUI::Widget(parent)
|
||||||
{
|
{
|
||||||
if (!s_cplusplus_icon) {
|
if (!s_cplusplus_icon) {
|
||||||
s_file_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
|
s_file_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png");
|
||||||
s_cplusplus_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png");
|
s_cplusplus_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png");
|
||||||
s_header_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png");
|
s_header_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-header.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
set_layout(make<GUI::VBoxLayout>());
|
set_layout(make<GUI::VBoxLayout>());
|
||||||
|
|
|
@ -41,20 +41,20 @@ ProcessStateWidget::ProcessStateWidget(GUI::Widget* parent)
|
||||||
set_layout(make<GUI::HBoxLayout>());
|
set_layout(make<GUI::HBoxLayout>());
|
||||||
|
|
||||||
auto pid_label_label = GUI::Label::construct("Process:", this);
|
auto pid_label_label = GUI::Label::construct("Process:", this);
|
||||||
pid_label_label->set_font(Font::default_bold_font());
|
pid_label_label->set_font(Gfx::Font::default_bold_font());
|
||||||
m_pid_label = GUI::Label::construct("", this);
|
m_pid_label = GUI::Label::construct("", this);
|
||||||
|
|
||||||
auto state_label_label = GUI::Label::construct("State:", this);
|
auto state_label_label = GUI::Label::construct("State:", this);
|
||||||
state_label_label->set_font(Font::default_bold_font());
|
state_label_label->set_font(Gfx::Font::default_bold_font());
|
||||||
m_state_label = GUI::Label::construct("", this);
|
m_state_label = GUI::Label::construct("", this);
|
||||||
|
|
||||||
// FIXME: This should show CPU% instead.
|
// FIXME: This should show CPU% instead.
|
||||||
auto cpu_label_label = GUI::Label::construct("Times scheduled:", this);
|
auto cpu_label_label = GUI::Label::construct("Times scheduled:", this);
|
||||||
cpu_label_label->set_font(Font::default_bold_font());
|
cpu_label_label->set_font(Gfx::Font::default_bold_font());
|
||||||
m_cpu_label = GUI::Label::construct("", this);
|
m_cpu_label = GUI::Label::construct("", this);
|
||||||
|
|
||||||
auto memory_label_label = GUI::Label::construct("Memory (resident):", this);
|
auto memory_label_label = GUI::Label::construct("Memory (resident):", this);
|
||||||
memory_label_label->set_font(Font::default_bold_font());
|
memory_label_label->set_font(Gfx::Font::default_bold_font());
|
||||||
m_memory_label = GUI::Label::construct("", this);
|
m_memory_label = GUI::Label::construct("", this);
|
||||||
|
|
||||||
m_timer = Core::Timer::construct(500, [this] {
|
m_timer = Core::Timer::construct(500, [this] {
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
if (role == Role::Font) {
|
if (role == Role::Font) {
|
||||||
extern String g_currently_open_file;
|
extern String g_currently_open_file;
|
||||||
if (node->name == g_currently_open_file)
|
if (node->name == g_currently_open_file)
|
||||||
return Font::default_bold_font();
|
return Gfx::Font::default_bold_font();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -169,11 +169,11 @@ Project::Project(const String& path, Vector<String>&& filenames)
|
||||||
{
|
{
|
||||||
m_name = FileSystemPath(m_path).basename();
|
m_name = FileSystemPath(m_path).basename();
|
||||||
|
|
||||||
m_file_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"));
|
m_file_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"));
|
||||||
m_cplusplus_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png"));
|
m_cplusplus_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-cplusplus.png"));
|
||||||
m_header_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png"));
|
m_header_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-header.png"));
|
||||||
m_directory_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));
|
m_directory_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-folder.png"));
|
||||||
m_project_icon = GIcon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"));
|
m_project_icon = GIcon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"));
|
||||||
|
|
||||||
for (auto& filename : filenames) {
|
for (auto& filename : filenames) {
|
||||||
m_files.append(ProjectFile::construct_with_name(filename));
|
m_files.append(ProjectFile::construct_with_name(filename));
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
WidgetTreeModel::WidgetTreeModel(GUI::Widget& root)
|
WidgetTreeModel::WidgetTreeModel(GUI::Widget& root)
|
||||||
: m_root(root)
|
: m_root(root)
|
||||||
{
|
{
|
||||||
m_widget_icon.set_bitmap_for_size(16, GraphicsBitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
|
m_widget_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetTreeModel::~WidgetTreeModel()
|
WidgetTreeModel::~WidgetTreeModel()
|
||||||
|
|
|
@ -175,7 +175,7 @@ int main(int argc, char** argv)
|
||||||
return files;
|
return files;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::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);
|
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)
|
if (input_box->exec() == GUI::InputBox::ExecCancel)
|
||||||
return;
|
return;
|
||||||
|
@ -193,7 +193,7 @@ int main(int argc, char** argv)
|
||||||
open_file(filename);
|
open_file(filename);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto add_existing_file_action = GUI::Action::create("Add existing file to project...", GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
|
auto add_existing_file_action = GUI::Action::create("Add existing file to project...", Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) {
|
||||||
auto result = GUI::FilePicker::get_open_filepath("Add existing file to project");
|
auto result = GUI::FilePicker::get_open_filepath("Add existing file to project");
|
||||||
if (!result.has_value())
|
if (!result.has_value())
|
||||||
return;
|
return;
|
||||||
|
@ -273,7 +273,7 @@ int main(int argc, char** argv)
|
||||||
GUI::ActionGroup tool_actions;
|
GUI::ActionGroup tool_actions;
|
||||||
tool_actions.set_exclusive(true);
|
tool_actions.set_exclusive(true);
|
||||||
|
|
||||||
auto cursor_tool_action = GUI::Action::create("Cursor", GraphicsBitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) {
|
auto cursor_tool_action = GUI::Action::create("Cursor", Gfx::Bitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) {
|
||||||
g_form_editor_widget->set_tool(make<CursorTool>(*g_form_editor_widget));
|
g_form_editor_widget->set_tool(make<CursorTool>(*g_form_editor_widget));
|
||||||
});
|
});
|
||||||
cursor_tool_action->set_checkable(true);
|
cursor_tool_action->set_checkable(true);
|
||||||
|
@ -284,7 +284,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
GUI::WidgetClassRegistration::for_each([&](const GUI::WidgetClassRegistration& reg) {
|
GUI::WidgetClassRegistration::for_each([&](const GUI::WidgetClassRegistration& reg) {
|
||||||
auto icon_path = String::format("/res/icons/widgets/%s.png", reg.class_name().characters());
|
auto icon_path = String::format("/res/icons/widgets/%s.png", reg.class_name().characters());
|
||||||
auto action = GUI::Action::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [®](auto&) {
|
auto action = GUI::Action::create(reg.class_name(), Gfx::Bitmap::load_from_file(icon_path), [®](auto&) {
|
||||||
g_form_editor_widget->set_tool(make<WidgetTool>(*g_form_editor_widget, reg));
|
g_form_editor_widget->set_tool(make<WidgetTool>(*g_form_editor_widget, reg));
|
||||||
auto widget = reg.construct(&g_form_editor_widget->form_widget());
|
auto widget = reg.construct(&g_form_editor_widget->form_widget());
|
||||||
widget->set_relative_rect(30, 30, 30, 30);
|
widget->set_relative_rect(30, 30, 30, 30);
|
||||||
|
@ -310,8 +310,8 @@ int main(int argc, char** argv)
|
||||||
wrapper->set_layout(make<GUI::VBoxLayout>());
|
wrapper->set_layout(make<GUI::VBoxLayout>());
|
||||||
auto label = GUI::Label::construct(text, wrapper);
|
auto label = GUI::Label::construct(text, wrapper);
|
||||||
label->set_fill_with_background_color(true);
|
label->set_fill_with_background_color(true);
|
||||||
label->set_text_alignment(TextAlignment::CenterLeft);
|
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||||
label->set_font(Font::default_bold_font());
|
label->set_font(Gfx::Font::default_bold_font());
|
||||||
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
label->set_preferred_size(0, 16);
|
label->set_preferred_size(0, 16);
|
||||||
wrapper->add_child(pane_widget);
|
wrapper->add_child(pane_widget);
|
||||||
|
@ -395,7 +395,7 @@ int main(int argc, char** argv)
|
||||||
update_actions();
|
update_actions();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto save_action = GUI::Action::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 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) {
|
||||||
if (g_currently_open_file.is_empty())
|
if (g_currently_open_file.is_empty())
|
||||||
return;
|
return;
|
||||||
current_editor().write_to_file(g_currently_open_file);
|
current_editor().write_to_file(g_currently_open_file);
|
||||||
|
@ -476,7 +476,7 @@ int main(int argc, char** argv)
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(edit_menu));
|
menubar->add_menu(move(edit_menu));
|
||||||
|
|
||||||
auto stop_action = GUI::Action::create("Stop", GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) {
|
auto stop_action = GUI::Action::create("Stop", Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) {
|
||||||
terminal_wrapper->kill_running_command();
|
terminal_wrapper->kill_running_command();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -485,14 +485,14 @@ int main(int argc, char** argv)
|
||||||
stop_action->set_enabled(false);
|
stop_action->set_enabled(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto build_action = GUI::Action::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 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/build.png"), [&](auto&) {
|
||||||
reveal_action_tab(terminal_wrapper);
|
reveal_action_tab(terminal_wrapper);
|
||||||
build(terminal_wrapper);
|
build(terminal_wrapper);
|
||||||
stop_action->set_enabled(true);
|
stop_action->set_enabled(true);
|
||||||
});
|
});
|
||||||
toolbar->add_action(build_action);
|
toolbar->add_action(build_action);
|
||||||
|
|
||||||
auto run_action = GUI::Action::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 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) {
|
||||||
reveal_action_tab(terminal_wrapper);
|
reveal_action_tab(terminal_wrapper);
|
||||||
run(terminal_wrapper);
|
run(terminal_wrapper);
|
||||||
stop_action->set_enabled(true);
|
stop_action->set_enabled(true);
|
||||||
|
@ -514,7 +514,7 @@ int main(int argc, char** argv)
|
||||||
view_menu->add_action(remove_current_editor_action);
|
view_menu->add_action(remove_current_editor_action);
|
||||||
menubar->add_menu(move(view_menu));
|
menubar->add_menu(move(view_menu));
|
||||||
|
|
||||||
auto small_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png");
|
auto small_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hack-studio.png");
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](auto&) {
|
help_menu->add_action(GUI::Action::create("About", [&](auto&) {
|
||||||
|
@ -550,16 +550,16 @@ void run(TerminalWrapper& wrapper)
|
||||||
|
|
||||||
struct TextStyle {
|
struct TextStyle {
|
||||||
Color color;
|
Color color;
|
||||||
const Font* font { nullptr };
|
const Gfx::Font* font { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
static TextStyle style_for_token_type(CppToken::Type type)
|
static TextStyle style_for_token_type(CppToken::Type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CppToken::Type::Keyword:
|
case CppToken::Type::Keyword:
|
||||||
return { Color::Black, &Font::default_bold_fixed_width_font() };
|
return { Color::Black, &Gfx::Font::default_bold_fixed_width_font() };
|
||||||
case CppToken::Type::KnownType:
|
case CppToken::Type::KnownType:
|
||||||
return { Color::from_rgb(0x929200), &Font::default_bold_fixed_width_font() };
|
return { Color::from_rgb(0x929200), &Gfx::Font::default_bold_fixed_width_font() };
|
||||||
case CppToken::Type::Identifier:
|
case CppToken::Type::Identifier:
|
||||||
return { Color::from_rgb(0x000092) };
|
return { Color::from_rgb(0x000092) };
|
||||||
case CppToken::Type::DoubleQuotedString:
|
case CppToken::Type::DoubleQuotedString:
|
||||||
|
|
|
@ -327,7 +327,7 @@ int main(int argc, char** argv)
|
||||||
} else if (parameter.type == "Color") {
|
} else if (parameter.type == "Color") {
|
||||||
dbg() << " u32 " << parameter.name << "_rgba = 0;";
|
dbg() << " u32 " << parameter.name << "_rgba = 0;";
|
||||||
dbg() << " stream >> " << parameter.name << "_rgba;";
|
dbg() << " stream >> " << parameter.name << "_rgba;";
|
||||||
dbg() << " " << parameter.name << " = Color::from_rgba(" << parameter.name << "_rgba);";
|
dbg() << " " << parameter.name << " = Gfx::Color::from_rgba(" << parameter.name << "_rgba);";
|
||||||
} else if (parameter.type == "Size") {
|
} else if (parameter.type == "Size") {
|
||||||
dbg() << " int " << parameter.name << "_width = 0;";
|
dbg() << " int " << parameter.name << "_width = 0;";
|
||||||
dbg() << " stream >> " << parameter.name << "_width;";
|
dbg() << " stream >> " << parameter.name << "_width;";
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
RemoteObjectGraphModel::RemoteObjectGraphModel(RemoteProcess& process)
|
RemoteObjectGraphModel::RemoteObjectGraphModel(RemoteProcess& process)
|
||||||
: m_process(process)
|
: m_process(process)
|
||||||
{
|
{
|
||||||
m_object_icon.set_bitmap_for_size(16, load_png("/res/icons/16x16/inspector-object.png"));
|
m_object_icon.set_bitmap_for_size(16, Gfx::load_png("/res/icons/16x16/inspector-object.png"));
|
||||||
m_window_icon.set_bitmap_for_size(16, load_png("/res/icons/16x16/window.png"));
|
m_window_icon.set_bitmap_for_size(16, Gfx::load_png("/res/icons/16x16/window.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteObjectGraphModel::~RemoteObjectGraphModel()
|
RemoteObjectGraphModel::~RemoteObjectGraphModel()
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
ProfileModel::ProfileModel(Profile& profile)
|
ProfileModel::ProfileModel(Profile& profile)
|
||||||
: m_profile(profile)
|
: m_profile(profile)
|
||||||
{
|
{
|
||||||
m_user_frame_icon.set_bitmap_for_size(16, GraphicsBitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
|
m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object.png"));
|
||||||
m_kernel_frame_icon.set_bitmap_for_size(16, GraphicsBitmap::load_from_file("/res/icons/16x16/inspector-object-red.png"));
|
m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/inspector-object-red.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileModel::~ProfileModel()
|
ProfileModel::~ProfileModel()
|
||||||
|
@ -109,7 +109,7 @@ String ProfileModel::column_name(int column) const
|
||||||
GUI::Model::ColumnMetadata ProfileModel::column_metadata(int column) const
|
GUI::Model::ColumnMetadata ProfileModel::column_metadata(int column) const
|
||||||
{
|
{
|
||||||
if (column == Column::SampleCount)
|
if (column == Column::SampleCount)
|
||||||
return ColumnMetadata { 0, TextAlignment::CenterRight };
|
return ColumnMetadata { 0, Gfx::TextAlignment::CenterRight };
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GUI::Widget* pare
|
||||||
, m_profile(profile)
|
, m_profile(profile)
|
||||||
{
|
{
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_background_color(Color::White);
|
set_background_color(Color::White);
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||||
|
|
|
@ -63,13 +63,13 @@ VBForm::VBForm(const String& name, GUI::Widget* parent)
|
||||||
widget->gwidget()->move_to_back();
|
widget->gwidget()->move_to_back();
|
||||||
}));
|
}));
|
||||||
m_context_menu->add_separator();
|
m_context_menu->add_separator();
|
||||||
m_context_menu->add_action(GUI::Action::create("Lay out horizontally", load_png("/res/icons/16x16/layout-horizontally.png"), [this](auto&) {
|
m_context_menu->add_action(GUI::Action::create("Lay out horizontally", Gfx::load_png("/res/icons/16x16/layout-horizontally.png"), [this](auto&) {
|
||||||
if (auto* widget = single_selected_widget()) {
|
if (auto* widget = single_selected_widget()) {
|
||||||
dbg() << "Giving " << *widget->gwidget() << " a horizontal box layout";
|
dbg() << "Giving " << *widget->gwidget() << " a horizontal box layout";
|
||||||
widget->gwidget()->set_layout(make<GUI::HBoxLayout>());
|
widget->gwidget()->set_layout(make<GUI::HBoxLayout>());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
m_context_menu->add_action(GUI::Action::create("Lay out vertically", load_png("/res/icons/16x16/layout-vertically.png"), [this](auto&) {
|
m_context_menu->add_action(GUI::Action::create("Lay out vertically", Gfx::load_png("/res/icons/16x16/layout-vertically.png"), [this](auto&) {
|
||||||
if (auto* widget = single_selected_widget()) {
|
if (auto* widget = single_selected_widget()) {
|
||||||
dbg() << "Giving " << *widget->gwidget() << " a vertical box layout";
|
dbg() << "Giving " << *widget->gwidget() << " a vertical box layout";
|
||||||
widget->gwidget()->set_layout(make<GUI::VBoxLayout>());
|
widget->gwidget()->set_layout(make<GUI::VBoxLayout>());
|
||||||
|
@ -138,7 +138,7 @@ bool VBForm::is_selected(const VBWidget& widget) const
|
||||||
return m_selected_widgets.contains(const_cast<VBWidget*>(&widget));
|
return m_selected_widgets.contains(const_cast<VBWidget*>(&widget));
|
||||||
}
|
}
|
||||||
|
|
||||||
VBWidget* VBForm::widget_at(const Point& position)
|
VBWidget* VBForm::widget_at(const Gfx::Point& position)
|
||||||
{
|
{
|
||||||
auto result = hit_test(position, GUI::Widget::ShouldRespectGreediness::No);
|
auto result = hit_test(position, GUI::Widget::ShouldRespectGreediness::No);
|
||||||
if (!result.widget)
|
if (!result.widget)
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
void set_name(const String& name) { m_name = name; }
|
void set_name(const String& name) { m_name = name; }
|
||||||
|
|
||||||
bool is_selected(const VBWidget&) const;
|
bool is_selected(const VBWidget&) const;
|
||||||
VBWidget* widget_at(const Point&);
|
VBWidget* widget_at(const Gfx::Point&);
|
||||||
|
|
||||||
void set_should_snap_to_grip(bool snap) { m_should_snap_to_grid = snap; }
|
void set_should_snap_to_grip(bool snap) { m_should_snap_to_grid = snap; }
|
||||||
bool should_snap_to_grid() const { return m_should_snap_to_grid; }
|
bool should_snap_to_grid() const { return m_should_snap_to_grid; }
|
||||||
|
@ -83,8 +83,8 @@ private:
|
||||||
NonnullRefPtrVector<VBWidget> m_widgets;
|
NonnullRefPtrVector<VBWidget> m_widgets;
|
||||||
HashMap<GUI::Widget*, VBWidget*> m_gwidget_map;
|
HashMap<GUI::Widget*, VBWidget*> m_gwidget_map;
|
||||||
HashTable<VBWidget*> m_selected_widgets;
|
HashTable<VBWidget*> m_selected_widgets;
|
||||||
Point m_transform_event_origin;
|
Gfx::Point m_transform_event_origin;
|
||||||
Point m_next_insertion_position;
|
Gfx::Point m_next_insertion_position;
|
||||||
Direction m_resize_direction { Direction::None };
|
Direction m_resize_direction { Direction::None };
|
||||||
Direction m_mouse_direction_type { Direction::None };
|
Direction m_mouse_direction_type { Direction::None };
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
|
|
|
@ -64,7 +64,7 @@ Rect VBWidget::rect() const
|
||||||
return m_gwidget->window_relative_rect();
|
return m_gwidget->window_relative_rect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VBWidget::set_rect(const Rect& rect)
|
void VBWidget::set_rect(const Gfx::Rect& rect)
|
||||||
{
|
{
|
||||||
if (rect == m_gwidget->window_relative_rect())
|
if (rect == m_gwidget->window_relative_rect())
|
||||||
return;
|
return;
|
||||||
|
@ -106,7 +106,7 @@ Rect VBWidget::grabber_rect(Direction direction) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Direction VBWidget::grabber_at(const Point& position) const
|
Direction VBWidget::grabber_at(const Gfx::Point& position) const
|
||||||
{
|
{
|
||||||
Direction found_grabber = Direction::None;
|
Direction found_grabber = Direction::None;
|
||||||
for_each_direction([&](Direction direction) {
|
for_each_direction([&](Direction direction) {
|
||||||
|
|
|
@ -80,10 +80,10 @@ public:
|
||||||
bool is_selected() const;
|
bool is_selected() const;
|
||||||
|
|
||||||
Rect rect() const;
|
Rect rect() const;
|
||||||
void set_rect(const Rect&);
|
void set_rect(const Gfx::Rect&);
|
||||||
|
|
||||||
Rect grabber_rect(Direction) const;
|
Rect grabber_rect(Direction) const;
|
||||||
Direction grabber_at(const Point&) const;
|
Direction grabber_at(const Gfx::Point&) const;
|
||||||
|
|
||||||
GUI::Widget* gwidget() { return m_gwidget; }
|
GUI::Widget* gwidget() { return m_gwidget; }
|
||||||
|
|
||||||
|
@ -113,5 +113,5 @@ private:
|
||||||
RefPtr<GUI::Widget> m_gwidget;
|
RefPtr<GUI::Widget> m_gwidget;
|
||||||
NonnullOwnPtrVector<VBProperty> m_properties;
|
NonnullOwnPtrVector<VBProperty> m_properties;
|
||||||
NonnullRefPtr<VBWidgetPropertyModel> m_property_model;
|
NonnullRefPtr<VBWidgetPropertyModel> m_property_model;
|
||||||
Rect m_transform_origin_rect;
|
Gfx::Rect m_transform_origin_rect;
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,8 +61,8 @@ GUI::Model::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) co
|
||||||
{
|
{
|
||||||
UNUSED_PARAM(column);
|
UNUSED_PARAM(column);
|
||||||
if (column == Column::Name)
|
if (column == Column::Name)
|
||||||
return { 110, TextAlignment::CenterLeft, &Font::default_bold_font() };
|
return { 110, Gfx::TextAlignment::CenterLeft, &Gfx::Font::default_bold_font() };
|
||||||
return { 90, TextAlignment::CenterLeft };
|
return { 90, Gfx::TextAlignment::CenterLeft };
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::Variant VBWidgetPropertyModel::data(const GUI::ModelIndex& index, Role role) const
|
GUI::Variant VBWidgetPropertyModel::data(const GUI::ModelIndex& index, Role role) const
|
||||||
|
|
|
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Visual Builder", load_png("/res/icons/32x32/app-visual-builder.png"), window);
|
GUI::AboutDialog::show("Visual Builder", Gfx::load_png("/res/icons/32x32/app-visual-builder.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
@ -113,82 +113,82 @@ RefPtr<GUI::Window> make_toolbox_window()
|
||||||
window->set_main_widget(widget);
|
window->set_main_widget(widget);
|
||||||
|
|
||||||
auto label_button = GUI::Button::construct(widget);
|
auto label_button = GUI::Button::construct(widget);
|
||||||
label_button->set_button_style(ButtonStyle::CoolBar);
|
label_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
label_button->set_tooltip("GLabel");
|
label_button->set_tooltip("GLabel");
|
||||||
label_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
label_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||||
label_button->on_click = [](GUI::Button&) {
|
label_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GLabel);
|
form->insert_widget(VBWidgetType::GLabel);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto button_button = GUI::Button::construct(widget);
|
auto button_button = GUI::Button::construct(widget);
|
||||||
button_button->set_button_style(ButtonStyle::CoolBar);
|
button_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
button_button->set_tooltip("GButton");
|
button_button->set_tooltip("GButton");
|
||||||
button_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
button_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||||
button_button->on_click = [](GUI::Button&) {
|
button_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GButton);
|
form->insert_widget(VBWidgetType::GButton);
|
||||||
};
|
};
|
||||||
auto spinbox_button = GUI::Button::construct(widget);
|
auto spinbox_button = GUI::Button::construct(widget);
|
||||||
spinbox_button->set_button_style(ButtonStyle::CoolBar);
|
spinbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
spinbox_button->set_tooltip("GSpinBox");
|
spinbox_button->set_tooltip("GSpinBox");
|
||||||
spinbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
spinbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||||
spinbox_button->on_click = [](GUI::Button&) {
|
spinbox_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GSpinBox);
|
form->insert_widget(VBWidgetType::GSpinBox);
|
||||||
};
|
};
|
||||||
auto editor_button = GUI::Button::construct(widget);
|
auto editor_button = GUI::Button::construct(widget);
|
||||||
editor_button->set_button_style(ButtonStyle::CoolBar);
|
editor_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
editor_button->set_tooltip("GTextEditor");
|
editor_button->set_tooltip("GTextEditor");
|
||||||
editor_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
editor_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||||
editor_button->on_click = [](GUI::Button&) {
|
editor_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GTextEditor);
|
form->insert_widget(VBWidgetType::GTextEditor);
|
||||||
};
|
};
|
||||||
auto progress_bar_button = GUI::Button::construct(widget);
|
auto progress_bar_button = GUI::Button::construct(widget);
|
||||||
progress_bar_button->set_button_style(ButtonStyle::CoolBar);
|
progress_bar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
progress_bar_button->set_tooltip("GProgressBar");
|
progress_bar_button->set_tooltip("GProgressBar");
|
||||||
progress_bar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
progress_bar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||||
progress_bar_button->on_click = [](GUI::Button&) {
|
progress_bar_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GProgressBar);
|
form->insert_widget(VBWidgetType::GProgressBar);
|
||||||
};
|
};
|
||||||
auto slider_button = GUI::Button::construct(widget);
|
auto slider_button = GUI::Button::construct(widget);
|
||||||
slider_button->set_button_style(ButtonStyle::CoolBar);
|
slider_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
slider_button->set_tooltip("GSlider");
|
slider_button->set_tooltip("GSlider");
|
||||||
slider_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
slider_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||||
slider_button->on_click = [](GUI::Button&) {
|
slider_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GSlider);
|
form->insert_widget(VBWidgetType::GSlider);
|
||||||
};
|
};
|
||||||
auto checkbox_button = GUI::Button::construct(widget);
|
auto checkbox_button = GUI::Button::construct(widget);
|
||||||
checkbox_button->set_button_style(ButtonStyle::CoolBar);
|
checkbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
checkbox_button->set_tooltip("GCheckBox");
|
checkbox_button->set_tooltip("GCheckBox");
|
||||||
checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
checkbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||||
checkbox_button->on_click = [](GUI::Button&) {
|
checkbox_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GCheckBox);
|
form->insert_widget(VBWidgetType::GCheckBox);
|
||||||
};
|
};
|
||||||
auto radiobutton_button = GUI::Button::construct(widget);
|
auto radiobutton_button = GUI::Button::construct(widget);
|
||||||
radiobutton_button->set_button_style(ButtonStyle::CoolBar);
|
radiobutton_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
radiobutton_button->set_tooltip("GRadioButton");
|
radiobutton_button->set_tooltip("GRadioButton");
|
||||||
radiobutton_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
radiobutton_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||||
radiobutton_button->on_click = [](GUI::Button&) {
|
radiobutton_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GRadioButton);
|
form->insert_widget(VBWidgetType::GRadioButton);
|
||||||
};
|
};
|
||||||
auto scrollbar_button = GUI::Button::construct(widget);
|
auto scrollbar_button = GUI::Button::construct(widget);
|
||||||
scrollbar_button->set_button_style(ButtonStyle::CoolBar);
|
scrollbar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
scrollbar_button->set_tooltip("GScrollBar");
|
scrollbar_button->set_tooltip("GScrollBar");
|
||||||
scrollbar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
scrollbar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||||
scrollbar_button->on_click = [](GUI::Button&) {
|
scrollbar_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GScrollBar);
|
form->insert_widget(VBWidgetType::GScrollBar);
|
||||||
};
|
};
|
||||||
auto groupbox_button = GUI::Button::construct(widget);
|
auto groupbox_button = GUI::Button::construct(widget);
|
||||||
groupbox_button->set_button_style(ButtonStyle::CoolBar);
|
groupbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
groupbox_button->set_tooltip("GGroupBox");
|
groupbox_button->set_tooltip("GGroupBox");
|
||||||
groupbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
groupbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||||
groupbox_button->on_click = [](GUI::Button&) {
|
groupbox_button->on_click = [](GUI::Button&) {
|
||||||
if (auto* form = VBForm::current())
|
if (auto* form = VBForm::current())
|
||||||
form->insert_widget(VBWidgetType::GGroupBox);
|
form->insert_widget(VBWidgetType::GGroupBox);
|
||||||
|
|
|
@ -134,17 +134,17 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b
|
||||||
};
|
};
|
||||||
m_timer->set_interval(100);
|
m_timer->set_interval(100);
|
||||||
set_frame_thickness(2);
|
set_frame_thickness(2);
|
||||||
set_frame_shape(FrameShape::Container);
|
set_frame_shape(Gfx::FrameShape::Container);
|
||||||
set_frame_shadow(FrameShadow::Sunken);
|
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||||
m_mine_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/mine.png");
|
m_mine_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/mine.png");
|
||||||
m_flag_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png");
|
m_flag_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png");
|
||||||
m_badflag_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/badflag.png");
|
m_badflag_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/badflag.png");
|
||||||
m_consider_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/consider.png");
|
m_consider_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/consider.png");
|
||||||
m_default_face_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/face-default.png");
|
m_default_face_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-default.png");
|
||||||
m_good_face_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/face-good.png");
|
m_good_face_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-good.png");
|
||||||
m_bad_face_bitmap = GraphicsBitmap::load_from_file("/res/icons/minesweeper/face-bad.png");
|
m_bad_face_bitmap = Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-bad.png");
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
m_number_bitmap[i] = GraphicsBitmap::load_from_file(String::format("/res/icons/minesweeper/%u.png", i + 1));
|
m_number_bitmap[i] = Gfx::Bitmap::load_from_file(String::format("/res/icons/minesweeper/%u.png", i + 1));
|
||||||
|
|
||||||
set_fill_with_background_color(true);
|
set_fill_with_background_color(true);
|
||||||
reset();
|
reset();
|
||||||
|
|
|
@ -113,14 +113,14 @@ private:
|
||||||
int m_mine_count { 0 };
|
int m_mine_count { 0 };
|
||||||
int m_unswept_empties { 0 };
|
int m_unswept_empties { 0 };
|
||||||
Vector<OwnPtr<Square>> m_squares;
|
Vector<OwnPtr<Square>> m_squares;
|
||||||
RefPtr<GraphicsBitmap> m_mine_bitmap;
|
RefPtr<Gfx::Bitmap> m_mine_bitmap;
|
||||||
RefPtr<GraphicsBitmap> m_flag_bitmap;
|
RefPtr<Gfx::Bitmap> m_flag_bitmap;
|
||||||
RefPtr<GraphicsBitmap> m_badflag_bitmap;
|
RefPtr<Gfx::Bitmap> m_badflag_bitmap;
|
||||||
RefPtr<GraphicsBitmap> m_consider_bitmap;
|
RefPtr<Gfx::Bitmap> m_consider_bitmap;
|
||||||
RefPtr<GraphicsBitmap> m_default_face_bitmap;
|
RefPtr<Gfx::Bitmap> m_default_face_bitmap;
|
||||||
RefPtr<GraphicsBitmap> m_good_face_bitmap;
|
RefPtr<Gfx::Bitmap> m_good_face_bitmap;
|
||||||
RefPtr<GraphicsBitmap> m_bad_face_bitmap;
|
RefPtr<Gfx::Bitmap> m_bad_face_bitmap;
|
||||||
RefPtr<GraphicsBitmap> m_number_bitmap[8];
|
RefPtr<Gfx::Bitmap> m_number_bitmap[8];
|
||||||
GUI::Button& m_face_button;
|
GUI::Button& m_face_button;
|
||||||
GUI::Label& m_flag_label;
|
GUI::Label& m_flag_label;
|
||||||
GUI::Label& m_time_label;
|
GUI::Label& m_time_label;
|
||||||
|
|
|
@ -69,14 +69,14 @@ int main(int argc, char** argv)
|
||||||
container->set_preferred_size(0, 36);
|
container->set_preferred_size(0, 36);
|
||||||
container->set_layout(make<GUI::HBoxLayout>());
|
container->set_layout(make<GUI::HBoxLayout>());
|
||||||
auto flag_icon_label = GUI::Label::construct(container);
|
auto flag_icon_label = GUI::Label::construct(container);
|
||||||
flag_icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png"));
|
flag_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png"));
|
||||||
auto flag_label = GUI::Label::construct(container);
|
auto flag_label = GUI::Label::construct(container);
|
||||||
auto face_button = GUI::Button::construct(container);
|
auto face_button = GUI::Button::construct(container);
|
||||||
face_button->set_button_style(ButtonStyle::CoolBar);
|
face_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||||
face_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
face_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||||
face_button->set_preferred_size(36, 0);
|
face_button->set_preferred_size(36, 0);
|
||||||
auto time_icon_label = GUI::Label::construct(container);
|
auto time_icon_label = GUI::Label::construct(container);
|
||||||
time_icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/timer.png"));
|
time_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png"));
|
||||||
auto time_label = GUI::Label::construct(container);
|
auto time_label = GUI::Label::construct(container);
|
||||||
auto field = Field::construct(*flag_label, *time_label, *face_button, widget, [&](Size size) {
|
auto field = Field::construct(*flag_label, *time_label, *face_button, widget, [&](Size size) {
|
||||||
size.set_height(size.height() + container->preferred_size().height());
|
size.set_height(size.height() + container->preferred_size().height());
|
||||||
|
@ -129,7 +129,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto help_menu = GUI::Menu::construct("Help");
|
auto help_menu = GUI::Menu::construct("Help");
|
||||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||||
GUI::AboutDialog::show("Minesweeper", load_png("/res/icons/32x32/app-minesweeper.png"), window);
|
GUI::AboutDialog::show("Minesweeper", Gfx::load_png("/res/icons/32x32/app-minesweeper.png"), window);
|
||||||
}));
|
}));
|
||||||
menubar->add_menu(move(help_menu));
|
menubar->add_menu(move(help_menu));
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
window->set_icon(load_png("/res/icons/minesweeper/mine.png"));
|
window->set_icon(Gfx::load_png("/res/icons/minesweeper/mine.png"));
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue