mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much better visual clue about what type of metric is being used.
This commit is contained in:
parent
656b01eb0f
commit
116cf92156
212 changed files with 1144 additions and 1144 deletions
|
@ -140,7 +140,7 @@ Window& Menu::ensure_menu_window()
|
|||
|
||||
int width = this->content_width();
|
||||
|
||||
Gfx::Point next_item_location(frame_thickness(), frame_thickness());
|
||||
Gfx::IntPoint next_item_location(frame_thickness(), frame_thickness());
|
||||
for (auto& item : m_items) {
|
||||
int height = 0;
|
||||
if (item.type() == MenuItem::Text)
|
||||
|
@ -186,7 +186,7 @@ void Menu::draw()
|
|||
ASSERT(menu_window()->backing_store());
|
||||
Gfx::Painter painter(*menu_window()->backing_store());
|
||||
|
||||
Gfx::Rect rect { {}, menu_window()->size() };
|
||||
Gfx::IntRect rect { {}, menu_window()->size() };
|
||||
Gfx::StylePainter::paint_window_frame(painter, rect, palette);
|
||||
painter.fill_rect(rect.shrunken(6, 6), palette.menu_base());
|
||||
int width = this->content_width();
|
||||
|
@ -201,7 +201,7 @@ void Menu::draw()
|
|||
has_items_with_icon = has_items_with_icon | !!item.icon();
|
||||
}
|
||||
|
||||
Gfx::Rect stripe_rect { frame_thickness(), frame_thickness(), s_stripe_width, menu_window()->height() - frame_thickness() * 2 };
|
||||
Gfx::IntRect stripe_rect { frame_thickness(), frame_thickness(), s_stripe_width, menu_window()->height() - frame_thickness() * 2 };
|
||||
painter.fill_rect(stripe_rect, palette.menu_stripe());
|
||||
painter.draw_line(stripe_rect.top_right(), stripe_rect.bottom_right(), palette.menu_stripe().darkened());
|
||||
|
||||
|
@ -210,9 +210,9 @@ void Menu::draw()
|
|||
if (is_scrollable()) {
|
||||
bool can_go_up = m_scroll_offset > 0;
|
||||
bool can_go_down = m_scroll_offset < m_max_scroll_offset;
|
||||
Gfx::Rect up_indicator_rect { frame_thickness(), frame_thickness(), content_width(), item_height() };
|
||||
Gfx::IntRect up_indicator_rect { frame_thickness(), frame_thickness(), content_width(), item_height() };
|
||||
painter.draw_text(up_indicator_rect, "\xE2\xAC\x86", Gfx::TextAlignment::Center, can_go_up ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
|
||||
Gfx::Rect down_indicator_rect { frame_thickness(), menu_window()->height() - item_height() - frame_thickness(), content_width(), item_height() };
|
||||
Gfx::IntRect down_indicator_rect { frame_thickness(), menu_window()->height() - item_height() - frame_thickness(), content_width(), item_height() };
|
||||
painter.draw_text(down_indicator_rect, "\xE2\xAC\x87", Gfx::TextAlignment::Center, can_go_down ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
|
||||
}
|
||||
|
||||
|
@ -227,16 +227,16 @@ void Menu::draw()
|
|||
} else if (!item.is_enabled()) {
|
||||
text_color = Color::MidGray;
|
||||
}
|
||||
Gfx::Rect text_rect = item.rect().translated(stripe_rect.width() + 6, 0);
|
||||
Gfx::IntRect text_rect = item.rect().translated(stripe_rect.width() + 6, 0);
|
||||
if (item.is_checkable()) {
|
||||
if (item.is_exclusive()) {
|
||||
Gfx::Rect radio_rect { item.rect().x() + 5, 0, 12, 12 };
|
||||
Gfx::IntRect radio_rect { item.rect().x() + 5, 0, 12, 12 };
|
||||
radio_rect.center_vertically_within(text_rect);
|
||||
Gfx::StylePainter::paint_radio_button(painter, radio_rect, palette, item.is_checked(), false);
|
||||
} else {
|
||||
Gfx::Rect checkmark_rect { item.rect().x() + 7, 0, s_checked_bitmap_width, s_checked_bitmap_height };
|
||||
Gfx::IntRect checkmark_rect { item.rect().x() + 7, 0, s_checked_bitmap_width, s_checked_bitmap_height };
|
||||
checkmark_rect.center_vertically_within(text_rect);
|
||||
Gfx::Rect checkbox_rect = checkmark_rect.inflated(4, 4);
|
||||
Gfx::IntRect checkbox_rect = checkmark_rect.inflated(4, 4);
|
||||
painter.fill_rect(checkbox_rect, palette.base());
|
||||
Gfx::StylePainter::paint_frame(painter, checkbox_rect, palette, Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2);
|
||||
if (item.is_checked()) {
|
||||
|
@ -244,7 +244,7 @@ void Menu::draw()
|
|||
}
|
||||
}
|
||||
} else if (item.icon()) {
|
||||
Gfx::Rect icon_rect { item.rect().x() + 3, 0, s_item_icon_width, s_item_icon_width };
|
||||
Gfx::IntRect icon_rect { item.rect().x() + 3, 0, s_item_icon_width, s_item_icon_width };
|
||||
icon_rect.center_vertically_within(text_rect);
|
||||
painter.blit(icon_rect.location(), *item.icon(), item.icon()->rect());
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ void Menu::draw()
|
|||
}
|
||||
if (item.is_submenu()) {
|
||||
static auto& submenu_arrow_bitmap = Gfx::CharacterBitmap::create_from_ascii(s_submenu_arrow_bitmap_data, s_submenu_arrow_bitmap_width, s_submenu_arrow_bitmap_height).leak_ref();
|
||||
Gfx::Rect submenu_arrow_rect {
|
||||
Gfx::IntRect submenu_arrow_rect {
|
||||
item.rect().right() - s_submenu_arrow_bitmap_width - 2,
|
||||
0,
|
||||
s_submenu_arrow_bitmap_width,
|
||||
|
@ -264,8 +264,8 @@ void Menu::draw()
|
|||
painter.draw_bitmap(submenu_arrow_rect.location(), submenu_arrow_bitmap, text_color);
|
||||
}
|
||||
} else if (item.type() == MenuItem::Separator) {
|
||||
Gfx::Point p1(item.rect().translated(stripe_rect.width() + 4, 0).x(), item.rect().center().y() - 1);
|
||||
Gfx::Point p2(width - 7, item.rect().center().y() - 1);
|
||||
Gfx::IntPoint p1(item.rect().translated(stripe_rect.width() + 4, 0).x(), item.rect().center().y() - 1);
|
||||
Gfx::IntPoint p2(width - 7, item.rect().center().y() - 1);
|
||||
painter.draw_line(p1, p2, palette.threed_shadow1());
|
||||
painter.draw_line(p1.translated(0, 1), p2.translated(0, 1), palette.threed_highlight());
|
||||
}
|
||||
|
@ -320,8 +320,8 @@ void Menu::handle_mouse_move_event(const MouseEvent& mouse_event)
|
|||
if (hovered_item() && hovered_item()->is_submenu()) {
|
||||
|
||||
auto item = *hovered_item();
|
||||
auto submenu_top_left = item.rect().location() + Gfx::Point { item.rect().width(), 0 };
|
||||
auto submenu_bottom_left = submenu_top_left + Gfx::Point { 0, item.submenu()->menu_window()->height() };
|
||||
auto submenu_top_left = item.rect().location() + Gfx::IntPoint { item.rect().width(), 0 };
|
||||
auto submenu_bottom_left = submenu_top_left + Gfx::IntPoint { 0, item.submenu()->menu_window()->height() };
|
||||
|
||||
auto safe_hover_triangle = Gfx::Triangle { m_last_position_in_hover, submenu_top_left, submenu_bottom_left };
|
||||
m_last_position_in_hover = mouse_event.position();
|
||||
|
@ -467,7 +467,7 @@ MenuItem* Menu::item_with_identifier(unsigned identifer)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
int Menu::item_index_at(const Gfx::Point& position)
|
||||
int Menu::item_index_at(const Gfx::IntPoint& position)
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& item : m_items) {
|
||||
|
@ -489,7 +489,7 @@ void Menu::redraw_if_theme_changed()
|
|||
redraw();
|
||||
}
|
||||
|
||||
void Menu::popup(const Gfx::Point& position)
|
||||
void Menu::popup(const Gfx::IntPoint& position)
|
||||
{
|
||||
if (is_empty()) {
|
||||
dbg() << "Menu: Empty menu popup";
|
||||
|
@ -500,7 +500,7 @@ void Menu::popup(const Gfx::Point& position)
|
|||
redraw_if_theme_changed();
|
||||
|
||||
const int margin = 30;
|
||||
Gfx::Point adjusted_pos = position;
|
||||
Gfx::IntPoint adjusted_pos = position;
|
||||
|
||||
if (adjusted_pos.x() + window.width() >= Screen::the().width() - margin) {
|
||||
adjusted_pos = adjusted_pos.translated(-window.width(), 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue