mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:18:12 +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
|
@ -32,7 +32,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
AboutDialog::AboutDialog(const StringView& name, const GraphicsBitmap* icon, Core::Object* parent)
|
||||
AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::Object* parent)
|
||||
: Dialog(parent)
|
||||
, m_name(name)
|
||||
, m_icon(icon)
|
||||
|
@ -62,11 +62,11 @@ AboutDialog::AboutDialog(const StringView& name, const GraphicsBitmap* icon, Cor
|
|||
|
||||
auto make_label = [&](const StringView& text, bool bold = false) {
|
||||
auto label = Label::construct(text, right_container);
|
||||
label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label->set_preferred_size(0, 14);
|
||||
if (bold)
|
||||
label->set_font(Font::default_bold_font());
|
||||
label->set_font(Gfx::Font::default_bold_font());
|
||||
};
|
||||
make_label(m_name, true);
|
||||
make_label("SerenityOS");
|
||||
|
|
|
@ -35,16 +35,16 @@ class AboutDialog final : public Dialog {
|
|||
public:
|
||||
virtual ~AboutDialog() override;
|
||||
|
||||
static void show(const StringView& name, const GraphicsBitmap* icon = nullptr, Core::Object* parent = nullptr)
|
||||
static void show(const StringView& name, const Gfx::Bitmap* icon = nullptr, Core::Object* parent = nullptr)
|
||||
{
|
||||
auto dialog = AboutDialog::construct(name, icon, parent);
|
||||
dialog->exec();
|
||||
}
|
||||
|
||||
private:
|
||||
AboutDialog(const StringView& name, const GraphicsBitmap* icon = nullptr, Core::Object* parent = nullptr);
|
||||
AboutDialog(const StringView& name, const Gfx::Bitmap* icon = nullptr, Core::Object* parent = nullptr);
|
||||
|
||||
String m_name;
|
||||
RefPtr<GraphicsBitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -171,19 +171,19 @@ void AbstractButton::keydown_event(KeyEvent& event)
|
|||
Widget::keydown_event(event);
|
||||
}
|
||||
|
||||
void AbstractButton::paint_text(Painter& painter, const Rect& rect, const Font& font, TextAlignment text_alignment)
|
||||
void AbstractButton::paint_text(Painter& painter, const Gfx::Rect& rect, const Gfx::Font& font, Gfx::TextAlignment text_alignment)
|
||||
{
|
||||
auto clipped_rect = rect.intersected(this->rect());
|
||||
|
||||
if (!is_enabled()) {
|
||||
painter.draw_text(clipped_rect.translated(1, 1), text(), font, text_alignment, Color::White, TextElision::Right);
|
||||
painter.draw_text(clipped_rect, text(), font, text_alignment, Color::from_rgb(0x808080), TextElision::Right);
|
||||
painter.draw_text(clipped_rect.translated(1, 1), text(), font, text_alignment, Color::White, Gfx::TextElision::Right);
|
||||
painter.draw_text(clipped_rect, text(), font, text_alignment, Color::from_rgb(0x808080), Gfx::TextElision::Right);
|
||||
return;
|
||||
}
|
||||
|
||||
if (text().is_empty())
|
||||
return;
|
||||
painter.draw_text(clipped_rect, text(), font, text_alignment, palette().button_text(), TextElision::Right);
|
||||
painter.draw_text(clipped_rect, text(), font, text_alignment, palette().button_text(), Gfx::TextElision::Right);
|
||||
if (is_focused())
|
||||
painter.draw_rect(clipped_rect.inflated(6, 4), Color(140, 140, 140));
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ protected:
|
|||
virtual void leave_event(Core::Event&) override;
|
||||
virtual void change_event(Event&) override;
|
||||
|
||||
void paint_text(Painter&, const Rect&, const Font&, TextAlignment);
|
||||
void paint_text(Painter&, const Gfx::Rect&, const Gfx::Font&, Gfx::TextAlignment);
|
||||
|
||||
private:
|
||||
virtual bool is_abstract_button() const final { return true; }
|
||||
|
|
|
@ -39,8 +39,8 @@ static const int minimum_column_width = 2;
|
|||
AbstractTableView::AbstractTableView(Widget* parent)
|
||||
: AbstractView(parent)
|
||||
{
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
set_frame_shape(Gfx::FrameShape::Container);
|
||||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
|
||||
set_should_hide_unnecessary_scrollbars(true);
|
||||
|
@ -144,7 +144,7 @@ void AbstractTableView::paint_headers(Painter& painter)
|
|||
Rect cell_rect(x_offset, 0, column_width + horizontal_padding() * 2, header_height());
|
||||
bool pressed = column_index == m_pressed_column_header_index && m_pressed_column_header_is_pressed;
|
||||
bool hovered = column_index == m_hovered_column_header_index && model()->column_metadata(column_index).sortable == Model::ColumnMetadata::Sortable::True;
|
||||
StylePainter::paint_button(painter, cell_rect, palette(), ButtonStyle::Normal, pressed, hovered);
|
||||
Gfx::StylePainter::paint_button(painter, cell_rect, palette(), Gfx::ButtonStyle::Normal, pressed, hovered);
|
||||
String text;
|
||||
if (is_key_column) {
|
||||
StringBuilder builder;
|
||||
|
@ -161,7 +161,7 @@ void AbstractTableView::paint_headers(Painter& painter)
|
|||
auto text_rect = cell_rect.translated(horizontal_padding(), 0);
|
||||
if (pressed)
|
||||
text_rect.move_by(1, 1);
|
||||
painter.draw_text(text_rect, text, header_font(), TextAlignment::CenterLeft, palette().button_text());
|
||||
painter.draw_text(text_rect, text, header_font(), Gfx::TextAlignment::CenterLeft, palette().button_text());
|
||||
x_offset += column_width + horizontal_padding() * 2;
|
||||
}
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ Menu& AbstractTableView::ensure_header_context_menu()
|
|||
return *m_header_context_menu;
|
||||
}
|
||||
|
||||
const Font& AbstractTableView::header_font()
|
||||
const Gfx::Font& AbstractTableView::header_font()
|
||||
{
|
||||
return Font::default_bold_font();
|
||||
return Gfx::Font::default_bold_font();
|
||||
}
|
||||
|
||||
void AbstractTableView::set_cell_painting_delegate(int column, OwnPtr<TableCellPaintingDelegate>&& delegate)
|
||||
|
@ -378,7 +378,7 @@ void AbstractTableView::mousedown_event(MouseEvent& event)
|
|||
AbstractView::mousedown_event(event);
|
||||
}
|
||||
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Point& position, bool& is_toggle) const
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position, bool& is_toggle) const
|
||||
{
|
||||
is_toggle = false;
|
||||
if (!model())
|
||||
|
@ -398,7 +398,7 @@ ModelIndex AbstractTableView::index_at_event_position(const Point& position, boo
|
|||
return {};
|
||||
}
|
||||
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Point& position) const
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position) const
|
||||
{
|
||||
bool is_toggle;
|
||||
auto index = index_at_event_position(position, is_toggle);
|
||||
|
@ -545,7 +545,7 @@ Rect AbstractTableView::row_rect(int item_index) const
|
|||
return { 0, header_height() + (item_index * item_height()), max(content_size().width(), width()), item_height() };
|
||||
}
|
||||
|
||||
Point AbstractTableView::adjusted_position(const Point& position) const
|
||||
Point AbstractTableView::adjusted_position(const Gfx::Point& position) const
|
||||
{
|
||||
return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class TableCellPaintingDelegate {
|
|||
public:
|
||||
virtual ~TableCellPaintingDelegate() {}
|
||||
|
||||
virtual void paint(Painter&, const Rect&, const Palette&, const Model&, const ModelIndex&) = 0;
|
||||
virtual void paint(Painter&, const Gfx::Rect&, const Palette&, const Model&, const ModelIndex&) = 0;
|
||||
};
|
||||
|
||||
class AbstractTableView : public AbstractView {
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
int horizontal_padding() const { return m_horizontal_padding; }
|
||||
|
||||
Point adjusted_position(const Point&) const;
|
||||
Point adjusted_position(const Gfx::Point&) const;
|
||||
|
||||
virtual Rect content_rect(const ModelIndex&) const override;
|
||||
Rect content_rect(int row, int column) const;
|
||||
|
@ -70,8 +70,8 @@ public:
|
|||
|
||||
void scroll_into_view(const ModelIndex&, Orientation);
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Point&, bool& is_toggle) const;
|
||||
virtual ModelIndex index_at_event_position(const Point&) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&, bool& is_toggle) const;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
|
||||
protected:
|
||||
virtual ~AbstractTableView() override;
|
||||
|
@ -91,7 +91,7 @@ protected:
|
|||
void paint_headers(Painter&);
|
||||
Rect header_rect(int column) const;
|
||||
|
||||
static const Font& header_font();
|
||||
static const Gfx::Font& header_font();
|
||||
void update_headers();
|
||||
void set_hovered_header_index(int);
|
||||
|
||||
|
@ -121,7 +121,7 @@ private:
|
|||
bool m_in_column_resize { false };
|
||||
bool m_alternating_row_colors { true };
|
||||
int m_horizontal_padding { 5 };
|
||||
Point m_column_resize_origin;
|
||||
Gfx::Point m_column_resize_origin;
|
||||
int m_column_resize_original_width { 0 };
|
||||
int m_resizing_column { -1 };
|
||||
int m_pressed_column_header_index { -1 };
|
||||
|
|
|
@ -161,7 +161,7 @@ void AbstractView::notify_selection_changed(Badge<ModelSelection>)
|
|||
update();
|
||||
}
|
||||
|
||||
NonnullRefPtr<Font> AbstractView::font_for_index(const ModelIndex& index) const
|
||||
NonnullRefPtr<Gfx::Font> AbstractView::font_for_index(const ModelIndex& index) const
|
||||
{
|
||||
if (!model())
|
||||
return font();
|
||||
|
@ -226,7 +226,7 @@ void AbstractView::mousemove_event(MouseEvent& event)
|
|||
dbg() << "Initiate drag!";
|
||||
auto drag_operation = DragOperation::construct();
|
||||
|
||||
RefPtr<GraphicsBitmap> bitmap;
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
|
||||
StringBuilder text_builder;
|
||||
StringBuilder data_builder;
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
virtual void did_update_selection();
|
||||
|
||||
virtual Rect content_rect(const ModelIndex&) const { return {}; }
|
||||
virtual ModelIndex index_at_event_position(const Point&) const = 0;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const = 0;
|
||||
void begin_editing(const ModelIndex&);
|
||||
void stop_editing();
|
||||
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
void notify_selection_changed(Badge<ModelSelection>);
|
||||
|
||||
NonnullRefPtr<Font> font_for_index(const ModelIndex&) const;
|
||||
NonnullRefPtr<Gfx::Font> font_for_index(const ModelIndex&) const;
|
||||
|
||||
protected:
|
||||
explicit AbstractView(Widget* parent);
|
||||
|
@ -92,9 +92,9 @@ protected:
|
|||
bool m_editable { false };
|
||||
ModelIndex m_edit_index;
|
||||
RefPtr<Widget> m_edit_widget;
|
||||
Rect m_edit_widget_content_rect;
|
||||
Gfx::Rect m_edit_widget_content_rect;
|
||||
|
||||
Point m_left_mousedown_position;
|
||||
Gfx::Point m_left_mousedown_position;
|
||||
bool m_might_drag { false };
|
||||
|
||||
private:
|
||||
|
|
|
@ -36,47 +36,47 @@ namespace CommonActions {
|
|||
|
||||
NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Open...", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent);
|
||||
return Action::create("Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent);
|
||||
return Action::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent);
|
||||
return Action::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent);
|
||||
return Action::create("Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent);
|
||||
return Action::create("Redo", { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Delete", { Mod_None, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent);
|
||||
return Action::create("Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent);
|
||||
return Action::create("Cut", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent);
|
||||
return Action::create("Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent);
|
||||
return Action::create("Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
|
@ -91,22 +91,22 @@ NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
|
|||
|
||||
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Go back", { Mod_Alt, Key_Left }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent);
|
||||
return Action::create("Go back", { Mod_Alt, Key_Left }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Go forward", { Mod_Alt, Key_Right }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent);
|
||||
return Action::create("Go forward", { Mod_Alt, Key_Right }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Go home", { Mod_Alt, Key_Home }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent);
|
||||
return Action::create("Go home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return Action::create("Reload", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent);
|
||||
return Action::create("Reload", { Mod_Ctrl, Key_R }, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ Action::Action(const StringView& text, Function<void(Action&)> on_activation_cal
|
|||
{
|
||||
}
|
||||
|
||||
Action::Action(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(Action&)> on_activation_callback, Core::Object* parent)
|
||||
Action::Action(const StringView& text, RefPtr<Gfx::Bitmap>&& icon, Function<void(Action&)> on_activation_callback, Core::Object* parent)
|
||||
: Core::Object(parent)
|
||||
, on_activation(move(on_activation_callback))
|
||||
, m_text(text)
|
||||
|
@ -131,7 +131,7 @@ Action::Action(const StringView& text, const Shortcut& shortcut, Function<void(A
|
|||
{
|
||||
}
|
||||
|
||||
Action::Action(const StringView& text, const Shortcut& shortcut, RefPtr<GraphicsBitmap>&& icon, Function<void(Action&)> on_activation_callback, Core::Object* parent)
|
||||
Action::Action(const StringView& text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap>&& icon, Function<void(Action&)> on_activation_callback, Core::Object* parent)
|
||||
: Core::Object(parent)
|
||||
, on_activation(move(on_activation_callback))
|
||||
, m_text(text)
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
{
|
||||
return adopt(*new Action(text, move(callback), parent));
|
||||
}
|
||||
static NonnullRefPtr<Action> create(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(Action&)> callback, Core::Object* parent = nullptr)
|
||||
static NonnullRefPtr<Action> create(const StringView& text, RefPtr<Gfx::Bitmap>&& icon, Function<void(Action&)> callback, Core::Object* parent = nullptr)
|
||||
{
|
||||
return adopt(*new Action(text, move(icon), move(callback), parent));
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
{
|
||||
return adopt(*new Action(text, shortcut, move(callback), parent));
|
||||
}
|
||||
static NonnullRefPtr<Action> create(const StringView& text, const Shortcut& shortcut, RefPtr<GraphicsBitmap>&& icon, Function<void(Action&)> callback, Core::Object* parent = nullptr)
|
||||
static NonnullRefPtr<Action> create(const StringView& text, const Shortcut& shortcut, RefPtr<Gfx::Bitmap>&& icon, Function<void(Action&)> callback, Core::Object* parent = nullptr)
|
||||
{
|
||||
return adopt(*new Action(text, shortcut, move(icon), move(callback), parent));
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ public:
|
|||
|
||||
String text() const { return m_text; }
|
||||
Shortcut shortcut() const { return m_shortcut; }
|
||||
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
||||
void set_icon(const GraphicsBitmap* icon) { m_icon = icon; }
|
||||
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
||||
void set_icon(const Gfx::Bitmap* icon) { m_icon = icon; }
|
||||
|
||||
const Core::Object* activator() const { return m_activator.ptr(); }
|
||||
Core::Object* activator() { return m_activator.ptr(); }
|
||||
|
@ -128,8 +128,8 @@ private:
|
|||
|
||||
Action(const StringView& text, Function<void(Action&)> = nullptr, Core::Object* = nullptr);
|
||||
Action(const StringView& text, const Shortcut&, Function<void(Action&)> = nullptr, Core::Object* = nullptr);
|
||||
Action(const StringView& text, const Shortcut&, RefPtr<GraphicsBitmap>&& icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr);
|
||||
Action(const StringView& text, RefPtr<GraphicsBitmap>&& icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr);
|
||||
Action(const StringView& text, const Shortcut&, RefPtr<Gfx::Bitmap>&& icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr);
|
||||
Action(const StringView& text, RefPtr<Gfx::Bitmap>&& icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr);
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_toolbar_button(Callback);
|
||||
|
@ -137,7 +137,7 @@ private:
|
|||
void for_each_menu_item(Callback);
|
||||
|
||||
String m_text;
|
||||
RefPtr<GraphicsBitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
Shortcut m_shortcut;
|
||||
bool m_enabled { true };
|
||||
bool m_checkable { false };
|
||||
|
|
|
@ -113,8 +113,8 @@ public:
|
|||
m_label->set_background_color(Color::from_rgb(0xdac7b5));
|
||||
m_label->set_fill_with_background_color(true);
|
||||
m_label->set_frame_thickness(1);
|
||||
m_label->set_frame_shape(FrameShape::Container);
|
||||
m_label->set_frame_shadow(FrameShadow::Plain);
|
||||
m_label->set_frame_shape(Gfx::FrameShape::Container);
|
||||
m_label->set_frame_shadow(Gfx::FrameShadow::Plain);
|
||||
set_main_widget(m_label);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public:
|
|||
RefPtr<Label> m_label;
|
||||
};
|
||||
|
||||
void Application::show_tooltip(const StringView& tooltip, const Point& screen_location)
|
||||
void Application::show_tooltip(const StringView& tooltip, const Gfx::Point& screen_location)
|
||||
{
|
||||
if (!m_tooltip_window) {
|
||||
m_tooltip_window = new TooltipWindow;
|
||||
|
@ -175,7 +175,7 @@ void Application::did_delete_last_window(Badge<Window>)
|
|||
void Application::set_system_palette(SharedBuffer& buffer)
|
||||
{
|
||||
if (!m_system_palette)
|
||||
m_system_palette = PaletteImpl::create_with_shared_buffer(buffer);
|
||||
m_system_palette = Gfx::PaletteImpl::create_with_shared_buffer(buffer);
|
||||
else
|
||||
m_system_palette->replace_internal_buffer({}, buffer);
|
||||
|
||||
|
|
|
@ -38,8 +38,10 @@ class SharedBuffer;
|
|||
namespace Core {
|
||||
class EventLoop;
|
||||
}
|
||||
namespace Gfx {
|
||||
class Palette;
|
||||
class Point;
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
class Action;
|
||||
|
@ -63,7 +65,7 @@ public:
|
|||
void register_global_shortcut_action(Badge<Action>, Action&);
|
||||
void unregister_global_shortcut_action(Badge<Action>, Action&);
|
||||
|
||||
void show_tooltip(const StringView&, const Point& screen_location);
|
||||
void show_tooltip(const StringView&, const Gfx::Point& screen_location);
|
||||
void hide_tooltip();
|
||||
|
||||
bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; }
|
||||
|
@ -83,8 +85,8 @@ public:
|
|||
private:
|
||||
OwnPtr<Core::EventLoop> m_event_loop;
|
||||
OwnPtr<MenuBar> m_menubar;
|
||||
RefPtr<PaletteImpl> m_palette;
|
||||
RefPtr<PaletteImpl> m_system_palette;
|
||||
RefPtr<Gfx::PaletteImpl> m_palette;
|
||||
RefPtr<Gfx::PaletteImpl> m_system_palette;
|
||||
HashMap<Shortcut, Action*> m_global_shortcut_actions;
|
||||
class TooltipWindow;
|
||||
TooltipWindow* m_tooltip_window { nullptr };
|
||||
|
|
|
@ -55,7 +55,7 @@ void Button::paint_event(PaintEvent& event)
|
|||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
StylePainter::paint_button(painter, rect(), palette(), m_button_style, is_being_pressed(), is_hovered(), is_checked(), is_enabled());
|
||||
Gfx::StylePainter::paint_button(painter, rect(), palette(), m_button_style, is_being_pressed(), is_hovered(), is_checked(), is_enabled());
|
||||
|
||||
if (text().is_empty() && !m_icon)
|
||||
return;
|
||||
|
@ -72,7 +72,7 @@ void Button::paint_event(PaintEvent& event)
|
|||
else
|
||||
painter.blit_dimmed(icon_location, *m_icon, m_icon->rect());
|
||||
}
|
||||
auto& font = is_checked() ? Font::default_bold_font() : this->font();
|
||||
auto& font = is_checked() ? Gfx::Font::default_bold_font() : this->font();
|
||||
if (m_icon && !text().is_empty()) {
|
||||
content_rect.move_by(m_icon->width() + 4, 0);
|
||||
content_rect.set_width(content_rect.width() - m_icon->width() - 4);
|
||||
|
@ -110,7 +110,7 @@ void Button::set_action(Action& action)
|
|||
set_checked(action.is_checked());
|
||||
}
|
||||
|
||||
void Button::set_icon(RefPtr<GraphicsBitmap>&& icon)
|
||||
void Button::set_icon(RefPtr<Gfx::Bitmap>&& icon)
|
||||
{
|
||||
if (m_icon == icon)
|
||||
return;
|
||||
|
|
|
@ -42,17 +42,17 @@ class Button : public AbstractButton {
|
|||
public:
|
||||
virtual ~Button() override;
|
||||
|
||||
void set_icon(RefPtr<GraphicsBitmap>&&);
|
||||
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
||||
GraphicsBitmap* icon() { return m_icon.ptr(); }
|
||||
void set_icon(RefPtr<Gfx::Bitmap>&&);
|
||||
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
||||
Gfx::Bitmap* icon() { return m_icon.ptr(); }
|
||||
|
||||
void set_text_alignment(TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||
TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
|
||||
Function<void(Button&)> on_click;
|
||||
|
||||
void set_button_style(ButtonStyle style) { m_button_style = style; }
|
||||
ButtonStyle button_style() const { return m_button_style; }
|
||||
void set_button_style(Gfx::ButtonStyle style) { m_button_style = style; }
|
||||
Gfx::ButtonStyle button_style() const { return m_button_style; }
|
||||
|
||||
virtual void click() override;
|
||||
|
||||
|
@ -69,9 +69,9 @@ protected:
|
|||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
RefPtr<GraphicsBitmap> m_icon;
|
||||
ButtonStyle m_button_style { ButtonStyle::Normal };
|
||||
TextAlignment m_text_alignment { TextAlignment::Center };
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
Gfx::ButtonStyle m_button_style { Gfx::ButtonStyle::Normal };
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||
WeakPtr<Action> m_action;
|
||||
bool m_focusable { true };
|
||||
};
|
||||
|
|
|
@ -45,7 +45,7 @@ static const char* s_checked_bitmap_data = {
|
|||
" "
|
||||
};
|
||||
|
||||
static CharacterBitmap* s_checked_bitmap;
|
||||
static Gfx::CharacterBitmap* s_checked_bitmap;
|
||||
static const int s_checked_bitmap_width = 9;
|
||||
static const int s_checked_bitmap_height = 9;
|
||||
static const int s_box_width = 13;
|
||||
|
@ -84,18 +84,18 @@ void CheckBox::paint_event(PaintEvent& event)
|
|||
s_box_width, s_box_height
|
||||
};
|
||||
painter.fill_rect(box_rect, palette().base());
|
||||
StylePainter::paint_frame(painter, box_rect, palette(), FrameShape::Container, FrameShadow::Sunken, 2);
|
||||
Gfx::StylePainter::paint_frame(painter, box_rect, palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2);
|
||||
|
||||
if (is_being_pressed())
|
||||
painter.draw_rect(box_rect.shrunken(4, 4), Color::MidGray);
|
||||
|
||||
if (is_checked()) {
|
||||
if (!s_checked_bitmap)
|
||||
s_checked_bitmap = &CharacterBitmap::create_from_ascii(s_checked_bitmap_data, s_checked_bitmap_width, s_checked_bitmap_height).leak_ref();
|
||||
s_checked_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_checked_bitmap_data, s_checked_bitmap_width, s_checked_bitmap_height).leak_ref();
|
||||
painter.draw_bitmap(box_rect.shrunken(4, 4).location(), *s_checked_bitmap, palette().base_text());
|
||||
}
|
||||
|
||||
paint_text(painter, text_rect, font(), TextAlignment::TopLeft);
|
||||
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
|
||||
}
|
||||
|
||||
void CheckBox::click()
|
||||
|
|
|
@ -51,8 +51,8 @@ ColumnsView::ColumnsView(Widget* parent)
|
|||
set_fill_with_background_color(true);
|
||||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
set_frame_shape(Gfx::FrameShape::Container);
|
||||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
|
||||
m_columns.append({ {}, 0 });
|
||||
|
@ -116,7 +116,7 @@ void ColumnsView::paint_event(PaintEvent& event)
|
|||
column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - s_arrow_bitmap_width - icon_spacing(), item_height()
|
||||
};
|
||||
auto text = model()->data(index).to_string();
|
||||
painter.draw_text(text_rect, text, TextAlignment::CenterLeft, text_color);
|
||||
painter.draw_text(text_rect, text, Gfx::TextAlignment::CenterLeft, text_color);
|
||||
|
||||
bool expandable = model()->row_count(index) > 0;
|
||||
if (expandable) {
|
||||
|
@ -125,7 +125,7 @@ void ColumnsView::paint_event(PaintEvent& event)
|
|||
s_arrow_bitmap_width, s_arrow_bitmap_height
|
||||
};
|
||||
arrow_rect.center_vertically_within(row_rect);
|
||||
static auto& arrow_bitmap = CharacterBitmap::create_from_ascii(s_arrow_bitmap_data, s_arrow_bitmap_width, s_arrow_bitmap_height).leak_ref();
|
||||
static auto& arrow_bitmap = Gfx::CharacterBitmap::create_from_ascii(s_arrow_bitmap_data, s_arrow_bitmap_width, s_arrow_bitmap_height).leak_ref();
|
||||
painter.draw_bitmap(arrow_rect.location(), arrow_bitmap, text_color);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void ColumnsView::update_column_sizes()
|
|||
set_content_size({ total_width, total_height });
|
||||
}
|
||||
|
||||
ModelIndex ColumnsView::index_at_event_position(const Point& a_position) const
|
||||
ModelIndex ColumnsView::index_at_event_position(const Gfx::Point& a_position) const
|
||||
{
|
||||
if (!model())
|
||||
return {};
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
int model_column() const { return m_model_column; }
|
||||
void set_model_column(int column) { m_model_column = column; }
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Point&) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
|
||||
private:
|
||||
ColumnsView(Widget* parent = nullptr);
|
||||
|
|
|
@ -44,7 +44,7 @@ Desktop::Desktop()
|
|||
{
|
||||
}
|
||||
|
||||
void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Rect& rect)
|
||||
void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect& rect)
|
||||
{
|
||||
if (m_rect == rect)
|
||||
return;
|
||||
|
|
|
@ -44,12 +44,12 @@ public:
|
|||
bool set_wallpaper(const StringView& path);
|
||||
|
||||
Rect rect() const { return m_rect; }
|
||||
void did_receive_screen_rect(Badge<WindowServerConnection>, const Rect&);
|
||||
void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect&);
|
||||
|
||||
Function<void(const Rect&)> on_rect_change;
|
||||
Function<void(const Gfx::Rect&)> on_rect_change;
|
||||
|
||||
private:
|
||||
Rect m_rect;
|
||||
Gfx::Rect m_rect;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ DragOperation::Outcome DragOperation::exec()
|
|||
|
||||
int bitmap_id = -1;
|
||||
Size bitmap_size;
|
||||
RefPtr<GraphicsBitmap> shared_bitmap;
|
||||
RefPtr<Gfx::Bitmap> shared_bitmap;
|
||||
if (m_bitmap) {
|
||||
shared_bitmap = m_bitmap->to_shareable_bitmap();
|
||||
shared_bitmap->shared_buffer()->share_with(WindowServerConnection::the().server_pid());
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
#include <LibCore/CEventLoop.h>
|
||||
#include <LibCore/CObject.h>
|
||||
|
||||
class GraphicsBitmap;
|
||||
namespace Gfx {
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -47,7 +49,7 @@ public:
|
|||
virtual ~DragOperation() override;
|
||||
|
||||
void set_text(const String& text) { m_text = text; }
|
||||
void set_bitmap(const GraphicsBitmap* bitmap) { m_bitmap = bitmap; }
|
||||
void set_bitmap(const Gfx::Bitmap* bitmap) { m_bitmap = bitmap; }
|
||||
void set_data(const String& data_type, const String& data)
|
||||
{
|
||||
m_data_type = data_type;
|
||||
|
@ -71,7 +73,7 @@ private:
|
|||
String m_text;
|
||||
String m_data_type;
|
||||
String m_data;
|
||||
RefPtr<GraphicsBitmap> m_bitmap;
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
|
||||
class WMWindowStateChangedEvent : public WMEvent {
|
||||
public:
|
||||
WMWindowStateChangedEvent(int client_id, int window_id, const StringView& title, const Rect& rect, bool is_active, WindowType window_type, bool is_minimized)
|
||||
WMWindowStateChangedEvent(int client_id, int window_id, const StringView& title, const Gfx::Rect& rect, bool is_active, WindowType window_type, bool is_minimized)
|
||||
: WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id)
|
||||
, m_title(title)
|
||||
, m_rect(rect)
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
|
||||
private:
|
||||
String m_title;
|
||||
Rect m_rect;
|
||||
Gfx::Rect m_rect;
|
||||
WindowType m_window_type;
|
||||
bool m_active;
|
||||
bool m_minimized;
|
||||
|
@ -134,7 +134,7 @@ private:
|
|||
|
||||
class WMWindowRectChangedEvent : public WMEvent {
|
||||
public:
|
||||
WMWindowRectChangedEvent(int client_id, int window_id, const Rect& rect)
|
||||
WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::Rect& rect)
|
||||
: WMEvent(Event::Type::WM_WindowRectChanged, client_id, window_id)
|
||||
, m_rect(rect)
|
||||
{
|
||||
|
@ -143,12 +143,12 @@ public:
|
|||
Rect rect() const { return m_rect; }
|
||||
|
||||
private:
|
||||
Rect m_rect;
|
||||
Gfx::Rect m_rect;
|
||||
};
|
||||
|
||||
class WMWindowIconBitmapChangedEvent : public WMEvent {
|
||||
public:
|
||||
WMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Size& icon_size)
|
||||
WMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Gfx::Size& icon_size)
|
||||
: WMEvent(Event::Type::WM_WindowIconBitmapChanged, client_id, window_id)
|
||||
, m_icon_buffer_id(icon_buffer_id)
|
||||
, m_icon_size(icon_size)
|
||||
|
@ -156,16 +156,16 @@ public:
|
|||
}
|
||||
|
||||
int icon_buffer_id() const { return m_icon_buffer_id; }
|
||||
const Size& icon_size() const { return m_icon_size; }
|
||||
const Gfx::Size& icon_size() const { return m_icon_size; }
|
||||
|
||||
private:
|
||||
int m_icon_buffer_id;
|
||||
Size m_icon_size;
|
||||
Gfx::Size m_icon_size;
|
||||
};
|
||||
|
||||
class MultiPaintEvent final : public Event {
|
||||
public:
|
||||
explicit MultiPaintEvent(const Vector<Rect, 32>& rects, const Size& window_size)
|
||||
explicit MultiPaintEvent(const Vector<Rect, 32>& rects, const Gfx::Size& window_size)
|
||||
: Event(Event::MultiPaint)
|
||||
, m_rects(rects)
|
||||
, m_window_size(window_size)
|
||||
|
@ -177,12 +177,12 @@ public:
|
|||
|
||||
private:
|
||||
Vector<Rect, 32> m_rects;
|
||||
Size m_window_size;
|
||||
Gfx::Size m_window_size;
|
||||
};
|
||||
|
||||
class PaintEvent final : public Event {
|
||||
public:
|
||||
explicit PaintEvent(const Rect& rect, const Size& window_size = Size())
|
||||
explicit PaintEvent(const Gfx::Rect& rect, const Gfx::Size& window_size = Size())
|
||||
: Event(Event::Paint)
|
||||
, m_rect(rect)
|
||||
, m_window_size(window_size)
|
||||
|
@ -193,42 +193,42 @@ public:
|
|||
Size window_size() const { return m_window_size; }
|
||||
|
||||
private:
|
||||
Rect m_rect;
|
||||
Size m_window_size;
|
||||
Gfx::Rect m_rect;
|
||||
Gfx::Size m_window_size;
|
||||
};
|
||||
|
||||
class ResizeEvent final : public Event {
|
||||
public:
|
||||
explicit ResizeEvent(const Size& old_size, const Size& size)
|
||||
explicit ResizeEvent(const Gfx::Size& old_size, const Gfx::Size& size)
|
||||
: Event(Event::Resize)
|
||||
, m_old_size(old_size)
|
||||
, m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
const Size& old_size() const { return m_old_size; }
|
||||
const Size& size() const { return m_size; }
|
||||
const Gfx::Size& old_size() const { return m_old_size; }
|
||||
const Gfx::Size& size() const { return m_size; }
|
||||
|
||||
private:
|
||||
Size m_old_size;
|
||||
Size m_size;
|
||||
Gfx::Size m_old_size;
|
||||
Gfx::Size m_size;
|
||||
};
|
||||
|
||||
class ContextMenuEvent final : public Event {
|
||||
public:
|
||||
explicit ContextMenuEvent(const Point& position, const Point& screen_position)
|
||||
explicit ContextMenuEvent(const Gfx::Point& position, const Gfx::Point& screen_position)
|
||||
: Event(Event::ContextMenu)
|
||||
, m_position(position)
|
||||
, m_screen_position(screen_position)
|
||||
{
|
||||
}
|
||||
|
||||
const Point& position() const { return m_position; }
|
||||
const Point& screen_position() const { return m_screen_position; }
|
||||
const Gfx::Point& position() const { return m_position; }
|
||||
const Gfx::Point& screen_position() const { return m_screen_position; }
|
||||
|
||||
private:
|
||||
Point m_position;
|
||||
Point m_screen_position;
|
||||
Gfx::Point m_position;
|
||||
Gfx::Point m_screen_position;
|
||||
};
|
||||
|
||||
class ShowEvent final : public Event {
|
||||
|
@ -280,7 +280,7 @@ private:
|
|||
|
||||
class MouseEvent final : public Event {
|
||||
public:
|
||||
MouseEvent(Type type, const Point& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta)
|
||||
MouseEvent(Type type, const Gfx::Point& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta)
|
||||
: Event(type)
|
||||
, m_position(position)
|
||||
, m_buttons(buttons)
|
||||
|
@ -299,7 +299,7 @@ public:
|
|||
int wheel_delta() const { return m_wheel_delta; }
|
||||
|
||||
private:
|
||||
Point m_position;
|
||||
Gfx::Point m_position;
|
||||
unsigned m_buttons { 0 };
|
||||
MouseButton m_button { MouseButton::None };
|
||||
unsigned m_modifiers { 0 };
|
||||
|
@ -308,7 +308,7 @@ private:
|
|||
|
||||
class DropEvent final : public Event {
|
||||
public:
|
||||
DropEvent(const Point& position, const String& text, const String& data_type, const String& data)
|
||||
DropEvent(const Gfx::Point& position, const String& text, const String& data_type, const String& data)
|
||||
: Event(Event::Drop)
|
||||
, m_position(position)
|
||||
, m_text(text)
|
||||
|
@ -317,13 +317,13 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
const Point& position() const { return m_position; }
|
||||
const Gfx::Point& position() const { return m_position; }
|
||||
const String& text() const { return m_text; }
|
||||
const String& data_type() const { return m_data_type; }
|
||||
const String& data() const { return m_data; }
|
||||
|
||||
private:
|
||||
Point m_position;
|
||||
Gfx::Point m_position;
|
||||
String m_text;
|
||||
String m_data_type;
|
||||
String m_data;
|
||||
|
|
|
@ -120,7 +120,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
clear_preview();
|
||||
};
|
||||
|
||||
auto open_parent_directory_action = Action::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [this](const Action&) {
|
||||
auto open_parent_directory_action = Action::create("Open parent directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [this](const Action&) {
|
||||
m_model->set_root_path(String::format("%s/..", m_model->root_path().characters()));
|
||||
clear_preview();
|
||||
});
|
||||
|
@ -132,7 +132,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
toolbar->add_action(go_home_action);
|
||||
toolbar->add_separator();
|
||||
|
||||
auto mkdir_action = Action::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) {
|
||||
auto mkdir_action = Action::create("New directory...", Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) {
|
||||
auto input_box = InputBox::construct("Enter name:", "New directory", this);
|
||||
if (input_box->exec() == InputBox::ExecOK && !input_box->text_value().is_empty()) {
|
||||
auto new_dir_path = FileSystemPath(String::format("%s/%s",
|
||||
|
@ -160,7 +160,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
filename_container->set_preferred_size(0, 20);
|
||||
filename_container->set_layout(make<HBoxLayout>());
|
||||
auto filename_label = Label::construct("File name:", filename_container);
|
||||
filename_label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
filename_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
filename_label->set_preferred_size(60, 0);
|
||||
m_filename_textbox = TextBox::construct(filename_container.ptr());
|
||||
|
@ -226,8 +226,8 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
auto preview_container = Frame::construct(horizontal_container);
|
||||
preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
preview_container->set_preferred_size(180, 0);
|
||||
preview_container->set_frame_shape(FrameShape::Container);
|
||||
preview_container->set_frame_shadow(FrameShadow::Sunken);
|
||||
preview_container->set_frame_shape(Gfx::FrameShape::Container);
|
||||
preview_container->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
preview_container->set_frame_thickness(2);
|
||||
preview_container->set_layout(make<VBoxLayout>());
|
||||
preview_container->layout()->set_margins({ 8, 8, 8, 8 });
|
||||
|
@ -238,7 +238,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
m_preview_image_label->set_preferred_size(160, 160);
|
||||
|
||||
m_preview_name_label = Label::construct(preview_container);
|
||||
m_preview_name_label->set_font(Font::default_bold_font());
|
||||
m_preview_name_label->set_font(Gfx::Font::default_bold_font());
|
||||
m_preview_name_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_preview_name_label->set_preferred_size(0, m_preview_name_label->font().glyph_height());
|
||||
|
||||
|
@ -254,7 +254,7 @@ FilePicker::~FilePicker()
|
|||
void FilePicker::set_preview(const FileSystemPath& path)
|
||||
{
|
||||
if (path.has_extension(".png")) {
|
||||
auto bitmap = load_png(path.string());
|
||||
auto bitmap = Gfx::load_png(path.string());
|
||||
if (!bitmap) {
|
||||
clear_preview();
|
||||
return;
|
||||
|
|
|
@ -441,14 +441,14 @@ GIcon FileSystemModel::icon_for(const Node& node) const
|
|||
return icon_for_file(node.mode, node.name);
|
||||
}
|
||||
|
||||
static HashMap<String, RefPtr<GraphicsBitmap>> s_thumbnail_cache;
|
||||
static HashMap<String, RefPtr<Gfx::Bitmap>> s_thumbnail_cache;
|
||||
|
||||
static RefPtr<GraphicsBitmap> render_thumbnail(const StringView& path)
|
||||
static RefPtr<Gfx::Bitmap> render_thumbnail(const StringView& path)
|
||||
{
|
||||
auto png_bitmap = GraphicsBitmap::load_from_file(path);
|
||||
auto png_bitmap = Gfx::Bitmap::load_from_file(path);
|
||||
if (!png_bitmap)
|
||||
return nullptr;
|
||||
auto thumbnail = GraphicsBitmap::create(png_bitmap->format(), { 32, 32 });
|
||||
auto thumbnail = Gfx::Bitmap::create(png_bitmap->format(), { 32, 32 });
|
||||
Painter painter(*thumbnail);
|
||||
painter.draw_scaled_bitmap(thumbnail->rect(), *png_bitmap, png_bitmap->rect());
|
||||
return thumbnail;
|
||||
|
@ -475,7 +475,7 @@ bool FileSystemModel::fetch_thumbnail_for(const Node& node)
|
|||
|
||||
auto weak_this = make_weak_ptr();
|
||||
|
||||
LibThread::BackgroundAction<RefPtr<GraphicsBitmap>>::create(
|
||||
LibThread::BackgroundAction<RefPtr<Gfx::Bitmap>>::create(
|
||||
[path] {
|
||||
return render_thumbnail(path);
|
||||
},
|
||||
|
@ -536,23 +536,23 @@ Model::ColumnMetadata FileSystemModel::column_metadata(int column) const
|
|||
{
|
||||
switch (column) {
|
||||
case Column::Icon:
|
||||
return { 16, TextAlignment::Center, nullptr, Model::ColumnMetadata::Sortable::False };
|
||||
return { 16, Gfx::TextAlignment::Center, nullptr, Model::ColumnMetadata::Sortable::False };
|
||||
case Column::Name:
|
||||
return { 120, TextAlignment::CenterLeft };
|
||||
return { 120, Gfx::TextAlignment::CenterLeft };
|
||||
case Column::Size:
|
||||
return { 80, TextAlignment::CenterRight };
|
||||
return { 80, Gfx::TextAlignment::CenterRight };
|
||||
case Column::Owner:
|
||||
return { 50, TextAlignment::CenterLeft };
|
||||
return { 50, Gfx::TextAlignment::CenterLeft };
|
||||
case Column::Group:
|
||||
return { 50, TextAlignment::CenterLeft };
|
||||
return { 50, Gfx::TextAlignment::CenterLeft };
|
||||
case Column::ModificationTime:
|
||||
return { 110, TextAlignment::CenterLeft };
|
||||
return { 110, Gfx::TextAlignment::CenterLeft };
|
||||
case Column::Permissions:
|
||||
return { 65, TextAlignment::CenterLeft };
|
||||
return { 65, Gfx::TextAlignment::CenterLeft };
|
||||
case Column::Inode:
|
||||
return { 60, TextAlignment::CenterRight };
|
||||
return { 60, Gfx::TextAlignment::CenterRight };
|
||||
case Column::SymlinkTarget:
|
||||
return { 120, TextAlignment::CenterLeft };
|
||||
return { 120, Gfx::TextAlignment::CenterLeft };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
size_t total_size { 0 };
|
||||
|
||||
mutable RefPtr<GraphicsBitmap> thumbnail;
|
||||
mutable RefPtr<Gfx::Bitmap> thumbnail;
|
||||
bool is_directory() const { return S_ISDIR(mode); }
|
||||
bool is_executable() const { return mode & (S_IXUSR | S_IXGRP | S_IXOTH); }
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ GFontDatabase::GFontDatabase()
|
|||
while (di.has_next()) {
|
||||
String name = di.next_path();
|
||||
auto path = String::format("/res/fonts/%s", name.characters());
|
||||
if (auto font = Font::load_from_file(path)) {
|
||||
if (auto font = Gfx::Font::load_from_file(path)) {
|
||||
Metadata metadata;
|
||||
metadata.path = path;
|
||||
metadata.glyph_height = font->glyph_height();
|
||||
|
@ -89,10 +89,10 @@ void GFontDatabase::for_each_fixed_width_font(Function<void(const StringView&)>
|
|||
callback(name);
|
||||
}
|
||||
|
||||
RefPtr<Font> GFontDatabase::get_by_name(const StringView& name)
|
||||
RefPtr<Gfx::Font> GFontDatabase::get_by_name(const StringView& name)
|
||||
{
|
||||
auto it = m_name_to_metadata.find(name);
|
||||
if (it == m_name_to_metadata.end())
|
||||
return nullptr;
|
||||
return Font::load_from_file((*it).value.path);
|
||||
return Gfx::Font::load_from_file((*it).value.path);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Gfx {
|
||||
class Font;
|
||||
}
|
||||
|
||||
struct Metadata {
|
||||
String path;
|
||||
|
@ -42,7 +44,7 @@ class GFontDatabase {
|
|||
public:
|
||||
static GFontDatabase& the();
|
||||
|
||||
RefPtr<Font> get_by_name(const StringView&);
|
||||
RefPtr<Gfx::Font> get_by_name(const StringView&);
|
||||
void for_each_font(Function<void(const StringView&)>);
|
||||
void for_each_fixed_width_font(Function<void(const StringView&)>);
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ Frame::~Frame()
|
|||
|
||||
void Frame::paint_event(PaintEvent& event)
|
||||
{
|
||||
if (m_shape == FrameShape::NoFrame)
|
||||
if (m_shape == Gfx::FrameShape::NoFrame)
|
||||
return;
|
||||
|
||||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
StylePainter::paint_frame(painter, rect(), palette(), m_shape, m_shadow, m_thickness, spans_entire_window_horizontally());
|
||||
Gfx::StylePainter::paint_frame(painter, rect(), palette(), m_shape, m_shadow, m_thickness, spans_entire_window_horizontally());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ public:
|
|||
int frame_thickness() const { return m_thickness; }
|
||||
void set_frame_thickness(int thickness) { m_thickness = thickness; }
|
||||
|
||||
FrameShadow frame_shadow() const { return m_shadow; }
|
||||
void set_frame_shadow(FrameShadow shadow) { m_shadow = shadow; }
|
||||
Gfx::FrameShadow frame_shadow() const { return m_shadow; }
|
||||
void set_frame_shadow(Gfx::FrameShadow shadow) { m_shadow = shadow; }
|
||||
|
||||
FrameShape frame_shape() const { return m_shape; }
|
||||
void set_frame_shape(FrameShape shape) { m_shape = shape; }
|
||||
Gfx::FrameShape frame_shape() const { return m_shape; }
|
||||
void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; }
|
||||
|
||||
Rect frame_inner_rect_for_size(const Size& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; }
|
||||
Rect frame_inner_rect_for_size(const Gfx::Size& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; }
|
||||
Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
|
||||
|
||||
protected:
|
||||
|
@ -54,8 +54,8 @@ protected:
|
|||
|
||||
private:
|
||||
int m_thickness { 0 };
|
||||
FrameShadow m_shadow { FrameShadow::Plain };
|
||||
FrameShape m_shape { FrameShape::NoFrame };
|
||||
Gfx::FrameShadow m_shadow { Gfx::FrameShadow::Plain };
|
||||
Gfx::FrameShape m_shape { Gfx::FrameShape::NoFrame };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -55,11 +55,11 @@ void GroupBox::paint_event(PaintEvent& event)
|
|||
0, font().glyph_height() / 2,
|
||||
width(), height() - font().glyph_height() / 2
|
||||
};
|
||||
StylePainter::paint_frame(painter, frame_rect, palette(), FrameShape::Box, FrameShadow::Sunken, 2);
|
||||
Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::FrameShadow::Sunken, 2);
|
||||
|
||||
Rect text_rect { 4, 0, font().width(m_title) + 6, font().glyph_height() };
|
||||
painter.fill_rect(text_rect, palette().button());
|
||||
painter.draw_text(text_rect, m_title, TextAlignment::Center, palette().button_text());
|
||||
painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text());
|
||||
}
|
||||
|
||||
void GroupBox::set_title(const StringView& title)
|
||||
|
|
|
@ -41,7 +41,7 @@ GIcon::GIcon(const GIcon& other)
|
|||
{
|
||||
}
|
||||
|
||||
GIcon::GIcon(RefPtr<GraphicsBitmap>&& bitmap)
|
||||
GIcon::GIcon(RefPtr<Gfx::Bitmap>&& bitmap)
|
||||
: GIcon()
|
||||
{
|
||||
if (bitmap) {
|
||||
|
@ -51,7 +51,7 @@ GIcon::GIcon(RefPtr<GraphicsBitmap>&& bitmap)
|
|||
}
|
||||
}
|
||||
|
||||
GIcon::GIcon(RefPtr<GraphicsBitmap>&& bitmap1, RefPtr<GraphicsBitmap>&& bitmap2)
|
||||
GIcon::GIcon(RefPtr<Gfx::Bitmap>&& bitmap1, RefPtr<Gfx::Bitmap>&& bitmap2)
|
||||
: GIcon(move(bitmap1))
|
||||
{
|
||||
if (bitmap2) {
|
||||
|
@ -61,14 +61,14 @@ GIcon::GIcon(RefPtr<GraphicsBitmap>&& bitmap1, RefPtr<GraphicsBitmap>&& bitmap2)
|
|||
}
|
||||
}
|
||||
|
||||
const GraphicsBitmap* GIconImpl::bitmap_for_size(int size) const
|
||||
const Gfx::Bitmap* GIconImpl::bitmap_for_size(int size) const
|
||||
{
|
||||
auto it = m_bitmaps.find(size);
|
||||
if (it != m_bitmaps.end())
|
||||
return it->value.ptr();
|
||||
|
||||
int best_diff_so_far = INT32_MAX;
|
||||
const GraphicsBitmap* best_fit = nullptr;
|
||||
const Gfx::Bitmap* best_fit = nullptr;
|
||||
for (auto& it : m_bitmaps) {
|
||||
int abs_diff = abs(it.key - size);
|
||||
if (abs_diff < best_diff_so_far) {
|
||||
|
@ -79,7 +79,7 @@ const GraphicsBitmap* GIconImpl::bitmap_for_size(int size) const
|
|||
return best_fit;
|
||||
}
|
||||
|
||||
void GIconImpl::set_bitmap_for_size(int size, RefPtr<GraphicsBitmap>&& bitmap)
|
||||
void GIconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap)
|
||||
{
|
||||
if (!bitmap) {
|
||||
m_bitmaps.remove(size);
|
||||
|
@ -90,7 +90,7 @@ void GIconImpl::set_bitmap_for_size(int size, RefPtr<GraphicsBitmap>&& bitmap)
|
|||
|
||||
GIcon GIcon::default_icon(const StringView& name)
|
||||
{
|
||||
auto bitmap16 = GraphicsBitmap::load_from_file(String::format("/res/icons/16x16/%s.png", String(name).characters()));
|
||||
auto bitmap32 = GraphicsBitmap::load_from_file(String::format("/res/icons/32x32/%s.png", String(name).characters()));
|
||||
auto bitmap16 = Gfx::Bitmap::load_from_file(String::format("/res/icons/16x16/%s.png", String(name).characters()));
|
||||
auto bitmap32 = Gfx::Bitmap::load_from_file(String::format("/res/icons/32x32/%s.png", String(name).characters()));
|
||||
return GIcon(move(bitmap16), move(bitmap32));
|
||||
}
|
||||
|
|
|
@ -34,19 +34,19 @@ public:
|
|||
static NonnullRefPtr<GIconImpl> create() { return adopt(*new GIconImpl); }
|
||||
~GIconImpl() {}
|
||||
|
||||
const GraphicsBitmap* bitmap_for_size(int) const;
|
||||
void set_bitmap_for_size(int, RefPtr<GraphicsBitmap>&&);
|
||||
const Gfx::Bitmap* bitmap_for_size(int) const;
|
||||
void set_bitmap_for_size(int, RefPtr<Gfx::Bitmap>&&);
|
||||
|
||||
private:
|
||||
GIconImpl() {}
|
||||
HashMap<int, RefPtr<GraphicsBitmap>> m_bitmaps;
|
||||
HashMap<int, RefPtr<Gfx::Bitmap>> m_bitmaps;
|
||||
};
|
||||
|
||||
class GIcon {
|
||||
public:
|
||||
GIcon();
|
||||
explicit GIcon(RefPtr<GraphicsBitmap>&&);
|
||||
explicit GIcon(RefPtr<GraphicsBitmap>&&, RefPtr<GraphicsBitmap>&&);
|
||||
explicit GIcon(RefPtr<Gfx::Bitmap>&&);
|
||||
explicit GIcon(RefPtr<Gfx::Bitmap>&&, RefPtr<Gfx::Bitmap>&&);
|
||||
explicit GIcon(const GIconImpl&);
|
||||
GIcon(const GIcon&);
|
||||
~GIcon() {}
|
||||
|
@ -60,8 +60,8 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
const GraphicsBitmap* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); }
|
||||
void set_bitmap_for_size(int size, RefPtr<GraphicsBitmap>&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); }
|
||||
const Gfx::Bitmap* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); }
|
||||
void set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); }
|
||||
|
||||
const GIconImpl& impl() const { return *m_impl; }
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ ItemView::ItemView(Widget* parent)
|
|||
{
|
||||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
set_frame_shape(Gfx::FrameShape::Container);
|
||||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
horizontal_scrollbar().set_visible(false);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ Rect ItemView::item_rect(int item_index) const
|
|||
};
|
||||
}
|
||||
|
||||
Vector<int> ItemView::items_intersecting_rect(const Rect& rect) const
|
||||
Vector<int> ItemView::items_intersecting_rect(const Gfx::Rect& rect) const
|
||||
{
|
||||
ASSERT(model());
|
||||
const auto& column_metadata = model()->column_metadata(model_column());
|
||||
|
@ -117,7 +117,7 @@ Vector<int> ItemView::items_intersecting_rect(const Rect& rect) const
|
|||
return item_indexes;
|
||||
}
|
||||
|
||||
ModelIndex ItemView::index_at_event_position(const Point& position) const
|
||||
ModelIndex ItemView::index_at_event_position(const Gfx::Point& position) const
|
||||
{
|
||||
ASSERT(model());
|
||||
// FIXME: Since all items are the same size, just compute the clicked item index
|
||||
|
@ -204,7 +204,7 @@ void ItemView::mousemove_event(MouseEvent& event)
|
|||
AbstractView::mousemove_event(event);
|
||||
}
|
||||
|
||||
void ItemView::get_item_rects(int item_index, const Font& font, const Variant& item_text, Rect& item_rect, Rect& icon_rect, Rect& text_rect) const
|
||||
void ItemView::get_item_rects(int item_index, const Gfx::Font& font, const Variant& item_text, Rect& item_rect, Rect& icon_rect, Rect& text_rect) const
|
||||
{
|
||||
item_rect = this->item_rect(item_index);
|
||||
icon_rect = { 0, 0, 32, 32 };
|
||||
|
@ -241,7 +241,7 @@ void ItemView::paint_event(PaintEvent& event)
|
|||
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
||||
auto column_metadata = model()->column_metadata(m_model_column);
|
||||
const Font& font = column_metadata.font ? *column_metadata.font : this->font();
|
||||
const Gfx::Font& font = column_metadata.font ? *column_metadata.font : this->font();
|
||||
|
||||
for (int item_index = 0; item_index < model()->row_count(); ++item_index) {
|
||||
auto model_index = model()->index(item_index, m_model_column);
|
||||
|
@ -272,7 +272,7 @@ void ItemView::paint_event(PaintEvent& event)
|
|||
else
|
||||
text_color = model()->data(model_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role()));
|
||||
painter.fill_rect(text_rect, background_color);
|
||||
painter.draw_text(text_rect, item_text.to_string(), font, TextAlignment::Center, text_color, TextElision::Right);
|
||||
painter.draw_text(text_rect, item_text.to_string(), font, Gfx::TextAlignment::Center, text_color, Gfx::TextElision::Right);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
int model_column() const { return m_model_column; }
|
||||
void set_model_column(int column) { m_model_column = column; }
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Point&) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
|
||||
private:
|
||||
explicit ItemView(Widget* parent);
|
||||
|
@ -66,20 +66,20 @@ private:
|
|||
|
||||
int item_count() const;
|
||||
Rect item_rect(int item_index) const;
|
||||
Vector<int> items_intersecting_rect(const Rect&) const;
|
||||
Vector<int> items_intersecting_rect(const Gfx::Rect&) const;
|
||||
void update_content_size();
|
||||
void get_item_rects(int item_index, const Font&, const Variant& item_text, Rect& item_rect, Rect& icon_rect, Rect& text_rect) const;
|
||||
void get_item_rects(int item_index, const Gfx::Font&, const Variant& item_text, Rect& item_rect, Rect& icon_rect, Rect& text_rect) const;
|
||||
|
||||
int m_horizontal_padding { 5 };
|
||||
int m_model_column { 0 };
|
||||
int m_visual_column_count { 0 };
|
||||
int m_visual_row_count { 0 };
|
||||
|
||||
Size m_effective_item_size { 80, 80 };
|
||||
Gfx::Size m_effective_item_size { 80, 80 };
|
||||
|
||||
bool m_rubber_banding { false };
|
||||
Point m_rubber_band_origin;
|
||||
Point m_rubber_band_current;
|
||||
Gfx::Point m_rubber_band_origin;
|
||||
Gfx::Point m_rubber_band_current;
|
||||
Vector<ModelIndex> m_rubber_band_remembered_selection;
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace GUI {
|
|||
class JsonArrayModel final : public Model {
|
||||
public:
|
||||
struct FieldSpec {
|
||||
FieldSpec(const String& a_column_name, TextAlignment a_text_alignment, Function<Variant(const JsonObject&)>&& a_massage_for_display, Function<Variant(const JsonObject&)>&& a_massage_for_sort = {}, Function<Variant(const JsonObject&)>&& a_massage_for_custom = {})
|
||||
FieldSpec(const String& a_column_name, Gfx::TextAlignment a_text_alignment, Function<Variant(const JsonObject&)>&& a_massage_for_display, Function<Variant(const JsonObject&)>&& a_massage_for_sort = {}, Function<Variant(const JsonObject&)>&& a_massage_for_custom = {})
|
||||
: column_name(a_column_name)
|
||||
, text_alignment(a_text_alignment)
|
||||
, massage_for_display(move(a_massage_for_display))
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
FieldSpec(const String& a_json_field_name, const String& a_column_name, TextAlignment a_text_alignment)
|
||||
FieldSpec(const String& a_json_field_name, const String& a_column_name, Gfx::TextAlignment a_text_alignment)
|
||||
: json_field_name(a_json_field_name)
|
||||
, column_name(a_column_name)
|
||||
, text_alignment(a_text_alignment)
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
String json_field_name;
|
||||
String column_name;
|
||||
TextAlignment text_alignment;
|
||||
Gfx::TextAlignment text_alignment;
|
||||
Function<Variant(const JsonObject&)> massage_for_display;
|
||||
Function<Variant(const JsonObject&)> massage_for_sort;
|
||||
Function<Variant(const JsonObject&)> massage_for_custom;
|
||||
|
|
|
@ -46,7 +46,7 @@ Label::~Label()
|
|||
{
|
||||
}
|
||||
|
||||
void Label::set_icon(GraphicsBitmap* icon)
|
||||
void Label::set_icon(Gfx::Bitmap* icon)
|
||||
{
|
||||
if (m_icon == icon)
|
||||
return;
|
||||
|
@ -87,10 +87,10 @@ void Label::paint_event(PaintEvent& event)
|
|||
text_rect.set_width(text_rect.width() - indent * 2);
|
||||
|
||||
if (is_enabled()) {
|
||||
painter.draw_text(text_rect, text(), m_text_alignment, palette().window_text(), TextElision::Right);
|
||||
painter.draw_text(text_rect, text(), m_text_alignment, palette().window_text(), Gfx::TextElision::Right);
|
||||
} else {
|
||||
painter.draw_text(text_rect.translated(1, 1), text(), font(), text_alignment(), Color::White, TextElision::Right);
|
||||
painter.draw_text(text_rect, text(), font(), text_alignment(), Color::from_rgb(0x808080), TextElision::Right);
|
||||
painter.draw_text(text_rect.translated(1, 1), text(), font(), text_alignment(), Color::White, Gfx::TextElision::Right);
|
||||
painter.draw_text(text_rect, text(), font(), text_alignment(), Color::from_rgb(0x808080), Gfx::TextElision::Right);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
#include <LibDraw/TextAlignment.h>
|
||||
#include <LibGUI/GFrame.h>
|
||||
|
||||
class GraphicsBitmap;
|
||||
namespace Gfx {
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -41,12 +43,12 @@ public:
|
|||
String text() const { return m_text; }
|
||||
void set_text(const StringView&);
|
||||
|
||||
void set_icon(GraphicsBitmap*);
|
||||
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
||||
GraphicsBitmap* icon() { return m_icon.ptr(); }
|
||||
void set_icon(Gfx::Bitmap*);
|
||||
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
||||
Gfx::Bitmap* icon() { return m_icon.ptr(); }
|
||||
|
||||
TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
void set_text_alignment(TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||
|
||||
bool should_stretch_icon() const { return m_should_stretch_icon; }
|
||||
void set_should_stretch_icon(bool b) { m_should_stretch_icon = b; }
|
||||
|
@ -61,8 +63,8 @@ protected:
|
|||
|
||||
private:
|
||||
String m_text;
|
||||
RefPtr<GraphicsBitmap> m_icon;
|
||||
TextAlignment m_text_alignment { TextAlignment::Center };
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||
bool m_should_stretch_icon { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ ListView::ListView(Widget* parent)
|
|||
{
|
||||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
set_frame_shape(Gfx::FrameShape::Container);
|
||||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ Rect ListView::content_rect(const ModelIndex& index) const
|
|||
return content_rect(index.row());
|
||||
}
|
||||
|
||||
ModelIndex ListView::index_at_event_position(const Point& point) const
|
||||
ModelIndex ListView::index_at_event_position(const Gfx::Point& point) const
|
||||
{
|
||||
ASSERT(model());
|
||||
|
||||
|
@ -99,7 +99,7 @@ ModelIndex ListView::index_at_event_position(const Point& point) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Point ListView::adjusted_position(const Point& position) const
|
||||
Point ListView::adjusted_position(const Gfx::Point& position) const
|
||||
{
|
||||
return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ public:
|
|||
|
||||
void scroll_into_view(const ModelIndex&, Orientation);
|
||||
|
||||
Point adjusted_position(const Point&) const;
|
||||
Point adjusted_position(const Gfx::Point&) const;
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Point&) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
virtual Rect content_rect(const ModelIndex&) const override;
|
||||
|
||||
int model_column() const { return m_model_column; }
|
||||
|
|
|
@ -84,7 +84,7 @@ void Menu::realize_if_needed()
|
|||
realize_menu();
|
||||
}
|
||||
|
||||
void Menu::popup(const Point& screen_position)
|
||||
void Menu::popup(const Gfx::Point& screen_position)
|
||||
{
|
||||
realize_if_needed();
|
||||
WindowServerConnection::the().post_message(WindowServer::PopupMenu(m_menu_id, screen_position));
|
||||
|
@ -123,12 +123,12 @@ int Menu::realize_menu()
|
|||
auto& action = *item.action();
|
||||
int icon_buffer_id = -1;
|
||||
if (action.icon()) {
|
||||
ASSERT(action.icon()->format() == GraphicsBitmap::Format::RGBA32);
|
||||
ASSERT(action.icon()->format() == Gfx::Bitmap::Format::RGBA32);
|
||||
ASSERT(action.icon()->size() == Size(16, 16));
|
||||
if (action.icon()->shared_buffer_id() == -1) {
|
||||
auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes());
|
||||
ASSERT(shared_buffer);
|
||||
auto shared_icon = GraphicsBitmap::create_with_shared_buffer(GraphicsBitmap::Format::RGBA32, *shared_buffer, action.icon()->size());
|
||||
auto shared_icon = Gfx::Bitmap::create_with_shared_buffer(Gfx::Bitmap::Format::RGBA32, *shared_buffer, action.icon()->size());
|
||||
memcpy(shared_buffer->data(), action.icon()->bits(0), action.icon()->size_in_bytes());
|
||||
shared_buffer->seal();
|
||||
shared_buffer->share_with(WindowServerConnection::the().server_pid());
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
#include <LibCore/CObject.h>
|
||||
#include <LibGUI/GMenuItem.h>
|
||||
|
||||
namespace Gfx {
|
||||
class Point;
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -54,7 +56,7 @@ public:
|
|||
void add_separator();
|
||||
void add_submenu(NonnullRefPtr<Menu>);
|
||||
|
||||
void popup(const Point& screen_position);
|
||||
void popup(const Gfx::Point& screen_position);
|
||||
void dismiss();
|
||||
|
||||
Function<void(unsigned)> on_item_activation;
|
||||
|
|
|
@ -52,15 +52,15 @@ MessageBox::~MessageBox()
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<GraphicsBitmap> MessageBox::icon() const
|
||||
RefPtr<Gfx::Bitmap> MessageBox::icon() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::Information:
|
||||
return GraphicsBitmap::load_from_file("/res/icons/32x32/msgbox-information.png");
|
||||
return Gfx::Bitmap::load_from_file("/res/icons/32x32/msgbox-information.png");
|
||||
case Type::Warning:
|
||||
return GraphicsBitmap::load_from_file("/res/icons/32x32/msgbox-warning.png");
|
||||
return Gfx::Bitmap::load_from_file("/res/icons/32x32/msgbox-warning.png");
|
||||
case Type::Error:
|
||||
return GraphicsBitmap::load_from_file("/res/icons/32x32/msgbox-error.png");
|
||||
return Gfx::Bitmap::load_from_file("/res/icons/32x32/msgbox-error.png");
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ private:
|
|||
bool should_include_ok_button() const;
|
||||
bool should_include_cancel_button() const;
|
||||
void build();
|
||||
RefPtr<GraphicsBitmap> icon() const;
|
||||
RefPtr<Gfx::Bitmap> icon() const;
|
||||
|
||||
String m_text;
|
||||
Type m_type { Type::None };
|
||||
|
|
|
@ -35,7 +35,9 @@
|
|||
#include <LibGUI/GModelIndex.h>
|
||||
#include <LibGUI/GVariant.h>
|
||||
|
||||
namespace Gfx {
|
||||
class Font;
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -51,8 +53,8 @@ class Model : public RefCounted<Model> {
|
|||
public:
|
||||
struct ColumnMetadata {
|
||||
int preferred_width { 0 };
|
||||
TextAlignment text_alignment { TextAlignment::CenterLeft };
|
||||
const Font* font { nullptr };
|
||||
Gfx::TextAlignment text_alignment { Gfx::TextAlignment::CenterLeft };
|
||||
const Gfx::Font* font { nullptr };
|
||||
enum class Sortable {
|
||||
False,
|
||||
True,
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include <LibGUI/GWindow.h>
|
||||
|
||||
namespace GUI {
|
||||
Painter::Painter(GraphicsBitmap& bitmap)
|
||||
: ::Painter(bitmap)
|
||||
Painter::Painter(Gfx::Bitmap& bitmap)
|
||||
: Gfx::Painter(bitmap)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ namespace GUI {
|
|||
|
||||
class Widget;
|
||||
|
||||
class Painter : public ::Painter {
|
||||
class Painter : public Gfx::Painter {
|
||||
public:
|
||||
explicit Painter(Widget&);
|
||||
explicit Painter(GraphicsBitmap&);
|
||||
explicit Painter(Gfx::Bitmap&);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace GUI {
|
|||
ProgressBar::ProgressBar(Widget* parent)
|
||||
: Frame(parent)
|
||||
{
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
set_frame_shape(Gfx::FrameShape::Container);
|
||||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ void ProgressBar::paint_event(PaintEvent& event)
|
|||
progress_text = builder.to_string();
|
||||
}
|
||||
|
||||
StylePainter::paint_progress_bar(painter, rect, palette(), m_min, m_max, m_value, progress_text);
|
||||
Gfx::StylePainter::paint_progress_bar(painter, rect, palette(), m_min, m_max, m_value, progress_text);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,11 +58,11 @@ void RadioButton::paint_event(PaintEvent& event)
|
|||
Rect circle_rect { { 2, 0 }, circle_size() };
|
||||
circle_rect.center_vertically_within(rect());
|
||||
|
||||
StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed());
|
||||
Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed());
|
||||
|
||||
Rect text_rect { circle_rect.right() + 4, 0, font().width(text()), font().glyph_height() };
|
||||
text_rect.center_vertically_within(rect());
|
||||
paint_text(painter, text_rect, font(), TextAlignment::TopLeft);
|
||||
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
|
|
|
@ -38,7 +38,7 @@ ResizeCorner::ResizeCorner(Widget* parent)
|
|||
set_background_role(ColorRole::Button);
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
set_preferred_size(16, 16);
|
||||
m_bitmap = GraphicsBitmap::load_from_file("/res/icons/resize-corner.png");
|
||||
m_bitmap = Gfx::Bitmap::load_from_file("/res/icons/resize-corner.png");
|
||||
ASSERT(m_bitmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ protected:
|
|||
virtual void leave_event(Core::Event&) override;
|
||||
|
||||
private:
|
||||
RefPtr<GraphicsBitmap> m_bitmap;
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -81,10 +81,10 @@ static const char* s_right_arrow_bitmap_data = {
|
|||
" "
|
||||
};
|
||||
|
||||
static CharacterBitmap* s_up_arrow_bitmap;
|
||||
static CharacterBitmap* s_down_arrow_bitmap;
|
||||
static CharacterBitmap* s_left_arrow_bitmap;
|
||||
static CharacterBitmap* s_right_arrow_bitmap;
|
||||
static Gfx::CharacterBitmap* s_up_arrow_bitmap;
|
||||
static Gfx::CharacterBitmap* s_down_arrow_bitmap;
|
||||
static Gfx::CharacterBitmap* s_left_arrow_bitmap;
|
||||
static Gfx::CharacterBitmap* s_right_arrow_bitmap;
|
||||
|
||||
ScrollBar::ScrollBar(Widget* parent)
|
||||
: ScrollBar(Orientation::Vertical, parent)
|
||||
|
@ -97,13 +97,13 @@ ScrollBar::ScrollBar(Orientation orientation, Widget* parent)
|
|||
{
|
||||
m_automatic_scrolling_timer = Core::Timer::construct(this);
|
||||
if (!s_up_arrow_bitmap)
|
||||
s_up_arrow_bitmap = &CharacterBitmap::create_from_ascii(s_up_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
s_up_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_up_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
if (!s_down_arrow_bitmap)
|
||||
s_down_arrow_bitmap = &CharacterBitmap::create_from_ascii(s_down_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
s_down_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_down_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
if (!s_left_arrow_bitmap)
|
||||
s_left_arrow_bitmap = &CharacterBitmap::create_from_ascii(s_left_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
s_left_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_left_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
if (!s_right_arrow_bitmap)
|
||||
s_right_arrow_bitmap = &CharacterBitmap::create_from_ascii(s_right_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
s_right_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_right_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
|
||||
if (m_orientation == Orientation::Vertical) {
|
||||
set_preferred_size(15, 0);
|
||||
|
@ -228,8 +228,8 @@ void ScrollBar::paint_event(PaintEvent& event)
|
|||
|
||||
painter.fill_rect(rect(), palette().button().lightened());
|
||||
|
||||
StylePainter::paint_button(painter, decrement_button_rect(), palette(), ButtonStyle::Normal, false, m_hovered_component == Component::DecrementButton);
|
||||
StylePainter::paint_button(painter, increment_button_rect(), palette(), ButtonStyle::Normal, false, m_hovered_component == Component::IncrementButton);
|
||||
Gfx::StylePainter::paint_button(painter, decrement_button_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_hovered_component == Component::DecrementButton);
|
||||
Gfx::StylePainter::paint_button(painter, increment_button_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_hovered_component == Component::IncrementButton);
|
||||
|
||||
if (length(orientation()) > default_button_size()) {
|
||||
painter.draw_bitmap(decrement_button_rect().location().translated(3, 3), orientation() == Orientation::Vertical ? *s_up_arrow_bitmap : *s_left_arrow_bitmap, has_scrubber() ? palette().button_text() : palette().threed_shadow1());
|
||||
|
@ -237,7 +237,7 @@ void ScrollBar::paint_event(PaintEvent& event)
|
|||
}
|
||||
|
||||
if (has_scrubber())
|
||||
StylePainter::paint_button(painter, scrubber_rect(), palette(), ButtonStyle::Normal, false, m_hovered_component == Component::Scrubber || m_scrubber_in_use);
|
||||
Gfx::StylePainter::paint_button(painter, scrubber_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_hovered_component == Component::Scrubber || m_scrubber_in_use);
|
||||
}
|
||||
|
||||
void ScrollBar::on_automatic_scrolling_timer_fired()
|
||||
|
|
|
@ -99,7 +99,7 @@ private:
|
|||
|
||||
bool m_scrubbing { false };
|
||||
int m_scrub_start_value { 0 };
|
||||
Point m_scrub_origin;
|
||||
Gfx::Point m_scrub_origin;
|
||||
|
||||
Orientation m_orientation { Orientation::Vertical };
|
||||
Component m_hovered_component { Component::Invalid };
|
||||
|
|
|
@ -118,7 +118,7 @@ void ScrollableWidget::update_scrollbar_ranges()
|
|||
m_vertical_scrollbar->set_big_step(visible_content_rect().height() - m_vertical_scrollbar->step());
|
||||
}
|
||||
|
||||
void ScrollableWidget::set_content_size(const Size& size)
|
||||
void ScrollableWidget::set_content_size(const Gfx::Size& size)
|
||||
{
|
||||
if (m_content_size == size)
|
||||
return;
|
||||
|
@ -126,7 +126,7 @@ void ScrollableWidget::set_content_size(const Size& size)
|
|||
update_scrollbar_ranges();
|
||||
}
|
||||
|
||||
void ScrollableWidget::set_size_occupied_by_fixed_elements(const Size& size)
|
||||
void ScrollableWidget::set_size_occupied_by_fixed_elements(const Gfx::Size& size)
|
||||
{
|
||||
if (m_size_occupied_by_fixed_elements == size)
|
||||
return;
|
||||
|
@ -154,14 +154,14 @@ Rect ScrollableWidget::visible_content_rect() const
|
|||
};
|
||||
}
|
||||
|
||||
void ScrollableWidget::scroll_into_view(const Rect& rect, Orientation orientation)
|
||||
void ScrollableWidget::scroll_into_view(const Gfx::Rect& rect, Orientation orientation)
|
||||
{
|
||||
if (orientation == Orientation::Vertical)
|
||||
return scroll_into_view(rect, false, true);
|
||||
return scroll_into_view(rect, true, false);
|
||||
}
|
||||
|
||||
void ScrollableWidget::scroll_into_view(const Rect& rect, bool scroll_horizontally, bool scroll_vertically)
|
||||
void ScrollableWidget::scroll_into_view(const Gfx::Rect& rect, bool scroll_horizontally, bool scroll_vertically)
|
||||
{
|
||||
auto visible_content_rect = this->visible_content_rect();
|
||||
if (visible_content_rect.contains(rect))
|
||||
|
@ -209,7 +209,7 @@ Rect ScrollableWidget::widget_inner_rect() const
|
|||
return rect;
|
||||
}
|
||||
|
||||
Point ScrollableWidget::to_content_position(const Point& widget_position) const
|
||||
Point ScrollableWidget::to_content_position(const Gfx::Point& widget_position) const
|
||||
{
|
||||
auto content_position = widget_position;
|
||||
content_position.move_by(horizontal_scrollbar().value(), vertical_scrollbar().value());
|
||||
|
@ -217,7 +217,7 @@ Point ScrollableWidget::to_content_position(const Point& widget_position) const
|
|||
return content_position;
|
||||
}
|
||||
|
||||
Point ScrollableWidget::to_widget_position(const Point& content_position) const
|
||||
Point ScrollableWidget::to_widget_position(const Gfx::Point& content_position) const
|
||||
{
|
||||
auto widget_position = content_position;
|
||||
widget_position.move_by(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
|
||||
Rect widget_inner_rect() const;
|
||||
|
||||
void scroll_into_view(const Rect&, Orientation);
|
||||
void scroll_into_view(const Rect&, bool scroll_horizontally, bool scroll_vertically);
|
||||
void scroll_into_view(const Gfx::Rect&, Orientation);
|
||||
void scroll_into_view(const Gfx::Rect&, bool scroll_horizontally, bool scroll_vertically);
|
||||
|
||||
void set_scrollbars_enabled(bool);
|
||||
bool is_scrollbars_enabled() const { return m_scrollbars_enabled; }
|
||||
|
@ -69,8 +69,8 @@ public:
|
|||
void set_should_hide_unnecessary_scrollbars(bool b) { m_should_hide_unnecessary_scrollbars = b; }
|
||||
bool should_hide_unnecessary_scrollbars() const { return m_should_hide_unnecessary_scrollbars; }
|
||||
|
||||
Point to_content_position(const Point& widget_position) const;
|
||||
Point to_widget_position(const Point& content_position) const;
|
||||
Point to_content_position(const Gfx::Point& widget_position) const;
|
||||
Point to_widget_position(const Gfx::Point& content_position) const;
|
||||
|
||||
protected:
|
||||
explicit ScrollableWidget(Widget* parent);
|
||||
|
@ -78,8 +78,8 @@ protected:
|
|||
virtual void resize_event(ResizeEvent&) override;
|
||||
virtual void mousewheel_event(MouseEvent&) override;
|
||||
virtual void did_scroll() {}
|
||||
void set_content_size(const Size&);
|
||||
void set_size_occupied_by_fixed_elements(const Size&);
|
||||
void set_content_size(const Gfx::Size&);
|
||||
void set_size_occupied_by_fixed_elements(const Gfx::Size&);
|
||||
|
||||
private:
|
||||
void update_scrollbar_ranges();
|
||||
|
@ -87,8 +87,8 @@ private:
|
|||
RefPtr<ScrollBar> m_vertical_scrollbar;
|
||||
RefPtr<ScrollBar> m_horizontal_scrollbar;
|
||||
RefPtr<Widget> m_corner_widget;
|
||||
Size m_content_size;
|
||||
Size m_size_occupied_by_fixed_elements;
|
||||
Gfx::Size m_content_size;
|
||||
Gfx::Size m_size_occupied_by_fixed_elements;
|
||||
bool m_scrollbars_enabled { true };
|
||||
bool m_should_hide_unnecessary_scrollbars { false };
|
||||
};
|
||||
|
|
|
@ -83,8 +83,8 @@ void Slider::paint_event(PaintEvent& event)
|
|||
track_rect.center_horizontally_within(inner_rect());
|
||||
}
|
||||
|
||||
StylePainter::paint_frame(painter, track_rect, palette(), FrameShape::Panel, FrameShadow::Sunken, 1);
|
||||
StylePainter::paint_button(painter, knob_rect(), palette(), ButtonStyle::Normal, false, m_knob_hovered);
|
||||
Gfx::StylePainter::paint_frame(painter, track_rect, palette(), Gfx::FrameShape::Panel, Gfx::FrameShadow::Sunken, 1);
|
||||
Gfx::StylePainter::paint_button(painter, knob_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_knob_hovered);
|
||||
}
|
||||
|
||||
Rect Slider::knob_rect() const
|
||||
|
|
|
@ -91,7 +91,7 @@ private:
|
|||
bool m_knob_hovered { false };
|
||||
bool m_dragging { false };
|
||||
int m_drag_origin_value { 0 };
|
||||
Point m_drag_origin;
|
||||
Gfx::Point m_drag_origin;
|
||||
KnobSizeMode m_knob_size_mode { KnobSizeMode::Fixed };
|
||||
Orientation m_orientation { Orientation::Horizontal };
|
||||
};
|
||||
|
|
|
@ -47,11 +47,11 @@ protected:
|
|||
private:
|
||||
Orientation m_orientation;
|
||||
bool m_resizing { false };
|
||||
Point m_resize_origin;
|
||||
Gfx::Point m_resize_origin;
|
||||
WeakPtr<Widget> m_first_resizee;
|
||||
WeakPtr<Widget> m_second_resizee;
|
||||
Size m_first_resizee_start_size;
|
||||
Size m_second_resizee_start_size;
|
||||
Gfx::Size m_first_resizee_start_size;
|
||||
Gfx::Size m_second_resizee_start_size;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -63,10 +63,10 @@ StatusBar::~StatusBar()
|
|||
NonnullRefPtr<Label> StatusBar::create_label()
|
||||
{
|
||||
auto label = Label::construct(this);
|
||||
label->set_frame_shadow(FrameShadow::Sunken);
|
||||
label->set_frame_shape(FrameShape::Panel);
|
||||
label->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
label->set_frame_shape(Gfx::FrameShape::Panel);
|
||||
label->set_frame_thickness(1);
|
||||
label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
return label;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ void StatusBar::paint_event(PaintEvent& event)
|
|||
{
|
||||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
StylePainter::paint_surface(painter, rect(), palette(), !spans_entire_window_horizontally());
|
||||
Gfx::StylePainter::paint_surface(painter, rect(), palette(), !spans_entire_window_horizontally());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ void TabWidget::resize_event(ResizeEvent& event)
|
|||
m_active_widget->set_relative_rect(child_rect_for_size(event.size()));
|
||||
}
|
||||
|
||||
Rect TabWidget::child_rect_for_size(const Size& size) const
|
||||
Rect TabWidget::child_rect_for_size(const Gfx::Size& size) const
|
||||
{
|
||||
Rect rect;
|
||||
switch (m_tab_position) {
|
||||
|
@ -143,15 +143,15 @@ void TabWidget::paint_event(PaintEvent& event)
|
|||
padding_rect.shrink(2, 2);
|
||||
}
|
||||
|
||||
StylePainter::paint_frame(painter, container_rect, palette(), FrameShape::Container, FrameShadow::Raised, 2);
|
||||
Gfx::StylePainter::paint_frame(painter, container_rect, palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Raised, 2);
|
||||
|
||||
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||
if (m_tabs[i].widget == m_active_widget)
|
||||
continue;
|
||||
bool hovered = i == m_hovered_tab_index;
|
||||
auto button_rect = this->button_rect(i);
|
||||
StylePainter::paint_tab_button(painter, button_rect, palette(), false, hovered, m_tabs[i].widget->is_enabled());
|
||||
painter.draw_text(button_rect.translated(0, 1), m_tabs[i].title, TextAlignment::Center, palette().button_text());
|
||||
Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), false, hovered, m_tabs[i].widget->is_enabled());
|
||||
painter.draw_text(button_rect.translated(0, 1), m_tabs[i].title, Gfx::TextAlignment::Center, palette().button_text());
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||
|
@ -159,8 +159,8 @@ void TabWidget::paint_event(PaintEvent& event)
|
|||
continue;
|
||||
bool hovered = i == m_hovered_tab_index;
|
||||
auto button_rect = this->button_rect(i);
|
||||
StylePainter::paint_tab_button(painter, button_rect, palette(), true, hovered, m_tabs[i].widget->is_enabled());
|
||||
painter.draw_text(button_rect.translated(0, 1), m_tabs[i].title, TextAlignment::Center, palette().button_text());
|
||||
Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), true, hovered, m_tabs[i].widget->is_enabled());
|
||||
painter.draw_text(button_rect.translated(0, 1), m_tabs[i].title, Gfx::TextAlignment::Center, palette().button_text());
|
||||
painter.draw_line(button_rect.bottom_left().translated(1, 1), button_rect.bottom_right().translated(-1, 1), palette().button());
|
||||
break;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ Rect TabWidget::button_rect(int index) const
|
|||
return rect;
|
||||
}
|
||||
|
||||
int TabWidget::TabData::width(const Font& font) const
|
||||
int TabWidget::TabData::width(const Gfx::Font& font) const
|
||||
{
|
||||
return 16 + font.width(title);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
|||
virtual void leave_event(Core::Event&) override;
|
||||
|
||||
private:
|
||||
Rect child_rect_for_size(const Size&) const;
|
||||
Rect child_rect_for_size(const Gfx::Size&) const;
|
||||
Rect button_rect(int index) const;
|
||||
Rect bar_rect() const;
|
||||
Rect container_rect() const;
|
||||
|
@ -73,8 +73,8 @@ private:
|
|||
RefPtr<Widget> m_active_widget;
|
||||
|
||||
struct TabData {
|
||||
Rect rect(const Font&) const;
|
||||
int width(const Font&) const;
|
||||
Rect rect(const Gfx::Font&) const;
|
||||
int width(const Gfx::Font&) const;
|
||||
String title;
|
||||
Widget* widget { nullptr };
|
||||
};
|
||||
|
|
|
@ -104,7 +104,7 @@ void TableView::paint_event(PaintEvent& event)
|
|||
continue;
|
||||
auto column_metadata = model()->column_metadata(column_index);
|
||||
int column_width = this->column_width(column_index);
|
||||
const Font& font = column_metadata.font ? *column_metadata.font : this->font();
|
||||
const Gfx::Font& font = column_metadata.font ? *column_metadata.font : this->font();
|
||||
bool is_key_column = model()->key_column() == column_index;
|
||||
Rect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height());
|
||||
if (is_key_column) {
|
||||
|
@ -128,7 +128,7 @@ void TableView::paint_event(PaintEvent& event)
|
|||
text_color = palette().selection_text();
|
||||
else
|
||||
text_color = model()->data(cell_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role()));
|
||||
painter.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, TextElision::Right);
|
||||
painter.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, Gfx::TextElision::Right);
|
||||
}
|
||||
}
|
||||
x_offset += column_width + horizontal_padding() * 2;
|
||||
|
|
|
@ -49,7 +49,7 @@ struct TextDocumentSpan {
|
|||
Color color;
|
||||
Optional<Color> background_color;
|
||||
bool is_skippable { false };
|
||||
const Font* font { nullptr };
|
||||
const Gfx::Font* font { nullptr };
|
||||
void* data { nullptr };
|
||||
};
|
||||
|
||||
|
|
|
@ -58,8 +58,8 @@ TextEditor::TextEditor(Type type, Widget* parent)
|
|||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
set_document(TextDocument::create());
|
||||
set_frame_shape(FrameShape::Container);
|
||||
set_frame_shadow(FrameShadow::Sunken);
|
||||
set_frame_shape(Gfx::FrameShape::Container);
|
||||
set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
set_frame_thickness(2);
|
||||
set_scrollbars_enabled(is_multi_line());
|
||||
set_font(GFontDatabase::the().get_by_name("Csilla Thin"));
|
||||
|
@ -86,7 +86,7 @@ void TextEditor::create_actions()
|
|||
m_paste_action = CommonActions::make_paste_action([&](auto&) { paste(); }, this);
|
||||
m_delete_action = CommonActions::make_delete_action([&](auto&) { do_delete(); }, this);
|
||||
m_go_to_line_action = Action::create(
|
||||
"Go to line...", { Mod_Ctrl, Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](auto&) {
|
||||
"Go to line...", { Mod_Ctrl, Key_L }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](auto&) {
|
||||
auto input_box = InputBox::construct("Line:", "Go to line", window());
|
||||
auto result = input_box->exec();
|
||||
if (result == InputBox::ExecOK) {
|
||||
|
@ -134,7 +134,7 @@ void TextEditor::update_content_size()
|
|||
set_size_occupied_by_fixed_elements({ ruler_width(), 0 });
|
||||
}
|
||||
|
||||
TextPosition TextEditor::text_position_at(const Point& a_position) const
|
||||
TextPosition TextEditor::text_position_at(const Gfx::Point& a_position) const
|
||||
{
|
||||
auto position = a_position;
|
||||
position.move_by(horizontal_scrollbar().value(), vertical_scrollbar().value());
|
||||
|
@ -161,10 +161,10 @@ TextPosition TextEditor::text_position_at(const Point& a_position) const
|
|||
|
||||
size_t column_index;
|
||||
switch (m_text_alignment) {
|
||||
case TextAlignment::CenterLeft:
|
||||
case Gfx::TextAlignment::CenterLeft:
|
||||
column_index = (position.x() + glyph_width() / 2) / glyph_width();
|
||||
if (is_line_wrapping_enabled()) {
|
||||
for_each_visual_line(line_index, [&](const Rect& rect, const StringView&, size_t start_of_line) {
|
||||
for_each_visual_line(line_index, [&](const Gfx::Rect& rect, const StringView&, size_t start_of_line) {
|
||||
if (rect.contains_vertically(position.y())) {
|
||||
column_index += start_of_line;
|
||||
return IterationDecision::Break;
|
||||
|
@ -173,7 +173,7 @@ TextPosition TextEditor::text_position_at(const Point& a_position) const
|
|||
});
|
||||
}
|
||||
break;
|
||||
case TextAlignment::CenterRight:
|
||||
case Gfx::TextAlignment::CenterRight:
|
||||
// FIXME: Support right-aligned line wrapping, I guess.
|
||||
ASSERT(!is_line_wrapping_enabled());
|
||||
column_index = (position.x() - content_x_for_position({ line_index, 0 }) + glyph_width() / 2) / glyph_width();
|
||||
|
@ -376,8 +376,8 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
painter.draw_text(
|
||||
ruler_line_rect.shrunken(2, 0).translated(0, m_line_spacing / 2),
|
||||
String::number(i + 1),
|
||||
is_current_line ? Font::default_bold_font() : font(),
|
||||
TextAlignment::TopRight,
|
||||
is_current_line ? Gfx::Font::default_bold_font() : font(),
|
||||
Gfx::TextAlignment::TopRight,
|
||||
is_current_line ? widget_background_color.darkened(0.2f) : widget_background_color.darkened(0.4f));
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
size_t selection_end_column_within_line = selection.end().line() == line_index ? selection.end().column() : line.length();
|
||||
|
||||
size_t visual_line_index = 0;
|
||||
for_each_visual_line(line_index, [&](const Rect& visual_line_rect, const StringView& visual_line_text, size_t start_of_visual_line) {
|
||||
for_each_visual_line(line_index, [&](const Gfx::Rect& visual_line_rect, const StringView& visual_line_text, size_t start_of_visual_line) {
|
||||
if (is_multi_line() && line_index == m_cursor.line())
|
||||
painter.fill_rect(visual_line_rect, widget_background_color.darkened(0.9f));
|
||||
#ifdef DEBUG_GTEXTEDITOR
|
||||
|
@ -425,7 +425,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
int advance = font().glyph_width(' ') + font().glyph_spacing();
|
||||
Rect character_rect = { visual_line_rect.location(), { font().glyph_width(' '), line_height() } };
|
||||
for (size_t i = 0; i < visual_line_text.length(); ++i) {
|
||||
const Font* font = &this->font();
|
||||
const Gfx::Font* font = &this->font();
|
||||
Color color;
|
||||
Optional<Color> background_color;
|
||||
TextPosition physical_position(line_index, start_of_visual_line + i);
|
||||
|
@ -479,7 +479,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
end_of_selection_within_visual_line - start_of_selection_within_visual_line
|
||||
};
|
||||
|
||||
painter.draw_text(selection_rect, visual_selected_text, TextAlignment::CenterLeft, palette().selection_text());
|
||||
painter.draw_text(selection_rect, visual_selected_text, Gfx::TextAlignment::CenterLeft, palette().selection_text());
|
||||
}
|
||||
}
|
||||
++visual_line_index;
|
||||
|
@ -894,8 +894,8 @@ int TextEditor::content_x_for_position(const TextPosition& position) const
|
|||
auto& line = this->line(position.line());
|
||||
int x_offset = -1;
|
||||
switch (m_text_alignment) {
|
||||
case TextAlignment::CenterLeft:
|
||||
for_each_visual_line(position.line(), [&](const Rect&, const StringView& view, size_t start_of_visual_line) {
|
||||
case Gfx::TextAlignment::CenterLeft:
|
||||
for_each_visual_line(position.line(), [&](const Gfx::Rect&, const StringView& view, size_t start_of_visual_line) {
|
||||
if (position.column() >= start_of_visual_line && ((position.column() - start_of_visual_line) <= view.length())) {
|
||||
x_offset = (position.column() - start_of_visual_line) * glyph_width();
|
||||
return IterationDecision::Break;
|
||||
|
@ -903,7 +903,7 @@ int TextEditor::content_x_for_position(const TextPosition& position) const
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
return m_horizontal_content_padding + x_offset;
|
||||
case TextAlignment::CenterRight:
|
||||
case Gfx::TextAlignment::CenterRight:
|
||||
// FIXME
|
||||
ASSERT(!is_line_wrapping_enabled());
|
||||
return content_width() - m_horizontal_content_padding - (line.length() * glyph_width()) + (position.column() * glyph_width());
|
||||
|
@ -928,7 +928,7 @@ Rect TextEditor::content_rect_for_position(const TextPosition& position) const
|
|||
}
|
||||
|
||||
Rect rect;
|
||||
for_each_visual_line(position.line(), [&](const Rect& visual_line_rect, const StringView& view, size_t start_of_visual_line) {
|
||||
for_each_visual_line(position.line(), [&](const Gfx::Rect& visual_line_rect, const StringView& view, size_t start_of_visual_line) {
|
||||
if (position.column() >= start_of_visual_line && ((position.column() - start_of_visual_line) <= view.length())) {
|
||||
// NOTE: We have to subtract the horizontal padding here since it's part of the visual line rect
|
||||
// *and* included in what we get from content_x_for_position().
|
||||
|
@ -1250,7 +1250,7 @@ void TextEditor::context_menu_event(ContextMenuEvent& event)
|
|||
m_context_menu->popup(event.screen_position());
|
||||
}
|
||||
|
||||
void TextEditor::set_text_alignment(TextAlignment alignment)
|
||||
void TextEditor::set_text_alignment(Gfx::TextAlignment alignment)
|
||||
{
|
||||
if (m_text_alignment == alignment)
|
||||
return;
|
||||
|
@ -1309,7 +1309,7 @@ void TextEditor::ensure_cursor_is_valid()
|
|||
size_t TextEditor::visual_line_containing(size_t line_index, size_t column) const
|
||||
{
|
||||
size_t visual_line_index = 0;
|
||||
for_each_visual_line(line_index, [&](const Rect&, const StringView& view, size_t start_of_visual_line) {
|
||||
for_each_visual_line(line_index, [&](const Gfx::Rect&, const StringView& view, size_t start_of_visual_line) {
|
||||
if (column >= start_of_visual_line && ((column - start_of_visual_line) < view.length()))
|
||||
return IterationDecision::Break;
|
||||
++visual_line_index;
|
||||
|
|
|
@ -70,8 +70,8 @@ public:
|
|||
bool is_line_wrapping_enabled() const { return m_line_wrapping_enabled; }
|
||||
void set_line_wrapping_enabled(bool);
|
||||
|
||||
TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
void set_text_alignment(TextAlignment);
|
||||
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
void set_text_alignment(Gfx::TextAlignment);
|
||||
|
||||
Type type() const { return m_type; }
|
||||
bool is_single_line() const { return m_type == SingleLine; }
|
||||
|
@ -154,7 +154,7 @@ protected:
|
|||
virtual void resize_event(ResizeEvent&) override;
|
||||
virtual void cursor_did_change() {}
|
||||
|
||||
TextPosition text_position_at(const Point&) const;
|
||||
TextPosition text_position_at(const Gfx::Point&) const;
|
||||
|
||||
private:
|
||||
friend class TextDocumentLine;
|
||||
|
@ -214,7 +214,7 @@ private:
|
|||
Type m_type { MultiLine };
|
||||
|
||||
TextPosition m_cursor;
|
||||
TextAlignment m_text_alignment { TextAlignment::CenterLeft };
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::CenterLeft };
|
||||
bool m_cursor_state { true };
|
||||
bool m_in_drag_select { false };
|
||||
bool m_ruler_visible { false };
|
||||
|
|
|
@ -75,7 +75,7 @@ void ToolBar::add_action(Action& action)
|
|||
else
|
||||
button->set_text(item->action->text());
|
||||
|
||||
button->set_button_style(ButtonStyle::CoolBar);
|
||||
button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
ASSERT(button->size_policy(Orientation::Horizontal) == SizePolicy::Fixed);
|
||||
ASSERT(button->size_policy(Orientation::Vertical) == SizePolicy::Fixed);
|
||||
|
@ -119,7 +119,7 @@ void ToolBar::paint_event(PaintEvent& event)
|
|||
painter.add_clip_rect(event.rect());
|
||||
|
||||
if (m_has_frame)
|
||||
StylePainter::paint_surface(painter, rect(), palette(), x() != 0, y() != 0);
|
||||
Gfx::StylePainter::paint_surface(painter, rect(), palette(), x() != 0, y() != 0);
|
||||
else
|
||||
painter.fill_rect(event.rect(), palette().button());
|
||||
}
|
||||
|
|
|
@ -56,22 +56,22 @@ TreeView::TreeView(Widget* parent)
|
|||
set_foreground_role(ColorRole::BaseText);
|
||||
set_size_columns_to_fit_content(true);
|
||||
set_headers_visible(false);
|
||||
m_expand_bitmap = GraphicsBitmap::load_from_file("/res/icons/treeview-expand.png");
|
||||
m_collapse_bitmap = GraphicsBitmap::load_from_file("/res/icons/treeview-collapse.png");
|
||||
m_expand_bitmap = Gfx::Bitmap::load_from_file("/res/icons/treeview-expand.png");
|
||||
m_collapse_bitmap = Gfx::Bitmap::load_from_file("/res/icons/treeview-collapse.png");
|
||||
}
|
||||
|
||||
TreeView::~TreeView()
|
||||
{
|
||||
}
|
||||
|
||||
ModelIndex TreeView::index_at_event_position(const Point& a_position, bool& is_toggle) const
|
||||
ModelIndex TreeView::index_at_event_position(const Gfx::Point& a_position, bool& is_toggle) const
|
||||
{
|
||||
auto position = a_position.translated(0, -header_height()).translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
|
||||
is_toggle = false;
|
||||
if (!model())
|
||||
return {};
|
||||
ModelIndex result;
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Rect& rect, const Rect& toggle_rect, int) {
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect& toggle_rect, int) {
|
||||
if (toggle_rect.contains(position)) {
|
||||
result = index;
|
||||
is_toggle = true;
|
||||
|
@ -198,7 +198,7 @@ void TreeView::paint_event(PaintEvent& event)
|
|||
|
||||
int painted_row_index = 0;
|
||||
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Rect& a_rect, const Rect& a_toggle_rect, int indent_level) {
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& a_rect, const Gfx::Rect& a_toggle_rect, int indent_level) {
|
||||
if (!a_rect.intersects_vertically(visible_content_rect))
|
||||
return IterationDecision::Continue;
|
||||
|
||||
|
@ -260,7 +260,7 @@ void TreeView::paint_event(PaintEvent& event)
|
|||
} else {
|
||||
if (!is_selected_row)
|
||||
text_color = model.data(cell_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role()));
|
||||
painter.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, TextElision::Right);
|
||||
painter.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, Gfx::TextElision::Right);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -276,7 +276,7 @@ void TreeView::paint_event(PaintEvent& event)
|
|||
rect.width() - icon_size() - icon_spacing(), rect.height()
|
||||
};
|
||||
auto node_text = model.data(index, Model::Role::Display).to_string();
|
||||
painter.draw_text(text_rect, node_text, TextAlignment::Center, text_color);
|
||||
painter.draw_text(text_rect, node_text, Gfx::TextAlignment::Center, text_color);
|
||||
auto index_at_indent = index;
|
||||
for (int i = indent_level; i > 0; --i) {
|
||||
auto parent_of_index_at_indent = index_at_indent.parent();
|
||||
|
@ -320,7 +320,7 @@ void TreeView::scroll_into_view(const ModelIndex& a_index, Orientation orientati
|
|||
if (!a_index.is_valid())
|
||||
return;
|
||||
Rect found_rect;
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Rect& rect, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect&, int) {
|
||||
if (index == a_index) {
|
||||
found_rect = rect;
|
||||
return IterationDecision::Break;
|
||||
|
@ -375,7 +375,7 @@ void TreeView::keydown_event(KeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Up) {
|
||||
ModelIndex previous_index;
|
||||
ModelIndex found_index;
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Rect&, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect&, const Gfx::Rect&, int) {
|
||||
if (index == cursor_index) {
|
||||
found_index = previous_index;
|
||||
return IterationDecision::Break;
|
||||
|
@ -392,7 +392,7 @@ void TreeView::keydown_event(KeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Down) {
|
||||
ModelIndex previous_index;
|
||||
ModelIndex found_index;
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Rect&, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect&, const Gfx::Rect&, int) {
|
||||
if (previous_index == cursor_index) {
|
||||
found_index = index;
|
||||
return IterationDecision::Break;
|
||||
|
@ -442,7 +442,7 @@ void TreeView::keydown_event(KeyEvent& event)
|
|||
int TreeView::item_count() const
|
||||
{
|
||||
int count = 0;
|
||||
traverse_in_paint_order([&](const ModelIndex&, const Rect&, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const ModelIndex&, const Gfx::Rect&, const Gfx::Rect&, int) {
|
||||
++count;
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
@ -491,7 +491,7 @@ void TreeView::update_column_sizes()
|
|||
|
||||
int tree_column_header_width = header_font().width(model.column_name(tree_column));
|
||||
int tree_column_width = tree_column_header_width;
|
||||
traverse_in_paint_order([&](const ModelIndex&, const Rect& rect, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const ModelIndex&, const Gfx::Rect& rect, const Gfx::Rect&, int) {
|
||||
tree_column_width = max(rect.right() - tree_column_x_offset, tree_column_width);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ protected:
|
|||
virtual void did_update_model() override;
|
||||
|
||||
private:
|
||||
virtual ModelIndex index_at_event_position(const Point&, bool& is_toggle) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&, bool& is_toggle) const override;
|
||||
|
||||
int item_height() const { return 16; }
|
||||
int max_item_width() const { return frame_inner_rect().width(); }
|
||||
|
@ -70,8 +70,8 @@ private:
|
|||
|
||||
mutable HashMap<void*, NonnullOwnPtr<MetadataForIndex>> m_view_metadata;
|
||||
|
||||
RefPtr<GraphicsBitmap> m_expand_bitmap;
|
||||
RefPtr<GraphicsBitmap> m_collapse_bitmap;
|
||||
RefPtr<Gfx::Bitmap> m_expand_bitmap;
|
||||
RefPtr<Gfx::Bitmap> m_collapse_bitmap;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -183,10 +183,10 @@ Variant::Variant(const JsonValue& value)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
Variant::Variant(const GraphicsBitmap& value)
|
||||
Variant::Variant(const Gfx::Bitmap& value)
|
||||
: m_type(Type::Bitmap)
|
||||
{
|
||||
m_value.as_bitmap = const_cast<GraphicsBitmap*>(&value);
|
||||
m_value.as_bitmap = const_cast<Gfx::Bitmap*>(&value);
|
||||
AK::ref_if_not_null(m_value.as_bitmap);
|
||||
}
|
||||
|
||||
|
@ -197,10 +197,10 @@ Variant::Variant(const GIcon& value)
|
|||
AK::ref_if_not_null(m_value.as_icon);
|
||||
}
|
||||
|
||||
Variant::Variant(const Font& value)
|
||||
Variant::Variant(const Gfx::Font& value)
|
||||
: m_type(Type::Font)
|
||||
{
|
||||
m_value.as_font = &const_cast<Font&>(value);
|
||||
m_value.as_font = &const_cast<Gfx::Font&>(value);
|
||||
AK::ref_if_not_null(m_value.as_font);
|
||||
}
|
||||
|
||||
|
@ -210,19 +210,19 @@ Variant::Variant(Color color)
|
|||
m_value.as_color = color.value();
|
||||
}
|
||||
|
||||
Variant::Variant(const Point& point)
|
||||
Variant::Variant(const Gfx::Point& point)
|
||||
: m_type(Type::Point)
|
||||
{
|
||||
m_value.as_point = { point.x(), point.y() };
|
||||
}
|
||||
|
||||
Variant::Variant(const Size& size)
|
||||
Variant::Variant(const Gfx::Size& size)
|
||||
: m_type(Type::Size)
|
||||
{
|
||||
m_value.as_size = { size.width(), size.height() };
|
||||
}
|
||||
|
||||
Variant::Variant(const Rect& rect)
|
||||
Variant::Variant(const Gfx::Rect& rect)
|
||||
: m_type(Type::Rect)
|
||||
{
|
||||
m_value.as_rect = (const RawRect&)rect;
|
||||
|
|
|
@ -47,12 +47,12 @@ public:
|
|||
Variant(unsigned);
|
||||
Variant(const char*);
|
||||
Variant(const String&);
|
||||
Variant(const GraphicsBitmap&);
|
||||
Variant(const Gfx::Bitmap&);
|
||||
Variant(const GIcon&);
|
||||
Variant(const Point&);
|
||||
Variant(const Size&);
|
||||
Variant(const Rect&);
|
||||
Variant(const Font&);
|
||||
Variant(const Gfx::Point&);
|
||||
Variant(const Gfx::Size&);
|
||||
Variant(const Gfx::Rect&);
|
||||
Variant(const Gfx::Font&);
|
||||
Variant(const AK::JsonValue&);
|
||||
Variant(Color);
|
||||
|
||||
|
@ -205,7 +205,7 @@ public:
|
|||
return m_value.as_string;
|
||||
}
|
||||
|
||||
const GraphicsBitmap& as_bitmap() const
|
||||
const Gfx::Bitmap& as_bitmap() const
|
||||
{
|
||||
ASSERT(type() == Type::Bitmap);
|
||||
return *m_value.as_bitmap;
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
return Color::from_rgba(m_value.as_color);
|
||||
}
|
||||
|
||||
const Font& as_font() const
|
||||
const Gfx::Font& as_font() const
|
||||
{
|
||||
ASSERT(type() == Type::Font);
|
||||
return *m_value.as_font;
|
||||
|
@ -266,15 +266,15 @@ private:
|
|||
|
||||
union {
|
||||
StringImpl* as_string;
|
||||
GraphicsBitmap* as_bitmap;
|
||||
Gfx::Bitmap* as_bitmap;
|
||||
GIconImpl* as_icon;
|
||||
Font* as_font;
|
||||
Gfx::Font* as_font;
|
||||
bool as_bool;
|
||||
i32 as_i32;
|
||||
i64 as_i64;
|
||||
unsigned as_uint;
|
||||
float as_float;
|
||||
RGBA32 as_color;
|
||||
Gfx::RGBA32 as_color;
|
||||
RawPoint as_point;
|
||||
RawSize as_size;
|
||||
RawRect as_rect;
|
||||
|
|
|
@ -94,7 +94,7 @@ const WidgetClassRegistration* WidgetClassRegistration::find(const String& class
|
|||
|
||||
Widget::Widget(Widget* parent)
|
||||
: Core::Object(parent, true)
|
||||
, m_font(Font::default_font())
|
||||
, m_font(Gfx::Font::default_font())
|
||||
, m_palette(Application::the().palette().impl())
|
||||
{
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ void Widget::child_event(Core::ChildEvent& event)
|
|||
return Core::Object::child_event(event);
|
||||
}
|
||||
|
||||
void Widget::set_relative_rect(const Rect& a_rect)
|
||||
void Widget::set_relative_rect(const Gfx::Rect& a_rect)
|
||||
{
|
||||
// Get rid of negative width/height values.
|
||||
Rect rect = {
|
||||
|
@ -391,7 +391,7 @@ void Widget::update()
|
|||
update(rect());
|
||||
}
|
||||
|
||||
void Widget::update(const Rect& rect)
|
||||
void Widget::update(const Gfx::Rect& rect)
|
||||
{
|
||||
if (!is_visible())
|
||||
return;
|
||||
|
@ -425,7 +425,7 @@ Rect Widget::screen_relative_rect() const
|
|||
return window_relative_rect().translated(window()->position());
|
||||
}
|
||||
|
||||
Widget* Widget::child_at(const Point& point) const
|
||||
Widget* Widget::child_at(const Gfx::Point& point) const
|
||||
{
|
||||
for (int i = children().size() - 1; i >= 0; --i) {
|
||||
if (!Core::is<Widget>(children()[i]))
|
||||
|
@ -439,7 +439,7 @@ Widget* Widget::child_at(const Point& point) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Widget::HitTestResult Widget::hit_test(const Point& position, ShouldRespectGreediness should_respect_greediness)
|
||||
Widget::HitTestResult Widget::hit_test(const Gfx::Point& position, ShouldRespectGreediness should_respect_greediness)
|
||||
{
|
||||
if (should_respect_greediness == ShouldRespectGreediness::Yes && is_greedy_for_hits())
|
||||
return { this, position };
|
||||
|
@ -478,13 +478,13 @@ void Widget::set_focus(bool focus)
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::set_font(const Font* font)
|
||||
void Widget::set_font(const Gfx::Font* font)
|
||||
{
|
||||
if (m_font.ptr() == font)
|
||||
return;
|
||||
|
||||
if (!font)
|
||||
m_font = Font::default_font();
|
||||
m_font = Gfx::Font::default_font();
|
||||
else
|
||||
m_font = *font;
|
||||
|
||||
|
@ -508,7 +508,7 @@ bool Widget::global_cursor_tracking() const
|
|||
return win->global_cursor_tracking_widget() == this;
|
||||
}
|
||||
|
||||
void Widget::set_preferred_size(const Size& size)
|
||||
void Widget::set_preferred_size(const Gfx::Size& size)
|
||||
{
|
||||
if (m_preferred_size == size)
|
||||
return;
|
||||
|
|
|
@ -44,7 +44,9 @@
|
|||
extern WidgetClassRegistration registration_##class_name; \
|
||||
WidgetClassRegistration registration_##class_name(#class_name, [](Widget* parent) { return class_name::construct(parent); });
|
||||
|
||||
class GraphicsBitmap;
|
||||
namespace Gfx {
|
||||
class Bitmap;
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
class Widget;
|
||||
|
@ -123,7 +125,7 @@ public:
|
|||
void set_size_policy(Orientation, SizePolicy);
|
||||
|
||||
Size preferred_size() const { return m_preferred_size; }
|
||||
void set_preferred_size(const Size&);
|
||||
void set_preferred_size(const Gfx::Size&);
|
||||
void set_preferred_size(int width, int height) { set_preferred_size({ width, height }); }
|
||||
|
||||
bool has_tooltip() const { return !m_tooltip.is_empty(); }
|
||||
|
@ -157,7 +159,7 @@ public:
|
|||
Size size() const { return m_relative_rect.size(); }
|
||||
|
||||
void update();
|
||||
void update(const Rect&);
|
||||
void update(const Gfx::Rect&);
|
||||
|
||||
virtual bool accepts_focus() const { return false; }
|
||||
|
||||
|
@ -170,10 +172,10 @@ public:
|
|||
Widget* widget { nullptr };
|
||||
Point local_position;
|
||||
};
|
||||
HitTestResult hit_test(const Point&, ShouldRespectGreediness = ShouldRespectGreediness::Yes);
|
||||
Widget* child_at(const Point&) const;
|
||||
HitTestResult hit_test(const Gfx::Point&, ShouldRespectGreediness = ShouldRespectGreediness::Yes);
|
||||
Widget* child_at(const Gfx::Point&) const;
|
||||
|
||||
void set_relative_rect(const Rect&);
|
||||
void set_relative_rect(const Gfx::Rect&);
|
||||
void set_relative_rect(int x, int y, int width, int height) { set_relative_rect({ x, y, width, height }); }
|
||||
|
||||
void set_x(int x) { set_relative_rect(x, y(), width(), height()); }
|
||||
|
@ -181,13 +183,13 @@ public:
|
|||
void set_width(int width) { set_relative_rect(x(), y(), width, height()); }
|
||||
void set_height(int height) { set_relative_rect(x(), y(), width(), height); }
|
||||
|
||||
void move_to(const Point& point) { set_relative_rect({ point, relative_rect().size() }); }
|
||||
void move_to(const Gfx::Point& point) { set_relative_rect({ point, relative_rect().size() }); }
|
||||
void move_to(int x, int y) { move_to({ x, y }); }
|
||||
void resize(const Size& size) { set_relative_rect({ relative_rect().location(), size }); }
|
||||
void resize(const Gfx::Size& size) { set_relative_rect({ relative_rect().location(), size }); }
|
||||
void resize(int width, int height) { resize({ width, height }); }
|
||||
|
||||
void move_by(int x, int y) { move_by({ x, y }); }
|
||||
void move_by(const Point& delta) { set_relative_rect({ relative_position().translated(delta), size() }); }
|
||||
void move_by(const Gfx::Point& delta) { set_relative_rect({ relative_position().translated(delta), size() }); }
|
||||
|
||||
ColorRole background_role() const { return m_background_role; }
|
||||
void set_background_role(ColorRole role) { m_background_role = role; }
|
||||
|
@ -228,9 +230,9 @@ public:
|
|||
void set_fill_with_background_color(bool b) { m_fill_with_background_color = b; }
|
||||
bool fill_with_background_color() const { return m_fill_with_background_color; }
|
||||
|
||||
const Font& font() const { return *m_font; }
|
||||
void set_font(const Font*);
|
||||
void set_font(const Font& font) { set_font(&font); }
|
||||
const Gfx::Font& font() const { return *m_font; }
|
||||
void set_font(const Gfx::Font*);
|
||||
void set_font(const Gfx::Font& font) { set_font(&font); }
|
||||
|
||||
void set_global_cursor_tracking(bool);
|
||||
bool global_cursor_tracking() const;
|
||||
|
@ -316,17 +318,17 @@ private:
|
|||
Window* m_window { nullptr };
|
||||
OwnPtr<Layout> m_layout;
|
||||
|
||||
Rect m_relative_rect;
|
||||
Gfx::Rect m_relative_rect;
|
||||
ColorRole m_background_role { ColorRole::Window };
|
||||
ColorRole m_foreground_role { ColorRole::WindowText };
|
||||
Color m_background_color;
|
||||
Color m_foreground_color;
|
||||
NonnullRefPtr<Font> m_font;
|
||||
NonnullRefPtr<Gfx::Font> m_font;
|
||||
String m_tooltip;
|
||||
|
||||
SizePolicy m_horizontal_size_policy { SizePolicy::Fill };
|
||||
SizePolicy m_vertical_size_policy { SizePolicy::Fill };
|
||||
Size m_preferred_size;
|
||||
Gfx::Size m_preferred_size;
|
||||
|
||||
bool m_fill_with_background_color { false };
|
||||
bool m_visible { true };
|
||||
|
@ -334,7 +336,7 @@ private:
|
|||
bool m_enabled { true };
|
||||
bool m_updates_enabled { true };
|
||||
|
||||
NonnullRefPtr<PaletteImpl> m_palette;
|
||||
NonnullRefPtr<Gfx::PaletteImpl> m_palette;
|
||||
};
|
||||
|
||||
inline Widget* Widget::parent_widget()
|
||||
|
|
|
@ -152,7 +152,7 @@ Rect Window::rect() const
|
|||
return WindowServerConnection::the().send_sync<WindowServer::GetWindowRect>(m_window_id)->rect();
|
||||
}
|
||||
|
||||
void Window::set_rect(const Rect& a_rect)
|
||||
void Window::set_rect(const Gfx::Rect& a_rect)
|
||||
{
|
||||
m_rect_when_windowless = a_rect;
|
||||
if (!m_window_id) {
|
||||
|
@ -332,7 +332,7 @@ void Window::update()
|
|||
update({ 0, 0, width(), height() });
|
||||
}
|
||||
|
||||
void Window::update(const Rect& a_rect)
|
||||
void Window::update(const Gfx::Rect& a_rect)
|
||||
{
|
||||
if (!m_window_id)
|
||||
return;
|
||||
|
@ -456,7 +456,7 @@ void Window::set_hovered_widget(Widget* widget)
|
|||
Core::EventLoop::current().post_event(*m_hovered_widget, make<Event>(Event::Enter));
|
||||
}
|
||||
|
||||
void Window::set_current_backing_bitmap(GraphicsBitmap& bitmap, bool flush_immediately)
|
||||
void Window::set_current_backing_bitmap(Gfx::Bitmap& bitmap, bool flush_immediately)
|
||||
{
|
||||
WindowServerConnection::the().send_sync<WindowServer::SetWindowBackingStore>(m_window_id, 32, bitmap.pitch(), bitmap.shared_buffer_id(), bitmap.has_alpha_channel(), bitmap.size(), flush_immediately);
|
||||
}
|
||||
|
@ -482,21 +482,21 @@ void Window::flip(const Vector<Rect, 32>& dirty_rects)
|
|||
m_back_bitmap->shared_buffer()->set_volatile();
|
||||
}
|
||||
|
||||
NonnullRefPtr<GraphicsBitmap> Window::create_shared_bitmap(GraphicsBitmap::Format format, const Size& size)
|
||||
NonnullRefPtr<Gfx::Bitmap> Window::create_shared_bitmap(Gfx::Bitmap::Format format, const Gfx::Size& size)
|
||||
{
|
||||
ASSERT(WindowServerConnection::the().server_pid());
|
||||
ASSERT(!size.is_empty());
|
||||
size_t pitch = round_up_to_power_of_two(size.width() * sizeof(RGBA32), 16);
|
||||
size_t pitch = round_up_to_power_of_two(size.width() * sizeof(Gfx::RGBA32), 16);
|
||||
size_t size_in_bytes = size.height() * pitch;
|
||||
auto shared_buffer = SharedBuffer::create_with_size(size_in_bytes);
|
||||
ASSERT(shared_buffer);
|
||||
shared_buffer->share_with(WindowServerConnection::the().server_pid());
|
||||
return GraphicsBitmap::create_with_shared_buffer(format, *shared_buffer, size);
|
||||
return Gfx::Bitmap::create_with_shared_buffer(format, *shared_buffer, size);
|
||||
}
|
||||
|
||||
NonnullRefPtr<GraphicsBitmap> Window::create_backing_bitmap(const Size& size)
|
||||
NonnullRefPtr<Gfx::Bitmap> Window::create_backing_bitmap(const Gfx::Size& size)
|
||||
{
|
||||
auto format = m_has_alpha_channel ? GraphicsBitmap::Format::RGBA32 : GraphicsBitmap::Format::RGB32;
|
||||
auto format = m_has_alpha_channel ? Gfx::Bitmap::Format::RGBA32 : Gfx::Bitmap::Format::RGB32;
|
||||
return create_shared_bitmap(format, size);
|
||||
}
|
||||
|
||||
|
@ -510,12 +510,12 @@ void Window::wm_event(WMEvent&)
|
|||
{
|
||||
}
|
||||
|
||||
void Window::set_icon(const GraphicsBitmap* icon)
|
||||
void Window::set_icon(const Gfx::Bitmap* icon)
|
||||
{
|
||||
if (m_icon == icon)
|
||||
return;
|
||||
|
||||
m_icon = create_shared_bitmap(GraphicsBitmap::Format::RGBA32, icon->size());
|
||||
m_icon = create_shared_bitmap(Gfx::Bitmap::Format::RGBA32, icon->size());
|
||||
{
|
||||
Painter painter(*m_icon);
|
||||
painter.blit({ 0, 0 }, *icon, icon->rect());
|
||||
|
@ -624,7 +624,7 @@ void Window::notify_state_changed(Badge<WindowServerConnection>, bool minimized,
|
|||
|
||||
// When double buffering is enabled, minimization/occlusion means we can mark the front bitmap volatile (in addition to the back bitmap.)
|
||||
// When double buffering is disabled, there is only the back bitmap (which we can now mark volatile!)
|
||||
RefPtr<GraphicsBitmap>& bitmap = m_double_buffering_enabled ? m_front_bitmap : m_back_bitmap;
|
||||
RefPtr<Gfx::Bitmap>& bitmap = m_double_buffering_enabled ? m_front_bitmap : m_back_bitmap;
|
||||
if (!bitmap)
|
||||
return;
|
||||
if (minimized || occluded) {
|
||||
|
|
|
@ -103,16 +103,16 @@ public:
|
|||
|
||||
Rect rect() const;
|
||||
Size size() const { return rect().size(); }
|
||||
void set_rect(const Rect&);
|
||||
void set_rect(const Gfx::Rect&);
|
||||
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
|
||||
|
||||
Point position() const { return rect().location(); }
|
||||
|
||||
void move_to(int x, int y) { move_to({ x, y }); }
|
||||
void move_to(const Point& point) { set_rect({ point, size() }); }
|
||||
void move_to(const Gfx::Point& point) { set_rect({ point, size() }); }
|
||||
|
||||
void resize(int width, int height) { resize({ width, height }); }
|
||||
void resize(const Size& size) { set_rect({ position(), size }); }
|
||||
void resize(const Gfx::Size& size) { set_rect({ position(), size }); }
|
||||
|
||||
virtual void event(Core::Event&) override;
|
||||
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
void set_focused_widget(Widget*);
|
||||
|
||||
void update();
|
||||
void update(const Rect&);
|
||||
void update(const Gfx::Rect&);
|
||||
|
||||
void set_global_cursor_tracking_widget(Widget*);
|
||||
Widget* global_cursor_tracking_widget() { return m_global_cursor_tracking_widget.ptr(); }
|
||||
|
@ -149,19 +149,19 @@ public:
|
|||
const Widget* hovered_widget() const { return m_hovered_widget.ptr(); }
|
||||
void set_hovered_widget(Widget*);
|
||||
|
||||
GraphicsBitmap* front_bitmap() { return m_front_bitmap.ptr(); }
|
||||
GraphicsBitmap* back_bitmap() { return m_back_bitmap.ptr(); }
|
||||
Gfx::Bitmap* front_bitmap() { return m_front_bitmap.ptr(); }
|
||||
Gfx::Bitmap* back_bitmap() { return m_back_bitmap.ptr(); }
|
||||
|
||||
Size size_increment() const { return m_size_increment; }
|
||||
void set_size_increment(const Size& increment) { m_size_increment = increment; }
|
||||
void set_size_increment(const Gfx::Size& increment) { m_size_increment = increment; }
|
||||
Size base_size() const { return m_base_size; }
|
||||
void set_base_size(const Size& size) { m_base_size = size; }
|
||||
void set_base_size(const Gfx::Size& size) { m_base_size = size; }
|
||||
|
||||
void set_override_cursor(StandardCursor);
|
||||
|
||||
void set_icon(const GraphicsBitmap*);
|
||||
void set_icon(const Gfx::Bitmap*);
|
||||
void apply_icon();
|
||||
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
||||
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
||||
|
||||
Vector<Widget*> focusable_widgets() const;
|
||||
|
||||
|
@ -183,14 +183,14 @@ protected:
|
|||
private:
|
||||
virtual bool is_window() const override final { return true; }
|
||||
|
||||
NonnullRefPtr<GraphicsBitmap> create_backing_bitmap(const Size&);
|
||||
NonnullRefPtr<GraphicsBitmap> create_shared_bitmap(GraphicsBitmap::Format, const Size&);
|
||||
void set_current_backing_bitmap(GraphicsBitmap&, bool flush_immediately = false);
|
||||
NonnullRefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::Size&);
|
||||
NonnullRefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::Bitmap::Format, const Gfx::Size&);
|
||||
void set_current_backing_bitmap(Gfx::Bitmap&, bool flush_immediately = false);
|
||||
void flip(const Vector<Rect, 32>& dirty_rects);
|
||||
|
||||
RefPtr<GraphicsBitmap> m_front_bitmap;
|
||||
RefPtr<GraphicsBitmap> m_back_bitmap;
|
||||
RefPtr<GraphicsBitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap> m_front_bitmap;
|
||||
RefPtr<Gfx::Bitmap> m_back_bitmap;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
int m_window_id { 0 };
|
||||
float m_opacity_when_windowless { 1.0f };
|
||||
RefPtr<Widget> m_main_widget;
|
||||
|
@ -198,11 +198,11 @@ private:
|
|||
WeakPtr<Widget> m_global_cursor_tracking_widget;
|
||||
WeakPtr<Widget> m_automatic_cursor_tracking_widget;
|
||||
WeakPtr<Widget> m_hovered_widget;
|
||||
Rect m_rect_when_windowless;
|
||||
Gfx::Rect m_rect_when_windowless;
|
||||
String m_title_when_windowless;
|
||||
Vector<Rect, 32> m_pending_paint_event_rects;
|
||||
Size m_size_increment;
|
||||
Size m_base_size;
|
||||
Gfx::Size m_size_increment;
|
||||
Gfx::Size m_base_size;
|
||||
Color m_background_color { Color::WarmGray };
|
||||
WindowType m_window_type { WindowType::Normal };
|
||||
bool m_is_active { false };
|
||||
|
|
|
@ -53,7 +53,7 @@ static void set_system_theme_from_shared_buffer_id(int id)
|
|||
{
|
||||
auto system_theme = SharedBuffer::create_from_shared_buffer_id(id);
|
||||
ASSERT(system_theme);
|
||||
set_system_theme(*system_theme);
|
||||
Gfx::set_system_theme(*system_theme);
|
||||
Application::the().set_system_palette(*system_theme);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue