mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:12:43 +00:00 
			
		
		
		
	LibGfx: Unpublish Gfx::Rect from global namespace
This commit is contained in:
		
							parent
							
								
									c39d44fc2e
								
							
						
					
					
						commit
						20cfd2a6bf
					
				
					 78 changed files with 262 additions and 260 deletions
				
			
		|  | @ -56,7 +56,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     auto window = GUI::Window::construct(); |     auto window = GUI::Window::construct(); | ||||||
|     window->set_title("About SerenityOS"); |     window->set_title("About SerenityOS"); | ||||||
|     Rect window_rect { 0, 0, 240, 180 }; |     Gfx::Rect window_rect { 0, 0, 240, 180 }; | ||||||
|     window_rect.center_within(GUI::Desktop::the().rect()); |     window_rect.center_within(GUI::Desktop::the().rect()); | ||||||
|     window->set_resizable(false); |     window->set_resizable(false); | ||||||
|     window->set_rect(window_rect); |     window->set_rect(window_rect); | ||||||
|  |  | ||||||
|  | @ -70,7 +70,7 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event) | ||||||
| 
 | 
 | ||||||
|     for (int y = 0; y < font().glyph_height(); ++y) { |     for (int y = 0; y < font().glyph_height(); ++y) { | ||||||
|         for (int x = 0; x < font().max_glyph_width(); ++x) { |         for (int x = 0; x < font().max_glyph_width(); ++x) { | ||||||
|             Rect rect { x * m_scale, y * m_scale, m_scale, m_scale }; |             Gfx::Rect rect { x * m_scale, y * m_scale, m_scale, m_scale }; | ||||||
|             if (x >= font().glyph_width(m_glyph)) { |             if (x >= font().glyph_width(m_glyph)) { | ||||||
|                 painter.fill_rect(rect, Color::MidGray); |                 painter.fill_rect(rect, Color::MidGray); | ||||||
|             } else { |             } else { | ||||||
|  |  | ||||||
|  | @ -62,11 +62,11 @@ void GlyphMapWidget::set_selected_glyph(u8 glyph) | ||||||
|     update(); |     update(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect GlyphMapWidget::get_outer_rect(u8 glyph) const | Gfx::Rect GlyphMapWidget::get_outer_rect(u8 glyph) const | ||||||
| { | { | ||||||
|     int row = glyph / columns(); |     int row = glyph / columns(); | ||||||
|     int column = glyph % columns(); |     int column = glyph % columns(); | ||||||
|     return Rect { |     return Gfx::Rect { | ||||||
|         column * (font().max_glyph_width() + m_horizontal_spacing) + 1, |         column * (font().max_glyph_width() + m_horizontal_spacing) + 1, | ||||||
|         row * (font().glyph_height() + m_vertical_spacing) + 1, |         row * (font().glyph_height() + m_vertical_spacing) + 1, | ||||||
|         font().max_glyph_width() + m_horizontal_spacing, |         font().max_glyph_width() + m_horizontal_spacing, | ||||||
|  | @ -94,8 +94,8 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event) | ||||||
| 
 | 
 | ||||||
|     for (int row = 0; row < rows(); ++row) { |     for (int row = 0; row < rows(); ++row) { | ||||||
|         for (int column = 0; column < columns(); ++column, ++glyph) { |         for (int column = 0; column < columns(); ++column, ++glyph) { | ||||||
|             Rect outer_rect = get_outer_rect(glyph); |             Gfx::Rect outer_rect = get_outer_rect(glyph); | ||||||
|             Rect inner_rect( |             Gfx::Rect inner_rect( | ||||||
|                 outer_rect.x() + m_horizontal_spacing / 2, |                 outer_rect.x() + m_horizontal_spacing / 2, | ||||||
|                 outer_rect.y() + m_vertical_spacing / 2, |                 outer_rect.y() + m_vertical_spacing / 2, | ||||||
|                 font().max_glyph_width(), |                 font().max_glyph_width(), | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ private: | ||||||
|     virtual void paint_event(GUI::PaintEvent&) override; |     virtual void paint_event(GUI::PaintEvent&) override; | ||||||
|     virtual void mousedown_event(GUI::MouseEvent&) override; |     virtual void mousedown_event(GUI::MouseEvent&) override; | ||||||
| 
 | 
 | ||||||
|     Rect get_outer_rect(u8 glyph) const; |     Gfx::Rect get_outer_rect(u8 glyph) const; | ||||||
| 
 | 
 | ||||||
|     RefPtr<Gfx::Font> m_font; |     RefPtr<Gfx::Font> m_font; | ||||||
|     int m_rows { 8 }; |     int m_rows { 8 }; | ||||||
|  |  | ||||||
|  | @ -335,7 +335,7 @@ void HexEditor::scroll_position_into_view(int position) | ||||||
| { | { | ||||||
|     int y = position / bytes_per_row(); |     int y = position / bytes_per_row(); | ||||||
|     int x = position % bytes_per_row(); |     int x = position % bytes_per_row(); | ||||||
|     Rect rect { |     Gfx::Rect rect { | ||||||
|         frame_thickness() + offset_margin_width() + (x * (character_width() * 3)) + 10, |         frame_thickness() + offset_margin_width() + (x * (character_width() * 3)) + 10, | ||||||
|         frame_thickness() + 5 + (y * line_height()), |         frame_thickness() + 5 + (y * line_height()), | ||||||
|         (character_width() * 3), |         (character_width() * 3), | ||||||
|  | @ -477,7 +477,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) | ||||||
|     painter.translate(frame_thickness(), frame_thickness()); |     painter.translate(frame_thickness(), frame_thickness()); | ||||||
|     painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value()); |     painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value()); | ||||||
| 
 | 
 | ||||||
|     Rect offset_clip_rect { |     Gfx::Rect offset_clip_rect { | ||||||
|         0, |         0, | ||||||
|         vertical_scrollbar().value(), |         vertical_scrollbar().value(), | ||||||
|         85, |         85, | ||||||
|  | @ -497,7 +497,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) | ||||||
| 
 | 
 | ||||||
|     // paint offsets
 |     // paint offsets
 | ||||||
|     for (int i = min_row; i < max_row; i++) { |     for (int i = min_row; i < max_row; i++) { | ||||||
|         Rect side_offset_rect { |         Gfx::Rect side_offset_rect { | ||||||
|             frame_thickness() + 5, |             frame_thickness() + 5, | ||||||
|             frame_thickness() + 5 + (i * line_height()), |             frame_thickness() + 5 + (i * line_height()), | ||||||
|             width() - width_occupied_by_vertical_scrollbar(), |             width() - width_occupied_by_vertical_scrollbar(), | ||||||
|  | @ -530,7 +530,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             Rect hex_display_rect { |             Gfx::Rect hex_display_rect { | ||||||
|                 frame_thickness() + offset_margin_width() + (j * (character_width() * 3)) + 10, |                 frame_thickness() + offset_margin_width() + (j * (character_width() * 3)) + 10, | ||||||
|                 frame_thickness() + 5 + (i * line_height()), |                 frame_thickness() + 5 + (i * line_height()), | ||||||
|                 (character_width() * 3), |                 (character_width() * 3), | ||||||
|  | @ -546,7 +546,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event) | ||||||
|             auto line = String::format("%02X", m_buffer[byte_position]); |             auto line = String::format("%02X", m_buffer[byte_position]); | ||||||
|             painter.draw_text(hex_display_rect, line, Gfx::TextAlignment::TopLeft, text_color); |             painter.draw_text(hex_display_rect, line, Gfx::TextAlignment::TopLeft, text_color); | ||||||
| 
 | 
 | ||||||
|             Rect text_display_rect { |             Gfx::Rect text_display_rect { | ||||||
|                 frame_thickness() + offset_margin_width() + (bytes_per_row() * (character_width() * 3)) + (j * character_width()) + 20, |                 frame_thickness() + offset_margin_width() + (bytes_per_row() * (character_width() * 3)) + (j * character_width()) + 20, | ||||||
|                 frame_thickness() + 5 + (i * line_height()), |                 frame_thickness() + 5 + (i * line_height()), | ||||||
|                 character_width(), |                 character_width(), | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ EllipseTool::~EllipseTool() | ||||||
| 
 | 
 | ||||||
| void EllipseTool::draw_using(GUI::Painter& painter) | void EllipseTool::draw_using(GUI::Painter& painter) | ||||||
| { | { | ||||||
|     auto ellipse_intersecting_rect = Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position); |     auto ellipse_intersecting_rect = Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position); | ||||||
|     switch (m_mode) { |     switch (m_mode) { | ||||||
|     case Mode::Outline: |     case Mode::Outline: | ||||||
|         painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_widget->color_for(m_drawing_button), m_thickness); |         painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_widget->color_for(m_drawing_button), m_thickness); | ||||||
|  |  | ||||||
|  | @ -38,21 +38,21 @@ EraseTool::~EraseTool() | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect) | Gfx::Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect) | ||||||
| { | { | ||||||
|     const int base_eraser_size = 10; |     const int base_eraser_size = 10; | ||||||
|     const int eraser_size = (base_eraser_size * m_thickness); |     const int eraser_size = (base_eraser_size * m_thickness); | ||||||
|     const int eraser_radius = eraser_size / 2; |     const int eraser_radius = eraser_size / 2; | ||||||
|     const auto ex = pos.x(); |     const auto ex = pos.x(); | ||||||
|     const auto ey = pos.y(); |     const auto ey = pos.y(); | ||||||
|     return Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect); |     return Gfx::Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void EraseTool::on_mousedown(GUI::MouseEvent& event) | void EraseTool::on_mousedown(GUI::MouseEvent& event) | ||||||
| { | { | ||||||
|     if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) |     if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) | ||||||
|         return; |         return; | ||||||
|     Rect r = build_rect(event.position(), m_widget->bitmap().rect()); |     Gfx::Rect r = build_rect(event.position(), m_widget->bitmap().rect()); | ||||||
|     GUI::Painter painter(m_widget->bitmap()); |     GUI::Painter painter(m_widget->bitmap()); | ||||||
|     painter.fill_rect(r, get_color()); |     painter.fill_rect(r, get_color()); | ||||||
|     m_widget->update(); |     m_widget->update(); | ||||||
|  | @ -64,7 +64,7 @@ void EraseTool::on_mousemove(GUI::MouseEvent& event) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { |     if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { | ||||||
|         Rect r = build_rect(event.position(), m_widget->bitmap().rect()); |         Gfx::Rect r = build_rect(event.position(), m_widget->bitmap().rect()); | ||||||
|         GUI::Painter painter(m_widget->bitmap()); |         GUI::Painter painter(m_widget->bitmap()); | ||||||
|         painter.fill_rect(r, get_color()); |         painter.fill_rect(r, get_color()); | ||||||
|         m_widget->update(); |         m_widget->update(); | ||||||
|  |  | ||||||
|  | @ -46,7 +46,7 @@ public: | ||||||
| private: | private: | ||||||
|     Color get_color() const; |     Color get_color() const; | ||||||
|     virtual const char* class_name() const override { return "EraseTool"; } |     virtual const char* class_name() const override { return "EraseTool"; } | ||||||
|     Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect); |     Gfx::Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect); | ||||||
|     RefPtr<GUI::Menu> m_context_menu; |     RefPtr<GUI::Menu> m_context_menu; | ||||||
| 
 | 
 | ||||||
|     bool m_use_secondary_color { true }; |     bool m_use_secondary_color { true }; | ||||||
|  |  | ||||||
|  | @ -95,7 +95,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* par | ||||||
|     m_primary_color_widget->set_frame_thickness(2); |     m_primary_color_widget->set_frame_thickness(2); | ||||||
|     m_primary_color_widget->set_frame_shape(Gfx::FrameShape::Container); |     m_primary_color_widget->set_frame_shape(Gfx::FrameShape::Container); | ||||||
|     m_primary_color_widget->set_frame_shadow(Gfx::FrameShadow::Sunken); |     m_primary_color_widget->set_frame_shadow(Gfx::FrameShadow::Sunken); | ||||||
|     Rect rect { 0, 0, 38, 15 }; |     Gfx::Rect rect { 0, 0, 38, 15 }; | ||||||
|     rect.center_within(m_secondary_color_widget->relative_rect()); |     rect.center_within(m_secondary_color_widget->relative_rect()); | ||||||
|     m_primary_color_widget->set_relative_rect(rect); |     m_primary_color_widget->set_relative_rect(rect); | ||||||
|     m_primary_color_widget->set_fill_with_background_color(true); |     m_primary_color_widget->set_fill_with_background_color(true); | ||||||
|  |  | ||||||
|  | @ -42,7 +42,7 @@ RectangleTool::~RectangleTool() | ||||||
| 
 | 
 | ||||||
| void RectangleTool::draw_using(GUI::Painter& painter) | void RectangleTool::draw_using(GUI::Painter& painter) | ||||||
| { | { | ||||||
|     auto rect_to_draw = Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position); |     auto rect_to_draw = Gfx::Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position); | ||||||
|     switch (m_mode) { |     switch (m_mode) { | ||||||
|     case Mode::Fill: |     case Mode::Fill: | ||||||
|         painter.fill_rect(rect_to_draw, m_widget->color_for(m_drawing_button)); |         painter.fill_rect(rect_to_draw, m_widget->color_for(m_drawing_button)); | ||||||
|  |  | ||||||
|  | @ -183,7 +183,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event) | ||||||
|     int x = 0; |     int x = 0; | ||||||
|     int i = 0; |     int i = 0; | ||||||
|     for (;;) { |     for (;;) { | ||||||
|         Rect rect(x, 0, white_key_width, frame_inner_rect().height()); |         Gfx::Rect rect(x, 0, white_key_width, frame_inner_rect().height()); | ||||||
|         painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::White); |         painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::White); | ||||||
|         painter.draw_rect(rect, Color::Black); |         painter.draw_rect(rect, Color::Black); | ||||||
|         if (i < white_key_labels_count) { |         if (i < white_key_labels_count) { | ||||||
|  | @ -205,7 +205,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event) | ||||||
|     x = white_key_width - black_key_x_offset; |     x = white_key_width - black_key_x_offset; | ||||||
|     i = 0; |     i = 0; | ||||||
|     for (;;) { |     for (;;) { | ||||||
|         Rect rect(x, 0, black_key_width, black_key_height); |         Gfx::Rect rect(x, 0, black_key_width, black_key_height); | ||||||
|         painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::Black); |         painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::Black); | ||||||
|         painter.draw_rect(rect, Color::Black); |         painter.draw_rect(rect, Color::Black); | ||||||
|         if (i < black_key_labels_count) { |         if (i < black_key_labels_count) { | ||||||
|  | @ -263,7 +263,7 @@ int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const | ||||||
|     bool black_key_on_left = note != 0 && key_pattern[(note - 1) % notes_per_octave] == Black; |     bool black_key_on_left = note != 0 && key_pattern[(note - 1) % notes_per_octave] == Black; | ||||||
|     if (black_key_on_left) { |     if (black_key_on_left) { | ||||||
|         int black_key_x = (white_keys * white_key_width) - black_key_x_offset; |         int black_key_x = (white_keys * white_key_width) - black_key_x_offset; | ||||||
|         Rect black_key(black_key_x, 0, black_key_width, black_key_height); |         Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height); | ||||||
|         if (black_key.contains(point)) |         if (black_key.contains(point)) | ||||||
|             return note - 1; |             return note - 1; | ||||||
|     } |     } | ||||||
|  | @ -271,7 +271,7 @@ int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const | ||||||
|     bool black_key_on_right = key_pattern[(note + 1) % notes_per_octave] == Black; |     bool black_key_on_right = key_pattern[(note + 1) % notes_per_octave] == Black; | ||||||
|     if (black_key_on_right) { |     if (black_key_on_right) { | ||||||
|         int black_key_x = ((white_keys + 1) * white_key_width) - black_key_x_offset; |         int black_key_x = ((white_keys + 1) * white_key_width) - black_key_x_offset; | ||||||
|         Rect black_key(black_key_x, 0, black_key_width, black_key_height); |         Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height); | ||||||
|         if (black_key.contains(point)) |         if (black_key.contains(point)) | ||||||
|             return note + 1; |             return note + 1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -80,7 +80,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) | ||||||
|             int x_pos = x * note_width; |             int x_pos = x * note_width; | ||||||
|             int next_x_pos = (x + 1) * note_width; |             int next_x_pos = (x + 1) * note_width; | ||||||
|             int distance_to_next_x = next_x_pos - x_pos; |             int distance_to_next_x = next_x_pos - x_pos; | ||||||
|             Rect rect(x_pos, y_pos, distance_to_next_x, note_height); |             Gfx::Rect rect(x_pos, y_pos, distance_to_next_x, note_height); | ||||||
| 
 | 
 | ||||||
|             if (m_roll_notes[y + note_offset][x] == On) |             if (m_roll_notes[y + note_offset][x] == On) | ||||||
|                 painter.fill_rect(rect, note_pressed_color); |                 painter.fill_rect(rect, note_pressed_color); | ||||||
|  |  | ||||||
|  | @ -69,7 +69,7 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!m_values.is_empty() && text_formatter) { |     if (!m_values.is_empty() && text_formatter) { | ||||||
|         Rect text_rect = inner_rect.shrunken(8, 8); |         Gfx::Rect text_rect = inner_rect.shrunken(8, 8); | ||||||
|         text_rect.set_height(font().glyph_height()); |         text_rect.set_height(font().glyph_height()); | ||||||
|         auto text = text_formatter(m_values.last(), m_max); |         auto text = text_formatter(m_values.last(), m_max); | ||||||
|         painter.draw_text(text_rect.translated(1, 1), text.characters(), Gfx::TextAlignment::CenterRight, Color::Black); |         painter.draw_text(text_rect.translated(1, 1), text.characters(), Gfx::TextAlignment::CenterRight, Color::Black); | ||||||
|  |  | ||||||
|  | @ -123,7 +123,7 @@ void TaskbarWindow::create_quick_launch_bar() | ||||||
| 
 | 
 | ||||||
| void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect) | void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect) | ||||||
| { | { | ||||||
|     Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() }; |     Gfx::Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() }; | ||||||
|     set_rect(new_rect); |     set_rect(new_rect); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ public: | ||||||
|     String title() const { return m_title; } |     String title() const { return m_title; } | ||||||
|     void set_title(const String& title) { m_title = title; } |     void set_title(const String& title) { m_title = title; } | ||||||
| 
 | 
 | ||||||
|     Rect rect() const { return m_rect; } |     Gfx::Rect rect() const { return m_rect; } | ||||||
|     void set_rect(const Gfx::Rect& rect) { m_rect = rect; } |     void set_rect(const Gfx::Rect& rect) { m_rect = rect; } | ||||||
| 
 | 
 | ||||||
|     GUI::Button* button() { return m_button; } |     GUI::Button* button() { return m_button; } | ||||||
|  |  | ||||||
|  | @ -90,7 +90,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     auto window = GUI::Window::construct(); |     auto window = GUI::Window::construct(); | ||||||
|     window->set_title("Welcome to Serenity"); |     window->set_title("Welcome to Serenity"); | ||||||
|     Rect window_rect { 0, 0, 640, 360 }; |     Gfx::Rect window_rect { 0, 0, 640, 360 }; | ||||||
|     window_rect.center_within(GUI::Desktop::the().rect()); |     window_rect.center_within(GUI::Desktop::the().rect()); | ||||||
|     window->set_resizable(true); |     window->set_resizable(true); | ||||||
|     window->set_rect(window_rect); |     window->set_rect(window_rect); | ||||||
|  |  | ||||||
|  | @ -168,11 +168,11 @@ void CursorTool::set_rubber_band_position(const Gfx::Point& position) | ||||||
|     m_editor.form_widget().update(); |     m_editor.form_widget().update(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect CursorTool::rubber_band_rect() const | Gfx::Rect CursorTool::rubber_band_rect() const | ||||||
| { | { | ||||||
|     if (!m_rubber_banding) |     if (!m_rubber_banding) | ||||||
|         return {}; |         return {}; | ||||||
|     return Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position); |     return Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&) | void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&) | ||||||
|  |  | ||||||
|  | @ -324,23 +324,23 @@ int main(int argc, char** argv) | ||||||
|                     dbg() << "            }"; |                     dbg() << "            }"; | ||||||
|                     dbg() << "            " << parameter.name << " = *" << parameter.name << "_impl;"; |                     dbg() << "            " << parameter.name << " = *" << parameter.name << "_impl;"; | ||||||
|                     dbg() << "        }"; |                     dbg() << "        }"; | ||||||
|                 } else if (parameter.type == "Color") { |                 } else if (parameter.type == "Gfx::Color") { | ||||||
|                     dbg() << "        u32 " << parameter.name << "_rgba = 0;"; |                     dbg() << "        u32 " << parameter.name << "_rgba = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_rgba;"; |                     dbg() << "        stream >> " << parameter.name << "_rgba;"; | ||||||
|                     dbg() << "        " << parameter.name << " = Gfx::Color::from_rgba(" << parameter.name << "_rgba);"; |                     dbg() << "        " << parameter.name << " = Gfx::Color::from_rgba(" << parameter.name << "_rgba);"; | ||||||
|                 } else if (parameter.type == "Size") { |                 } else if (parameter.type == "Gfx::Size") { | ||||||
|                     dbg() << "        int " << parameter.name << "_width = 0;"; |                     dbg() << "        int " << parameter.name << "_width = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_width;"; |                     dbg() << "        stream >> " << parameter.name << "_width;"; | ||||||
|                     dbg() << "        int " << parameter.name << "_height = 0;"; |                     dbg() << "        int " << parameter.name << "_height = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_height;"; |                     dbg() << "        stream >> " << parameter.name << "_height;"; | ||||||
|                     dbg() << "        " << parameter.name << " = { " << parameter.name << "_width, " << parameter.name << "_height };"; |                     dbg() << "        " << parameter.name << " = { " << parameter.name << "_width, " << parameter.name << "_height };"; | ||||||
|                 } else if (parameter.type == "Point") { |                 } else if (parameter.type == "Gfx::Point") { | ||||||
|                     dbg() << "        int " << parameter.name << "_x = 0;"; |                     dbg() << "        int " << parameter.name << "_x = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_x;"; |                     dbg() << "        stream >> " << parameter.name << "_x;"; | ||||||
|                     dbg() << "        int " << parameter.name << "_y = 0;"; |                     dbg() << "        int " << parameter.name << "_y = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_y;"; |                     dbg() << "        stream >> " << parameter.name << "_y;"; | ||||||
|                     dbg() << "        " << parameter.name << " = { " << parameter.name << "_x, " << parameter.name << "_y };"; |                     dbg() << "        " << parameter.name << " = { " << parameter.name << "_x, " << parameter.name << "_y };"; | ||||||
|                 } else if (parameter.type == "Rect") { |                 } else if (parameter.type == "Gfx::Rect") { | ||||||
|                     dbg() << "        int " << parameter.name << "_x = 0;"; |                     dbg() << "        int " << parameter.name << "_x = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_x;"; |                     dbg() << "        stream >> " << parameter.name << "_x;"; | ||||||
|                     dbg() << "        int " << parameter.name << "_y = 0;"; |                     dbg() << "        int " << parameter.name << "_y = 0;"; | ||||||
|  | @ -350,7 +350,7 @@ int main(int argc, char** argv) | ||||||
|                     dbg() << "        int " << parameter.name << "_height = 0;"; |                     dbg() << "        int " << parameter.name << "_height = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_height;"; |                     dbg() << "        stream >> " << parameter.name << "_height;"; | ||||||
|                     dbg() << "        " << parameter.name << " = { " << parameter.name << "_x, " << parameter.name << "_y, " << parameter.name << "_width, " << parameter.name << "_height };"; |                     dbg() << "        " << parameter.name << " = { " << parameter.name << "_x, " << parameter.name << "_y, " << parameter.name << "_width, " << parameter.name << "_height };"; | ||||||
|                 } else if (parameter.type == "Vector<Rect>") { |                 } else if (parameter.type == "Vector<Gfx::Rect>") { | ||||||
|                     dbg() << "        int " << parameter.name << "_size = 0;"; |                     dbg() << "        int " << parameter.name << "_size = 0;"; | ||||||
|                     dbg() << "        stream >> " << parameter.name << "_size;"; |                     dbg() << "        stream >> " << parameter.name << "_size;"; | ||||||
|                     dbg() << "        for (int i = 0; i < " << parameter.name << "_size; ++i) {"; |                     dbg() << "        for (int i = 0; i < " << parameter.name << "_size; ++i) {"; | ||||||
|  | @ -399,20 +399,20 @@ int main(int argc, char** argv) | ||||||
|                     dbg() << "            stream << static_cast<i32>(m_" << parameter.name << ".length());"; |                     dbg() << "            stream << static_cast<i32>(m_" << parameter.name << ".length());"; | ||||||
|                     dbg() << "            stream << m_" << parameter.name << ";"; |                     dbg() << "            stream << m_" << parameter.name << ";"; | ||||||
|                     dbg() << "        }"; |                     dbg() << "        }"; | ||||||
|                 } else if (parameter.type == "Color") { |                 } else if (parameter.type == "Gfx::Color") { | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".value();"; |                     dbg() << "        stream << m_" << parameter.name << ".value();"; | ||||||
|                 } else if (parameter.type == "Size") { |                 } else if (parameter.type == "Gfx::Size") { | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".width();"; |                     dbg() << "        stream << m_" << parameter.name << ".width();"; | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".height();"; |                     dbg() << "        stream << m_" << parameter.name << ".height();"; | ||||||
|                 } else if (parameter.type == "Point") { |                 } else if (parameter.type == "Gfx::Point") { | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".x();"; |                     dbg() << "        stream << m_" << parameter.name << ".x();"; | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".y();"; |                     dbg() << "        stream << m_" << parameter.name << ".y();"; | ||||||
|                 } else if (parameter.type == "Rect") { |                 } else if (parameter.type == "Gfx::Rect") { | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".x();"; |                     dbg() << "        stream << m_" << parameter.name << ".x();"; | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".y();"; |                     dbg() << "        stream << m_" << parameter.name << ".y();"; | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".width();"; |                     dbg() << "        stream << m_" << parameter.name << ".width();"; | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".height();"; |                     dbg() << "        stream << m_" << parameter.name << ".height();"; | ||||||
|                 } else if (parameter.type == "Vector<Rect>") { |                 } else if (parameter.type == "Vector<Gfx::Rect>") { | ||||||
|                     dbg() << "        stream << m_" << parameter.name << ".size();"; |                     dbg() << "        stream << m_" << parameter.name << ".size();"; | ||||||
|                     dbg() << "        for (auto& rect : m_" << parameter.name << ") {"; |                     dbg() << "        for (auto& rect : m_" << parameter.name << ") {"; | ||||||
|                     dbg() << "            stream << rect.x();"; |                     dbg() << "            stream << rect.x();"; | ||||||
|  |  | ||||||
|  | @ -59,7 +59,7 @@ VBWidget::~VBWidget() | ||||||
|     m_gwidget->parent()->remove_child(*m_gwidget); |     m_gwidget->parent()->remove_child(*m_gwidget); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect VBWidget::rect() const | Gfx::Rect VBWidget::rect() const | ||||||
| { | { | ||||||
|     return m_gwidget->window_relative_rect(); |     return m_gwidget->window_relative_rect(); | ||||||
| } | } | ||||||
|  | @ -80,7 +80,7 @@ bool VBWidget::is_selected() const | ||||||
|     return m_form.is_selected(*this); |     return m_form.is_selected(*this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect VBWidget::grabber_rect(Direction direction) const | Gfx::Rect VBWidget::grabber_rect(Direction direction) const | ||||||
| { | { | ||||||
|     int grabber_size = 5; |     int grabber_size = 5; | ||||||
|     int half_grabber_size = grabber_size / 2; |     int half_grabber_size = grabber_size / 2; | ||||||
|  |  | ||||||
|  | @ -79,10 +79,10 @@ public: | ||||||
| 
 | 
 | ||||||
|     bool is_selected() const; |     bool is_selected() const; | ||||||
| 
 | 
 | ||||||
|     Rect rect() const; |     Gfx::Rect rect() const; | ||||||
|     void set_rect(const Gfx::Rect&); |     void set_rect(const Gfx::Rect&); | ||||||
| 
 | 
 | ||||||
|     Rect grabber_rect(Direction) const; |     Gfx::Rect grabber_rect(Direction) const; | ||||||
|     Direction grabber_at(const Gfx::Point&) const; |     Direction grabber_at(const Gfx::Point&) const; | ||||||
| 
 | 
 | ||||||
|     GUI::Widget* gwidget() { return m_gwidget; } |     GUI::Widget* gwidget() { return m_gwidget; } | ||||||
|  | @ -98,7 +98,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     void property_did_change(); |     void property_did_change(); | ||||||
| 
 | 
 | ||||||
|     Rect transform_origin_rect() const { return m_transform_origin_rect; } |     Gfx::Rect transform_origin_rect() const { return m_transform_origin_rect; } | ||||||
|     void capture_transform_origin_rect(); |     void capture_transform_origin_rect(); | ||||||
| 
 | 
 | ||||||
|     bool is_in_layout() const; |     bool is_in_layout() const; | ||||||
|  |  | ||||||
|  | @ -237,7 +237,7 @@ void Field::reset() | ||||||
|         for (int c = 0; c < columns(); ++c) { |         for (int c = 0; c < columns(); ++c) { | ||||||
|             if (!m_squares[i]) |             if (!m_squares[i]) | ||||||
|                 m_squares[i] = make<Square>(); |                 m_squares[i] = make<Square>(); | ||||||
|             Rect rect = { frame_thickness() + c * square_size(), frame_thickness() + r * square_size(), square_size(), square_size() }; |             Gfx::Rect rect = { frame_thickness() + c * square_size(), frame_thickness() + r * square_size(), square_size(), square_size() }; | ||||||
|             auto& square = this->square(r, c); |             auto& square = this->square(r, c); | ||||||
|             square.field = this; |             square.field = this; | ||||||
|             square.row = r; |             square.row = r; | ||||||
|  |  | ||||||
|  | @ -90,13 +90,13 @@ void SnakeGame::spawn_fruit() | ||||||
|     m_fruit_type = rand() % m_fruit_bitmaps.size(); |     m_fruit_type = rand() % m_fruit_bitmaps.size(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect SnakeGame::score_rect() const | Gfx::Rect SnakeGame::score_rect() const | ||||||
| { | { | ||||||
|     int score_width = font().width(m_score_text); |     int score_width = font().width(m_score_text); | ||||||
|     return { width() - score_width - 2, height() - font().glyph_height() - 2, score_width, font().glyph_height() }; |     return { width() - score_width - 2, height() - font().glyph_height() - 2, score_width, font().glyph_height() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect SnakeGame::high_score_rect() const | Gfx::Rect SnakeGame::high_score_rect() const | ||||||
| { | { | ||||||
|     int high_score_width = font().width(m_high_score_text); |     int high_score_width = font().width(m_high_score_text); | ||||||
|     return { 2, height() - font().glyph_height() - 2, high_score_width, font().glyph_height() }; |     return { 2, height() - font().glyph_height() - 2, high_score_width, font().glyph_height() }; | ||||||
|  | @ -193,7 +193,7 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect SnakeGame::cell_rect(const Coordinate& coord) const | Gfx::Rect SnakeGame::cell_rect(const Coordinate& coord) const | ||||||
| { | { | ||||||
|     auto game_rect = rect(); |     auto game_rect = rect(); | ||||||
|     auto cell_size = Size(game_rect.width() / m_columns, game_rect.height() / m_rows); |     auto cell_size = Size(game_rect.width() / m_columns, game_rect.height() / m_rows); | ||||||
|  | @ -216,10 +216,10 @@ void SnakeGame::paint_event(GUI::PaintEvent& event) | ||||||
|         auto rect = cell_rect(part); |         auto rect = cell_rect(part); | ||||||
|         painter.fill_rect(rect, Color::from_rgb(0xaaaa00)); |         painter.fill_rect(rect, Color::from_rgb(0xaaaa00)); | ||||||
| 
 | 
 | ||||||
|         Rect left_side(rect.x(), rect.y(), 2, rect.height()); |         Gfx::Rect left_side(rect.x(), rect.y(), 2, rect.height()); | ||||||
|         Rect top_side(rect.x(), rect.y(), rect.width(), 2); |         Gfx::Rect top_side(rect.x(), rect.y(), rect.width(), 2); | ||||||
|         Rect right_side(rect.right() - 1, rect.y(), 2, rect.height()); |         Gfx::Rect right_side(rect.right() - 1, rect.y(), 2, rect.height()); | ||||||
|         Rect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2); |         Gfx::Rect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2); | ||||||
|         painter.fill_rect(left_side, Color::from_rgb(0xcccc00)); |         painter.fill_rect(left_side, Color::from_rgb(0xcccc00)); | ||||||
|         painter.fill_rect(right_side, Color::from_rgb(0x888800)); |         painter.fill_rect(right_side, Color::from_rgb(0x888800)); | ||||||
|         painter.fill_rect(top_side, Color::from_rgb(0xcccc00)); |         painter.fill_rect(top_side, Color::from_rgb(0xcccc00)); | ||||||
|  |  | ||||||
|  | @ -63,9 +63,9 @@ private: | ||||||
|     bool is_available(const Coordinate&); |     bool is_available(const Coordinate&); | ||||||
|     void queue_velocity(int v, int h); |     void queue_velocity(int v, int h); | ||||||
|     const Velocity& last_velocity() const; |     const Velocity& last_velocity() const; | ||||||
|     Rect cell_rect(const Coordinate&) const; |     Gfx::Rect cell_rect(const Coordinate&) const; | ||||||
|     Rect score_rect() const; |     Gfx::Rect score_rect() const; | ||||||
|     Rect high_score_rect() const; |     Gfx::Rect high_score_rect() const; | ||||||
| 
 | 
 | ||||||
|     int m_rows { 20 }; |     int m_rows { 20 }; | ||||||
|     int m_columns { 20 }; |     int m_columns { 20 }; | ||||||
|  |  | ||||||
|  | @ -103,7 +103,7 @@ void AbstractTableView::update_content_size() | ||||||
|     set_size_occupied_by_fixed_elements({ 0, header_height() }); |     set_size_occupied_by_fixed_elements({ 0, header_height() }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect AbstractTableView::header_rect(int column_index) const | Gfx::Rect AbstractTableView::header_rect(int column_index) const | ||||||
| { | { | ||||||
|     if (!model()) |     if (!model()) | ||||||
|         return {}; |         return {}; | ||||||
|  | @ -141,7 +141,7 @@ void AbstractTableView::paint_headers(Painter& painter) | ||||||
|             continue; |             continue; | ||||||
|         int column_width = this->column_width(column_index); |         int column_width = this->column_width(column_index); | ||||||
|         bool is_key_column = model()->key_column() == column_index; |         bool is_key_column = model()->key_column() == column_index; | ||||||
|         Rect cell_rect(x_offset, 0, column_width + horizontal_padding() * 2, header_height()); |         Gfx::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 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; |         bool hovered = column_index == m_hovered_column_header_index && model()->column_metadata(column_index).sortable == Model::ColumnMetadata::Sortable::True; | ||||||
|         Gfx::StylePainter::paint_button(painter, cell_rect, palette(), Gfx::ButtonStyle::Normal, pressed, hovered); |         Gfx::StylePainter::paint_button(painter, cell_rect, palette(), Gfx::ButtonStyle::Normal, pressed, hovered); | ||||||
|  | @ -217,7 +217,7 @@ void AbstractTableView::set_cell_painting_delegate(int column, OwnPtr<TableCellP | ||||||
| 
 | 
 | ||||||
| void AbstractTableView::update_headers() | void AbstractTableView::update_headers() | ||||||
| { | { | ||||||
|     Rect rect { 0, 0, frame_inner_rect().width(), header_height() }; |     Gfx::Rect rect { 0, 0, frame_inner_rect().width(), header_height() }; | ||||||
|     rect.move_by(frame_thickness(), frame_thickness()); |     rect.move_by(frame_thickness(), frame_thickness()); | ||||||
|     update(rect); |     update(rect); | ||||||
| } | } | ||||||
|  | @ -229,7 +229,7 @@ AbstractTableView::ColumnData& AbstractTableView::column_data(int column) const | ||||||
|     return m_column_data.at(column); |     return m_column_data.at(column); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect AbstractTableView::column_resize_grabbable_rect(int column) const | Gfx::Rect AbstractTableView::column_resize_grabbable_rect(int column) const | ||||||
| { | { | ||||||
|     if (!model()) |     if (!model()) | ||||||
|         return {}; |         return {}; | ||||||
|  | @ -525,7 +525,7 @@ void AbstractTableView::leave_event(Core::Event&) | ||||||
|     set_hovered_header_index(-1); |     set_hovered_header_index(-1); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect AbstractTableView::content_rect(int row, int column) const | Gfx::Rect AbstractTableView::content_rect(int row, int column) const | ||||||
| { | { | ||||||
|     auto row_rect = this->row_rect(row); |     auto row_rect = this->row_rect(row); | ||||||
|     int x = 0; |     int x = 0; | ||||||
|  | @ -535,12 +535,12 @@ Rect AbstractTableView::content_rect(int row, int column) const | ||||||
|     return { row_rect.x() + x, row_rect.y(), column_width(column) + horizontal_padding() * 2, item_height() }; |     return { row_rect.x() + x, row_rect.y(), column_width(column) + horizontal_padding() * 2, item_height() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect AbstractTableView::content_rect(const ModelIndex& index) const | Gfx::Rect AbstractTableView::content_rect(const ModelIndex& index) const | ||||||
| { | { | ||||||
|     return content_rect(index.row(), index.column()); |     return content_rect(index.row(), index.column()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect AbstractTableView::row_rect(int item_index) const | Gfx::Rect AbstractTableView::row_rect(int item_index) const | ||||||
| { | { | ||||||
|     return { 0, header_height() + (item_index * item_height()), max(content_size().width(), width()), item_height() }; |     return { 0, header_height() + (item_index * item_height()), max(content_size().width(), width()), item_height() }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -64,9 +64,9 @@ public: | ||||||
| 
 | 
 | ||||||
|     Point adjusted_position(const Gfx::Point&) const; |     Point adjusted_position(const Gfx::Point&) const; | ||||||
| 
 | 
 | ||||||
|     virtual Rect content_rect(const ModelIndex&) const override; |     virtual Gfx::Rect content_rect(const ModelIndex&) const override; | ||||||
|     Rect content_rect(int row, int column) const; |     Gfx::Rect content_rect(int row, int column) const; | ||||||
|     Rect row_rect(int item_index) const; |     Gfx::Rect row_rect(int item_index) const; | ||||||
| 
 | 
 | ||||||
|     void scroll_into_view(const ModelIndex&, Orientation); |     void scroll_into_view(const ModelIndex&, Orientation); | ||||||
| 
 | 
 | ||||||
|  | @ -89,7 +89,7 @@ protected: | ||||||
|     virtual void toggle_index(const ModelIndex&) {} |     virtual void toggle_index(const ModelIndex&) {} | ||||||
| 
 | 
 | ||||||
|     void paint_headers(Painter&); |     void paint_headers(Painter&); | ||||||
|     Rect header_rect(int column) const; |     Gfx::Rect header_rect(int column) const; | ||||||
| 
 | 
 | ||||||
|     static const Gfx::Font& header_font(); |     static const Gfx::Font& header_font(); | ||||||
|     void update_headers(); |     void update_headers(); | ||||||
|  | @ -109,7 +109,7 @@ protected: | ||||||
|     Menu& ensure_header_context_menu(); |     Menu& ensure_header_context_menu(); | ||||||
|     RefPtr<Menu> m_header_context_menu; |     RefPtr<Menu> m_header_context_menu; | ||||||
| 
 | 
 | ||||||
|     Rect column_resize_grabbable_rect(int) const; |     Gfx::Rect column_resize_grabbable_rect(int) const; | ||||||
|     int column_width(int) const; |     int column_width(int) const; | ||||||
|     void update_content_size(); |     void update_content_size(); | ||||||
|     virtual void update_column_sizes(); |     virtual void update_column_sizes(); | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ public: | ||||||
|     virtual void did_update_model(); |     virtual void did_update_model(); | ||||||
|     virtual void did_update_selection(); |     virtual void did_update_selection(); | ||||||
| 
 | 
 | ||||||
|     virtual Rect content_rect(const ModelIndex&) const { return {}; } |     virtual Gfx::Rect content_rect(const ModelIndex&) const { return {}; } | ||||||
|     virtual ModelIndex index_at_event_position(const Gfx::Point&) const = 0; |     virtual ModelIndex index_at_event_position(const Gfx::Point&) const = 0; | ||||||
|     void begin_editing(const ModelIndex&); |     void begin_editing(const ModelIndex&); | ||||||
|     void stop_editing(); |     void stop_editing(); | ||||||
|  |  | ||||||
|  | @ -137,7 +137,7 @@ void Application::show_tooltip(const StringView& tooltip, const Gfx::Point& scre | ||||||
|     } |     } | ||||||
|     m_tooltip_window->set_tooltip(tooltip); |     m_tooltip_window->set_tooltip(tooltip); | ||||||
| 
 | 
 | ||||||
|     Rect desktop_rect = Desktop::the().rect(); |     Gfx::Rect desktop_rect = Desktop::the().rect(); | ||||||
| 
 | 
 | ||||||
|     const int margin = 30; |     const int margin = 30; | ||||||
|     Point adjusted_pos = screen_location; |     Point adjusted_pos = screen_location; | ||||||
|  |  | ||||||
|  | @ -119,7 +119,7 @@ void BoxLayout::run(Widget& widget) | ||||||
|             continue; |             continue; | ||||||
|         if (!entry.widget->is_visible()) |         if (!entry.widget->is_visible()) | ||||||
|             continue; |             continue; | ||||||
|         Rect rect(current_x, current_y, 0, 0); |         Gfx::Rect rect(current_x, current_y, 0, 0); | ||||||
|         if (entry.layout) { |         if (entry.layout) { | ||||||
|             // FIXME: Implement recursive layout.
 |             // FIXME: Implement recursive layout.
 | ||||||
|             ASSERT_NOT_REACHED(); |             ASSERT_NOT_REACHED(); | ||||||
|  |  | ||||||
|  | @ -78,7 +78,7 @@ void Button::paint_event(PaintEvent& event) | ||||||
|         content_rect.set_width(content_rect.width() - m_icon->width() - 4); |         content_rect.set_width(content_rect.width() - m_icon->width() - 4); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect text_rect { 0, 0, font.width(text()), font.glyph_height() }; |     Gfx::Rect text_rect { 0, 0, font.width(text()), font.glyph_height() }; | ||||||
|     if (text_rect.width() > content_rect.width()) |     if (text_rect.width() > content_rect.width()) | ||||||
|         text_rect.set_width(content_rect.width()); |         text_rect.set_width(content_rect.width()); | ||||||
|     text_rect.align_within(content_rect, text_alignment()); |     text_rect.align_within(content_rect, text_alignment()); | ||||||
|  |  | ||||||
|  | @ -79,7 +79,7 @@ void CheckBox::paint_event(PaintEvent& event) | ||||||
|     if (fill_with_background_color()) |     if (fill_with_background_color()) | ||||||
|         painter.fill_rect(rect(), palette().window()); |         painter.fill_rect(rect(), palette().window()); | ||||||
| 
 | 
 | ||||||
|     Rect box_rect { |     Gfx::Rect box_rect { | ||||||
|         0, height() / 2 - s_box_height / 2 - 1, |         0, height() / 2 - s_box_height / 2 - 1, | ||||||
|         s_box_width, s_box_height |         s_box_width, s_box_height | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -101,17 +101,17 @@ void ColumnsView::paint_event(PaintEvent& event) | ||||||
|                 text_color = palette().selection_text(); |                 text_color = palette().selection_text(); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             Rect row_rect { column_x, row * item_height(), column.width, item_height() }; |             Gfx::Rect row_rect { column_x, row * item_height(), column.width, item_height() }; | ||||||
|             painter.fill_rect(row_rect, background_color); |             painter.fill_rect(row_rect, background_color); | ||||||
| 
 | 
 | ||||||
|             auto icon = model()->data(index, Model::Role::Icon); |             auto icon = model()->data(index, Model::Role::Icon); | ||||||
|             Rect icon_rect = { column_x + icon_spacing(), 0, icon_size(), icon_size() }; |             Gfx::Rect icon_rect = { column_x + icon_spacing(), 0, icon_size(), icon_size() }; | ||||||
|             icon_rect.center_vertically_within(row_rect); |             icon_rect.center_vertically_within(row_rect); | ||||||
|             if (icon.is_icon()) |             if (icon.is_icon()) | ||||||
|                 if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) |                 if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) | ||||||
|                     painter.blit(icon_rect.location(), *bitmap, bitmap->rect()); |                     painter.blit(icon_rect.location(), *bitmap, bitmap->rect()); | ||||||
| 
 | 
 | ||||||
|             Rect text_rect = { |             Gfx::Rect text_rect = { | ||||||
|                 icon_rect.right() + 1 + icon_spacing(), row * item_height(), |                 icon_rect.right() + 1 + icon_spacing(), row * item_height(), | ||||||
|                 column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - s_arrow_bitmap_width - icon_spacing(), item_height() |                 column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - s_arrow_bitmap_width - icon_spacing(), item_height() | ||||||
|             }; |             }; | ||||||
|  | @ -120,7 +120,7 @@ void ColumnsView::paint_event(PaintEvent& event) | ||||||
| 
 | 
 | ||||||
|             bool expandable = model()->row_count(index) > 0; |             bool expandable = model()->row_count(index) > 0; | ||||||
|             if (expandable) { |             if (expandable) { | ||||||
|                 Rect arrow_rect = { |                 Gfx::Rect arrow_rect = { | ||||||
|                     text_rect.right() + 1 + icon_spacing(), 0, |                     text_rect.right() + 1 + icon_spacing(), 0, | ||||||
|                     s_arrow_bitmap_width, s_arrow_bitmap_height |                     s_arrow_bitmap_width, s_arrow_bitmap_height | ||||||
|                 }; |                 }; | ||||||
|  |  | ||||||
|  | @ -118,7 +118,7 @@ void ComboBox::open() | ||||||
|         model()->row_count() * m_list_view->item_height() + m_list_view->frame_thickness() * 2 |         model()->row_count() * m_list_view->item_height() + m_list_view->frame_thickness() * 2 | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     Rect list_window_rect { my_screen_rect.bottom_left(), size }; |     Gfx::Rect list_window_rect { my_screen_rect.bottom_left(), size }; | ||||||
|     list_window_rect.intersect(Desktop::the().rect().shrunken(0, 128)); |     list_window_rect.intersect(Desktop::the().rect().shrunken(0, 128)); | ||||||
| 
 | 
 | ||||||
|     m_list_window->set_rect(list_window_rect); |     m_list_window->set_rect(list_window_rect); | ||||||
|  |  | ||||||
|  | @ -43,7 +43,7 @@ public: | ||||||
|     String wallpaper() const; |     String wallpaper() const; | ||||||
|     bool set_wallpaper(const StringView& path); |     bool set_wallpaper(const StringView& path); | ||||||
| 
 | 
 | ||||||
|     Rect rect() const { return m_rect; } |     Gfx::Rect rect() const { return m_rect; } | ||||||
|     void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect&); |     void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect&); | ||||||
| 
 | 
 | ||||||
|     Function<void(const Gfx::Rect&)> on_rect_change; |     Function<void(const Gfx::Rect&)> on_rect_change; | ||||||
|  |  | ||||||
|  | @ -119,7 +119,7 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     String title() const { return m_title; } |     String title() const { return m_title; } | ||||||
|     Rect rect() const { return m_rect; } |     Gfx::Rect rect() const { return m_rect; } | ||||||
|     bool is_active() const { return m_active; } |     bool is_active() const { return m_active; } | ||||||
|     WindowType window_type() const { return m_window_type; } |     WindowType window_type() const { return m_window_type; } | ||||||
|     bool is_minimized() const { return m_minimized; } |     bool is_minimized() const { return m_minimized; } | ||||||
|  | @ -140,7 +140,7 @@ public: | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect rect() const { return m_rect; } |     Gfx::Rect rect() const { return m_rect; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Gfx::Rect m_rect; |     Gfx::Rect m_rect; | ||||||
|  | @ -165,18 +165,18 @@ private: | ||||||
| 
 | 
 | ||||||
| class MultiPaintEvent final : public Event { | class MultiPaintEvent final : public Event { | ||||||
| public: | public: | ||||||
|     explicit MultiPaintEvent(const Vector<Rect, 32>& rects, const Gfx::Size& window_size) |     explicit MultiPaintEvent(const Vector<Gfx::Rect, 32>& rects, const Gfx::Size& window_size) | ||||||
|         : Event(Event::MultiPaint) |         : Event(Event::MultiPaint) | ||||||
|         , m_rects(rects) |         , m_rects(rects) | ||||||
|         , m_window_size(window_size) |         , m_window_size(window_size) | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const Vector<Rect, 32>& rects() const { return m_rects; } |     const Vector<Gfx::Rect, 32>& rects() const { return m_rects; } | ||||||
|     Size window_size() const { return m_window_size; } |     Size window_size() const { return m_window_size; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Vector<Rect, 32> m_rects; |     Vector<Gfx::Rect, 32> m_rects; | ||||||
|     Gfx::Size m_window_size; |     Gfx::Size m_window_size; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -189,7 +189,7 @@ public: | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect rect() const { return m_rect; } |     Gfx::Rect rect() const { return m_rect; } | ||||||
|     Size window_size() const { return m_window_size; } |     Size window_size() const { return m_window_size; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  |  | ||||||
|  | @ -45,8 +45,8 @@ public: | ||||||
|     Gfx::FrameShape frame_shape() const { return m_shape; } |     Gfx::FrameShape frame_shape() const { return m_shape; } | ||||||
|     void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; } |     void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; } | ||||||
| 
 | 
 | ||||||
|     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 }; } |     Gfx::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()); } |     Gfx::Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); } | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|     explicit Frame(Widget* parent = nullptr); |     explicit Frame(Widget* parent = nullptr); | ||||||
|  |  | ||||||
|  | @ -51,13 +51,13 @@ void GroupBox::paint_event(PaintEvent& event) | ||||||
|     Painter painter(*this); |     Painter painter(*this); | ||||||
|     painter.add_clip_rect(event.rect()); |     painter.add_clip_rect(event.rect()); | ||||||
| 
 | 
 | ||||||
|     Rect frame_rect { |     Gfx::Rect frame_rect { | ||||||
|         0, font().glyph_height() / 2, |         0, font().glyph_height() / 2, | ||||||
|         width(), height() - font().glyph_height() / 2 |         width(), height() - font().glyph_height() / 2 | ||||||
|     }; |     }; | ||||||
|     Gfx::StylePainter::paint_frame(painter, frame_rect, palette(), Gfx::FrameShape::Box, Gfx::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() }; |     Gfx::Rect text_rect { 4, 0, font().width(m_title) + 6, font().glyph_height() }; | ||||||
|     painter.fill_rect(text_rect, palette().button()); |     painter.fill_rect(text_rect, palette().button()); | ||||||
|     painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text()); |     painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text()); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -85,7 +85,7 @@ void ItemView::update_content_size() | ||||||
|     set_content_size({ content_width, content_height }); |     set_content_size({ content_width, content_height }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ItemView::item_rect(int item_index) const | Gfx::Rect ItemView::item_rect(int item_index) const | ||||||
| { | { | ||||||
|     if (!m_visual_row_count || !m_visual_column_count) |     if (!m_visual_row_count || !m_visual_column_count) | ||||||
|         return {}; |         return {}; | ||||||
|  | @ -106,9 +106,9 @@ Vector<int> ItemView::items_intersecting_rect(const Gfx::Rect& rect) const | ||||||
|     const auto& font = column_metadata.font ? *column_metadata.font : this->font(); |     const auto& font = column_metadata.font ? *column_metadata.font : this->font(); | ||||||
|     Vector<int> item_indexes; |     Vector<int> item_indexes; | ||||||
|     for (int item_index = 0; item_index < item_count(); ++item_index) { |     for (int item_index = 0; item_index < item_count(); ++item_index) { | ||||||
|         Rect item_rect; |         Gfx::Rect item_rect; | ||||||
|         Rect icon_rect; |         Gfx::Rect icon_rect; | ||||||
|         Rect text_rect; |         Gfx::Rect text_rect; | ||||||
|         auto item_text = model()->data(model()->index(item_index, model_column())); |         auto item_text = model()->data(model()->index(item_index, model_column())); | ||||||
|         get_item_rects(item_index, font, item_text, item_rect, icon_rect, text_rect); |         get_item_rects(item_index, font, item_text, item_rect, icon_rect, text_rect); | ||||||
|         if (icon_rect.intersects(rect) || text_rect.intersects(rect)) |         if (icon_rect.intersects(rect) || text_rect.intersects(rect)) | ||||||
|  | @ -126,9 +126,9 @@ ModelIndex ItemView::index_at_event_position(const Gfx::Point& position) const | ||||||
|     const auto& column_metadata = model()->column_metadata(model_column()); |     const auto& column_metadata = model()->column_metadata(model_column()); | ||||||
|     const auto& font = column_metadata.font ? *column_metadata.font : this->font(); |     const auto& font = column_metadata.font ? *column_metadata.font : this->font(); | ||||||
|     for (int item_index = 0; item_index < item_count(); ++item_index) { |     for (int item_index = 0; item_index < item_count(); ++item_index) { | ||||||
|         Rect item_rect; |         Gfx::Rect item_rect; | ||||||
|         Rect icon_rect; |         Gfx::Rect icon_rect; | ||||||
|         Rect text_rect; |         Gfx::Rect text_rect; | ||||||
|         auto index = model()->index(item_index, model_column()); |         auto index = model()->index(item_index, model_column()); | ||||||
|         auto item_text = model()->data(index); |         auto item_text = model()->data(index); | ||||||
|         get_item_rects(item_index, font, item_text, item_rect, icon_rect, text_rect); |         get_item_rects(item_index, font, item_text, item_rect, icon_rect, text_rect); | ||||||
|  | @ -186,7 +186,7 @@ void ItemView::mousemove_event(MouseEvent& event) | ||||||
|     if (m_rubber_banding) { |     if (m_rubber_banding) { | ||||||
|         if (m_rubber_band_current != event.position()) { |         if (m_rubber_band_current != event.position()) { | ||||||
|             m_rubber_band_current = event.position(); |             m_rubber_band_current = event.position(); | ||||||
|             auto rubber_band_rect = Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current); |             auto rubber_band_rect = Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current); | ||||||
|             selection().clear(); |             selection().clear(); | ||||||
|             for (auto item_index : items_intersecting_rect(rubber_band_rect)) { |             for (auto item_index : items_intersecting_rect(rubber_band_rect)) { | ||||||
|                 selection().add(model()->index(item_index, model_column())); |                 selection().add(model()->index(item_index, model_column())); | ||||||
|  | @ -204,7 +204,7 @@ void ItemView::mousemove_event(MouseEvent& event) | ||||||
|     AbstractView::mousemove_event(event); |     AbstractView::mousemove_event(event); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 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 | void ItemView::get_item_rects(int item_index, const Gfx::Font& font, const Variant& item_text, Gfx::Rect& item_rect, Gfx::Rect& icon_rect, Gfx::Rect& text_rect) const | ||||||
| { | { | ||||||
|     item_rect = this->item_rect(item_index); |     item_rect = this->item_rect(item_index); | ||||||
|     icon_rect = { 0, 0, 32, 32 }; |     icon_rect = { 0, 0, 32, 32 }; | ||||||
|  | @ -224,7 +224,7 @@ void ItemView::second_paint_event(PaintEvent& event) | ||||||
|     Painter painter(*this); |     Painter painter(*this); | ||||||
|     painter.add_clip_rect(event.rect()); |     painter.add_clip_rect(event.rect()); | ||||||
| 
 | 
 | ||||||
|     auto rubber_band_rect = Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current); |     auto rubber_band_rect = Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current); | ||||||
|     painter.fill_rect(rubber_band_rect, parent_widget()->palette().rubber_band_fill()); |     painter.fill_rect(rubber_band_rect, parent_widget()->palette().rubber_band_fill()); | ||||||
|     painter.draw_rect(rubber_band_rect, parent_widget()->palette().rubber_band_border()); |     painter.draw_rect(rubber_band_rect, parent_widget()->palette().rubber_band_border()); | ||||||
| } | } | ||||||
|  | @ -256,9 +256,9 @@ void ItemView::paint_event(PaintEvent& event) | ||||||
|         auto icon = model()->data(model_index, Model::Role::Icon); |         auto icon = model()->data(model_index, Model::Role::Icon); | ||||||
|         auto item_text = model()->data(model_index, Model::Role::Display); |         auto item_text = model()->data(model_index, Model::Role::Display); | ||||||
| 
 | 
 | ||||||
|         Rect item_rect; |         Gfx::Rect item_rect; | ||||||
|         Rect icon_rect; |         Gfx::Rect icon_rect; | ||||||
|         Rect text_rect; |         Gfx::Rect text_rect; | ||||||
|         get_item_rects(item_index, font, item_text, item_rect, icon_rect, text_rect); |         get_item_rects(item_index, font, item_text, item_rect, icon_rect, text_rect); | ||||||
| 
 | 
 | ||||||
|         if (icon.is_icon()) { |         if (icon.is_icon()) { | ||||||
|  |  | ||||||
|  | @ -65,10 +65,10 @@ private: | ||||||
|     virtual void keydown_event(KeyEvent&) override; |     virtual void keydown_event(KeyEvent&) override; | ||||||
| 
 | 
 | ||||||
|     int item_count() const; |     int item_count() const; | ||||||
|     Rect item_rect(int item_index) const; |     Gfx::Rect item_rect(int item_index) const; | ||||||
|     Vector<int> items_intersecting_rect(const Gfx::Rect&) const; |     Vector<int> items_intersecting_rect(const Gfx::Rect&) const; | ||||||
|     void update_content_size(); |     void update_content_size(); | ||||||
|     void get_item_rects(int item_index, const Gfx::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, Gfx::Rect& item_rect, Gfx::Rect& icon_rect, Gfx::Rect& text_rect) const; | ||||||
| 
 | 
 | ||||||
|     int m_horizontal_padding { 5 }; |     int m_horizontal_padding { 5 }; | ||||||
|     int m_model_column { 0 }; |     int m_model_column { 0 }; | ||||||
|  |  | ||||||
|  | @ -76,12 +76,12 @@ void ListView::did_update_model() | ||||||
|     update(); |     update(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ListView::content_rect(int row) const | Gfx::Rect ListView::content_rect(int row) const | ||||||
| { | { | ||||||
|     return { 0, row * item_height(), content_width(), item_height() }; |     return { 0, row * item_height(), content_width(), item_height() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ListView::content_rect(const ModelIndex& index) const | Gfx::Rect ListView::content_rect(const ModelIndex& index) const | ||||||
| { | { | ||||||
|     return content_rect(index.row()); |     return content_rect(index.row()); | ||||||
| } | } | ||||||
|  | @ -138,7 +138,7 @@ void ListView::paint_event(PaintEvent& event) | ||||||
| 
 | 
 | ||||||
|         auto column_metadata = model()->column_metadata(m_model_column); |         auto column_metadata = model()->column_metadata(m_model_column); | ||||||
| 
 | 
 | ||||||
|         Rect row_rect(0, y, content_width(), item_height()); |         Gfx::Rect row_rect(0, y, content_width(), item_height()); | ||||||
|         painter.fill_rect(row_rect, background_color); |         painter.fill_rect(row_rect, background_color); | ||||||
|         auto index = model()->index(row_index, m_model_column); |         auto index = model()->index(row_index, m_model_column); | ||||||
|         auto data = model()->data(index); |         auto data = model()->data(index); | ||||||
|  | @ -163,7 +163,7 @@ void ListView::paint_event(PaintEvent& event) | ||||||
|         ++painted_item_index; |         ++painted_item_index; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     Rect unpainted_rect(0, painted_item_index * item_height(), exposed_width, height()); |     Gfx::Rect unpainted_rect(0, painted_item_index * item_height(), exposed_width, height()); | ||||||
|     painter.fill_rect(unpainted_rect, palette().color(background_role())); |     painter.fill_rect(unpainted_rect, palette().color(background_role())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -54,7 +54,7 @@ public: | ||||||
|     Point adjusted_position(const Gfx::Point&) const; |     Point adjusted_position(const Gfx::Point&) const; | ||||||
| 
 | 
 | ||||||
|     virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; |     virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; | ||||||
|     virtual Rect content_rect(const ModelIndex&) const override; |     virtual Gfx::Rect content_rect(const ModelIndex&) const override; | ||||||
| 
 | 
 | ||||||
|     int model_column() const { return m_model_column; } |     int model_column() const { return m_model_column; } | ||||||
|     void set_model_column(int column) { m_model_column = column; } |     void set_model_column(int column) { m_model_column = column; } | ||||||
|  | @ -66,7 +66,7 @@ private: | ||||||
|     virtual void keydown_event(KeyEvent&) override; |     virtual void keydown_event(KeyEvent&) override; | ||||||
|     virtual void resize_event(ResizeEvent&) override; |     virtual void resize_event(ResizeEvent&) override; | ||||||
| 
 | 
 | ||||||
|     Rect content_rect(int row) const; |     Gfx::Rect content_rect(int row) const; | ||||||
|     int item_count() const; |     int item_count() const; | ||||||
|     void update_content_size(); |     void update_content_size(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -55,12 +55,12 @@ void RadioButton::paint_event(PaintEvent& event) | ||||||
|     Painter painter(*this); |     Painter painter(*this); | ||||||
|     painter.add_clip_rect(event.rect()); |     painter.add_clip_rect(event.rect()); | ||||||
| 
 | 
 | ||||||
|     Rect circle_rect { { 2, 0 }, circle_size() }; |     Gfx::Rect circle_rect { { 2, 0 }, circle_size() }; | ||||||
|     circle_rect.center_vertically_within(rect()); |     circle_rect.center_vertically_within(rect()); | ||||||
| 
 | 
 | ||||||
|     Gfx::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() }; |     Gfx::Rect text_rect { circle_rect.right() + 4, 0, font().width(text()), font().glyph_height() }; | ||||||
|     text_rect.center_vertically_within(rect()); |     text_rect.center_vertically_within(rect()); | ||||||
|     paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft); |     paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -149,12 +149,12 @@ void ScrollBar::set_value(int value) | ||||||
|     update(); |     update(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ScrollBar::decrement_button_rect() const | Gfx::Rect ScrollBar::decrement_button_rect() const | ||||||
| { | { | ||||||
|     return { 0, 0, button_width(), button_height() }; |     return { 0, 0, button_width(), button_height() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ScrollBar::increment_button_rect() const | Gfx::Rect ScrollBar::increment_button_rect() const | ||||||
| { | { | ||||||
|     if (orientation() == Orientation::Vertical) |     if (orientation() == Orientation::Vertical) | ||||||
|         return { 0, height() - button_height(), button_width(), button_height() }; |         return { 0, height() - button_height(), button_width(), button_height() }; | ||||||
|  | @ -162,7 +162,7 @@ Rect ScrollBar::increment_button_rect() const | ||||||
|         return { width() - button_width(), 0, button_width(), button_height() }; |         return { width() - button_width(), 0, button_width(), button_height() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ScrollBar::decrement_gutter_rect() const | Gfx::Rect ScrollBar::decrement_gutter_rect() const | ||||||
| { | { | ||||||
|     if (orientation() == Orientation::Vertical) |     if (orientation() == Orientation::Vertical) | ||||||
|         return { 0, button_height(), button_width(), scrubber_rect().top() - button_height() }; |         return { 0, button_height(), button_width(), scrubber_rect().top() - button_height() }; | ||||||
|  | @ -170,7 +170,7 @@ Rect ScrollBar::decrement_gutter_rect() const | ||||||
|         return { button_width(), 0, scrubber_rect().x() - button_width(), button_height() }; |         return { button_width(), 0, scrubber_rect().x() - button_width(), button_height() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ScrollBar::increment_gutter_rect() const | Gfx::Rect ScrollBar::increment_gutter_rect() const | ||||||
| { | { | ||||||
|     auto scrubber_rect = this->scrubber_rect(); |     auto scrubber_rect = this->scrubber_rect(); | ||||||
|     if (orientation() == Orientation::Vertical) |     if (orientation() == Orientation::Vertical) | ||||||
|  | @ -199,7 +199,7 @@ int ScrollBar::scrubber_size() const | ||||||
|     return ::max(pixel_range - value_range, button_size()); |     return ::max(pixel_range - value_range, button_size()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ScrollBar::scrubber_rect() const | Gfx::Rect ScrollBar::scrubber_rect() const | ||||||
| { | { | ||||||
|     if (!has_scrubber() || length(orientation()) <= (button_size() * 2) + scrubber_size()) |     if (!has_scrubber() || length(orientation()) <= (button_size() * 2) + scrubber_size()) | ||||||
|         return {}; |         return {}; | ||||||
|  |  | ||||||
|  | @ -81,11 +81,11 @@ private: | ||||||
|     int button_size() const { return length(orientation()) <= (default_button_size() * 2) ? length(orientation()) / 2 : default_button_size(); } |     int button_size() const { return length(orientation()) <= (default_button_size() * 2) ? length(orientation()) / 2 : default_button_size(); } | ||||||
|     int button_width() const { return orientation() == Orientation::Vertical ? width() : button_size(); } |     int button_width() const { return orientation() == Orientation::Vertical ? width() : button_size(); } | ||||||
|     int button_height() const { return orientation() == Orientation::Horizontal ? height() : button_size(); } |     int button_height() const { return orientation() == Orientation::Horizontal ? height() : button_size(); } | ||||||
|     Rect decrement_button_rect() const; |     Gfx::Rect decrement_button_rect() const; | ||||||
|     Rect increment_button_rect() const; |     Gfx::Rect increment_button_rect() const; | ||||||
|     Rect decrement_gutter_rect() const; |     Gfx::Rect decrement_gutter_rect() const; | ||||||
|     Rect increment_gutter_rect() const; |     Gfx::Rect increment_gutter_rect() const; | ||||||
|     Rect scrubber_rect() const; |     Gfx::Rect scrubber_rect() const; | ||||||
|     int scrubber_size() const; |     int scrubber_size() const; | ||||||
|     int scrubbable_range_in_pixels() const; |     int scrubbable_range_in_pixels() const; | ||||||
|     void on_automatic_scrolling_timer_fired(); |     void on_automatic_scrolling_timer_fired(); | ||||||
|  |  | ||||||
|  | @ -81,7 +81,7 @@ void ScrollableWidget::custom_layout() | ||||||
| 
 | 
 | ||||||
|     m_corner_widget->set_visible(m_vertical_scrollbar->is_visible() && m_horizontal_scrollbar->is_visible()); |     m_corner_widget->set_visible(m_vertical_scrollbar->is_visible() && m_horizontal_scrollbar->is_visible()); | ||||||
|     if (m_corner_widget->is_visible()) { |     if (m_corner_widget->is_visible()) { | ||||||
|         Rect corner_rect { m_horizontal_scrollbar->relative_rect().right() + 1, m_vertical_scrollbar->relative_rect().bottom() + 1, width_occupied_by_vertical_scrollbar(), height_occupied_by_horizontal_scrollbar() }; |         Gfx::Rect corner_rect { m_horizontal_scrollbar->relative_rect().right() + 1, m_vertical_scrollbar->relative_rect().bottom() + 1, width_occupied_by_vertical_scrollbar(), height_occupied_by_horizontal_scrollbar() }; | ||||||
|         m_corner_widget->set_relative_rect(corner_rect); |         m_corner_widget->set_relative_rect(corner_rect); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -144,7 +144,7 @@ int ScrollableWidget::width_occupied_by_vertical_scrollbar() const | ||||||
|     return m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->width() : 0; |     return m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->width() : 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ScrollableWidget::visible_content_rect() const | Gfx::Rect ScrollableWidget::visible_content_rect() const | ||||||
| { | { | ||||||
|     return { |     return { | ||||||
|         m_horizontal_scrollbar->value(), |         m_horizontal_scrollbar->value(), | ||||||
|  | @ -201,7 +201,7 @@ void ScrollableWidget::scroll_to_bottom() | ||||||
|     scroll_into_view({ 0, content_height(), 1, 1 }, Orientation::Vertical); |     scroll_into_view({ 0, content_height(), 1, 1 }, Orientation::Vertical); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect ScrollableWidget::widget_inner_rect() const | Gfx::Rect ScrollableWidget::widget_inner_rect() const | ||||||
| { | { | ||||||
|     auto rect = frame_inner_rect(); |     auto rect = frame_inner_rect(); | ||||||
|     rect.set_width(rect.width() - width_occupied_by_vertical_scrollbar()); |     rect.set_width(rect.width() - width_occupied_by_vertical_scrollbar()); | ||||||
|  |  | ||||||
|  | @ -41,9 +41,9 @@ public: | ||||||
|     int content_width() const { return m_content_size.width(); } |     int content_width() const { return m_content_size.width(); } | ||||||
|     int content_height() const { return m_content_size.height(); } |     int content_height() const { return m_content_size.height(); } | ||||||
| 
 | 
 | ||||||
|     Rect visible_content_rect() const; |     Gfx::Rect visible_content_rect() const; | ||||||
| 
 | 
 | ||||||
|     Rect widget_inner_rect() const; |     Gfx::Rect widget_inner_rect() const; | ||||||
| 
 | 
 | ||||||
|     void scroll_into_view(const Gfx::Rect&, Orientation); |     void scroll_into_view(const Gfx::Rect&, Orientation); | ||||||
|     void scroll_into_view(const Gfx::Rect&, bool scroll_horizontally, bool scroll_vertically); |     void scroll_into_view(const Gfx::Rect&, bool scroll_horizontally, bool scroll_vertically); | ||||||
|  |  | ||||||
|  | @ -73,7 +73,7 @@ void Slider::paint_event(PaintEvent& event) | ||||||
|     Painter painter(*this); |     Painter painter(*this); | ||||||
|     painter.add_clip_rect(event.rect()); |     painter.add_clip_rect(event.rect()); | ||||||
| 
 | 
 | ||||||
|     Rect track_rect; |     Gfx::Rect track_rect; | ||||||
| 
 | 
 | ||||||
|     if (orientation() == Orientation::Horizontal) { |     if (orientation() == Orientation::Horizontal) { | ||||||
|         track_rect = { inner_rect().x(), 0, inner_rect().width(), track_size() }; |         track_rect = { inner_rect().x(), 0, inner_rect().width(), track_size() }; | ||||||
|  | @ -87,10 +87,10 @@ void Slider::paint_event(PaintEvent& event) | ||||||
|     Gfx::StylePainter::paint_button(painter, knob_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_knob_hovered); |     Gfx::StylePainter::paint_button(painter, knob_rect(), palette(), Gfx::ButtonStyle::Normal, false, m_knob_hovered); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect Slider::knob_rect() const | Gfx::Rect Slider::knob_rect() const | ||||||
| { | { | ||||||
|     auto inner_rect = this->inner_rect(); |     auto inner_rect = this->inner_rect(); | ||||||
|     Rect rect; |     Gfx::Rect rect; | ||||||
|     rect.set_secondary_offset_for_orientation(orientation(), 0); |     rect.set_secondary_offset_for_orientation(orientation(), 0); | ||||||
|     rect.set_secondary_size_for_orientation(orientation(), knob_secondary_size()); |     rect.set_secondary_size_for_orientation(orientation(), knob_secondary_size()); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -60,9 +60,9 @@ public: | ||||||
|     int knob_secondary_size() const { return 20; } |     int knob_secondary_size() const { return 20; } | ||||||
| 
 | 
 | ||||||
|     bool knob_dragging() const { return m_dragging; } |     bool knob_dragging() const { return m_dragging; } | ||||||
|     Rect knob_rect() const; |     Gfx::Rect knob_rect() const; | ||||||
| 
 | 
 | ||||||
|     Rect inner_rect() const |     Gfx::Rect inner_rect() const | ||||||
|     { |     { | ||||||
|         if (orientation() == Orientation::Horizontal) |         if (orientation() == Orientation::Horizontal) | ||||||
|             return rect().shrunken(20, 0); |             return rect().shrunken(20, 0); | ||||||
|  |  | ||||||
|  | @ -70,9 +70,9 @@ void TabWidget::resize_event(ResizeEvent& event) | ||||||
|     m_active_widget->set_relative_rect(child_rect_for_size(event.size())); |     m_active_widget->set_relative_rect(child_rect_for_size(event.size())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TabWidget::child_rect_for_size(const Gfx::Size& size) const | Gfx::Rect TabWidget::child_rect_for_size(const Gfx::Size& size) const | ||||||
| { | { | ||||||
|     Rect rect; |     Gfx::Rect rect; | ||||||
|     switch (m_tab_position) { |     switch (m_tab_position) { | ||||||
|     case TabPosition::Top: |     case TabPosition::Top: | ||||||
|         rect = { { container_padding(), bar_height() + container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } }; |         rect = { { container_padding(), bar_height() + container_padding() }, { size.width() - container_padding() * 2, size.height() - bar_height() - container_padding() * 2 } }; | ||||||
|  | @ -109,7 +109,7 @@ void TabWidget::child_event(Core::ChildEvent& event) | ||||||
|     Widget::child_event(event); |     Widget::child_event(event); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TabWidget::bar_rect() const | Gfx::Rect TabWidget::bar_rect() const | ||||||
| { | { | ||||||
|     switch (m_tab_position) { |     switch (m_tab_position) { | ||||||
|     case TabPosition::Top: |     case TabPosition::Top: | ||||||
|  | @ -120,7 +120,7 @@ Rect TabWidget::bar_rect() const | ||||||
|     ASSERT_NOT_REACHED(); |     ASSERT_NOT_REACHED(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TabWidget::container_rect() const | Gfx::Rect TabWidget::container_rect() const | ||||||
| { | { | ||||||
|     switch (m_tab_position) { |     switch (m_tab_position) { | ||||||
|     case TabPosition::Top: |     case TabPosition::Top: | ||||||
|  | @ -166,12 +166,12 @@ void TabWidget::paint_event(PaintEvent& event) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TabWidget::button_rect(int index) const | Gfx::Rect TabWidget::button_rect(int index) const | ||||||
| { | { | ||||||
|     int x_offset = 2; |     int x_offset = 2; | ||||||
|     for (int i = 0; i < index; ++i) |     for (int i = 0; i < index; ++i) | ||||||
|         x_offset += m_tabs[i].width(font()); |         x_offset += m_tabs[i].width(font()); | ||||||
|     Rect rect { x_offset, 0, m_tabs[index].width(font()), bar_height() }; |     Gfx::Rect rect { x_offset, 0, m_tabs[index].width(font()), bar_height() }; | ||||||
|     if (m_tabs[index].widget != m_active_widget) { |     if (m_tabs[index].widget != m_active_widget) { | ||||||
|         rect.move_by(0, 2); |         rect.move_by(0, 2); | ||||||
|         rect.set_height(rect.height() - 2); |         rect.set_height(rect.height() - 2); | ||||||
|  |  | ||||||
|  | @ -64,16 +64,16 @@ protected: | ||||||
|     virtual void leave_event(Core::Event&) override; |     virtual void leave_event(Core::Event&) override; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Rect child_rect_for_size(const Gfx::Size&) const; |     Gfx::Rect child_rect_for_size(const Gfx::Size&) const; | ||||||
|     Rect button_rect(int index) const; |     Gfx::Rect button_rect(int index) const; | ||||||
|     Rect bar_rect() const; |     Gfx::Rect bar_rect() const; | ||||||
|     Rect container_rect() const; |     Gfx::Rect container_rect() const; | ||||||
|     void update_bar(); |     void update_bar(); | ||||||
| 
 | 
 | ||||||
|     RefPtr<Widget> m_active_widget; |     RefPtr<Widget> m_active_widget; | ||||||
| 
 | 
 | ||||||
|     struct TabData { |     struct TabData { | ||||||
|         Rect rect(const Gfx::Font&) const; |         Gfx::Rect rect(const Gfx::Font&) const; | ||||||
|         int width(const Gfx::Font&) const; |         int width(const Gfx::Font&) const; | ||||||
|         String title; |         String title; | ||||||
|         Widget* widget { nullptr }; |         Widget* widget { nullptr }; | ||||||
|  |  | ||||||
|  | @ -106,7 +106,7 @@ void TableView::paint_event(PaintEvent& event) | ||||||
|             int column_width = this->column_width(column_index); |             int column_width = this->column_width(column_index); | ||||||
|             const Gfx::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; |             bool is_key_column = model()->key_column() == column_index; | ||||||
|             Rect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height()); |             Gfx::Rect cell_rect(horizontal_padding() + x_offset, y, column_width, item_height()); | ||||||
|             if (is_key_column) { |             if (is_key_column) { | ||||||
|                 auto cell_rect_for_fill = cell_rect.inflated(horizontal_padding() * 2, 0); |                 auto cell_rect_for_fill = cell_rect.inflated(horizontal_padding() * 2, 0); | ||||||
|                 painter.fill_rect(cell_rect_for_fill, key_column_background_color); |                 painter.fill_rect(cell_rect_for_fill, key_column_background_color); | ||||||
|  | @ -136,7 +136,7 @@ void TableView::paint_event(PaintEvent& event) | ||||||
|         ++painted_item_index; |         ++painted_item_index; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     Rect unpainted_rect(0, header_height() + painted_item_index * item_height(), exposed_width, height()); |     Gfx::Rect unpainted_rect(0, header_height() + painted_item_index * item_height(), exposed_width, height()); | ||||||
|     painter.fill_rect(unpainted_rect, widget_background_color); |     painter.fill_rect(unpainted_rect, widget_background_color); | ||||||
| 
 | 
 | ||||||
|     // Untranslate the painter vertically and do the column headers.
 |     // Untranslate the painter vertically and do the column headers.
 | ||||||
|  |  | ||||||
|  | @ -310,7 +310,7 @@ int TextEditor::ruler_width() const | ||||||
|     return 5 * font().glyph_width('x') + 4; |     return 5 * font().glyph_width('x') + 4; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TextEditor::ruler_content_rect(size_t line_index) const | Gfx::Rect TextEditor::ruler_content_rect(size_t line_index) const | ||||||
| { | { | ||||||
|     if (!m_ruler_visible) |     if (!m_ruler_visible) | ||||||
|         return {}; |         return {}; | ||||||
|  | @ -322,12 +322,12 @@ Rect TextEditor::ruler_content_rect(size_t line_index) const | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TextEditor::ruler_rect_in_inner_coordinates() const | Gfx::Rect TextEditor::ruler_rect_in_inner_coordinates() const | ||||||
| { | { | ||||||
|     return { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar() }; |     return { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TextEditor::visible_text_rect_in_inner_coordinates() const | Gfx::Rect TextEditor::visible_text_rect_in_inner_coordinates() const | ||||||
| { | { | ||||||
|     return { |     return { | ||||||
|         m_horizontal_content_padding + (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + 1) : 0), |         m_horizontal_content_padding + (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + 1) : 0), | ||||||
|  | @ -382,7 +382,7 @@ void TextEditor::paint_event(PaintEvent& event) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect text_clip_rect { |     Gfx::Rect text_clip_rect { | ||||||
|         (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + frame_thickness() + 1) : frame_thickness()), |         (m_ruler_visible ? (ruler_rect_in_inner_coordinates().right() + frame_thickness() + 1) : frame_thickness()), | ||||||
|         frame_thickness(), |         frame_thickness(), | ||||||
|         width() - width_occupied_by_vertical_scrollbar() - ruler_width(), |         width() - width_occupied_by_vertical_scrollbar() - ruler_width(), | ||||||
|  | @ -423,7 +423,7 @@ void TextEditor::paint_event(PaintEvent& event) | ||||||
|                 painter.draw_text(visual_line_rect, visual_line_text, m_text_alignment, palette().color(foreground_role())); |                 painter.draw_text(visual_line_rect, visual_line_text, m_text_alignment, palette().color(foreground_role())); | ||||||
|             } else { |             } else { | ||||||
|                 int advance = font().glyph_width(' ') + font().glyph_spacing(); |                 int advance = font().glyph_width(' ') + font().glyph_spacing(); | ||||||
|                 Rect character_rect = { visual_line_rect.location(), { font().glyph_width(' '), line_height() } }; |                 Gfx::Rect character_rect = { visual_line_rect.location(), { font().glyph_width(' '), line_height() } }; | ||||||
|                 for (size_t i = 0; i < visual_line_text.length(); ++i) { |                 for (size_t i = 0; i < visual_line_text.length(); ++i) { | ||||||
|                     const Gfx::Font* font = &this->font(); |                     const Gfx::Font* font = &this->font(); | ||||||
|                     Color color; |                     Color color; | ||||||
|  | @ -462,7 +462,7 @@ void TextEditor::paint_event(PaintEvent& event) | ||||||
|                         ? content_x_for_position({ line_index, (size_t)selection_end_column_within_line }) |                         ? content_x_for_position({ line_index, (size_t)selection_end_column_within_line }) | ||||||
|                         : visual_line_rect.right() + 1; |                         : visual_line_rect.right() + 1; | ||||||
| 
 | 
 | ||||||
|                     Rect selection_rect { |                     Gfx::Rect selection_rect { | ||||||
|                         selection_left, |                         selection_left, | ||||||
|                         visual_line_rect.y(), |                         visual_line_rect.y(), | ||||||
|                         selection_right - selection_left, |                         selection_right - selection_left, | ||||||
|  | @ -912,7 +912,7 @@ int TextEditor::content_x_for_position(const TextPosition& position) const | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TextEditor::content_rect_for_position(const TextPosition& position) const | Gfx::Rect TextEditor::content_rect_for_position(const TextPosition& position) const | ||||||
| { | { | ||||||
|     if (!position.is_valid()) |     if (!position.is_valid()) | ||||||
|         return {}; |         return {}; | ||||||
|  | @ -922,12 +922,12 @@ Rect TextEditor::content_rect_for_position(const TextPosition& position) const | ||||||
|     int x = content_x_for_position(position); |     int x = content_x_for_position(position); | ||||||
| 
 | 
 | ||||||
|     if (is_single_line()) { |     if (is_single_line()) { | ||||||
|         Rect rect { x, 0, 1, font().glyph_height() + 2 }; |         Gfx::Rect rect { x, 0, 1, font().glyph_height() + 2 }; | ||||||
|         rect.center_vertically_within({ {}, frame_inner_rect().size() }); |         rect.center_vertically_within({ {}, frame_inner_rect().size() }); | ||||||
|         return rect; |         return rect; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect rect; |     Gfx::Rect rect; | ||||||
|     for_each_visual_line(position.line(), [&](const Gfx::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())) { |         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
 |             // NOTE: We have to subtract the horizontal padding here since it's part of the visual line rect
 | ||||||
|  | @ -945,12 +945,12 @@ Rect TextEditor::content_rect_for_position(const TextPosition& position) const | ||||||
|     return rect; |     return rect; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TextEditor::cursor_content_rect() const | Gfx::Rect TextEditor::cursor_content_rect() const | ||||||
| { | { | ||||||
|     return content_rect_for_position(m_cursor); |     return content_rect_for_position(m_cursor); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TextEditor::line_widget_rect(size_t line_index) const | Gfx::Rect TextEditor::line_widget_rect(size_t line_index) const | ||||||
| { | { | ||||||
|     auto rect = line_content_rect(line_index); |     auto rect = line_content_rect(line_index); | ||||||
|     rect.set_x(frame_thickness()); |     rect.set_x(frame_thickness()); | ||||||
|  | @ -976,11 +976,11 @@ void TextEditor::scroll_cursor_into_view() | ||||||
|     scroll_position_into_view(m_cursor); |     scroll_position_into_view(m_cursor); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TextEditor::line_content_rect(size_t line_index) const | Gfx::Rect TextEditor::line_content_rect(size_t line_index) const | ||||||
| { | { | ||||||
|     auto& line = this->line(line_index); |     auto& line = this->line(line_index); | ||||||
|     if (is_single_line()) { |     if (is_single_line()) { | ||||||
|         Rect line_rect = { content_x_for_position({ line_index, 0 }), 0, (int)line.length() * glyph_width(), font().glyph_height() + 2 }; |         Gfx::Rect line_rect = { content_x_for_position({ line_index, 0 }), 0, (int)line.length() * glyph_width(), font().glyph_height() + 2 }; | ||||||
|         line_rect.center_vertically_within({ {}, frame_inner_rect().size() }); |         line_rect.center_vertically_within({ {}, frame_inner_rect().size() }); | ||||||
|         return line_rect; |         return line_rect; | ||||||
|     } |     } | ||||||
|  | @ -1362,7 +1362,7 @@ void TextEditor::for_each_visual_line(size_t line_index, Callback callback) cons | ||||||
| 
 | 
 | ||||||
|     for (auto visual_line_break : visual_data.visual_line_breaks) { |     for (auto visual_line_break : visual_data.visual_line_breaks) { | ||||||
|         auto visual_line_view = StringView(line.characters() + start_of_line, visual_line_break - start_of_line); |         auto visual_line_view = StringView(line.characters() + start_of_line, visual_line_break - start_of_line); | ||||||
|         Rect visual_line_rect { |         Gfx::Rect visual_line_rect { | ||||||
|             visual_data.visual_rect.x(), |             visual_data.visual_rect.x(), | ||||||
|             visual_data.visual_rect.y() + ((int)visual_line_index * line_height()), |             visual_data.visual_rect.y() + ((int)visual_line_index * line_height()), | ||||||
|             font().width(visual_line_view), |             font().width(visual_line_view), | ||||||
|  |  | ||||||
|  | @ -173,10 +173,10 @@ private: | ||||||
|     void update_content_size(); |     void update_content_size(); | ||||||
|     void did_change(); |     void did_change(); | ||||||
| 
 | 
 | ||||||
|     Rect line_content_rect(size_t item_index) const; |     Gfx::Rect line_content_rect(size_t item_index) const; | ||||||
|     Rect line_widget_rect(size_t line_index) const; |     Gfx::Rect line_widget_rect(size_t line_index) const; | ||||||
|     Rect cursor_content_rect() const; |     Gfx::Rect cursor_content_rect() const; | ||||||
|     Rect content_rect_for_position(const TextPosition&) const; |     Gfx::Rect content_rect_for_position(const TextPosition&) const; | ||||||
|     void update_cursor(); |     void update_cursor(); | ||||||
|     const NonnullOwnPtrVector<TextDocumentLine>& lines() const { return document().lines(); } |     const NonnullOwnPtrVector<TextDocumentLine>& lines() const { return document().lines(); } | ||||||
|     NonnullOwnPtrVector<TextDocumentLine>& lines() { return document().lines(); } |     NonnullOwnPtrVector<TextDocumentLine>& lines() { return document().lines(); } | ||||||
|  | @ -185,13 +185,13 @@ private: | ||||||
|     TextDocumentLine& current_line() { return line(m_cursor.line()); } |     TextDocumentLine& current_line() { return line(m_cursor.line()); } | ||||||
|     const TextDocumentLine& current_line() const { return line(m_cursor.line()); } |     const TextDocumentLine& current_line() const { return line(m_cursor.line()); } | ||||||
|     int ruler_width() const; |     int ruler_width() const; | ||||||
|     Rect ruler_content_rect(size_t line) const; |     Gfx::Rect ruler_content_rect(size_t line) const; | ||||||
|     void toggle_selection_if_needed_for_event(const KeyEvent&); |     void toggle_selection_if_needed_for_event(const KeyEvent&); | ||||||
|     void delete_selection(); |     void delete_selection(); | ||||||
|     void did_update_selection(); |     void did_update_selection(); | ||||||
|     int content_x_for_position(const TextPosition&) const; |     int content_x_for_position(const TextPosition&) const; | ||||||
|     Rect ruler_rect_in_inner_coordinates() const; |     Gfx::Rect ruler_rect_in_inner_coordinates() const; | ||||||
|     Rect visible_text_rect_in_inner_coordinates() const; |     Gfx::Rect visible_text_rect_in_inner_coordinates() const; | ||||||
|     void recompute_all_visual_lines(); |     void recompute_all_visual_lines(); | ||||||
|     void ensure_cursor_is_valid(); |     void ensure_cursor_is_valid(); | ||||||
|     void flush_pending_change_notification_if_needed(); |     void flush_pending_change_notification_if_needed(); | ||||||
|  | @ -244,7 +244,7 @@ private: | ||||||
| 
 | 
 | ||||||
|     struct LineVisualData { |     struct LineVisualData { | ||||||
|         Vector<size_t, 1> visual_line_breaks; |         Vector<size_t, 1> visual_line_breaks; | ||||||
|         Rect visual_rect; |         Gfx::Rect visual_rect; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     NonnullOwnPtrVector<LineVisualData> m_line_visual_data; |     NonnullOwnPtrVector<LineVisualData> m_line_visual_data; | ||||||
|  |  | ||||||
|  | @ -138,11 +138,11 @@ void TreeView::traverse_in_paint_order(Callback callback) const | ||||||
|             auto& metadata = ensure_metadata_for_index(index); |             auto& metadata = ensure_metadata_for_index(index); | ||||||
|             int x_offset = tree_column_x_offset + horizontal_padding() + indent_level * indent_width_in_pixels(); |             int x_offset = tree_column_x_offset + horizontal_padding() + indent_level * indent_width_in_pixels(); | ||||||
|             auto node_text = model.data(index, Model::Role::Display).to_string(); |             auto node_text = model.data(index, Model::Role::Display).to_string(); | ||||||
|             Rect rect = { |             Gfx::Rect rect = { | ||||||
|                 x_offset, y_offset, |                 x_offset, y_offset, | ||||||
|                 icon_size() + icon_spacing() + text_padding() + font().width(node_text) + text_padding(), item_height() |                 icon_size() + icon_spacing() + text_padding() + font().width(node_text) + text_padding(), item_height() | ||||||
|             }; |             }; | ||||||
|             Rect toggle_rect; |             Gfx::Rect toggle_rect; | ||||||
|             if (row_count_at_index > 0) { |             if (row_count_at_index > 0) { | ||||||
|                 int toggle_x = tree_column_x_offset + horizontal_padding() + indent_width_in_pixels() * indent_level - icon_size() / 2 - 4; |                 int toggle_x = tree_column_x_offset + horizontal_padding() + indent_width_in_pixels() * indent_level - icon_size() / 2 - 4; | ||||||
|                 toggle_rect = { toggle_x, rect.y(), toggle_size(), toggle_size() }; |                 toggle_rect = { toggle_x, rect.y(), toggle_size(), toggle_size() }; | ||||||
|  | @ -230,7 +230,7 @@ void TreeView::paint_event(PaintEvent& event) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         Rect row_rect { 0, rect.y(), frame_inner_rect().width(), rect.height() }; |         Gfx::Rect row_rect { 0, rect.y(), frame_inner_rect().width(), rect.height() }; | ||||||
|         painter.fill_rect(row_rect, background_color); |         painter.fill_rect(row_rect, background_color); | ||||||
| 
 | 
 | ||||||
|         int x_offset = 0; |         int x_offset = 0; | ||||||
|  | @ -244,7 +244,7 @@ void TreeView::paint_event(PaintEvent& event) | ||||||
|             painter.draw_rect(toggle_rect, text_color); |             painter.draw_rect(toggle_rect, text_color); | ||||||
| 
 | 
 | ||||||
|             if (column_index != tree_column) { |             if (column_index != tree_column) { | ||||||
|                 Rect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height()); |                 Gfx::Rect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height()); | ||||||
|                 auto cell_index = model.sibling(index.row(), column_index, index.parent()); |                 auto cell_index = model.sibling(index.row(), column_index, index.parent()); | ||||||
| 
 | 
 | ||||||
|                 if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) { |                 if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) { | ||||||
|  | @ -265,13 +265,13 @@ void TreeView::paint_event(PaintEvent& event) | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 // It's the tree column!
 |                 // It's the tree column!
 | ||||||
|                 Rect icon_rect = { rect.x(), rect.y(), icon_size(), icon_size() }; |                 Gfx::Rect icon_rect = { rect.x(), rect.y(), icon_size(), icon_size() }; | ||||||
|                 auto icon = model.data(index, Model::Role::Icon); |                 auto icon = model.data(index, Model::Role::Icon); | ||||||
|                 if (icon.is_icon()) { |                 if (icon.is_icon()) { | ||||||
|                     if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) |                     if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) | ||||||
|                         painter.blit(icon_rect.location(), *bitmap, bitmap->rect()); |                         painter.blit(icon_rect.location(), *bitmap, bitmap->rect()); | ||||||
|                 } |                 } | ||||||
|                 Rect text_rect = { |                 Gfx::Rect text_rect = { | ||||||
|                     icon_rect.right() + 1 + icon_spacing(), rect.y(), |                     icon_rect.right() + 1 + icon_spacing(), rect.y(), | ||||||
|                     rect.width() - icon_size() - icon_spacing(), rect.height() |                     rect.width() - icon_size() - icon_spacing(), rect.height() | ||||||
|                 }; |                 }; | ||||||
|  | @ -319,7 +319,7 @@ void TreeView::scroll_into_view(const ModelIndex& a_index, Orientation orientati | ||||||
| { | { | ||||||
|     if (!a_index.is_valid()) |     if (!a_index.is_valid()) | ||||||
|         return; |         return; | ||||||
|     Rect found_rect; |     Gfx::Rect found_rect; | ||||||
|     traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect&, int) { |     traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect&, int) { | ||||||
|         if (index == a_index) { |         if (index == a_index) { | ||||||
|             found_rect = rect; |             found_rect = rect; | ||||||
|  |  | ||||||
|  | @ -194,7 +194,7 @@ public: | ||||||
|         return { m_value.as_size.width, m_value.as_size.height }; |         return { m_value.as_size.width, m_value.as_size.height }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect as_rect() const |     Gfx::Rect as_rect() const | ||||||
|     { |     { | ||||||
|         return { as_point(), as_size() }; |         return { as_point(), as_size() }; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -128,7 +128,7 @@ void Widget::child_event(Core::ChildEvent& event) | ||||||
| void Widget::set_relative_rect(const Gfx::Rect& a_rect) | void Widget::set_relative_rect(const Gfx::Rect& a_rect) | ||||||
| { | { | ||||||
|     // Get rid of negative width/height values.
 |     // Get rid of negative width/height values.
 | ||||||
|     Rect rect = { |     Gfx::Rect rect = { | ||||||
|         a_rect.x(), |         a_rect.x(), | ||||||
|         a_rect.y(), |         a_rect.y(), | ||||||
|         max(a_rect.width(), 0), |         max(a_rect.width(), 0), | ||||||
|  | @ -411,7 +411,7 @@ void Widget::update(const Gfx::Rect& rect) | ||||||
|         window->update(rect.translated(window_relative_rect().location())); |         window->update(rect.translated(window_relative_rect().location())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect Widget::window_relative_rect() const | Gfx::Rect Widget::window_relative_rect() const | ||||||
| { | { | ||||||
|     auto rect = relative_rect(); |     auto rect = relative_rect(); | ||||||
|     for (auto* parent = parent_widget(); parent; parent = parent->parent_widget()) { |     for (auto* parent = parent_widget(); parent; parent = parent->parent_widget()) { | ||||||
|  | @ -420,7 +420,7 @@ Rect Widget::window_relative_rect() const | ||||||
|     return rect; |     return rect; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect Widget::screen_relative_rect() const | Gfx::Rect Widget::screen_relative_rect() const | ||||||
| { | { | ||||||
|     return window_relative_rect().translated(window()->position()); |     return window_relative_rect().translated(window()->position()); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -143,11 +143,11 @@ public: | ||||||
|     // This is called after children have been painted.
 |     // This is called after children have been painted.
 | ||||||
|     virtual void second_paint_event(PaintEvent&); |     virtual void second_paint_event(PaintEvent&); | ||||||
| 
 | 
 | ||||||
|     Rect relative_rect() const { return m_relative_rect; } |     Gfx::Rect relative_rect() const { return m_relative_rect; } | ||||||
|     Point relative_position() const { return m_relative_rect.location(); } |     Point relative_position() const { return m_relative_rect.location(); } | ||||||
| 
 | 
 | ||||||
|     Rect window_relative_rect() const; |     Gfx::Rect window_relative_rect() const; | ||||||
|     Rect screen_relative_rect() const; |     Gfx::Rect screen_relative_rect() const; | ||||||
| 
 | 
 | ||||||
|     int x() const { return m_relative_rect.x(); } |     int x() const { return m_relative_rect.x(); } | ||||||
|     int y() const { return m_relative_rect.y(); } |     int y() const { return m_relative_rect.y(); } | ||||||
|  | @ -155,7 +155,7 @@ public: | ||||||
|     int height() const { return m_relative_rect.height(); } |     int height() const { return m_relative_rect.height(); } | ||||||
|     int length(Orientation orientation) const { return orientation == Orientation::Vertical ? height() : width(); } |     int length(Orientation orientation) const { return orientation == Orientation::Vertical ? height() : width(); } | ||||||
| 
 | 
 | ||||||
|     Rect rect() const { return { 0, 0, width(), height() }; } |     Gfx::Rect rect() const { return { 0, 0, width(), height() }; } | ||||||
|     Size size() const { return m_relative_rect.size(); } |     Size size() const { return m_relative_rect.size(); } | ||||||
| 
 | 
 | ||||||
|     void update(); |     void update(); | ||||||
|  |  | ||||||
|  | @ -145,7 +145,7 @@ String Window::title() const | ||||||
|     return WindowServerConnection::the().send_sync<WindowServer::GetWindowTitle>(m_window_id)->title(); |     return WindowServerConnection::the().send_sync<WindowServer::GetWindowTitle>(m_window_id)->title(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect Window::rect() const | Gfx::Rect Window::rect() const | ||||||
| { | { | ||||||
|     if (!m_window_id) |     if (!m_window_id) | ||||||
|         return m_rect_when_windowless; |         return m_rect_when_windowless; | ||||||
|  | @ -264,7 +264,7 @@ void Window::event(Core::Event& event) | ||||||
|             set_current_backing_bitmap(*m_back_bitmap, true); |             set_current_backing_bitmap(*m_back_bitmap, true); | ||||||
| 
 | 
 | ||||||
|         if (m_window_id) { |         if (m_window_id) { | ||||||
|             Vector<Rect> rects_to_send; |             Vector<Gfx::Rect> rects_to_send; | ||||||
|             for (auto& r : rects) |             for (auto& r : rects) | ||||||
|                 rects_to_send.append(r); |                 rects_to_send.append(r); | ||||||
|             WindowServerConnection::the().post_message(WindowServer::DidFinishPainting(m_window_id, rects_to_send)); |             WindowServerConnection::the().post_message(WindowServer::DidFinishPainting(m_window_id, rects_to_send)); | ||||||
|  | @ -351,7 +351,7 @@ void Window::update(const Gfx::Rect& a_rect) | ||||||
|             auto rects = move(m_pending_paint_event_rects); |             auto rects = move(m_pending_paint_event_rects); | ||||||
|             if (rects.is_empty()) |             if (rects.is_empty()) | ||||||
|                 return; |                 return; | ||||||
|             Vector<Rect> rects_to_send; |             Vector<Gfx::Rect> rects_to_send; | ||||||
|             for (auto& r : rects) |             for (auto& r : rects) | ||||||
|                 rects_to_send.append(r); |                 rects_to_send.append(r); | ||||||
|             WindowServerConnection::the().post_message(WindowServer::InvalidateRect(m_window_id, rects_to_send)); |             WindowServerConnection::the().post_message(WindowServer::InvalidateRect(m_window_id, rects_to_send)); | ||||||
|  | @ -461,7 +461,7 @@ void Window::set_current_backing_bitmap(Gfx::Bitmap& bitmap, bool flush_immediat | ||||||
|     WindowServerConnection::the().send_sync<WindowServer::SetWindowBackingStore>(m_window_id, 32, bitmap.pitch(), bitmap.shared_buffer_id(), bitmap.has_alpha_channel(), bitmap.size(), 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); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Window::flip(const Vector<Rect, 32>& dirty_rects) | void Window::flip(const Vector<Gfx::Rect, 32>& dirty_rects) | ||||||
| { | { | ||||||
|     swap(m_front_bitmap, m_back_bitmap); |     swap(m_front_bitmap, m_back_bitmap); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -101,7 +101,7 @@ public: | ||||||
|     int width() const { return rect().width(); } |     int width() const { return rect().width(); } | ||||||
|     int height() const { return rect().height(); } |     int height() const { return rect().height(); } | ||||||
| 
 | 
 | ||||||
|     Rect rect() const; |     Gfx::Rect rect() const; | ||||||
|     Size size() const { return rect().size(); } |     Size size() const { return rect().size(); } | ||||||
|     void set_rect(const Gfx::Rect&); |     void set_rect(const Gfx::Rect&); | ||||||
|     void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); } |     void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); } | ||||||
|  | @ -186,7 +186,7 @@ private: | ||||||
|     NonnullRefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::Size&); |     NonnullRefPtr<Gfx::Bitmap> create_backing_bitmap(const Gfx::Size&); | ||||||
|     NonnullRefPtr<Gfx::Bitmap> create_shared_bitmap(Gfx::Bitmap::Format, 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 set_current_backing_bitmap(Gfx::Bitmap&, bool flush_immediately = false); | ||||||
|     void flip(const Vector<Rect, 32>& dirty_rects); |     void flip(const Vector<Gfx::Rect, 32>& dirty_rects); | ||||||
| 
 | 
 | ||||||
|     RefPtr<Gfx::Bitmap> m_front_bitmap; |     RefPtr<Gfx::Bitmap> m_front_bitmap; | ||||||
|     RefPtr<Gfx::Bitmap> m_back_bitmap; |     RefPtr<Gfx::Bitmap> m_back_bitmap; | ||||||
|  | @ -200,7 +200,7 @@ private: | ||||||
|     WeakPtr<Widget> m_hovered_widget; |     WeakPtr<Widget> m_hovered_widget; | ||||||
|     Gfx::Rect m_rect_when_windowless; |     Gfx::Rect m_rect_when_windowless; | ||||||
|     String m_title_when_windowless; |     String m_title_when_windowless; | ||||||
|     Vector<Rect, 32> m_pending_paint_event_rects; |     Vector<Gfx::Rect, 32> m_pending_paint_event_rects; | ||||||
|     Gfx::Size m_size_increment; |     Gfx::Size m_size_increment; | ||||||
|     Gfx::Size m_base_size; |     Gfx::Size m_base_size; | ||||||
|     Color m_background_color { Color::WarmGray }; |     Color m_background_color { Color::WarmGray }; | ||||||
|  |  | ||||||
|  | @ -27,6 +27,8 @@ | ||||||
| #include "Rect.h" | #include "Rect.h" | ||||||
| #include <AK/StdLibExtras.h> | #include <AK/StdLibExtras.h> | ||||||
| 
 | 
 | ||||||
|  | namespace Gfx { | ||||||
|  | 
 | ||||||
| void Rect::intersect(const Rect& other) | void Rect::intersect(const Rect& other) | ||||||
| { | { | ||||||
|     int l = max(left(), other.left()); |     int l = max(left(), other.left()); | ||||||
|  | @ -126,3 +128,5 @@ void Rect::align_within(const Rect& other, TextAlignment alignment) | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -333,5 +333,3 @@ inline const LogStream& operator<<(const LogStream& stream, const Rect& value) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 |  | ||||||
| using Gfx::Rect; |  | ||||||
|  |  | ||||||
|  | @ -57,7 +57,7 @@ public: | ||||||
|     Function<void(const Gfx::Rect&)> on_set_needs_display; |     Function<void(const Gfx::Rect&)> on_set_needs_display; | ||||||
| 
 | 
 | ||||||
|     void set_viewport_rect(const Gfx::Rect&); |     void set_viewport_rect(const Gfx::Rect&); | ||||||
|     Rect viewport_rect() const { return m_viewport_rect; } |     Gfx::Rect viewport_rect() const { return m_viewport_rect; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit Frame(HtmlView&); |     explicit Frame(HtmlView&); | ||||||
|  |  | ||||||
|  | @ -55,7 +55,7 @@ HtmlView::HtmlView(GUI::Widget* parent) | ||||||
|             update(); |             update(); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         Rect adjusted_rect = content_rect; |         Gfx::Rect adjusted_rect = content_rect; | ||||||
|         adjusted_rect.set_location(to_widget_position(content_rect.location())); |         adjusted_rect.set_location(to_widget_position(content_rect.location())); | ||||||
|         update(adjusted_rect); |         update(adjusted_rect); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ LayoutListItemMarker::~LayoutListItemMarker() | ||||||
| 
 | 
 | ||||||
| void LayoutListItemMarker::render(RenderingContext& context) | void LayoutListItemMarker::render(RenderingContext& context) | ||||||
| { | { | ||||||
|     Rect bullet_rect { 0, 0, 4, 4 }; |     Gfx::Rect bullet_rect { 0, 0, 4, 4 }; | ||||||
|     bullet_rect.center_within(enclosing_int_rect(rect())); |     bullet_rect.center_within(enclosing_int_rect(rect())); | ||||||
|     // FIXME: It would be nicer to not have to go via the parent here to get our inherited style.
 |     // FIXME: It would be nicer to not have to go via the parent here to get our inherited style.
 | ||||||
|     auto color = parent()->style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text()); |     auto color = parent()->style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text()); | ||||||
|  |  | ||||||
|  | @ -47,7 +47,7 @@ public: | ||||||
|     bool should_show_line_box_borders() const { return m_should_show_line_box_borders; } |     bool should_show_line_box_borders() const { return m_should_show_line_box_borders; } | ||||||
|     void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; } |     void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; } | ||||||
| 
 | 
 | ||||||
|     Rect viewport_rect() const { return m_viewport_rect; } |     Gfx::Rect viewport_rect() const { return m_viewport_rect; } | ||||||
|     void set_viewport_rect(const Gfx::Rect& rect) { m_viewport_rect = rect; } |     void set_viewport_rect(const Gfx::Rect& rect) { m_viewport_rect = rect; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  |  | ||||||
|  | @ -137,17 +137,17 @@ static inline Color lookup_color(unsigned color) | ||||||
|     return Color::from_rgb(xterm_colors[color]); |     return Color::from_rgb(xterm_colors[color]); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TerminalWidget::glyph_rect(u16 row, u16 column) | Gfx::Rect TerminalWidget::glyph_rect(u16 row, u16 column) | ||||||
| { | { | ||||||
|     int y = row * m_line_height; |     int y = row * m_line_height; | ||||||
|     int x = column * font().glyph_width('x'); |     int x = column * font().glyph_width('x'); | ||||||
|     return { x + frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x'), font().glyph_height() }; |     return { x + frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x'), font().glyph_height() }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect TerminalWidget::row_rect(u16 row) | Gfx::Rect TerminalWidget::row_rect(u16 row) | ||||||
| { | { | ||||||
|     int y = row * m_line_height; |     int y = row * m_line_height; | ||||||
|     Rect rect = { frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x') * m_terminal.columns(), font().glyph_height() }; |     Gfx::Rect rect = { frame_thickness() + m_inset, y + frame_thickness() + m_inset, font().glyph_width('x') * m_terminal.columns(), font().glyph_height() }; | ||||||
|     rect.inflate(0, m_line_spacing); |     rect.inflate(0, m_line_spacing); | ||||||
|     return rect; |     return rect; | ||||||
| } | } | ||||||
|  | @ -282,7 +282,7 @@ void TerminalWidget::paint_event(GUI::PaintEvent& event) | ||||||
| 
 | 
 | ||||||
|     painter.add_clip_rect(event.rect()); |     painter.add_clip_rect(event.rect()); | ||||||
| 
 | 
 | ||||||
|     Rect terminal_buffer_rect(frame_inner_rect().top_left(), { frame_inner_rect().width() - m_scrollbar->width(), frame_inner_rect().height() }); |     Gfx::Rect terminal_buffer_rect(frame_inner_rect().top_left(), { frame_inner_rect().width() - m_scrollbar->width(), frame_inner_rect().height() }); | ||||||
|     painter.add_clip_rect(terminal_buffer_rect); |     painter.add_clip_rect(terminal_buffer_rect); | ||||||
| 
 | 
 | ||||||
|     if (m_visual_beep_timer->is_active()) |     if (m_visual_beep_timer->is_active()) | ||||||
|  | @ -399,7 +399,7 @@ void TerminalWidget::flush_dirty_lines() | ||||||
|         m_terminal.m_need_full_flush = false; |         m_terminal.m_need_full_flush = false; | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     Rect rect; |     Gfx::Rect rect; | ||||||
|     for (int i = 0; i < m_terminal.rows(); ++i) { |     for (int i = 0; i < m_terminal.rows(); ++i) { | ||||||
|         if (m_terminal.line(i).dirty) { |         if (m_terminal.line(i).dirty) { | ||||||
|             rect = rect.united(row_rect(i)); |             rect = rect.united(row_rect(i)); | ||||||
|  | @ -430,7 +430,7 @@ void TerminalWidget::relayout(const Gfx::Size& size) | ||||||
|     int new_rows = (size.height() - base_size.height()) / m_line_height; |     int new_rows = (size.height() - base_size.height()) / m_line_height; | ||||||
|     m_terminal.set_size(new_columns, new_rows); |     m_terminal.set_size(new_columns, new_rows); | ||||||
| 
 | 
 | ||||||
|     Rect scrollbar_rect = { |     Gfx::Rect scrollbar_rect = { | ||||||
|         size.width() - m_scrollbar->width() - frame_thickness(), |         size.width() - m_scrollbar->width() - frame_thickness(), | ||||||
|         frame_thickness(), |         frame_thickness(), | ||||||
|         m_scrollbar->width(), |         m_scrollbar->width(), | ||||||
|  |  | ||||||
|  | @ -114,8 +114,8 @@ private: | ||||||
| 
 | 
 | ||||||
|     void set_logical_focus(bool); |     void set_logical_focus(bool); | ||||||
| 
 | 
 | ||||||
|     Rect glyph_rect(u16 row, u16 column); |     Gfx::Rect glyph_rect(u16 row, u16 column); | ||||||
|     Rect row_rect(u16 row); |     Gfx::Rect row_rect(u16 row); | ||||||
| 
 | 
 | ||||||
|     void update_cursor(); |     void update_cursor(); | ||||||
|     void invalidate_cursor(); |     void invalidate_cursor(); | ||||||
|  |  | ||||||
|  | @ -187,7 +187,7 @@ void WSCompositor::compose() | ||||||
|             // we want to try to blit the backing store at the same place
 |             // we want to try to blit the backing store at the same place
 | ||||||
|             // it was previously, and fill the rest of the window with its
 |             // it was previously, and fill the rest of the window with its
 | ||||||
|             // background color.
 |             // background color.
 | ||||||
|             Rect backing_rect; |             Gfx::Rect backing_rect; | ||||||
|             backing_rect.set_size(backing_store->size()); |             backing_rect.set_size(backing_store->size()); | ||||||
|             switch (WSWindowManager::the().resize_direction_of_window(window)) { |             switch (WSWindowManager::the().resize_direction_of_window(window)) { | ||||||
|             case ResizeDirection::None: |             case ResizeDirection::None: | ||||||
|  | @ -212,7 +212,7 @@ void WSCompositor::compose() | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             Rect dirty_rect_in_backing_coordinates = dirty_rect |             Gfx::Rect dirty_rect_in_backing_coordinates = dirty_rect | ||||||
|                                                          .intersected(window.rect()) |                                                          .intersected(window.rect()) | ||||||
|                                                          .intersected(backing_rect) |                                                          .intersected(backing_rect) | ||||||
|                                                          .translated(-backing_rect.location()); |                                                          .translated(-backing_rect.location()); | ||||||
|  | @ -257,7 +257,7 @@ void WSCompositor::compose() | ||||||
| 
 | 
 | ||||||
| void WSCompositor::flush(const Gfx::Rect& a_rect) | void WSCompositor::flush(const Gfx::Rect& a_rect) | ||||||
| { | { | ||||||
|     auto rect = Rect::intersection(a_rect, WSScreen::the().rect()); |     auto rect = Gfx::Rect::intersection(a_rect, WSScreen::the().rect()); | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG_COUNTERS | #ifdef DEBUG_COUNTERS | ||||||
|     dbgprintf("[WM] flush #%u (%d,%d %dx%d)\n", ++m_flush_count, rect.x(), rect.y(), rect.width(), rect.height()); |     dbgprintf("[WM] flush #%u (%d,%d %dx%d)\n", ++m_flush_count, rect.x(), rect.y(), rect.width(), rect.height()); | ||||||
|  | @ -302,7 +302,7 @@ void WSCompositor::invalidate() | ||||||
| 
 | 
 | ||||||
| void WSCompositor::invalidate(const Gfx::Rect& a_rect) | void WSCompositor::invalidate(const Gfx::Rect& a_rect) | ||||||
| { | { | ||||||
|     auto rect = Rect::intersection(a_rect, WSScreen::the().rect()); |     auto rect = Gfx::Rect::intersection(a_rect, WSScreen::the().rect()); | ||||||
|     if (rect.is_empty()) |     if (rect.is_empty()) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|  | @ -369,7 +369,7 @@ void WSCompositor::run_animations() | ||||||
|             float width_delta_per_step = (float)(from_rect.width() - to_rect.width()) / minimize_animation_steps; |             float width_delta_per_step = (float)(from_rect.width() - to_rect.width()) / minimize_animation_steps; | ||||||
|             float height_delta_per_step = (float)(from_rect.height() - to_rect.height()) / minimize_animation_steps; |             float height_delta_per_step = (float)(from_rect.height() - to_rect.height()) / minimize_animation_steps; | ||||||
| 
 | 
 | ||||||
|             Rect rect { |             Gfx::Rect rect { | ||||||
|                 from_rect.x() - (int)(x_delta_per_step * animation_index), |                 from_rect.x() - (int)(x_delta_per_step * animation_index), | ||||||
|                 from_rect.y() - (int)(y_delta_per_step * animation_index), |                 from_rect.y() - (int)(y_delta_per_step * animation_index), | ||||||
|                 from_rect.width() - (int)(width_delta_per_step * animation_index), |                 from_rect.width() - (int)(width_delta_per_step * animation_index), | ||||||
|  | @ -405,7 +405,7 @@ void WSCompositor::set_resolution(int desired_width, int desired_height) | ||||||
|     compose(); |     compose(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSCompositor::current_cursor_rect() const | Gfx::Rect WSCompositor::current_cursor_rect() const | ||||||
| { | { | ||||||
|     auto& wm = WSWindowManager::the(); |     auto& wm = WSWindowManager::the(); | ||||||
|     return { WSScreen::the().cursor_location().translated(-wm.active_cursor().hotspot()), wm.active_cursor().size() }; |     return { WSScreen::the().cursor_location().translated(-wm.active_cursor().hotspot()), wm.active_cursor().size() }; | ||||||
|  | @ -433,7 +433,7 @@ void WSCompositor::draw_geometry_label() | ||||||
|         int height_steps = (window_being_moved_or_resized->height() - window_being_moved_or_resized->base_size().height()) / window_being_moved_or_resized->size_increment().height(); |         int height_steps = (window_being_moved_or_resized->height() - window_being_moved_or_resized->base_size().height()) / window_being_moved_or_resized->size_increment().height(); | ||||||
|         geometry_string = String::format("%s (%dx%d)", geometry_string.characters(), width_steps, height_steps); |         geometry_string = String::format("%s (%dx%d)", geometry_string.characters(), width_steps, height_steps); | ||||||
|     } |     } | ||||||
|     auto geometry_label_rect = Rect { 0, 0, wm.font().width(geometry_string) + 16, wm.font().glyph_height() + 10 }; |     auto geometry_label_rect = Gfx::Rect { 0, 0, wm.font().width(geometry_string) + 16, wm.font().glyph_height() + 10 }; | ||||||
|     geometry_label_rect.center_within(window_being_moved_or_resized->rect()); |     geometry_label_rect.center_within(window_being_moved_or_resized->rect()); | ||||||
|     m_back_painter->fill_rect(geometry_label_rect, Color::WarmGray); |     m_back_painter->fill_rect(geometry_label_rect, Color::WarmGray); | ||||||
|     m_back_painter->draw_rect(geometry_label_rect, Color::DarkGray); |     m_back_painter->draw_rect(geometry_label_rect, Color::DarkGray); | ||||||
|  | @ -444,7 +444,7 @@ void WSCompositor::draw_geometry_label() | ||||||
| void WSCompositor::draw_cursor() | void WSCompositor::draw_cursor() | ||||||
| { | { | ||||||
|     auto& wm = WSWindowManager::the(); |     auto& wm = WSWindowManager::the(); | ||||||
|     Rect cursor_rect = current_cursor_rect(); |     Gfx::Rect cursor_rect = current_cursor_rect(); | ||||||
|     m_back_painter->blit(cursor_rect.location(), wm.active_cursor().bitmap(), wm.active_cursor().rect()); |     m_back_painter->blit(cursor_rect.location(), wm.active_cursor().bitmap(), wm.active_cursor().rect()); | ||||||
| 
 | 
 | ||||||
|     if (wm.dnd_client()) { |     if (wm.dnd_client()) { | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ public: | ||||||
|     Point hotspot() const { return m_hotspot; } |     Point hotspot() const { return m_hotspot; } | ||||||
|     const Gfx::Bitmap& bitmap() const { return *m_bitmap; } |     const Gfx::Bitmap& bitmap() const { return *m_bitmap; } | ||||||
| 
 | 
 | ||||||
|     Rect rect() const { return m_bitmap->rect(); } |     Gfx::Rect rect() const { return m_bitmap->rect(); } | ||||||
|     Size size() const { return m_bitmap->size(); } |     Size size() const { return m_bitmap->size(); } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  |  | ||||||
|  | @ -135,8 +135,8 @@ public: | ||||||
|     { |     { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect old_rect() const { return m_old_rect; } |     Gfx::Rect old_rect() const { return m_old_rect; } | ||||||
|     Rect rect() const { return m_rect; } |     Gfx::Rect rect() const { return m_rect; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Gfx::Rect m_old_rect; |     Gfx::Rect m_old_rect; | ||||||
|  |  | ||||||
|  | @ -77,7 +77,7 @@ WSMenu* WSMenuItem::submenu() | ||||||
|     return WSMenuManager::the().find_internal_menu_by_id(m_submenu_id); |     return WSMenuManager::the().find_internal_menu_by_id(m_submenu_id); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSMenuItem::rect() const | Gfx::Rect WSMenuItem::rect() const | ||||||
| { | { | ||||||
|     if (!m_menu.is_scrollable()) |     if (!m_menu.is_scrollable()) | ||||||
|         return m_rect; |         return m_rect; | ||||||
|  |  | ||||||
|  | @ -214,8 +214,8 @@ void WSMenuManager::draw() | ||||||
|             if (!existing_applet) |             if (!existing_applet) | ||||||
|                 continue; |                 continue; | ||||||
| 
 | 
 | ||||||
|             Rect new_applet_rect(right_edge_x - existing_applet->size().width(), 0, existing_applet->size().width(), existing_applet->size().height()); |             Gfx::Rect new_applet_rect(right_edge_x - existing_applet->size().width(), 0, existing_applet->size().width(), existing_applet->size().height()); | ||||||
|             Rect dummy_menubar_rect(0, 0, 0, 18); |             Gfx::Rect dummy_menubar_rect(0, 0, 0, 18); | ||||||
|             new_applet_rect.center_vertically_within(dummy_menubar_rect); |             new_applet_rect.center_vertically_within(dummy_menubar_rect); | ||||||
| 
 | 
 | ||||||
|             existing_applet->set_rect_in_menubar(new_applet_rect); |             existing_applet->set_rect_in_menubar(new_applet_rect); | ||||||
|  | @ -463,8 +463,8 @@ void WSMenuManager::add_applet(WSWindow& applet) | ||||||
|             right_edge_x = existing_applet->rect_in_menubar().x() - 4; |             right_edge_x = existing_applet->rect_in_menubar().x() - 4; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Rect new_applet_rect(right_edge_x - applet.size().width(), 0, applet.size().width(), applet.size().height()); |     Gfx::Rect new_applet_rect(right_edge_x - applet.size().width(), 0, applet.size().width(), applet.size().height()); | ||||||
|     Rect dummy_menubar_rect(0, 0, 0, 18); |     Gfx::Rect dummy_menubar_rect(0, 0, 0, 18); | ||||||
|     new_applet_rect.center_vertically_within(dummy_menubar_rect); |     new_applet_rect.center_vertically_within(dummy_menubar_rect); | ||||||
| 
 | 
 | ||||||
|     applet.set_rect_in_menubar(new_applet_rect); |     applet.set_rect_in_menubar(new_applet_rect); | ||||||
|  | @ -493,7 +493,7 @@ void WSMenuManager::invalidate_applet(const WSWindow& applet, const Gfx::Rect& r | ||||||
|     window().invalidate(rect.translated(applet.rect_in_menubar().location())); |     window().invalidate(rect.translated(applet.rect_in_menubar().location())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSMenuManager::menubar_rect() const | Gfx::Rect WSMenuManager::menubar_rect() const | ||||||
| { | { | ||||||
|     return { 0, 0, WSScreen::the().rect().width(), 18 }; |     return { 0, 0, WSScreen::the().rect().width(), 18 }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ public: | ||||||
| 
 | 
 | ||||||
|     Vector<WeakPtr<WSMenu>>& open_menu_stack() { return m_open_menu_stack; } |     Vector<WeakPtr<WSMenu>>& open_menu_stack() { return m_open_menu_stack; } | ||||||
| 
 | 
 | ||||||
|     Rect menubar_rect() const; |     Gfx::Rect menubar_rect() const; | ||||||
|     static int menubar_menu_margin() { return 16; } |     static int menubar_menu_margin() { return 16; } | ||||||
| 
 | 
 | ||||||
|     void set_needs_window_resize(); |     void set_needs_window_resize(); | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ public: | ||||||
|     static WSScreen& the(); |     static WSScreen& the(); | ||||||
| 
 | 
 | ||||||
|     Size size() const { return { width(), height() }; } |     Size size() const { return { width(), height() }; } | ||||||
|     Rect rect() const { return { 0, 0, width(), height() }; } |     Gfx::Rect rect() const { return { 0, 0, width(), height() }; } | ||||||
| 
 | 
 | ||||||
|     Point cursor_location() const { return m_cursor_location; } |     Point cursor_location() const { return m_cursor_location; } | ||||||
|     unsigned mouse_button_state() const { return m_mouse_button_state; } |     unsigned mouse_button_state() const { return m_mouse_button_state; } | ||||||
|  |  | ||||||
|  | @ -94,7 +94,7 @@ void WSWindow::set_title(const String& title) | ||||||
| 
 | 
 | ||||||
| void WSWindow::set_rect(const Gfx::Rect& rect) | void WSWindow::set_rect(const Gfx::Rect& rect) | ||||||
| { | { | ||||||
|     Rect old_rect; |     Gfx::Rect old_rect; | ||||||
|     if (m_rect == rect) |     if (m_rect == rect) | ||||||
|         return; |         return; | ||||||
|     old_rect = m_rect; |     old_rect = m_rect; | ||||||
|  | @ -371,7 +371,7 @@ void WSWindow::set_fullscreen(bool fullscreen) | ||||||
|     if (m_fullscreen == fullscreen) |     if (m_fullscreen == fullscreen) | ||||||
|         return; |         return; | ||||||
|     m_fullscreen = fullscreen; |     m_fullscreen = fullscreen; | ||||||
|     Rect new_window_rect = m_rect; |     Gfx::Rect new_window_rect = m_rect; | ||||||
|     if (m_fullscreen) { |     if (m_fullscreen) { | ||||||
|         m_saved_nonfullscreen_rect = m_rect; |         m_saved_nonfullscreen_rect = m_rect; | ||||||
|         new_window_rect = WSScreen::the().rect(); |         new_window_rect = WSScreen::the().rect(); | ||||||
|  |  | ||||||
|  | @ -147,12 +147,12 @@ void WSWindowFrame::did_set_maximized(Badge<WSWindow>, bool maximized) | ||||||
|     m_maximize_button->set_bitmap(maximized ? *s_unmaximize_button_bitmap : *s_maximize_button_bitmap); |     m_maximize_button->set_bitmap(maximized ? *s_unmaximize_button_bitmap : *s_maximize_button_bitmap); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSWindowFrame::title_bar_rect() const | Gfx::Rect WSWindowFrame::title_bar_rect() const | ||||||
| { | { | ||||||
|     return { 3, 3, m_window.width(), window_titlebar_height }; |     return { 3, 3, m_window.width(), window_titlebar_height }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSWindowFrame::title_bar_icon_rect() const | Gfx::Rect WSWindowFrame::title_bar_icon_rect() const | ||||||
| { | { | ||||||
|     auto titlebar_rect = title_bar_rect(); |     auto titlebar_rect = title_bar_rect(); | ||||||
|     return { |     return { | ||||||
|  | @ -163,7 +163,7 @@ Rect WSWindowFrame::title_bar_icon_rect() const | ||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSWindowFrame::title_bar_text_rect() const | Gfx::Rect WSWindowFrame::title_bar_text_rect() const | ||||||
| { | { | ||||||
|     auto titlebar_rect = title_bar_rect(); |     auto titlebar_rect = title_bar_rect(); | ||||||
|     auto titlebar_icon_rect = title_bar_icon_rect(); |     auto titlebar_icon_rect = title_bar_icon_rect(); | ||||||
|  | @ -273,7 +273,7 @@ static Gfx::Rect frame_rect_for_window(WSWindow& window) | ||||||
|     return frame_rect_for_window(window, window.rect()); |     return frame_rect_for_window(window, window.rect()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSWindowFrame::rect() const | Gfx::Rect WSWindowFrame::rect() const | ||||||
| { | { | ||||||
|     return frame_rect_for_window(m_window); |     return frame_rect_for_window(m_window); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -372,7 +372,7 @@ void WSWindowManager::start_window_resize(WSWindow& window, const Gfx::Point& po | ||||||
|         { ResizeDirection::Left, ResizeDirection::None, ResizeDirection::Right }, |         { ResizeDirection::Left, ResizeDirection::None, ResizeDirection::Right }, | ||||||
|         { ResizeDirection::DownLeft, ResizeDirection::Down, ResizeDirection::DownRight }, |         { ResizeDirection::DownLeft, ResizeDirection::Down, ResizeDirection::DownRight }, | ||||||
|     }; |     }; | ||||||
|     Rect outer_rect = window.frame().rect(); |     Gfx::Rect outer_rect = window.frame().rect(); | ||||||
|     ASSERT(outer_rect.contains(position)); |     ASSERT(outer_rect.contains(position)); | ||||||
|     int window_relative_x = position.x() - outer_rect.x(); |     int window_relative_x = position.x() - outer_rect.x(); | ||||||
|     int window_relative_y = position.y() - outer_rect.y(); |     int window_relative_y = position.y() - outer_rect.y(); | ||||||
|  | @ -937,7 +937,7 @@ bool WSWindowManager::any_opaque_window_above_this_one_contains_rect(const WSWin | ||||||
|     return found_containing_window; |     return found_containing_window; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Rect WSWindowManager::menubar_rect() const | Gfx::Rect WSWindowManager::menubar_rect() const | ||||||
| { | { | ||||||
|     if (active_fullscreen_window()) |     if (active_fullscreen_window()) | ||||||
|         return {}; |         return {}; | ||||||
|  | @ -1212,9 +1212,9 @@ ResizeDirection WSWindowManager::resize_direction_of_window(const WSWindow& wind | ||||||
|     return m_resize_direction; |     return m_resize_direction; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Rect WSWindowManager::maximized_window_rect(const WSWindow& window) const | Gfx::Rect WSWindowManager::maximized_window_rect(const WSWindow& window) const | ||||||
| { | { | ||||||
|     Rect rect = WSScreen::the().rect(); |     Gfx::Rect rect = WSScreen::the().rect(); | ||||||
| 
 | 
 | ||||||
|     // Subtract window title bar (leaving the border)
 |     // Subtract window title bar (leaving the border)
 | ||||||
|     rect.set_y(rect.y() + window.frame().title_bar_rect().height()); |     rect.set_y(rect.y() + window.frame().title_bar_rect().height()); | ||||||
|  |  | ||||||
|  | @ -1,11 +1,11 @@ | ||||||
| endpoint WindowClient = 4 | endpoint WindowClient = 4 | ||||||
| { | { | ||||||
|     Paint(i32 window_id, Size window_size, Vector<Rect> rects) =| |     Paint(i32 window_id, Gfx::Size window_size, Vector<Gfx::Rect> rects) =| | ||||||
|     MouseMove(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| |     MouseMove(i32 window_id, Gfx::Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| | ||||||
|     MouseDown(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| |     MouseDown(i32 window_id, Gfx::Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| | ||||||
|     MouseDoubleClick(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| |     MouseDoubleClick(i32 window_id, Gfx::Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| | ||||||
|     MouseUp(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| |     MouseUp(i32 window_id, Gfx::Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| | ||||||
|     MouseWheel(i32 window_id, Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| |     MouseWheel(i32 window_id, Gfx::Point mouse_position, u32 button, u32 buttons, u32 modifiers, i32 wheel_delta) =| | ||||||
|     WindowEntered(i32 window_id) =| |     WindowEntered(i32 window_id) =| | ||||||
|     WindowLeft(i32 window_id) =| |     WindowLeft(i32 window_id) =| | ||||||
|     KeyDown(i32 window_id, u8 character, u32 key, u32 modifiers) =| |     KeyDown(i32 window_id, u8 character, u32 key, u32 modifiers) =| | ||||||
|  | @ -14,25 +14,25 @@ endpoint WindowClient = 4 | ||||||
|     WindowDeactivated(i32 window_id) =| |     WindowDeactivated(i32 window_id) =| | ||||||
|     WindowStateChanged(i32 window_id, bool minimized, bool occluded) =| |     WindowStateChanged(i32 window_id, bool minimized, bool occluded) =| | ||||||
|     WindowCloseRequest(i32 window_id) =| |     WindowCloseRequest(i32 window_id) =| | ||||||
|     WindowResized(i32 window_id, Rect old_rect, Rect new_rect) =| |     WindowResized(i32 window_id, Gfx::Rect old_rect, Gfx::Rect new_rect) =| | ||||||
| 
 | 
 | ||||||
|     MenuItemActivated(i32 menu_id, i32 identifier) =| |     MenuItemActivated(i32 menu_id, i32 identifier) =| | ||||||
| 
 | 
 | ||||||
|     ScreenRectChanged(Rect rect) =| |     ScreenRectChanged(Gfx::Rect rect) =| | ||||||
| 
 | 
 | ||||||
|     ClipboardContentsChanged(String content_type) =| |     ClipboardContentsChanged(String content_type) =| | ||||||
| 
 | 
 | ||||||
|     WM_WindowRemoved(i32 wm_id, i32 client_id, i32 window_id) =| |     WM_WindowRemoved(i32 wm_id, i32 client_id, i32 window_id) =| | ||||||
|     WM_WindowStateChanged(i32 wm_id, i32 client_id, i32 window_id, bool is_active, bool is_minimized, i32 window_type, String title, Rect rect) =| |     WM_WindowStateChanged(i32 wm_id, i32 client_id, i32 window_id, bool is_active, bool is_minimized, i32 window_type, String title, Gfx::Rect rect) =| | ||||||
|     WM_WindowIconBitmapChanged(i32 wm_id, i32 client_id, i32 window_id, i32 icon_buffer_id, Size icon_size) =| |     WM_WindowIconBitmapChanged(i32 wm_id, i32 client_id, i32 window_id, i32 icon_buffer_id, Gfx::Size icon_size) =| | ||||||
|     WM_WindowRectChanged(i32 wm_id, i32 client_id, i32 window_id, Rect rect) =| |     WM_WindowRectChanged(i32 wm_id, i32 client_id, i32 window_id, Gfx::Rect rect) =| | ||||||
| 
 | 
 | ||||||
|     AsyncSetWallpaperFinished(bool success) =| |     AsyncSetWallpaperFinished(bool success) =| | ||||||
| 
 | 
 | ||||||
|     DragAccepted() =| |     DragAccepted() =| | ||||||
|     DragCancelled() =| |     DragCancelled() =| | ||||||
| 
 | 
 | ||||||
|     DragDropped(i32 window_id, Point mouse_position, String text, String data_type, String data) =| |     DragDropped(i32 window_id, Gfx::Point mouse_position, String text, String data_type, String data) =| | ||||||
| 
 | 
 | ||||||
|     UpdateSystemTheme(i32 system_theme_buffer_id) =| |     UpdateSystemTheme(i32 system_theme_buffer_id) =| | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| endpoint WindowServer = 2 | endpoint WindowServer = 2 | ||||||
| { | { | ||||||
|     Greet() => (i32 client_id, Rect screen_rect, i32 system_theme_buffer_id) |     Greet() => (i32 client_id, Gfx::Rect screen_rect, i32 system_theme_buffer_id) | ||||||
| 
 | 
 | ||||||
|     CreateMenubar() => (i32 menubar_id) |     CreateMenubar() => (i32 menubar_id) | ||||||
|     DestroyMenubar(i32 menubar_id) => () |     DestroyMenubar(i32 menubar_id) => () | ||||||
|  | @ -28,7 +28,7 @@ endpoint WindowServer = 2 | ||||||
|     UpdateMenuItem(i32 menu_id, i32 identifier, i32 submenu_id, String text, bool enabled, bool checkable, bool checked, String shortcut) => () |     UpdateMenuItem(i32 menu_id, i32 identifier, i32 submenu_id, String text, bool enabled, bool checkable, bool checked, String shortcut) => () | ||||||
| 
 | 
 | ||||||
|     CreateWindow( |     CreateWindow( | ||||||
|         Rect rect, |         Gfx::Rect rect, | ||||||
|         bool has_alpha_channel, |         bool has_alpha_channel, | ||||||
|         bool modal, |         bool modal, | ||||||
|         bool minimizable, |         bool minimizable, | ||||||
|  | @ -36,8 +36,8 @@ endpoint WindowServer = 2 | ||||||
|         bool fullscreen, |         bool fullscreen, | ||||||
|         bool show_titlebar, |         bool show_titlebar, | ||||||
|         float opacity, |         float opacity, | ||||||
|         Size base_size, |         Gfx::Size base_size, | ||||||
|         Size size_increment, |         Gfx::Size size_increment, | ||||||
|         i32 type, |         i32 type, | ||||||
|         String title) => (i32 window_id) |         String title) => (i32 window_id) | ||||||
| 
 | 
 | ||||||
|  | @ -46,37 +46,37 @@ endpoint WindowServer = 2 | ||||||
|     SetWindowTitle(i32 window_id, String title) => () |     SetWindowTitle(i32 window_id, String title) => () | ||||||
|     GetWindowTitle(i32 window_id) => (String title) |     GetWindowTitle(i32 window_id) => (String title) | ||||||
| 
 | 
 | ||||||
|     SetWindowRect(i32 window_id, Rect rect) => () |     SetWindowRect(i32 window_id, Gfx::Rect rect) => () | ||||||
|     GetWindowRect(i32 window_id) => (Rect rect) |     GetWindowRect(i32 window_id) => (Gfx::Rect rect) | ||||||
| 
 | 
 | ||||||
|     InvalidateRect(i32 window_id, Vector<Rect> rects) =| |     InvalidateRect(i32 window_id, Vector<Gfx::Rect> rects) =| | ||||||
|     DidFinishPainting(i32 window_id, Vector<Rect> rects) =| |     DidFinishPainting(i32 window_id, Vector<Gfx::Rect> rects) =| | ||||||
| 
 | 
 | ||||||
|     SetGlobalCursorTracking(i32 window_id, bool enabled) => () |     SetGlobalCursorTracking(i32 window_id, bool enabled) => () | ||||||
|     SetWindowOpacity(i32 window_id, float opacity) => () |     SetWindowOpacity(i32 window_id, float opacity) => () | ||||||
| 
 | 
 | ||||||
|     SetWindowBackingStore(i32 window_id, i32 bpp, i32 pitch, i32 shared_buffer_id, bool has_alpha_channel, Size size, bool flush_immediately) => () |     SetWindowBackingStore(i32 window_id, i32 bpp, i32 pitch, i32 shared_buffer_id, bool has_alpha_channel, Gfx::Size size, bool flush_immediately) => () | ||||||
|     GetClipboardContents() => (i32 shared_buffer_id, i32 content_size, String content_type) |     GetClipboardContents() => (i32 shared_buffer_id, i32 content_size, String content_type) | ||||||
|     SetClipboardContents(i32 shared_buffer_id, i32 content_size, String content_type) => () |     SetClipboardContents(i32 shared_buffer_id, i32 content_size, String content_type) => () | ||||||
| 
 | 
 | ||||||
|     WM_SetActiveWindow(i32 client_id, i32 window_id) =| |     WM_SetActiveWindow(i32 client_id, i32 window_id) =| | ||||||
|     WM_SetWindowMinimized(i32 client_id, i32 window_id, bool minimized) =| |     WM_SetWindowMinimized(i32 client_id, i32 window_id, bool minimized) =| | ||||||
|     WM_StartWindowResize(i32 client_id, i32 window_id) =| |     WM_StartWindowResize(i32 client_id, i32 window_id) =| | ||||||
|     WM_PopupWindowMenu(i32 client_id, i32 window_id, Point screen_position) =| |     WM_PopupWindowMenu(i32 client_id, i32 window_id, Gfx::Point screen_position) =| | ||||||
|     WM_SetWindowTaskbarRect(i32 client_id, i32 window_id, Rect rect) =| |     WM_SetWindowTaskbarRect(i32 client_id, i32 window_id, Gfx::Rect rect) =| | ||||||
| 
 | 
 | ||||||
|     SetWindowHasAlphaChannel(i32 window_id, bool has_alpha_channel) => () |     SetWindowHasAlphaChannel(i32 window_id, bool has_alpha_channel) => () | ||||||
|     MoveWindowToFront(i32 window_id) => () |     MoveWindowToFront(i32 window_id) => () | ||||||
|     SetFullscreen(i32 window_id, bool fullscreen) => () |     SetFullscreen(i32 window_id, bool fullscreen) => () | ||||||
|     PopupMenu(i32 menu_id, Point screen_position) => () |     PopupMenu(i32 menu_id, Gfx::Point screen_position) => () | ||||||
|     DismissMenu(i32 menu_id) => () |     DismissMenu(i32 menu_id) => () | ||||||
| 
 | 
 | ||||||
|     AsyncSetWallpaper(String path) =| |     AsyncSetWallpaper(String path) =| | ||||||
|     SetResolution(Size resolution) => () |     SetResolution(Gfx::Size resolution) => () | ||||||
|     SetWindowIconBitmap(i32 window_id, i32 icon_buffer_id, Size icon_size) => () |     SetWindowIconBitmap(i32 window_id, i32 icon_buffer_id, Gfx::Size icon_size) => () | ||||||
| 
 | 
 | ||||||
|     GetWallpaper() => (String path) |     GetWallpaper() => (String path) | ||||||
|     SetWindowOverrideCursor(i32 window_id, i32 cursor_type) => () |     SetWindowOverrideCursor(i32 window_id, i32 cursor_type) => () | ||||||
| 
 | 
 | ||||||
|     StartDrag(String text, String data_type, String data, i32 bitmap_id, Size bitmap_size) => (bool started) |     StartDrag(String text, String data_type, String data, i32 bitmap_id, Gfx::Size bitmap_size) => (bool started) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling