mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45: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
Notes:
sideshowbarker
2024-07-19 05:43:51 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/116cf921560
212 changed files with 1144 additions and 1144 deletions
|
@ -120,7 +120,7 @@ void BookmarksBarWidget::did_update_model()
|
|||
auto title = model()->data(model()->index(item_index, 0)).to_string();
|
||||
auto url = model()->data(model()->index(item_index, 1)).to_string();
|
||||
|
||||
Gfx::Rect rect { width, 0, font().width(title) + 32, height() };
|
||||
Gfx::IntRect rect { width, 0, font().width(title) + 32, height() };
|
||||
|
||||
auto& button = add<GUI::Button>();
|
||||
m_bookmarks.append(button);
|
||||
|
|
|
@ -409,7 +409,7 @@ void Tab::did_become_active()
|
|||
GUI::Application::the().set_menubar(m_menubar);
|
||||
}
|
||||
|
||||
void Tab::context_menu_requested(const Gfx::Point& screen_position)
|
||||
void Tab::context_menu_requested(const Gfx::IntPoint& screen_position)
|
||||
{
|
||||
m_tab_context_menu->popup(screen_position);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
void load(const URL&);
|
||||
|
||||
void did_become_active();
|
||||
void context_menu_requested(const Gfx::Point& screen_position);
|
||||
void context_menu_requested(const Gfx::IntPoint& screen_position);
|
||||
|
||||
Function<void(String)> on_title_change;
|
||||
Function<void(const URL&)> on_tab_open_request;
|
||||
|
|
|
@ -249,16 +249,16 @@ void CalendarWidget::CalendarTile::paint_event(GUI::PaintEvent& event)
|
|||
painter.draw_line(frame_inner_rect().top_left(), frame_inner_rect().top_right(), Color::NamedColor::Black);
|
||||
painter.draw_line(frame_inner_rect().bottom_left(), frame_inner_rect().bottom_right(), Color::NamedColor::Black);
|
||||
|
||||
Gfx::Rect day_rect = Gfx::Rect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4);
|
||||
Gfx::IntRect day_rect = Gfx::IntRect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4);
|
||||
|
||||
int weekday_characters_width = (font().glyph_width('0') * (m_weekday_name.length() + 1)) + 4;
|
||||
if (m_display_weekday_name && (frame_inner_rect().height() > (font().glyph_height() + 4) * 2) && (frame_inner_rect().width() > weekday_characters_width)) {
|
||||
auto weekday_rect = Gfx::Rect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4);
|
||||
auto weekday_rect = Gfx::IntRect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4);
|
||||
weekday_rect.set_top(frame_inner_rect().y() + 2);
|
||||
painter.draw_text(weekday_rect, m_weekday_name, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text());
|
||||
day_rect.set_y(frame_inner_rect().y() + 15);
|
||||
} else {
|
||||
day_rect = Gfx::Rect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4);
|
||||
day_rect = Gfx::IntRect(frame_inner_rect().x(), frame_inner_rect().y(), frame_inner_rect().width(), font().glyph_height() + 4);
|
||||
day_rect.set_y(frame_inner_rect().y() + 4);
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ void CalendarWidget::CalendarTile::paint_event(GUI::PaintEvent& event)
|
|||
auto display_date = (m_date_time.day() == 1 && frame_inner_rect().width() > highlight_rect_width) ? m_display_date : String::number(m_date_time.day());
|
||||
|
||||
if (m_calendar.is_today(m_date_time)) {
|
||||
auto highlight_rect = Gfx::Rect(day_rect.width() / 2 - (highlight_rect_width / 2), day_rect.y(), highlight_rect_width, font().glyph_height() + 4);
|
||||
auto highlight_rect = Gfx::IntRect(day_rect.width() / 2 - (highlight_rect_width / 2), day_rect.y(), highlight_rect_width, font().glyph_height() + 4);
|
||||
painter.draw_rect(highlight_rect, palette().base_text());
|
||||
painter.draw_text(day_rect, display_date, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text());
|
||||
} else
|
||||
|
|
|
@ -198,7 +198,7 @@ void DisplaySettingsWidget::create_frame()
|
|||
m_resolution_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_resolution_combo->set_preferred_size(0, 22);
|
||||
m_resolution_combo->set_only_allow_values_from_model(true);
|
||||
m_resolution_combo->set_model(*ItemListModel<Gfx::Size>::create(m_resolutions));
|
||||
m_resolution_combo->set_model(*ItemListModel<Gfx::IntSize>::create(m_resolutions));
|
||||
m_resolution_combo->on_change = [this](auto&, const GUI::ModelIndex& index) {
|
||||
this->m_monitor_widget->set_desktop_resolution(m_resolutions.at(index.row()));
|
||||
this->m_monitor_widget->update();
|
||||
|
@ -301,7 +301,7 @@ void DisplaySettingsWidget::load_current_settings()
|
|||
}
|
||||
|
||||
/// Resolution ////////////////////////////////////////////////////////////////////////////////
|
||||
Gfx::Size find_size;
|
||||
Gfx::IntSize find_size;
|
||||
|
||||
bool okay = false;
|
||||
// Let's attempt to find the current resolution and select it!
|
||||
|
@ -318,7 +318,7 @@ void DisplaySettingsWidget::load_current_settings()
|
|||
}
|
||||
|
||||
size_t index = m_resolutions.find_first_index(find_size).value_or(0);
|
||||
Gfx::Size m_current_resolution = m_resolutions.at(index);
|
||||
Gfx::IntSize m_current_resolution = m_resolutions.at(index);
|
||||
m_monitor_widget->set_desktop_resolution(m_current_resolution);
|
||||
m_resolution_combo->set_selected_index(index);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
|
||||
Vector<String> m_wallpapers;
|
||||
Vector<String> m_modes;
|
||||
Vector<Gfx::Size> m_resolutions;
|
||||
Vector<Gfx::IntSize> m_resolutions;
|
||||
|
||||
RefPtr<GUI::Widget> m_root_widget;
|
||||
RefPtr<MonitorWidget> m_monitor_widget;
|
||||
|
|
|
@ -54,12 +54,12 @@ String MonitorWidget::wallpaper_mode()
|
|||
return m_desktop_wallpaper_mode;
|
||||
}
|
||||
|
||||
void MonitorWidget::set_desktop_resolution(Gfx::Size resolution)
|
||||
void MonitorWidget::set_desktop_resolution(Gfx::IntSize resolution)
|
||||
{
|
||||
m_desktop_resolution = resolution;
|
||||
}
|
||||
|
||||
Gfx::Size MonitorWidget::desktop_resolution()
|
||||
Gfx::IntSize MonitorWidget::desktop_resolution()
|
||||
{
|
||||
return m_desktop_resolution;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ Gfx::Color MonitorWidget::background_color()
|
|||
|
||||
void MonitorWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
Gfx::Rect screen_rect = { 0, 0, m_desktop_resolution.width(), m_desktop_resolution.height() };
|
||||
Gfx::IntRect screen_rect = { 0, 0, m_desktop_resolution.width(), m_desktop_resolution.height() };
|
||||
auto screen_bitmap = Gfx::Bitmap::create(m_monitor_bitmap->format(), m_desktop_resolution);
|
||||
GUI::Painter screen_painter(*screen_bitmap);
|
||||
screen_painter.fill_rect(screen_rect, m_desktop_color);
|
||||
|
@ -85,7 +85,7 @@ void MonitorWidget::paint_event(GUI::PaintEvent& event)
|
|||
if (m_desktop_wallpaper_mode == "simple") {
|
||||
screen_painter.blit({ 0, 0 }, *m_desktop_wallpaper_bitmap, m_desktop_wallpaper_bitmap->rect());
|
||||
} else if (m_desktop_wallpaper_mode == "center") {
|
||||
Gfx::Point offset { screen_rect.width() / 2 - m_desktop_wallpaper_bitmap->size().width() / 2, screen_rect.height() / 2 - m_desktop_wallpaper_bitmap->size().height() / 2 };
|
||||
Gfx::IntPoint offset { screen_rect.width() / 2 - m_desktop_wallpaper_bitmap->size().width() / 2, screen_rect.height() / 2 - m_desktop_wallpaper_bitmap->size().height() / 2 };
|
||||
screen_painter.blit_offset(screen_rect.location(), *m_desktop_wallpaper_bitmap, screen_rect, offset);
|
||||
} else if (m_desktop_wallpaper_mode == "tile") {
|
||||
screen_painter.draw_tiled_bitmap(screen_bitmap->rect(), *m_desktop_wallpaper_bitmap);
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
void set_wallpaper_mode(String mode);
|
||||
String wallpaper_mode();
|
||||
|
||||
void set_desktop_resolution(Gfx::Size resolution);
|
||||
Gfx::Size desktop_resolution();
|
||||
void set_desktop_resolution(Gfx::IntSize resolution);
|
||||
Gfx::IntSize desktop_resolution();
|
||||
|
||||
void set_background_color(Gfx::Color background_color);
|
||||
Gfx::Color background_color();
|
||||
|
@ -50,12 +50,12 @@ public:
|
|||
private:
|
||||
virtual void paint_event(GUI::PaintEvent& event) override;
|
||||
|
||||
Gfx::Rect m_monitor_rect;
|
||||
Gfx::IntRect m_monitor_rect;
|
||||
RefPtr<Gfx::Bitmap> m_monitor_bitmap;
|
||||
|
||||
String m_desktop_wallpaper_path;
|
||||
RefPtr<Gfx::Bitmap> m_desktop_wallpaper_bitmap;
|
||||
String m_desktop_wallpaper_mode;
|
||||
Gfx::Size m_desktop_resolution;
|
||||
Gfx::IntSize m_desktop_resolution;
|
||||
Gfx::Color m_desktop_color;
|
||||
};
|
||||
|
|
|
@ -68,7 +68,7 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
for (int y = 0; y < font().glyph_height(); ++y) {
|
||||
for (int x = 0; x < font().max_glyph_width(); ++x) {
|
||||
Gfx::Rect rect { x * m_scale, y * m_scale, m_scale, m_scale };
|
||||
Gfx::IntRect rect { x * m_scale, y * m_scale, m_scale, m_scale };
|
||||
if (x >= font().glyph_width(m_glyph)) {
|
||||
painter.fill_rect(rect, palette().threed_shadow1());
|
||||
} else {
|
||||
|
|
|
@ -60,11 +60,11 @@ void GlyphMapWidget::set_selected_glyph(int glyph)
|
|||
update();
|
||||
}
|
||||
|
||||
Gfx::Rect GlyphMapWidget::get_outer_rect(int glyph) const
|
||||
Gfx::IntRect GlyphMapWidget::get_outer_rect(int glyph) const
|
||||
{
|
||||
int row = glyph / columns();
|
||||
int column = glyph % columns();
|
||||
return Gfx::Rect {
|
||||
return Gfx::IntRect {
|
||||
column * (font().max_glyph_width() + m_horizontal_spacing) + 1,
|
||||
row * (font().glyph_height() + m_vertical_spacing) + 1,
|
||||
font().max_glyph_width() + m_horizontal_spacing,
|
||||
|
@ -89,8 +89,8 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event)
|
|||
painter.fill_rect(frame_inner_rect(), palette().base());
|
||||
|
||||
for (int glyph = 0; glyph < m_glyph_count; ++glyph) {
|
||||
Gfx::Rect outer_rect = get_outer_rect(glyph);
|
||||
Gfx::Rect inner_rect(
|
||||
Gfx::IntRect outer_rect = get_outer_rect(glyph);
|
||||
Gfx::IntRect inner_rect(
|
||||
outer_rect.x() + m_horizontal_spacing / 2,
|
||||
outer_rect.y() + m_vertical_spacing / 2,
|
||||
font().max_glyph_width(),
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
|
||||
Gfx::Rect get_outer_rect(int glyph) const;
|
||||
Gfx::IntRect get_outer_rect(int glyph) const;
|
||||
|
||||
RefPtr<Gfx::Font> m_font;
|
||||
int m_glyph_count;
|
||||
|
|
|
@ -336,7 +336,7 @@ void HexEditor::scroll_position_into_view(int position)
|
|||
{
|
||||
int y = position / bytes_per_row();
|
||||
int x = position % bytes_per_row();
|
||||
Gfx::Rect rect {
|
||||
Gfx::IntRect rect {
|
||||
frame_thickness() + offset_margin_width() + (x * (character_width() * 3)) + 10,
|
||||
frame_thickness() + 5 + (y * line_height()),
|
||||
(character_width() * 3),
|
||||
|
@ -490,7 +490,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
painter.translate(frame_thickness(), frame_thickness());
|
||||
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
||||
Gfx::Rect offset_clip_rect {
|
||||
Gfx::IntRect offset_clip_rect {
|
||||
0,
|
||||
vertical_scrollbar().value(),
|
||||
85,
|
||||
|
@ -510,7 +510,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
// paint offsets
|
||||
for (int i = min_row; i < max_row; i++) {
|
||||
Gfx::Rect side_offset_rect {
|
||||
Gfx::IntRect side_offset_rect {
|
||||
frame_thickness() + 5,
|
||||
frame_thickness() + 5 + (i * line_height()),
|
||||
width() - width_occupied_by_vertical_scrollbar(),
|
||||
|
@ -548,7 +548,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::Rect hex_display_rect {
|
||||
Gfx::IntRect hex_display_rect {
|
||||
frame_thickness() + offset_margin_width() + (j * (character_width() * 3)) + 10,
|
||||
frame_thickness() + 5 + (i * line_height()),
|
||||
(character_width() * 3),
|
||||
|
@ -565,7 +565,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
|
|||
auto line = String::format("%02X", m_buffer[byte_position]);
|
||||
painter.draw_text(hex_display_rect, line, Gfx::TextAlignment::TopLeft, text_color);
|
||||
|
||||
Gfx::Rect text_display_rect {
|
||||
Gfx::IntRect text_display_rect {
|
||||
frame_thickness() + offset_margin_width() + (bytes_per_row() * (character_width() * 3)) + (j * character_width()) + 20,
|
||||
frame_thickness() + 5 + (i * line_height()),
|
||||
character_width(),
|
||||
|
|
|
@ -50,7 +50,7 @@ void KeyButton::paint_event(GUI::PaintEvent& event)
|
|||
painter.fill_rect(content_rect, Color::from_rgb(0x8C7272));
|
||||
|
||||
if (!text().is_empty()) {
|
||||
Gfx::Rect text_rect { 0, 0, font.width(text()), font.glyph_height() };
|
||||
Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() };
|
||||
text_rect.align_within(content_rect, Gfx::TextAlignment::Center);
|
||||
|
||||
auto clipped_rect = rect().intersected(this->rect());
|
||||
|
|
|
@ -58,7 +58,7 @@ void KeyboardMapperWidget::create_frame()
|
|||
m_keys.resize(KEY_COUNT);
|
||||
|
||||
for (unsigned i = 0; i < KEY_COUNT; i++) {
|
||||
Gfx::Rect rect = { keys[i].x, keys[i].y, keys[i].width, keys[i].height };
|
||||
Gfx::IntRect rect = { keys[i].x, keys[i].y, keys[i].width, keys[i].height };
|
||||
|
||||
auto& tmp_button = main_widget.add<KeyButton>();
|
||||
tmp_button.set_relative_rect(rect);
|
||||
|
|
|
@ -179,7 +179,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
|
|||
int x = 0;
|
||||
int i = 0;
|
||||
for (;;) {
|
||||
Gfx::Rect rect(x, 0, white_key_width, frame_inner_rect().height());
|
||||
Gfx::IntRect rect(x, 0, white_key_width, frame_inner_rect().height());
|
||||
painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::White);
|
||||
painter.draw_rect(rect, Color::Black);
|
||||
if (i < white_key_labels_count) {
|
||||
|
@ -201,7 +201,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
|
|||
x = white_key_width - black_key_x_offset;
|
||||
i = 0;
|
||||
for (;;) {
|
||||
Gfx::Rect rect(x, 0, black_key_width, black_key_height);
|
||||
Gfx::IntRect rect(x, 0, black_key_width, black_key_height);
|
||||
painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::Black);
|
||||
painter.draw_rect(rect, Color::Black);
|
||||
if (i < black_key_labels_count) {
|
||||
|
@ -245,7 +245,7 @@ static inline int note_from_white_keys(int white_keys)
|
|||
return note;
|
||||
}
|
||||
|
||||
int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const
|
||||
int KeysWidget::note_for_event_position(const Gfx::IntPoint& a_point) const
|
||||
{
|
||||
if (!frame_inner_rect().contains(a_point))
|
||||
return -1;
|
||||
|
@ -259,7 +259,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;
|
||||
if (black_key_on_left) {
|
||||
int black_key_x = (white_keys * white_key_width) - black_key_x_offset;
|
||||
Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height);
|
||||
Gfx::IntRect black_key(black_key_x, 0, black_key_width, black_key_height);
|
||||
if (black_key.contains(point))
|
||||
return note - 1;
|
||||
}
|
||||
|
@ -267,7 +267,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;
|
||||
if (black_key_on_right) {
|
||||
int black_key_x = ((white_keys + 1) * white_key_width) - black_key_x_offset;
|
||||
Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height);
|
||||
Gfx::IntRect black_key(black_key_x, 0, black_key_width, black_key_height);
|
||||
if (black_key.contains(point))
|
||||
return note + 1;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
|
||||
int note_for_event_position(const Gfx::Point&) const;
|
||||
int note_for_event_position(const Gfx::IntPoint&) const;
|
||||
|
||||
AudioEngine& m_audio_engine;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
|
|||
int x_pos = x * m_note_width;
|
||||
int next_x_pos = (x + 1) * m_note_width;
|
||||
int distance_to_next_x = next_x_pos - x_pos;
|
||||
Gfx::Rect rect(x_pos, y_pos, distance_to_next_x, note_height);
|
||||
Gfx::IntRect rect(x_pos, y_pos, distance_to_next_x, note_height);
|
||||
|
||||
if (key_pattern[key_pattern_index] == Black)
|
||||
painter.fill_rect(rect, Color::LightGray);
|
||||
|
@ -128,7 +128,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
|
|||
int y = ((note_count - 1) - note) * note_height;
|
||||
int height = note_height;
|
||||
|
||||
Gfx::Rect rect(x, y, width, height);
|
||||
Gfx::IntRect rect(x, y, width, height);
|
||||
painter.fill_rect(rect, note_pressed_color);
|
||||
painter.draw_rect(rect, Color::Black);
|
||||
}
|
||||
|
|
|
@ -74,12 +74,12 @@ void WaveEditor::paint_event(GUI::PaintEvent& event)
|
|||
int left_y = sample_to_y(recorded_sample[x].left);
|
||||
int right_y = sample_to_y(recorded_sample[x].right);
|
||||
|
||||
Gfx::Point left_point1(prev_x * width_scale, left_prev_y);
|
||||
Gfx::Point left_point2(x * width_scale, left_y);
|
||||
Gfx::IntPoint left_point1(prev_x * width_scale, left_prev_y);
|
||||
Gfx::IntPoint left_point2(x * width_scale, left_y);
|
||||
painter.draw_line(left_point1, left_point2, left_wave_colors[RecordedSample]);
|
||||
|
||||
Gfx::Point right_point1(prev_x * width_scale, right_prev_y);
|
||||
Gfx::Point right_point2(x * width_scale, right_y);
|
||||
Gfx::IntPoint right_point1(prev_x * width_scale, right_prev_y);
|
||||
Gfx::IntPoint right_point2(x * width_scale, right_y);
|
||||
painter.draw_line(right_point1, right_point2, right_wave_colors[RecordedSample]);
|
||||
|
||||
prev_x = x;
|
||||
|
|
|
@ -71,12 +71,12 @@ void WaveWidget::paint_event(GUI::PaintEvent& event)
|
|||
int y_left = sample_to_y(buffer[x].left);
|
||||
int y_right = sample_to_y(buffer[x].right);
|
||||
|
||||
Gfx::Point point1_left(prev_x * width_scale, prev_y_left);
|
||||
Gfx::Point point2_left(x * width_scale, y_left);
|
||||
Gfx::IntPoint point1_left(prev_x * width_scale, prev_y_left);
|
||||
Gfx::IntPoint point2_left(x * width_scale, y_left);
|
||||
painter.draw_line(point1_left, point2_left, left_wave_color);
|
||||
|
||||
Gfx::Point point1_right(prev_x * width_scale, prev_y_right);
|
||||
Gfx::Point point2_right(x * width_scale, y_right);
|
||||
Gfx::IntPoint point1_right(prev_x * width_scale, prev_y_right);
|
||||
Gfx::IntPoint point2_right(x * width_scale, y_right);
|
||||
painter.draw_line(point1_right, point2_right, right_wave_color);
|
||||
|
||||
prev_x = x;
|
||||
|
|
|
@ -43,7 +43,7 @@ BucketTool::~BucketTool()
|
|||
{
|
||||
}
|
||||
|
||||
static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Color target_color, Color fill_color)
|
||||
static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::IntPoint& start_position, Color target_color, Color fill_color)
|
||||
{
|
||||
ASSERT(bitmap.bpp() == 32);
|
||||
|
||||
|
@ -53,7 +53,7 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Co
|
|||
if (!bitmap.rect().contains(start_position))
|
||||
return;
|
||||
|
||||
Queue<Gfx::Point> queue;
|
||||
Queue<Gfx::IntPoint> queue;
|
||||
queue.enqueue(start_position);
|
||||
while (!queue.is_empty()) {
|
||||
auto position = queue.dequeue();
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
CreateNewLayerDialog::CreateNewLayerDialog(const Gfx::Size& suggested_size, GUI::Window* parent_window)
|
||||
CreateNewLayerDialog::CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window)
|
||||
: Dialog(parent_window)
|
||||
{
|
||||
set_title("Create new layer");
|
||||
|
|
|
@ -33,13 +33,13 @@ namespace PixelPaint {
|
|||
class CreateNewLayerDialog final : public GUI::Dialog {
|
||||
C_OBJECT(CreateNewLayerDialog);
|
||||
public:
|
||||
const Gfx::Size& layer_size() const { return m_layer_size; }
|
||||
const Gfx::IntSize& layer_size() const { return m_layer_size; }
|
||||
const String& layer_name() const { return m_layer_name; }
|
||||
|
||||
private:
|
||||
CreateNewLayerDialog(const Gfx::Size& suggested_size, GUI::Window* parent_window);
|
||||
CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window);
|
||||
|
||||
Gfx::Size m_layer_size;
|
||||
Gfx::IntSize m_layer_size;
|
||||
String m_layer_name;
|
||||
|
||||
RefPtr<GUI::TextBox> m_name_textbox;
|
||||
|
|
|
@ -43,7 +43,7 @@ EllipseTool::~EllipseTool()
|
|||
{
|
||||
}
|
||||
|
||||
void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::Rect& ellipse_intersecting_rect)
|
||||
void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& ellipse_intersecting_rect)
|
||||
{
|
||||
switch (m_mode) {
|
||||
case Mode::Outline:
|
||||
|
@ -72,7 +72,7 @@ void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve
|
|||
{
|
||||
if (event.button() == m_drawing_button) {
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
draw_using(painter, Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position));
|
||||
draw_using(painter, Gfx::IntRect::from_two_points(m_ellipse_start_position, m_ellipse_end_position));
|
||||
m_drawing_button = GUI::MouseButton::None;
|
||||
m_editor->update();
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void EllipseTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event)
|
|||
painter.add_clip_rect(event.rect());
|
||||
auto preview_start = m_editor->layer_position_to_editor_position(layer, m_ellipse_start_position).to_int_point();
|
||||
auto preview_end = m_editor->layer_position_to_editor_position(layer, m_ellipse_end_position).to_int_point();
|
||||
draw_using(painter, Gfx::Rect::from_two_points(preview_start, preview_end));
|
||||
draw_using(painter, Gfx::IntRect::from_two_points(preview_start, preview_end));
|
||||
}
|
||||
|
||||
void EllipseTool::on_keydown(GUI::KeyEvent& event)
|
||||
|
|
|
@ -51,11 +51,11 @@ private:
|
|||
};
|
||||
|
||||
virtual const char* class_name() const override { return "EllipseTool"; }
|
||||
void draw_using(GUI::Painter&, const Gfx::Rect&);
|
||||
void draw_using(GUI::Painter&, const Gfx::IntRect&);
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
Gfx::Point m_ellipse_start_position;
|
||||
Gfx::Point m_ellipse_end_position;
|
||||
Gfx::IntPoint m_ellipse_start_position;
|
||||
Gfx::IntPoint m_ellipse_end_position;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
int m_thickness { 1 };
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
|
@ -42,21 +42,21 @@ EraseTool::~EraseTool()
|
|||
{
|
||||
}
|
||||
|
||||
Gfx::Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect)
|
||||
Gfx::IntRect EraseTool::build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect)
|
||||
{
|
||||
const int base_eraser_size = 10;
|
||||
const int eraser_size = (base_eraser_size * m_thickness);
|
||||
const int eraser_radius = eraser_size / 2;
|
||||
const auto ex = pos.x();
|
||||
const auto ey = pos.y();
|
||||
return Gfx::Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect);
|
||||
return Gfx::IntRect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect);
|
||||
}
|
||||
|
||||
void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||
{
|
||||
if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right)
|
||||
return;
|
||||
Gfx::Rect r = build_rect(event.position(), layer.rect());
|
||||
Gfx::IntRect r = build_rect(event.position(), layer.rect());
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
painter.clear_rect(r, get_color());
|
||||
layer.did_modify_bitmap(*m_editor->image());
|
||||
|
@ -65,7 +65,7 @@ void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve
|
|||
void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||
{
|
||||
if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) {
|
||||
Gfx::Rect r = build_rect(event.position(), layer.rect());
|
||||
Gfx::IntRect r = build_rect(event.position(), layer.rect());
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
painter.clear_rect(r, get_color());
|
||||
layer.did_modify_bitmap(*m_editor->image());
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
private:
|
||||
Gfx::Color get_color() const;
|
||||
virtual const char* class_name() const override { return "EraseTool"; }
|
||||
Gfx::Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect);
|
||||
Gfx::IntRect build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect);
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
|
||||
bool m_use_secondary_color { false };
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
RefPtr<Image> Image::create_with_size(const Gfx::Size& size)
|
||||
RefPtr<Image> Image::create_with_size(const Gfx::IntSize& size)
|
||||
{
|
||||
if (size.is_empty())
|
||||
return nullptr;
|
||||
|
@ -43,12 +43,12 @@ RefPtr<Image> Image::create_with_size(const Gfx::Size& size)
|
|||
return adopt(*new Image(size));
|
||||
}
|
||||
|
||||
Image::Image(const Gfx::Size& size)
|
||||
Image::Image(const Gfx::IntSize& size)
|
||||
: m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
void Image::paint_into(GUI::Painter& painter, const Gfx::Rect& dest_rect)
|
||||
void Image::paint_into(GUI::Painter& painter, const Gfx::IntRect& dest_rect)
|
||||
{
|
||||
float scale = (float)dest_rect.width() / (float)rect().width();
|
||||
Gfx::PainterStateSaver saver(painter);
|
||||
|
|
|
@ -51,18 +51,18 @@ public:
|
|||
|
||||
class Image : public RefCounted<Image> {
|
||||
public:
|
||||
static RefPtr<Image> create_with_size(const Gfx::Size&);
|
||||
static RefPtr<Image> create_with_size(const Gfx::IntSize&);
|
||||
|
||||
size_t layer_count() const { return m_layers.size(); }
|
||||
const Layer& layer(size_t index) const { return m_layers.at(index); }
|
||||
Layer& layer(size_t index) { return m_layers.at(index); }
|
||||
|
||||
const Gfx::Size& size() const { return m_size; }
|
||||
Gfx::Rect rect() const { return { {}, m_size }; }
|
||||
const Gfx::IntSize& size() const { return m_size; }
|
||||
Gfx::IntRect rect() const { return { {}, m_size }; }
|
||||
|
||||
void add_layer(NonnullRefPtr<Layer>);
|
||||
|
||||
void paint_into(GUI::Painter&, const Gfx::Rect& dest_rect);
|
||||
void paint_into(GUI::Painter&, const Gfx::IntRect& dest_rect);
|
||||
|
||||
void move_layer_to_front(Layer&);
|
||||
void move_layer_to_back(Layer&);
|
||||
|
@ -79,12 +79,12 @@ public:
|
|||
size_t index_of(const Layer&) const;
|
||||
|
||||
private:
|
||||
explicit Image(const Gfx::Size&);
|
||||
explicit Image(const Gfx::IntSize&);
|
||||
|
||||
void did_change();
|
||||
void did_modify_layer_stack();
|
||||
|
||||
Gfx::Size m_size;
|
||||
Gfx::IntSize m_size;
|
||||
NonnullRefPtrVector<Layer> m_layers;
|
||||
|
||||
HashTable<ImageClient*> m_clients;
|
||||
|
|
|
@ -76,12 +76,12 @@ void ImageEditor::paint_event(GUI::PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(const Layer& layer, const Gfx::Rect& layer_rect) const
|
||||
Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(const Layer& layer, const Gfx::IntRect& layer_rect) const
|
||||
{
|
||||
return image_rect_to_editor_rect(layer_rect.translated(layer.location()));
|
||||
}
|
||||
|
||||
Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::Rect& image_rect) const
|
||||
Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::IntRect& image_rect) const
|
||||
{
|
||||
Gfx::FloatRect editor_rect;
|
||||
editor_rect.set_location(image_position_to_editor_position(image_rect.location()));
|
||||
|
@ -90,7 +90,7 @@ Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::Rect& image_rec
|
|||
return editor_rect;
|
||||
}
|
||||
|
||||
Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::Rect& editor_rect) const
|
||||
Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::IntRect& editor_rect) const
|
||||
{
|
||||
Gfx::FloatRect image_rect;
|
||||
image_rect.set_location(editor_position_to_image_position(editor_rect.location()));
|
||||
|
@ -99,12 +99,12 @@ Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::Rect& editor_re
|
|||
return image_rect;
|
||||
}
|
||||
|
||||
Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(const Layer& layer, const Gfx::Point& layer_position) const
|
||||
Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(const Layer& layer, const Gfx::IntPoint& layer_position) const
|
||||
{
|
||||
return image_position_to_editor_position(layer_position.translated(layer.location()));
|
||||
}
|
||||
|
||||
Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::Point& image_position) const
|
||||
Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::IntPoint& image_position) const
|
||||
{
|
||||
Gfx::FloatPoint editor_position;
|
||||
editor_position.set_x(m_editor_image_rect.x() + ((float)image_position.x() * m_scale));
|
||||
|
@ -112,7 +112,7 @@ Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::Point&
|
|||
return editor_position;
|
||||
}
|
||||
|
||||
Gfx::FloatPoint ImageEditor::editor_position_to_image_position(const Gfx::Point& editor_position) const
|
||||
Gfx::FloatPoint ImageEditor::editor_position_to_image_position(const Gfx::IntPoint& editor_position) const
|
||||
{
|
||||
Gfx::FloatPoint image_position;
|
||||
image_position.set_x(((float)editor_position.x() - m_editor_image_rect.x()) / m_scale);
|
||||
|
@ -131,7 +131,7 @@ GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(const GUI::MouseEv
|
|||
auto image_position = editor_position_to_image_position(event.position());
|
||||
return {
|
||||
static_cast<GUI::Event::Type>(event.type()),
|
||||
Gfx::Point(image_position.x(), image_position.y()),
|
||||
Gfx::IntPoint(image_position.x(), image_position.y()),
|
||||
event.buttons(),
|
||||
event.button(),
|
||||
event.modifiers(),
|
||||
|
@ -145,7 +145,7 @@ GUI::MouseEvent ImageEditor::event_adjusted_for_layer(const GUI::MouseEvent& eve
|
|||
image_position.move_by(-layer.location().x(), -layer.location().y());
|
||||
return {
|
||||
static_cast<GUI::Event::Type>(event.type()),
|
||||
Gfx::Point(image_position.x(), image_position.y()),
|
||||
Gfx::IntPoint(image_position.x(), image_position.y()),
|
||||
event.buttons(),
|
||||
event.button(),
|
||||
event.modifiers(),
|
||||
|
@ -331,14 +331,14 @@ void ImageEditor::set_secondary_color(Color color)
|
|||
on_secondary_color_change(color);
|
||||
}
|
||||
|
||||
Layer* ImageEditor::layer_at_editor_position(const Gfx::Point& editor_position)
|
||||
Layer* ImageEditor::layer_at_editor_position(const Gfx::IntPoint& editor_position)
|
||||
{
|
||||
if (!m_image)
|
||||
return nullptr;
|
||||
auto image_position = editor_position_to_image_position(editor_position);
|
||||
for (ssize_t i = m_image->layer_count() - 1; i >= 0; --i) {
|
||||
auto& layer = m_image->layer(i);
|
||||
if (layer.relative_rect().contains(Gfx::Point(image_position.x(), image_position.y())))
|
||||
if (layer.relative_rect().contains(Gfx::IntPoint(image_position.x(), image_position.y())))
|
||||
return const_cast<Layer*>(&layer);
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -350,12 +350,12 @@ void ImageEditor::relayout()
|
|||
return;
|
||||
auto& image = *this->image();
|
||||
|
||||
Gfx::Size new_size;
|
||||
Gfx::IntSize new_size;
|
||||
new_size.set_width(image.size().width() * m_scale);
|
||||
new_size.set_height(image.size().height() * m_scale);
|
||||
m_editor_image_rect.set_size(new_size);
|
||||
|
||||
Gfx::Point new_location;
|
||||
Gfx::IntPoint new_location;
|
||||
new_location.set_x((width() / 2) - (new_size.width() / 2) - (m_pan_origin.x() * m_scale));
|
||||
new_location.set_y((height() / 2) - (new_size.height() / 2) - (m_pan_origin.y() * m_scale));
|
||||
m_editor_image_rect.set_location(new_location);
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
void layers_did_change();
|
||||
|
||||
Layer* layer_at_editor_position(const Gfx::Point&);
|
||||
Layer* layer_at_editor_position(const Gfx::IntPoint&);
|
||||
|
||||
Color primary_color() const { return m_primary_color; }
|
||||
void set_primary_color(Color);
|
||||
|
@ -72,12 +72,12 @@ public:
|
|||
|
||||
Function<void(Layer*)> on_active_layer_change;
|
||||
|
||||
Gfx::FloatRect layer_rect_to_editor_rect(const Layer&, const Gfx::Rect&) const;
|
||||
Gfx::FloatRect image_rect_to_editor_rect(const Gfx::Rect&) const;
|
||||
Gfx::FloatRect editor_rect_to_image_rect(const Gfx::Rect&) const;
|
||||
Gfx::FloatPoint layer_position_to_editor_position(const Layer&, const Gfx::Point&) const;
|
||||
Gfx::FloatPoint image_position_to_editor_position(const Gfx::Point&) const;
|
||||
Gfx::FloatPoint editor_position_to_image_position(const Gfx::Point&) const;
|
||||
Gfx::FloatRect layer_rect_to_editor_rect(const Layer&, const Gfx::IntRect&) const;
|
||||
Gfx::FloatRect image_rect_to_editor_rect(const Gfx::IntRect&) const;
|
||||
Gfx::FloatRect editor_rect_to_image_rect(const Gfx::IntRect&) const;
|
||||
Gfx::FloatPoint layer_position_to_editor_position(const Layer&, const Gfx::IntPoint&) const;
|
||||
Gfx::FloatPoint image_position_to_editor_position(const Gfx::IntPoint&) const;
|
||||
Gfx::FloatPoint editor_position_to_image_position(const Gfx::IntPoint&) const;
|
||||
|
||||
private:
|
||||
ImageEditor();
|
||||
|
@ -110,11 +110,11 @@ private:
|
|||
Color m_primary_color { Color::Black };
|
||||
Color m_secondary_color { Color::White };
|
||||
|
||||
Gfx::Rect m_editor_image_rect;
|
||||
Gfx::IntRect m_editor_image_rect;
|
||||
float m_scale { 1 };
|
||||
Gfx::FloatPoint m_pan_origin;
|
||||
Gfx::FloatPoint m_saved_pan_origin;
|
||||
Gfx::Point m_click_position;
|
||||
Gfx::IntPoint m_click_position;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
RefPtr<Layer> Layer::create_with_size(const Gfx::Size& size, const String& name)
|
||||
RefPtr<Layer> Layer::create_with_size(const Gfx::IntSize& size, const String& name)
|
||||
{
|
||||
if (size.is_empty())
|
||||
return nullptr;
|
||||
|
@ -41,7 +41,7 @@ RefPtr<Layer> Layer::create_with_size(const Gfx::Size& size, const String& name)
|
|||
return adopt(*new Layer(size, name));
|
||||
}
|
||||
|
||||
Layer::Layer(const Gfx::Size& size, const String& name)
|
||||
Layer::Layer(const Gfx::IntSize& size, const String& name)
|
||||
: m_name(name)
|
||||
{
|
||||
m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA32, size);
|
||||
|
|
|
@ -40,19 +40,19 @@ class Layer : public RefCounted<Layer> {
|
|||
AK_MAKE_NONMOVABLE(Layer);
|
||||
|
||||
public:
|
||||
static RefPtr<Layer> create_with_size(const Gfx::Size&, const String& name);
|
||||
static RefPtr<Layer> create_with_size(const Gfx::IntSize&, const String& name);
|
||||
|
||||
~Layer() {}
|
||||
|
||||
const Gfx::Point& location() const { return m_location; }
|
||||
void set_location(const Gfx::Point& location) { m_location = location; }
|
||||
const Gfx::IntPoint& location() const { return m_location; }
|
||||
void set_location(const Gfx::IntPoint& location) { m_location = location; }
|
||||
|
||||
const Gfx::Bitmap& bitmap() const { return *m_bitmap; }
|
||||
Gfx::Bitmap& bitmap() { return *m_bitmap; }
|
||||
Gfx::Size size() const { return bitmap().size(); }
|
||||
Gfx::IntSize size() const { return bitmap().size(); }
|
||||
|
||||
Gfx::Rect relative_rect() const { return { location(), size() }; }
|
||||
Gfx::Rect rect() const { return { {}, size() }; }
|
||||
Gfx::IntRect relative_rect() const { return { location(), size() }; }
|
||||
Gfx::IntRect rect() const { return { {}, size() }; }
|
||||
|
||||
const String& name() const { return m_name; }
|
||||
void set_name(const String& name) { m_name = name; }
|
||||
|
@ -63,10 +63,10 @@ public:
|
|||
bool is_selected() const { return m_selected; }
|
||||
|
||||
private:
|
||||
explicit Layer(const Gfx::Size&, const String& name);
|
||||
explicit Layer(const Gfx::IntSize&, const String& name);
|
||||
|
||||
String m_name;
|
||||
Gfx::Point m_location;
|
||||
Gfx::IntPoint m_location;
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
|
||||
bool m_selected { false };
|
||||
|
|
|
@ -102,11 +102,11 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
painter.draw_rect(adjusted_rect, Color::Black);
|
||||
|
||||
Gfx::Rect thumbnail_rect { adjusted_rect.x(), adjusted_rect.y(), adjusted_rect.height(), adjusted_rect.height() };
|
||||
Gfx::IntRect thumbnail_rect { adjusted_rect.x(), adjusted_rect.y(), adjusted_rect.height(), adjusted_rect.height() };
|
||||
thumbnail_rect.shrink(8, 8);
|
||||
painter.draw_scaled_bitmap(thumbnail_rect, layer.bitmap(), layer.bitmap().rect());
|
||||
|
||||
Gfx::Rect text_rect { thumbnail_rect.right() + 10, adjusted_rect.y(), adjusted_rect.width(), adjusted_rect.height() };
|
||||
Gfx::IntRect text_rect { thumbnail_rect.right() + 10, adjusted_rect.y(), adjusted_rect.width(), adjusted_rect.height() };
|
||||
text_rect.intersect(adjusted_rect);
|
||||
|
||||
painter.draw_text(text_rect, layer.name(), Gfx::TextAlignment::CenterLeft, layer.is_selected() ? palette().selection_text() : palette().button_text());
|
||||
|
@ -121,7 +121,7 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event)
|
|||
paint_gadget(m_gadgets[m_moving_gadget_index.value()]);
|
||||
}
|
||||
|
||||
Optional<size_t> LayerListWidget::gadget_at(const Gfx::Point& position)
|
||||
Optional<size_t> LayerListWidget::gadget_at(const Gfx::IntPoint& position)
|
||||
{
|
||||
for (size_t i = 0; i < m_gadgets.size(); ++i) {
|
||||
if (m_gadgets[i].rect.contains(position))
|
||||
|
|
|
@ -69,21 +69,21 @@ private:
|
|||
|
||||
struct Gadget {
|
||||
size_t layer_index { 0 };
|
||||
Gfx::Rect rect;
|
||||
Gfx::Rect temporary_rect_during_move;
|
||||
Gfx::IntRect rect;
|
||||
Gfx::IntRect temporary_rect_during_move;
|
||||
bool is_moving { false };
|
||||
Gfx::Point movement_delta;
|
||||
Gfx::IntPoint movement_delta;
|
||||
};
|
||||
|
||||
bool is_moving_gadget() const { return m_moving_gadget_index.has_value(); }
|
||||
|
||||
Optional<size_t> gadget_at(const Gfx::Point&);
|
||||
Optional<size_t> gadget_at(const Gfx::IntPoint&);
|
||||
|
||||
Vector<Gadget> m_gadgets;
|
||||
RefPtr<Image> m_image;
|
||||
|
||||
Optional<size_t> m_moving_gadget_index;
|
||||
Gfx::Point m_moving_event_origin;
|
||||
Gfx::IntPoint m_moving_event_origin;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
static Gfx::Point constrain_line_angle(const Gfx::Point& start_pos, const Gfx::Point& end_pos, float angle_increment)
|
||||
static Gfx::IntPoint constrain_line_angle(const Gfx::IntPoint& start_pos, const Gfx::IntPoint& end_pos, float angle_increment)
|
||||
{
|
||||
float current_angle = atan2(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + M_PI * 2.;
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ private:
|
|||
virtual const char* class_name() const override { return "LineTool"; }
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
Gfx::Point m_line_start_position;
|
||||
Gfx::Point m_line_end_position;
|
||||
Gfx::IntPoint m_line_start_position;
|
||||
Gfx::IntPoint m_line_end_position;
|
||||
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
|
@ -46,8 +46,8 @@ private:
|
|||
virtual bool is_move_tool() const override { return true; }
|
||||
|
||||
RefPtr<Layer> m_layer_being_moved;
|
||||
Gfx::Point m_event_origin;
|
||||
Gfx::Point m_layer_origin;
|
||||
Gfx::IntPoint m_event_origin;
|
||||
Gfx::IntPoint m_layer_origin;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
RefPtr<Layer> m_context_menu_layer;
|
||||
};
|
||||
|
|
|
@ -88,7 +88,7 @@ PaletteWidget::PaletteWidget(ImageEditor& editor)
|
|||
set_secondary_color(m_editor.secondary_color());
|
||||
|
||||
m_primary_color_widget = add<GUI::Frame>();
|
||||
Gfx::Rect rect { 0, 0, 38, 15 };
|
||||
Gfx::IntRect rect { 0, 0, 38, 15 };
|
||||
rect.center_within(m_secondary_color_widget->relative_rect());
|
||||
m_primary_color_widget->set_relative_rect(rect);
|
||||
m_primary_color_widget->set_fill_with_background_color(true);
|
||||
|
|
|
@ -64,7 +64,7 @@ void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent
|
|||
return;
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
|
||||
if (m_last_drawing_event_position != Gfx::Point(-1, -1))
|
||||
if (m_last_drawing_event_position != Gfx::IntPoint(-1, -1))
|
||||
painter.draw_line(m_last_drawing_event_position, event.position(), m_editor->color_for(event), m_thickness);
|
||||
else
|
||||
painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness);
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
private:
|
||||
virtual const char* class_name() const override { return "PenTool"; }
|
||||
|
||||
Gfx::Point m_last_drawing_event_position { -1, -1 };
|
||||
Gfx::IntPoint m_last_drawing_event_position { -1, -1 };
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
int m_thickness { 1 };
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
|
@ -43,7 +43,7 @@ RectangleTool::~RectangleTool()
|
|||
{
|
||||
}
|
||||
|
||||
void RectangleTool::draw_using(GUI::Painter& painter, const Gfx::Rect& rect)
|
||||
void RectangleTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& rect)
|
||||
{
|
||||
switch (m_mode) {
|
||||
case Mode::Fill:
|
||||
|
@ -78,7 +78,7 @@ void RectangleTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseE
|
|||
{
|
||||
if (event.button() == m_drawing_button) {
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
auto rect = Gfx::Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position);
|
||||
auto rect = Gfx::IntRect::from_two_points(m_rectangle_start_position, m_rectangle_end_position);
|
||||
draw_using(painter, rect);
|
||||
m_drawing_button = GUI::MouseButton::None;
|
||||
layer.did_modify_bitmap(*m_editor->image());
|
||||
|
@ -101,7 +101,7 @@ void RectangleTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event)
|
|||
|
||||
GUI::Painter painter(*m_editor);
|
||||
painter.add_clip_rect(event.rect());
|
||||
auto rect = Gfx::Rect::from_two_points(m_editor->layer_position_to_editor_position(layer, m_rectangle_start_position).to_int_point(), m_editor->layer_position_to_editor_position(layer, m_rectangle_end_position).to_int_point());
|
||||
auto rect = Gfx::IntRect::from_two_points(m_editor->layer_position_to_editor_position(layer, m_rectangle_start_position).to_int_point(), m_editor->layer_position_to_editor_position(layer, m_rectangle_end_position).to_int_point());
|
||||
draw_using(painter, rect);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,11 @@ private:
|
|||
};
|
||||
|
||||
virtual const char* class_name() const override { return "RectangleTool"; }
|
||||
void draw_using(GUI::Painter&, const Gfx::Rect&);
|
||||
void draw_using(GUI::Painter&, const Gfx::IntRect&);
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
Gfx::Point m_rectangle_start_position;
|
||||
Gfx::Point m_rectangle_end_position;
|
||||
Gfx::IntPoint m_rectangle_start_position;
|
||||
Gfx::IntPoint m_rectangle_end_position;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
Mode m_mode { Mode::Outline };
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
virtual const char* class_name() const override { return "SprayTool"; }
|
||||
void paint_it();
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
Gfx::Point m_last_pos;
|
||||
Gfx::IntPoint m_last_pos;
|
||||
Color m_color;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
GUI::ActionGroup m_thickness_actions;
|
||||
|
|
|
@ -138,12 +138,12 @@ void QSWidget::relayout()
|
|||
|
||||
float scale_factor = (float)m_scale / 100.0f;
|
||||
|
||||
Gfx::Size new_size;
|
||||
Gfx::IntSize new_size;
|
||||
new_size.set_width(m_bitmap->width() * scale_factor);
|
||||
new_size.set_height(m_bitmap->height() * scale_factor);
|
||||
m_bitmap_rect.set_size(new_size);
|
||||
|
||||
Gfx::Point new_location;
|
||||
Gfx::IntPoint new_location;
|
||||
new_location.set_x((width() / 2) - (new_size.width() / 2) - (m_pan_origin.x() * scale_factor));
|
||||
new_location.set_y((height() / 2) - (new_size.height() / 2) - (m_pan_origin.y() * scale_factor));
|
||||
m_bitmap_rect.set_location(new_location);
|
||||
|
|
|
@ -76,11 +76,11 @@ private:
|
|||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
int m_toolbar_height { 28 };
|
||||
|
||||
Gfx::Rect m_bitmap_rect;
|
||||
Gfx::IntRect m_bitmap_rect;
|
||||
int m_scale { 100 };
|
||||
Gfx::FloatPoint m_pan_origin;
|
||||
|
||||
Gfx::Point m_click_position;
|
||||
Gfx::IntPoint m_click_position;
|
||||
Gfx::FloatPoint m_saved_pan_origin;
|
||||
Vector<String> m_files_in_same_dir;
|
||||
};
|
||||
|
|
|
@ -60,8 +60,8 @@ void SampleWidget::paint_event(GUI::PaintEvent& event)
|
|||
++count;
|
||||
|
||||
if (count >= samples_per_pixel) {
|
||||
Gfx::Point min_point = { x, y_offset + static_cast<int>(-sample_max * frame_inner_rect().height() / 2) };
|
||||
Gfx::Point max_point = { x++, y_offset + static_cast<int>(sample_max * frame_inner_rect().height() / 2) };
|
||||
Gfx::IntPoint min_point = { x, y_offset + static_cast<int>(-sample_max * frame_inner_rect().height() / 2) };
|
||||
Gfx::IntPoint max_point = { x++, y_offset + static_cast<int>(sample_max * frame_inner_rect().height() / 2) };
|
||||
painter.draw_line(min_point, max_point, Color::Green);
|
||||
|
||||
count = 0;
|
||||
|
|
|
@ -53,20 +53,20 @@ void GraphWidget::paint_event(GUI::PaintEvent& event)
|
|||
auto inner_rect = frame_inner_rect();
|
||||
float scale = (float)inner_rect.height() / (float)m_max;
|
||||
|
||||
Gfx::Point prev_point;
|
||||
Gfx::IntPoint prev_point;
|
||||
for (size_t i = 0; i < m_values.size(); ++i) {
|
||||
int x = inner_rect.right() - (i * 2) + 1;
|
||||
if (x < 0)
|
||||
break;
|
||||
float scaled_value = (float)m_values.at(m_values.size() - i - 1) * scale;
|
||||
Gfx::Point point = { x, inner_rect.bottom() - (int)scaled_value };
|
||||
Gfx::IntPoint point = { x, inner_rect.bottom() - (int)scaled_value };
|
||||
if (i != 0)
|
||||
painter.draw_line(prev_point, point, m_graph_color);
|
||||
prev_point = point;
|
||||
}
|
||||
|
||||
if (!m_values.is_empty() && text_formatter) {
|
||||
Gfx::Rect text_rect = inner_rect.shrunken(8, 8);
|
||||
Gfx::IntRect text_rect = inner_rect.shrunken(8, 8);
|
||||
text_rect.set_height(font().glyph_height());
|
||||
auto text = text_formatter(m_values.last(), m_max);
|
||||
painter.draw_text(text_rect.translated(1, 1), text.characters(), Gfx::TextAlignment::CenterRight, Color::Black);
|
||||
|
|
|
@ -37,7 +37,7 @@ class PagemapPaintingDelegate final : public GUI::TableCellPaintingDelegate {
|
|||
public:
|
||||
virtual ~PagemapPaintingDelegate() override {}
|
||||
|
||||
virtual void paint(GUI::Painter& painter, const Gfx::Rect& a_rect, const Gfx::Palette&, const GUI::Model& model, const GUI::ModelIndex& index) override
|
||||
virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Gfx::Palette&, const GUI::Model& model, const GUI::ModelIndex& index) override
|
||||
{
|
||||
auto rect = a_rect.shrunken(2, 2);
|
||||
auto pagemap = model.data(index, GUI::Model::Role::Custom).to_string();
|
||||
|
|
|
@ -287,7 +287,7 @@ class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate
|
|||
public:
|
||||
virtual ~ProgressBarPaintingDelegate() override { }
|
||||
|
||||
virtual void paint(GUI::Painter& painter, const Gfx::Rect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override
|
||||
virtual void paint(GUI::Painter& painter, const Gfx::IntRect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override
|
||||
{
|
||||
auto rect = a_rect.shrunken(2, 2);
|
||||
auto percentage = model.data(index, GUI::Model::Role::Custom).to_i32();
|
||||
|
|
|
@ -156,7 +156,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("Welcome");
|
||||
Gfx::Rect window_rect { 0, 0, 640, 360 };
|
||||
Gfx::IntRect window_rect { 0, 0, 640, 360 };
|
||||
window_rect.center_within(GUI::Desktop::the().rect());
|
||||
window->set_resizable(true);
|
||||
window->set_rect(window_rect);
|
||||
|
|
|
@ -145,7 +145,7 @@ void Cube::timer_event(Core::TimerEvent&)
|
|||
painter.fill_rect_with_gradient(Gfx::Orientation::Vertical, m_bitmap->rect(), Gfx::Color::White, Gfx::Color::Blue);
|
||||
|
||||
auto to_point = [](const FloatVector3& v) {
|
||||
return Gfx::Point(v.x(), v.y());
|
||||
return Gfx::IntPoint(v.x(), v.y());
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(indices) / sizeof(indices[0]) / 3; i++) {
|
||||
|
|
|
@ -64,7 +64,7 @@ void EyesWidget::paint_event(GUI::PaintEvent& event)
|
|||
void EyesWidget::render_eyeball(int index, GUI::Painter& painter) const
|
||||
{
|
||||
auto eye_width = width() / m_num_eyes;
|
||||
Gfx::Rect bounds { index * eye_width, 0, eye_width, height() };
|
||||
Gfx::IntRect bounds { index * eye_width, 0, eye_width, height() };
|
||||
auto width_thickness = max(int(eye_width / 5.5), 1);
|
||||
auto height_thickness = max(int(height() / 5.5), 1);
|
||||
|
||||
|
@ -73,12 +73,12 @@ void EyesWidget::render_eyeball(int index, GUI::Painter& painter) const
|
|||
bounds.shrink(width_thickness, height_thickness);
|
||||
painter.fill_ellipse(bounds, palette().base());
|
||||
|
||||
Gfx::Point pupil_center = this->pupil_center(bounds);
|
||||
Gfx::Size pupil_size {
|
||||
Gfx::IntPoint pupil_center = this->pupil_center(bounds);
|
||||
Gfx::IntSize pupil_size {
|
||||
bounds.width() / 5,
|
||||
bounds.height() / 5
|
||||
};
|
||||
Gfx::Rect pupil {
|
||||
Gfx::IntRect pupil {
|
||||
pupil_center.x() - pupil_size.width() / 2,
|
||||
pupil_center.y() - pupil_size.height() / 2,
|
||||
pupil_size.width(),
|
||||
|
@ -88,7 +88,7 @@ void EyesWidget::render_eyeball(int index, GUI::Painter& painter) const
|
|||
painter.fill_ellipse(pupil, palette().base_text());
|
||||
}
|
||||
|
||||
Gfx::Point EyesWidget::pupil_center(Gfx::Rect& eyeball_bounds) const
|
||||
Gfx::IntPoint EyesWidget::pupil_center(Gfx::IntRect& eyeball_bounds) const
|
||||
{
|
||||
auto mouse_vector = m_mouse_position - eyeball_bounds.center();
|
||||
double dx = mouse_vector.x();
|
||||
|
|
|
@ -46,8 +46,8 @@ private:
|
|||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
|
||||
void render_eyeball(int index, GUI::Painter&) const;
|
||||
Gfx::Point pupil_center(Gfx::Rect& eyeball_bounds) const;
|
||||
Gfx::IntPoint pupil_center(Gfx::IntRect& eyeball_bounds) const;
|
||||
|
||||
Gfx::Point m_mouse_position;
|
||||
Gfx::IntPoint m_mouse_position;
|
||||
int m_num_eyes { -1 };
|
||||
};
|
||||
|
|
|
@ -114,10 +114,10 @@ public:
|
|||
auto off_x = 80;
|
||||
auto off_y = 38;
|
||||
|
||||
Gfx::Point p1;
|
||||
Gfx::Point p2;
|
||||
Gfx::Point p3;
|
||||
Gfx::Point p4;
|
||||
Gfx::IntPoint p1;
|
||||
Gfx::IntPoint p2;
|
||||
Gfx::IntPoint p3;
|
||||
Gfx::IntPoint p4;
|
||||
|
||||
p1.set_x(radius * cos(M_PI * m_wheel_delta_acc / 18) + off_x);
|
||||
p1.set_y(radius * sin(M_PI * m_wheel_delta_acc / 18) + off_y);
|
||||
|
|
|
@ -153,7 +153,7 @@ void CursorTool::on_keydown(GUI::KeyEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void CursorTool::set_rubber_band_position(const Gfx::Point& position)
|
||||
void CursorTool::set_rubber_band_position(const Gfx::IntPoint& position)
|
||||
{
|
||||
if (m_rubber_band_position == position)
|
||||
return;
|
||||
|
@ -171,11 +171,11 @@ void CursorTool::set_rubber_band_position(const Gfx::Point& position)
|
|||
m_editor.form_widget().update();
|
||||
}
|
||||
|
||||
Gfx::Rect CursorTool::rubber_band_rect() const
|
||||
Gfx::IntRect CursorTool::rubber_band_rect() const
|
||||
{
|
||||
if (!m_rubber_banding)
|
||||
return {};
|
||||
return Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position);
|
||||
return Gfx::IntRect::from_two_points(m_rubber_band_origin, m_rubber_band_position);
|
||||
}
|
||||
|
||||
void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&)
|
||||
|
|
|
@ -47,14 +47,14 @@ private:
|
|||
virtual void on_keydown(GUI::KeyEvent&) override;
|
||||
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) override;
|
||||
|
||||
void set_rubber_band_position(const Gfx::Point&);
|
||||
Gfx::Rect rubber_band_rect() const;
|
||||
void set_rubber_band_position(const Gfx::IntPoint&);
|
||||
Gfx::IntRect rubber_band_rect() const;
|
||||
|
||||
Gfx::Point m_drag_origin;
|
||||
HashMap<GUI::Widget*, Gfx::Point> m_positions_before_drag;
|
||||
Gfx::IntPoint m_drag_origin;
|
||||
HashMap<GUI::Widget*, Gfx::IntPoint> m_positions_before_drag;
|
||||
bool m_dragging { false };
|
||||
|
||||
bool m_rubber_banding { false };
|
||||
Gfx::Point m_rubber_band_origin;
|
||||
Gfx::Point m_rubber_band_position;
|
||||
Gfx::IntPoint m_rubber_band_origin;
|
||||
Gfx::IntPoint m_rubber_band_position;
|
||||
};
|
||||
|
|
|
@ -80,7 +80,7 @@ void Editor::focusout_event(Core::Event& event)
|
|||
GUI::TextEditor::focusout_event(event);
|
||||
}
|
||||
|
||||
Gfx::Rect Editor::breakpoint_icon_rect(size_t line_number) const
|
||||
Gfx::IntRect Editor::breakpoint_icon_rect(size_t line_number) const
|
||||
{
|
||||
auto ruler_line_rect = ruler_content_rect(line_number);
|
||||
|
||||
|
@ -140,7 +140,7 @@ static HashMap<String, String>& man_paths()
|
|||
return paths;
|
||||
}
|
||||
|
||||
void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::Point& screen_location)
|
||||
void Editor::show_documentation_tooltip_if_available(const String& hovered_token, const Gfx::IntPoint& screen_location)
|
||||
{
|
||||
auto it = man_paths().find(hovered_token);
|
||||
if (it == man_paths().end()) {
|
||||
|
|
|
@ -61,10 +61,10 @@ private:
|
|||
virtual void enter_event(Core::Event&) override;
|
||||
virtual void leave_event(Core::Event&) override;
|
||||
|
||||
void show_documentation_tooltip_if_available(const String&, const Gfx::Point& screen_location);
|
||||
void show_documentation_tooltip_if_available(const String&, const Gfx::IntPoint& screen_location);
|
||||
void navigate_to_include_if_available(String);
|
||||
|
||||
Gfx::Rect breakpoint_icon_rect(size_t line_number) const;
|
||||
Gfx::IntRect breakpoint_icon_rect(size_t line_number) const;
|
||||
static const Gfx::Bitmap& breakpoint_icon_bitmap();
|
||||
static const Gfx::Bitmap& current_position_icon_bitmap();
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ void VBForm::insert_widget(VBWidgetType type)
|
|||
{
|
||||
auto* insertion_parent = single_selected_widget();
|
||||
auto widget = VBWidget::create(type, *this, insertion_parent);
|
||||
Gfx::Point insertion_position = m_next_insertion_position;
|
||||
Gfx::IntPoint insertion_position = m_next_insertion_position;
|
||||
if (insertion_parent)
|
||||
insertion_position.move_by(insertion_parent->gwidget()->window_relative_rect().location());
|
||||
widget->set_rect({ insertion_position, { m_grid_size * 10 + 1, m_grid_size * 5 + 1 } });
|
||||
|
@ -136,7 +136,7 @@ bool VBForm::is_selected(const VBWidget& widget) const
|
|||
return m_selected_widgets.contains(const_cast<VBWidget*>(&widget));
|
||||
}
|
||||
|
||||
VBWidget* VBForm::widget_at(const Gfx::Point& position)
|
||||
VBWidget* VBForm::widget_at(const Gfx::IntPoint& position)
|
||||
{
|
||||
auto result = hit_test(position, GUI::Widget::ShouldRespectGreediness::No);
|
||||
if (!result.widget)
|
||||
|
@ -354,7 +354,7 @@ void VBForm::mousemove_event(GUI::MouseEvent& event)
|
|||
if (widget.is_in_layout())
|
||||
return;
|
||||
auto new_rect = widget.transform_origin_rect();
|
||||
Gfx::Size minimum_size { 5, 5 };
|
||||
Gfx::IntSize minimum_size { 5, 5 };
|
||||
new_rect.set_x(new_rect.x() + change_x);
|
||||
new_rect.set_y(new_rect.y() + change_y);
|
||||
new_rect.set_width(max(minimum_size.width(), new_rect.width() + change_w));
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
void set_name(const String& name) { m_name = name; }
|
||||
|
||||
bool is_selected(const VBWidget&) const;
|
||||
VBWidget* widget_at(const Gfx::Point&);
|
||||
VBWidget* widget_at(const Gfx::IntPoint&);
|
||||
|
||||
void set_should_snap_to_grip(bool snap) { m_should_snap_to_grid = snap; }
|
||||
bool should_snap_to_grid() const { return m_should_snap_to_grid; }
|
||||
|
@ -85,8 +85,8 @@ private:
|
|||
NonnullRefPtrVector<VBWidget> m_widgets;
|
||||
HashMap<GUI::Widget*, VBWidget*> m_gwidget_map;
|
||||
HashTable<VBWidget*> m_selected_widgets;
|
||||
Gfx::Point m_transform_event_origin;
|
||||
Gfx::Point m_next_insertion_position;
|
||||
Gfx::IntPoint m_transform_event_origin;
|
||||
Gfx::IntPoint m_next_insertion_position;
|
||||
Direction m_resize_direction { Direction::None };
|
||||
Direction m_mouse_direction_type { Direction::None };
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
|
|
|
@ -59,12 +59,12 @@ VBWidget::~VBWidget()
|
|||
m_gwidget->parent()->remove_child(*m_gwidget);
|
||||
}
|
||||
|
||||
Gfx::Rect VBWidget::rect() const
|
||||
Gfx::IntRect VBWidget::rect() const
|
||||
{
|
||||
return m_gwidget->window_relative_rect();
|
||||
}
|
||||
|
||||
void VBWidget::set_rect(const Gfx::Rect& rect)
|
||||
void VBWidget::set_rect(const Gfx::IntRect& rect)
|
||||
{
|
||||
if (rect == m_gwidget->window_relative_rect())
|
||||
return;
|
||||
|
@ -80,7 +80,7 @@ bool VBWidget::is_selected() const
|
|||
return m_form.is_selected(*this);
|
||||
}
|
||||
|
||||
Gfx::Rect VBWidget::grabber_rect(Direction direction) const
|
||||
Gfx::IntRect VBWidget::grabber_rect(Direction direction) const
|
||||
{
|
||||
int grabber_size = 5;
|
||||
int half_grabber_size = grabber_size / 2;
|
||||
|
@ -106,7 +106,7 @@ Gfx::Rect VBWidget::grabber_rect(Direction direction) const
|
|||
}
|
||||
}
|
||||
|
||||
Direction VBWidget::grabber_at(const Gfx::Point& position) const
|
||||
Direction VBWidget::grabber_at(const Gfx::IntPoint& position) const
|
||||
{
|
||||
Direction found_grabber = Direction::None;
|
||||
for_each_direction([&](Direction direction) {
|
||||
|
|
|
@ -74,11 +74,11 @@ public:
|
|||
|
||||
bool is_selected() const;
|
||||
|
||||
Gfx::Rect rect() const;
|
||||
void set_rect(const Gfx::Rect&);
|
||||
Gfx::IntRect rect() const;
|
||||
void set_rect(const Gfx::IntRect&);
|
||||
|
||||
Gfx::Rect grabber_rect(Direction) const;
|
||||
Direction grabber_at(const Gfx::Point&) const;
|
||||
Gfx::IntRect grabber_rect(Direction) const;
|
||||
Direction grabber_at(const Gfx::IntPoint&) const;
|
||||
|
||||
GUI::Widget* gwidget() { return m_gwidget; }
|
||||
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
void property_did_change();
|
||||
|
||||
Gfx::Rect transform_origin_rect() const { return m_transform_origin_rect; }
|
||||
Gfx::IntRect transform_origin_rect() const { return m_transform_origin_rect; }
|
||||
void capture_transform_origin_rect();
|
||||
|
||||
bool is_in_layout() const;
|
||||
|
@ -108,5 +108,5 @@ private:
|
|||
RefPtr<GUI::Widget> m_gwidget;
|
||||
NonnullOwnPtrVector<VBProperty> m_properties;
|
||||
NonnullRefPtr<VBWidgetPropertyModel> m_property_model;
|
||||
Gfx::Rect m_transform_origin_rect;
|
||||
Gfx::IntRect m_transform_origin_rect;
|
||||
};
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
bool m_chord { false };
|
||||
};
|
||||
|
||||
Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::Size)> on_size_changed)
|
||||
Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::IntSize)> on_size_changed)
|
||||
: m_face_button(face_button)
|
||||
, m_flag_label(flag_label)
|
||||
, m_time_label(time_label)
|
||||
|
@ -241,7 +241,7 @@ void Field::reset()
|
|||
for (size_t c = 0; c < columns(); ++c) {
|
||||
if (!m_squares[i])
|
||||
m_squares[i] = make<Square>();
|
||||
Gfx::Rect rect = { frame_thickness() + static_cast<int>(c) * square_size(), frame_thickness() + static_cast<int>(r) * square_size(), square_size(), square_size() };
|
||||
Gfx::IntRect rect = { frame_thickness() + static_cast<int>(c) * square_size(), frame_thickness() + static_cast<int>(r) * square_size(), square_size(), square_size() };
|
||||
auto& square = this->square(r, c);
|
||||
square.field = this;
|
||||
square.row = r;
|
||||
|
@ -329,13 +329,13 @@ void Field::paint_event(GUI::PaintEvent& event)
|
|||
painter.add_clip_rect(inner_rect);
|
||||
|
||||
for (int y = inner_rect.top() - 1; y <= inner_rect.bottom(); y += square_size()) {
|
||||
Gfx::Point a { inner_rect.left(), y };
|
||||
Gfx::Point b { inner_rect.right(), y };
|
||||
Gfx::IntPoint a { inner_rect.left(), y };
|
||||
Gfx::IntPoint b { inner_rect.right(), y };
|
||||
painter.draw_line(a, b, palette().threed_shadow1());
|
||||
}
|
||||
for (int x = frame_inner_rect().left() - 1; x <= frame_inner_rect().right(); x += square_size()) {
|
||||
Gfx::Point a { x, inner_rect.top() };
|
||||
Gfx::Point b { x, inner_rect.bottom() };
|
||||
Gfx::IntPoint a { x, inner_rect.top() };
|
||||
Gfx::IntPoint b { x, inner_rect.bottom() };
|
||||
painter.draw_line(a, b, palette().threed_shadow1());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class Field final : public GUI::Frame {
|
|||
friend class Square;
|
||||
friend class SquareLabel;
|
||||
public:
|
||||
Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::Size)> on_size_changed);
|
||||
Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::IntSize)> on_size_changed);
|
||||
virtual ~Field() override;
|
||||
|
||||
size_t rows() const { return m_rows; }
|
||||
|
@ -126,5 +126,5 @@ private:
|
|||
bool m_chord_preview { false };
|
||||
bool m_first_click { true };
|
||||
bool m_single_chording { true };
|
||||
Function<void(Gfx::Size)> m_on_size_changed;
|
||||
Function<void(Gfx::IntSize)> m_on_size_changed;
|
||||
};
|
||||
|
|
|
@ -92,13 +92,13 @@ void SnakeGame::spawn_fruit()
|
|||
m_fruit_type = rand() % m_fruit_bitmaps.size();
|
||||
}
|
||||
|
||||
Gfx::Rect SnakeGame::score_rect() const
|
||||
Gfx::IntRect SnakeGame::score_rect() const
|
||||
{
|
||||
int score_width = font().width(m_score_text);
|
||||
return { width() - score_width - 2, height() - font().glyph_height() - 2, score_width, font().glyph_height() };
|
||||
}
|
||||
|
||||
Gfx::Rect SnakeGame::high_score_rect() const
|
||||
Gfx::IntRect SnakeGame::high_score_rect() const
|
||||
{
|
||||
int high_score_width = font().width(m_high_score_text);
|
||||
return { 2, height() - font().glyph_height() - 2, high_score_width, font().glyph_height() };
|
||||
|
@ -197,10 +197,10 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::Rect SnakeGame::cell_rect(const Coordinate& coord) const
|
||||
Gfx::IntRect SnakeGame::cell_rect(const Coordinate& coord) const
|
||||
{
|
||||
auto game_rect = rect();
|
||||
auto cell_size = Gfx::Size(game_rect.width() / m_columns, game_rect.height() / m_rows);
|
||||
auto cell_size = Gfx::IntSize(game_rect.width() / m_columns, game_rect.height() / m_rows);
|
||||
return {
|
||||
coord.column * cell_size.width(),
|
||||
coord.row * cell_size.height(),
|
||||
|
@ -220,10 +220,10 @@ void SnakeGame::paint_event(GUI::PaintEvent& event)
|
|||
auto rect = cell_rect(part);
|
||||
painter.fill_rect(rect, Color::from_rgb(0xaaaa00));
|
||||
|
||||
Gfx::Rect left_side(rect.x(), rect.y(), 2, rect.height());
|
||||
Gfx::Rect top_side(rect.x(), rect.y(), rect.width(), 2);
|
||||
Gfx::Rect right_side(rect.right() - 1, rect.y(), 2, rect.height());
|
||||
Gfx::Rect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2);
|
||||
Gfx::IntRect left_side(rect.x(), rect.y(), 2, rect.height());
|
||||
Gfx::IntRect top_side(rect.x(), rect.y(), rect.width(), 2);
|
||||
Gfx::IntRect right_side(rect.right() - 1, rect.y(), 2, rect.height());
|
||||
Gfx::IntRect bottom_side(rect.x(), rect.bottom() - 1, rect.width(), 2);
|
||||
painter.fill_rect(left_side, Color::from_rgb(0xcccc00));
|
||||
painter.fill_rect(right_side, Color::from_rgb(0x888800));
|
||||
painter.fill_rect(top_side, Color::from_rgb(0xcccc00));
|
||||
|
|
|
@ -63,9 +63,9 @@ private:
|
|||
bool is_available(const Coordinate&);
|
||||
void queue_velocity(int v, int h);
|
||||
const Velocity& last_velocity() const;
|
||||
Gfx::Rect cell_rect(const Coordinate&) const;
|
||||
Gfx::Rect score_rect() const;
|
||||
Gfx::Rect high_score_rect() const;
|
||||
Gfx::IntRect cell_rect(const Coordinate&) const;
|
||||
Gfx::IntRect score_rect() const;
|
||||
Gfx::IntRect high_score_rect() const;
|
||||
|
||||
int m_rows { 20 };
|
||||
int m_columns { 20 };
|
||||
|
|
|
@ -79,13 +79,13 @@ static const NonnullRefPtr<Gfx::CharacterBitmap> s_club = Gfx::CharacterBitmap::
|
|||
static RefPtr<Gfx::Bitmap> s_background;
|
||||
|
||||
Card::Card(Type type, uint8_t value)
|
||||
: m_rect(Gfx::Rect({}, { width, height }))
|
||||
: m_rect(Gfx::IntRect({}, { width, height }))
|
||||
, m_front(*Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { width, height }))
|
||||
, m_type(type)
|
||||
, m_value(value)
|
||||
{
|
||||
ASSERT(value < card_count);
|
||||
Gfx::Rect paint_rect({ 0, 0 }, { width, height });
|
||||
Gfx::IntRect paint_rect({ 0, 0 }, { width, height });
|
||||
|
||||
if (s_background.is_null()) {
|
||||
s_background = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, { width, height });
|
||||
|
@ -96,7 +96,7 @@ Card::Card(Type type, uint8_t value)
|
|||
ASSERT(!image.is_null());
|
||||
|
||||
float aspect_ratio = image->width() / static_cast<float>(image->height());
|
||||
auto target_size = Gfx::Size(static_cast<int>(aspect_ratio * (height - 5)), height - 5);
|
||||
auto target_size = Gfx::IntSize(static_cast<int>(aspect_ratio * (height - 5)), height - 5);
|
||||
|
||||
bg_painter.draw_scaled_bitmap(
|
||||
{ { (width - target_size.width()) / 2, (height - target_size.height()) / 2 }, target_size },
|
||||
|
|
|
@ -50,9 +50,9 @@ public:
|
|||
|
||||
virtual ~Card() override;
|
||||
|
||||
Gfx::Rect& rect() { return m_rect; }
|
||||
Gfx::Point position() const { return m_rect.location(); }
|
||||
const Gfx::Point& old_positon() const { return m_old_position; }
|
||||
Gfx::IntRect& rect() { return m_rect; }
|
||||
Gfx::IntPoint position() const { return m_rect.location(); }
|
||||
const Gfx::IntPoint& old_positon() const { return m_old_position; }
|
||||
uint8_t value() const { return m_value; };
|
||||
Type type() const { return m_type; }
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
bool is_upside_down() const { return m_upside_down; }
|
||||
Gfx::Color color() const { return (m_type == Diamonds || m_type == Hearts) ? Color::Red : Color::Black; }
|
||||
|
||||
void set_position(const Gfx::Point p) { m_rect.set_location(p); }
|
||||
void set_position(const Gfx::IntPoint p) { m_rect.set_location(p); }
|
||||
void set_moving(bool moving) { m_moving = moving; }
|
||||
void set_upside_down(bool upside_down) { m_upside_down = upside_down; }
|
||||
|
||||
|
@ -74,9 +74,9 @@ public:
|
|||
private:
|
||||
Card(Type type, uint8_t value);
|
||||
|
||||
Gfx::Rect m_rect;
|
||||
Gfx::IntRect m_rect;
|
||||
NonnullRefPtr<Gfx::Bitmap> m_front;
|
||||
Gfx::Point m_old_position;
|
||||
Gfx::IntPoint m_old_position;
|
||||
Type m_type;
|
||||
uint8_t m_value;
|
||||
bool m_old_position_valid { false };
|
||||
|
|
|
@ -36,7 +36,7 @@ CardStack::CardStack()
|
|||
{
|
||||
}
|
||||
|
||||
CardStack::CardStack(const Gfx::Point& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step)
|
||||
CardStack::CardStack(const Gfx::IntPoint& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step)
|
||||
: m_position(position)
|
||||
, m_type(type)
|
||||
, m_shift_x(shift_x)
|
||||
|
@ -110,7 +110,7 @@ void CardStack::rebound_cards()
|
|||
card.set_position(m_stack_positions.at(card_index++));
|
||||
}
|
||||
|
||||
void CardStack::add_all_grabbed_cards(const Gfx::Point& click_location, NonnullRefPtrVector<Card>& grabbed)
|
||||
void CardStack::add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector<Card>& grabbed)
|
||||
{
|
||||
ASSERT(grabbed.is_empty());
|
||||
|
||||
|
@ -218,7 +218,7 @@ NonnullRefPtr<Card> CardStack::pop()
|
|||
|
||||
void CardStack::calculate_bounding_box()
|
||||
{
|
||||
m_bounding_box = Gfx::Rect(m_position, { Card::width, Card::height });
|
||||
m_bounding_box = Gfx::IntRect(m_position, { Card::width, Card::height });
|
||||
|
||||
if (m_stack.is_empty())
|
||||
return;
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
};
|
||||
|
||||
CardStack();
|
||||
CardStack(const Gfx::Point& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step = 1);
|
||||
CardStack(const Gfx::IntPoint& position, Type type, uint8_t shift_x, uint8_t shift_y, uint8_t step = 1);
|
||||
|
||||
bool is_dirty() const { return m_dirty; }
|
||||
bool is_empty() const { return m_stack.is_empty(); }
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
size_t count() const { return m_stack.size(); }
|
||||
const Card& peek() const { return m_stack.last(); }
|
||||
Card& peek() { return m_stack.last(); }
|
||||
const Gfx::Rect& bounding_box() const { return m_bounding_box; }
|
||||
const Gfx::IntRect& bounding_box() const { return m_bounding_box; }
|
||||
|
||||
void set_focused(bool focused) { m_focused = focused; }
|
||||
void set_dirty() { m_dirty = true; };
|
||||
|
@ -59,7 +59,7 @@ public:
|
|||
void rebound_cards();
|
||||
|
||||
bool is_allowed_to_push(const Card&) const;
|
||||
void add_all_grabbed_cards(const Gfx::Point& click_location, NonnullRefPtrVector<Card>& grabbed);
|
||||
void add_all_grabbed_cards(const Gfx::IntPoint& click_location, NonnullRefPtrVector<Card>& grabbed);
|
||||
void draw(GUI::Painter&, const Gfx::Color& background_color);
|
||||
void clear();
|
||||
|
||||
|
@ -67,14 +67,14 @@ private:
|
|||
void calculate_bounding_box();
|
||||
|
||||
NonnullRefPtrVector<Card> m_stack;
|
||||
Vector<Gfx::Point> m_stack_positions;
|
||||
Gfx::Point m_position;
|
||||
Gfx::Rect m_bounding_box;
|
||||
Vector<Gfx::IntPoint> m_stack_positions;
|
||||
Gfx::IntPoint m_position;
|
||||
Gfx::IntRect m_bounding_box;
|
||||
Type m_type { Invalid };
|
||||
uint8_t m_shift_x { 0 };
|
||||
uint8_t m_shift_y { 0 };
|
||||
uint8_t m_step {};
|
||||
bool m_focused { false };
|
||||
bool m_dirty { false };
|
||||
Gfx::Rect m_base;
|
||||
Gfx::IntRect m_base;
|
||||
};
|
||||
|
|
|
@ -124,7 +124,7 @@ private:
|
|||
Animation m_animation;
|
||||
CardStack* m_focused_stack { nullptr };
|
||||
CardStack m_stacks[StackLocation::__Count];
|
||||
Gfx::Point m_mouse_down_location;
|
||||
Gfx::IntPoint m_mouse_down_location;
|
||||
bool m_mouse_down { false };
|
||||
bool m_repaint_all { true };
|
||||
bool m_has_to_repaint { true };
|
||||
|
|
|
@ -155,7 +155,7 @@ void AbstractButton::keydown_event(KeyEvent& event)
|
|||
Widget::keydown_event(event);
|
||||
}
|
||||
|
||||
void AbstractButton::paint_text(Painter& painter, const Gfx::Rect& rect, const Gfx::Font& font, Gfx::TextAlignment text_alignment)
|
||||
void AbstractButton::paint_text(Painter& painter, const Gfx::IntRect& rect, const Gfx::Font& font, Gfx::TextAlignment text_alignment)
|
||||
{
|
||||
auto clipped_rect = rect.intersected(this->rect());
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ protected:
|
|||
virtual void save_to(JsonObject&) override;
|
||||
virtual bool set_property(const StringView& name, const JsonValue& value) override;
|
||||
|
||||
void paint_text(Painter&, const Gfx::Rect&, const Gfx::Font&, Gfx::TextAlignment);
|
||||
void paint_text(Painter&, const Gfx::IntRect&, const Gfx::Font&, Gfx::TextAlignment);
|
||||
|
||||
private:
|
||||
virtual bool is_abstract_button() const final { return true; }
|
||||
|
|
|
@ -109,7 +109,7 @@ void AbstractTableView::update_content_size()
|
|||
set_size_occupied_by_fixed_elements({ 0, header_height() });
|
||||
}
|
||||
|
||||
Gfx::Rect AbstractTableView::header_rect(int column_index) const
|
||||
Gfx::IntRect AbstractTableView::header_rect(int column_index) const
|
||||
{
|
||||
if (!model())
|
||||
return {};
|
||||
|
@ -147,7 +147,7 @@ void AbstractTableView::paint_headers(Painter& painter)
|
|||
continue;
|
||||
int column_width = this->column_width(column_index);
|
||||
bool is_key_column = model()->key_column() == column_index;
|
||||
Gfx::Rect cell_rect(x_offset, 0, column_width + horizontal_padding() * 2, header_height());
|
||||
Gfx::IntRect cell_rect(x_offset, 0, column_width + horizontal_padding() * 2, header_height());
|
||||
bool pressed = column_index == m_pressed_column_header_index && m_pressed_column_header_is_pressed;
|
||||
bool hovered = column_index == m_hovered_column_header_index && model()->is_column_sortable(column_index);
|
||||
Gfx::StylePainter::paint_button(painter, cell_rect, palette(), Gfx::ButtonStyle::Normal, pressed, hovered);
|
||||
|
@ -224,7 +224,7 @@ void AbstractTableView::set_cell_painting_delegate(int column, OwnPtr<TableCellP
|
|||
|
||||
void AbstractTableView::update_headers()
|
||||
{
|
||||
Gfx::Rect rect { 0, 0, frame_inner_rect().width(), header_height() };
|
||||
Gfx::IntRect rect { 0, 0, frame_inner_rect().width(), header_height() };
|
||||
rect.move_by(frame_thickness(), frame_thickness());
|
||||
update(rect);
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ AbstractTableView::ColumnData& AbstractTableView::column_data(int column) const
|
|||
return m_column_data.at(column);
|
||||
}
|
||||
|
||||
Gfx::Rect AbstractTableView::column_resize_grabbable_rect(int column) const
|
||||
Gfx::IntRect AbstractTableView::column_resize_grabbable_rect(int column) const
|
||||
{
|
||||
if (!model())
|
||||
return {};
|
||||
|
@ -257,7 +257,7 @@ void AbstractTableView::mousemove_event(MouseEvent& event)
|
|||
return AbstractView::mousemove_event(event);
|
||||
|
||||
auto adjusted_position = this->adjusted_position(event.position());
|
||||
Gfx::Point horizontally_adjusted_position(adjusted_position.x(), event.position().y());
|
||||
Gfx::IntPoint horizontally_adjusted_position(adjusted_position.x(), event.position().y());
|
||||
|
||||
if (m_in_column_resize) {
|
||||
auto delta = adjusted_position - m_column_resize_origin;
|
||||
|
@ -315,7 +315,7 @@ void AbstractTableView::mousemove_event(MouseEvent& event)
|
|||
void AbstractTableView::mouseup_event(MouseEvent& event)
|
||||
{
|
||||
auto adjusted_position = this->adjusted_position(event.position());
|
||||
Gfx::Point horizontally_adjusted_position(adjusted_position.x(), event.position().y());
|
||||
Gfx::IntPoint horizontally_adjusted_position(adjusted_position.x(), event.position().y());
|
||||
if (event.button() == MouseButton::Left) {
|
||||
if (m_in_column_resize) {
|
||||
if (!column_resize_grabbable_rect(m_resizing_column).contains(horizontally_adjusted_position))
|
||||
|
@ -352,7 +352,7 @@ void AbstractTableView::mousedown_event(MouseEvent& event)
|
|||
return AbstractView::mousedown_event(event);
|
||||
|
||||
auto adjusted_position = this->adjusted_position(event.position());
|
||||
Gfx::Point horizontally_adjusted_position(adjusted_position.x(), event.position().y());
|
||||
Gfx::IntPoint horizontally_adjusted_position(adjusted_position.x(), event.position().y());
|
||||
|
||||
if (event.y() < header_height()) {
|
||||
int column_count = model()->column_count();
|
||||
|
@ -386,7 +386,7 @@ void AbstractTableView::mousedown_event(MouseEvent& event)
|
|||
AbstractView::mousedown_event(event);
|
||||
}
|
||||
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position, bool& is_toggle) const
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Gfx::IntPoint& position, bool& is_toggle) const
|
||||
{
|
||||
is_toggle = false;
|
||||
if (!model())
|
||||
|
@ -406,7 +406,7 @@ ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position
|
|||
return {};
|
||||
}
|
||||
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Gfx::Point& position) const
|
||||
ModelIndex AbstractTableView::index_at_event_position(const Gfx::IntPoint& position) const
|
||||
{
|
||||
bool is_toggle;
|
||||
auto index = index_at_event_position(position, is_toggle);
|
||||
|
@ -489,7 +489,7 @@ void AbstractTableView::leave_event(Core::Event& event)
|
|||
set_hovered_header_index(-1);
|
||||
}
|
||||
|
||||
Gfx::Rect AbstractTableView::content_rect(int row, int column) const
|
||||
Gfx::IntRect AbstractTableView::content_rect(int row, int column) const
|
||||
{
|
||||
auto row_rect = this->row_rect(row);
|
||||
int x = 0;
|
||||
|
@ -499,17 +499,17 @@ Gfx::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() };
|
||||
}
|
||||
|
||||
Gfx::Rect AbstractTableView::content_rect(const ModelIndex& index) const
|
||||
Gfx::IntRect AbstractTableView::content_rect(const ModelIndex& index) const
|
||||
{
|
||||
return content_rect(index.row(), index.column());
|
||||
}
|
||||
|
||||
Gfx::Rect AbstractTableView::row_rect(int item_index) const
|
||||
Gfx::IntRect AbstractTableView::row_rect(int item_index) const
|
||||
{
|
||||
return { 0, header_height() + (item_index * item_height()), max(content_size().width(), width()), item_height() };
|
||||
}
|
||||
|
||||
Gfx::Point AbstractTableView::adjusted_position(const Gfx::Point& position) const
|
||||
Gfx::IntPoint AbstractTableView::adjusted_position(const Gfx::IntPoint& position) const
|
||||
{
|
||||
return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class TableCellPaintingDelegate {
|
|||
public:
|
||||
virtual ~TableCellPaintingDelegate() {}
|
||||
|
||||
virtual void paint(Painter&, const Gfx::Rect&, const Gfx::Palette&, const Model&, const ModelIndex&) = 0;
|
||||
virtual void paint(Painter&, const Gfx::IntRect&, const Gfx::Palette&, const Model&, const ModelIndex&) = 0;
|
||||
};
|
||||
|
||||
class AbstractTableView : public AbstractView {
|
||||
|
@ -56,16 +56,16 @@ public:
|
|||
|
||||
int horizontal_padding() const { return m_horizontal_padding; }
|
||||
|
||||
Gfx::Point adjusted_position(const Gfx::Point&) const;
|
||||
Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const;
|
||||
|
||||
virtual Gfx::Rect content_rect(const ModelIndex&) const override;
|
||||
Gfx::Rect content_rect(int row, int column) const;
|
||||
Gfx::Rect row_rect(int item_index) const;
|
||||
virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
|
||||
Gfx::IntRect content_rect(int row, int column) const;
|
||||
Gfx::IntRect row_rect(int item_index) const;
|
||||
|
||||
void scroll_into_view(const ModelIndex&, Orientation);
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&, bool& is_toggle) const;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&, bool& is_toggle) const;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
|
||||
|
||||
virtual void select_all() override;
|
||||
|
||||
|
@ -86,7 +86,7 @@ protected:
|
|||
virtual void toggle_index(const ModelIndex&) {}
|
||||
|
||||
void paint_headers(Painter&);
|
||||
Gfx::Rect header_rect(int column) const;
|
||||
Gfx::IntRect header_rect(int column) const;
|
||||
|
||||
static const Gfx::Font& header_font();
|
||||
void update_headers();
|
||||
|
@ -106,7 +106,7 @@ protected:
|
|||
Menu& ensure_header_context_menu();
|
||||
RefPtr<Menu> m_header_context_menu;
|
||||
|
||||
Gfx::Rect column_resize_grabbable_rect(int) const;
|
||||
Gfx::IntRect column_resize_grabbable_rect(int) const;
|
||||
int column_width(int) const;
|
||||
void update_content_size();
|
||||
virtual void update_column_sizes();
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
bool m_in_column_resize { false };
|
||||
bool m_alternating_row_colors { true };
|
||||
int m_horizontal_padding { 5 };
|
||||
Gfx::Point m_column_resize_origin;
|
||||
Gfx::IntPoint m_column_resize_origin;
|
||||
int m_column_resize_original_width { 0 };
|
||||
int m_resizing_column { -1 };
|
||||
int m_pressed_column_header_index { -1 };
|
||||
|
|
|
@ -51,8 +51,8 @@ public:
|
|||
virtual void did_update_model(unsigned flags);
|
||||
virtual void did_update_selection();
|
||||
|
||||
virtual Gfx::Rect content_rect(const ModelIndex&) const { return {}; }
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const = 0;
|
||||
virtual Gfx::IntRect content_rect(const ModelIndex&) const { return {}; }
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const = 0;
|
||||
void begin_editing(const ModelIndex&);
|
||||
void stop_editing();
|
||||
|
||||
|
@ -92,9 +92,9 @@ protected:
|
|||
bool m_editable { false };
|
||||
ModelIndex m_edit_index;
|
||||
RefPtr<Widget> m_edit_widget;
|
||||
Gfx::Rect m_edit_widget_content_rect;
|
||||
Gfx::IntRect m_edit_widget_content_rect;
|
||||
|
||||
Gfx::Point m_left_mousedown_position;
|
||||
Gfx::IntPoint m_left_mousedown_position;
|
||||
bool m_might_drag { false };
|
||||
|
||||
ModelIndex m_hovered_index;
|
||||
|
|
|
@ -141,7 +141,7 @@ private:
|
|||
RefPtr<Label> m_label;
|
||||
};
|
||||
|
||||
void Application::show_tooltip(const StringView& tooltip, const Gfx::Point& screen_location)
|
||||
void Application::show_tooltip(const StringView& tooltip, const Gfx::IntPoint& screen_location)
|
||||
{
|
||||
if (!m_tooltip_window) {
|
||||
m_tooltip_window = TooltipWindow::construct();
|
||||
|
@ -149,10 +149,10 @@ void Application::show_tooltip(const StringView& tooltip, const Gfx::Point& scre
|
|||
}
|
||||
m_tooltip_window->set_tooltip(tooltip);
|
||||
|
||||
Gfx::Rect desktop_rect = Desktop::the().rect();
|
||||
Gfx::IntRect desktop_rect = Desktop::the().rect();
|
||||
|
||||
const int margin = 30;
|
||||
Gfx::Point adjusted_pos = screen_location;
|
||||
Gfx::IntPoint adjusted_pos = screen_location;
|
||||
if (adjusted_pos.x() + m_tooltip_window->width() >= desktop_rect.width() - margin) {
|
||||
adjusted_pos = adjusted_pos.translated(-m_tooltip_window->width(), 0);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
void register_global_shortcut_action(Badge<Action>, Action&);
|
||||
void unregister_global_shortcut_action(Badge<Action>, Action&);
|
||||
|
||||
void show_tooltip(const StringView&, const Gfx::Point& screen_location);
|
||||
void show_tooltip(const StringView&, const Gfx::IntPoint& screen_location);
|
||||
void hide_tooltip();
|
||||
|
||||
bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; }
|
||||
|
|
|
@ -51,7 +51,7 @@ void BoxLayout::run(Widget& widget)
|
|||
if (m_entries.is_empty())
|
||||
return;
|
||||
|
||||
Gfx::Size available_size = widget.size();
|
||||
Gfx::IntSize available_size = widget.size();
|
||||
int number_of_entries_with_fixed_size = 0;
|
||||
|
||||
int number_of_visible_entries = 0;
|
||||
|
@ -99,8 +99,8 @@ void BoxLayout::run(Widget& widget)
|
|||
if (should_log)
|
||||
dbgprintf("BoxLayout: available_size=%s, fixed=%d, fill=%d\n", available_size.to_string().characters(), number_of_entries_with_fixed_size, number_of_entries_with_automatic_size);
|
||||
|
||||
Gfx::Size automatic_size;
|
||||
Gfx::Size automatic_size_for_last_entry;
|
||||
Gfx::IntSize automatic_size;
|
||||
Gfx::IntSize automatic_size_for_last_entry;
|
||||
|
||||
if (number_of_entries_with_automatic_size) {
|
||||
if (m_orientation == Orientation::Horizontal) {
|
||||
|
@ -135,7 +135,7 @@ void BoxLayout::run(Widget& widget)
|
|||
continue;
|
||||
if (!entry.widget->is_visible())
|
||||
continue;
|
||||
Gfx::Rect rect(current_x, current_y, 0, 0);
|
||||
Gfx::IntRect rect(current_x, current_y, 0, 0);
|
||||
if (entry.layout) {
|
||||
// FIXME: Implement recursive layout.
|
||||
ASSERT_NOT_REACHED();
|
||||
|
|
|
@ -58,7 +58,7 @@ void Button::paint_event(PaintEvent& event)
|
|||
return;
|
||||
|
||||
auto content_rect = rect().shrunken(8, 2);
|
||||
auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Gfx::Point();
|
||||
auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Gfx::IntPoint();
|
||||
if (m_icon && !text().is_empty())
|
||||
icon_location.set_x(content_rect.x());
|
||||
if (is_being_pressed() || is_checked())
|
||||
|
@ -79,7 +79,7 @@ void Button::paint_event(PaintEvent& event)
|
|||
content_rect.set_width(content_rect.width() - m_icon->width() - 4);
|
||||
}
|
||||
|
||||
Gfx::Rect text_rect { 0, 0, font.width(text()), font.glyph_height() };
|
||||
Gfx::IntRect text_rect { 0, 0, font.width(text()), font.glyph_height() };
|
||||
if (text_rect.width() > content_rect.width())
|
||||
text_rect.set_width(content_rect.width());
|
||||
text_rect.align_within(content_rect, text_alignment());
|
||||
|
|
|
@ -78,7 +78,7 @@ void CheckBox::paint_event(PaintEvent& event)
|
|||
if (is_enabled() && is_hovered())
|
||||
painter.fill_rect(rect(), palette().hover_highlight());
|
||||
|
||||
Gfx::Rect box_rect {
|
||||
Gfx::IntRect box_rect {
|
||||
0, height() / 2 - s_box_height / 2 - 1,
|
||||
s_box_width, s_box_height
|
||||
};
|
||||
|
|
|
@ -46,7 +46,7 @@ ColorInput::~ColorInput()
|
|||
{
|
||||
}
|
||||
|
||||
Gfx::Rect ColorInput::color_rect() const
|
||||
Gfx::IntRect ColorInput::color_rect() const
|
||||
{
|
||||
auto color_box_padding = 3;
|
||||
auto color_box_size = height() - color_box_padding - color_box_padding;
|
||||
|
|
|
@ -57,7 +57,7 @@ protected:
|
|||
private:
|
||||
ColorInput();
|
||||
|
||||
Gfx::Rect color_rect() const;
|
||||
Gfx::IntRect color_rect() const;
|
||||
void set_color_without_changing_text(Color);
|
||||
|
||||
Color m_color;
|
||||
|
|
|
@ -73,7 +73,7 @@ private:
|
|||
|
||||
RefPtr<Gfx::Bitmap> m_custom_colors;
|
||||
bool m_being_pressed { false };
|
||||
Gfx::Point m_last_position;
|
||||
Gfx::IntPoint m_last_position;
|
||||
|
||||
void pick_color_at_position(GUI::MouseEvent& event);
|
||||
|
||||
|
|
|
@ -122,11 +122,11 @@ void ColumnsView::paint_event(PaintEvent& event)
|
|||
text_color = palette().selection_text();
|
||||
}
|
||||
|
||||
Gfx::Rect row_rect { column_x, row * item_height(), column.width, item_height() };
|
||||
Gfx::IntRect row_rect { column_x, row * item_height(), column.width, item_height() };
|
||||
painter.fill_rect(row_rect, background_color);
|
||||
|
||||
auto icon = model()->data(index, Model::Role::Icon);
|
||||
Gfx::Rect icon_rect = { column_x + icon_spacing(), 0, icon_size(), icon_size() };
|
||||
Gfx::IntRect icon_rect = { column_x + icon_spacing(), 0, icon_size(), icon_size() };
|
||||
icon_rect.center_vertically_within(row_rect);
|
||||
if (icon.is_icon()) {
|
||||
if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) {
|
||||
|
@ -137,7 +137,7 @@ void ColumnsView::paint_event(PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::Rect text_rect = {
|
||||
Gfx::IntRect text_rect = {
|
||||
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()
|
||||
};
|
||||
|
@ -146,7 +146,7 @@ void ColumnsView::paint_event(PaintEvent& event)
|
|||
|
||||
bool expandable = model()->row_count(index) > 0;
|
||||
if (expandable) {
|
||||
Gfx::Rect arrow_rect = {
|
||||
Gfx::IntRect arrow_rect = {
|
||||
text_rect.right() + 1 + icon_spacing(), 0,
|
||||
s_arrow_bitmap_width, s_arrow_bitmap_height
|
||||
};
|
||||
|
@ -214,7 +214,7 @@ void ColumnsView::update_column_sizes()
|
|||
set_content_size({ total_width, total_height });
|
||||
}
|
||||
|
||||
ModelIndex ColumnsView::index_at_event_position(const Gfx::Point& a_position) const
|
||||
ModelIndex ColumnsView::index_at_event_position(const Gfx::IntPoint& a_position) const
|
||||
{
|
||||
if (!model())
|
||||
return {};
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
int model_column() const { return m_model_column; }
|
||||
void set_model_column(int column) { m_model_column = column; }
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
|
||||
|
||||
private:
|
||||
ColumnsView();
|
||||
|
|
|
@ -144,12 +144,12 @@ void ComboBox::open()
|
|||
auto item_text = model()->data(index).to_string();
|
||||
longest_item_width = max(longest_item_width, m_list_view->font().width(item_text));
|
||||
}
|
||||
Gfx::Size size {
|
||||
Gfx::IntSize size {
|
||||
max(width(), longest_item_width + m_list_view->width_occupied_by_vertical_scrollbar() + m_list_view->frame_thickness() * 2 + m_list_view->horizontal_padding()),
|
||||
model()->row_count() * m_list_view->item_height() + m_list_view->frame_thickness() * 2
|
||||
};
|
||||
|
||||
Gfx::Rect list_window_rect { my_screen_rect.bottom_left(), size };
|
||||
Gfx::IntRect list_window_rect { my_screen_rect.bottom_left(), size };
|
||||
list_window_rect.intersect(Desktop::the().rect().shrunken(0, 128));
|
||||
|
||||
m_list_window->set_rect(list_window_rect);
|
||||
|
|
|
@ -45,7 +45,7 @@ Desktop::Desktop()
|
|||
{
|
||||
}
|
||||
|
||||
void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect& rect)
|
||||
void Desktop::did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::IntRect& rect)
|
||||
{
|
||||
if (m_rect == rect)
|
||||
return;
|
||||
|
|
|
@ -45,13 +45,13 @@ public:
|
|||
String wallpaper() const;
|
||||
bool set_wallpaper(const StringView& path);
|
||||
|
||||
Gfx::Rect rect() const { return m_rect; }
|
||||
void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::Rect&);
|
||||
Gfx::IntRect rect() const { return m_rect; }
|
||||
void did_receive_screen_rect(Badge<WindowServerConnection>, const Gfx::IntRect&);
|
||||
|
||||
Function<void(const Gfx::Rect&)> on_rect_change;
|
||||
Function<void(const Gfx::IntRect&)> on_rect_change;
|
||||
|
||||
private:
|
||||
Gfx::Rect m_rect;
|
||||
Gfx::IntRect m_rect;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ DragOperation::Outcome DragOperation::exec()
|
|||
ASSERT(!m_event_loop);
|
||||
|
||||
int bitmap_id = -1;
|
||||
Gfx::Size bitmap_size;
|
||||
Gfx::IntSize bitmap_size;
|
||||
RefPtr<Gfx::Bitmap> shared_bitmap;
|
||||
if (m_bitmap) {
|
||||
shared_bitmap = m_bitmap->to_bitmap_backed_by_shared_buffer();
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
DropEvent::DropEvent(const Gfx::Point& position, const String& text, NonnullRefPtr<Core::MimeData> mime_data)
|
||||
DropEvent::DropEvent(const Gfx::IntPoint& position, const String& text, NonnullRefPtr<Core::MimeData> mime_data)
|
||||
: Event(Event::Drop)
|
||||
, m_position(position)
|
||||
, m_text(text)
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
|
||||
class WMWindowStateChangedEvent : public WMEvent {
|
||||
public:
|
||||
WMWindowStateChangedEvent(int client_id, int window_id, const StringView& title, const Gfx::Rect& rect, bool is_active, WindowType window_type, bool is_minimized, bool is_frameless, int progress)
|
||||
WMWindowStateChangedEvent(int client_id, int window_id, const StringView& title, const Gfx::IntRect& rect, bool is_active, WindowType window_type, bool is_minimized, bool is_frameless, int progress)
|
||||
: WMEvent(Event::Type::WM_WindowStateChanged, client_id, window_id)
|
||||
, m_title(title)
|
||||
, m_rect(rect)
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
}
|
||||
|
||||
String title() const { return m_title; }
|
||||
Gfx::Rect rect() const { return m_rect; }
|
||||
Gfx::IntRect rect() const { return m_rect; }
|
||||
bool is_active() const { return m_active; }
|
||||
WindowType window_type() const { return m_window_type; }
|
||||
bool is_minimized() const { return m_minimized; }
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
|
||||
private:
|
||||
String m_title;
|
||||
Gfx::Rect m_rect;
|
||||
Gfx::IntRect m_rect;
|
||||
WindowType m_window_type;
|
||||
bool m_active;
|
||||
bool m_minimized;
|
||||
|
@ -143,21 +143,21 @@ private:
|
|||
|
||||
class WMWindowRectChangedEvent : public WMEvent {
|
||||
public:
|
||||
WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::Rect& rect)
|
||||
WMWindowRectChangedEvent(int client_id, int window_id, const Gfx::IntRect& rect)
|
||||
: WMEvent(Event::Type::WM_WindowRectChanged, client_id, window_id)
|
||||
, m_rect(rect)
|
||||
{
|
||||
}
|
||||
|
||||
Gfx::Rect rect() const { return m_rect; }
|
||||
Gfx::IntRect rect() const { return m_rect; }
|
||||
|
||||
private:
|
||||
Gfx::Rect m_rect;
|
||||
Gfx::IntRect m_rect;
|
||||
};
|
||||
|
||||
class WMWindowIconBitmapChangedEvent : public WMEvent {
|
||||
public:
|
||||
WMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Gfx::Size& icon_size)
|
||||
WMWindowIconBitmapChangedEvent(int client_id, int window_id, int icon_buffer_id, const Gfx::IntSize& icon_size)
|
||||
: WMEvent(Event::Type::WM_WindowIconBitmapChanged, client_id, window_id)
|
||||
, m_icon_buffer_id(icon_buffer_id)
|
||||
, m_icon_size(icon_size)
|
||||
|
@ -165,79 +165,79 @@ public:
|
|||
}
|
||||
|
||||
int icon_buffer_id() const { return m_icon_buffer_id; }
|
||||
const Gfx::Size& icon_size() const { return m_icon_size; }
|
||||
const Gfx::IntSize& icon_size() const { return m_icon_size; }
|
||||
|
||||
private:
|
||||
int m_icon_buffer_id;
|
||||
Gfx::Size m_icon_size;
|
||||
Gfx::IntSize m_icon_size;
|
||||
};
|
||||
|
||||
class MultiPaintEvent final : public Event {
|
||||
public:
|
||||
explicit MultiPaintEvent(const Vector<Gfx::Rect, 32>& rects, const Gfx::Size& window_size)
|
||||
explicit MultiPaintEvent(const Vector<Gfx::IntRect, 32>& rects, const Gfx::IntSize& window_size)
|
||||
: Event(Event::MultiPaint)
|
||||
, m_rects(rects)
|
||||
, m_window_size(window_size)
|
||||
{
|
||||
}
|
||||
|
||||
const Vector<Gfx::Rect, 32>& rects() const { return m_rects; }
|
||||
Gfx::Size window_size() const { return m_window_size; }
|
||||
const Vector<Gfx::IntRect, 32>& rects() const { return m_rects; }
|
||||
Gfx::IntSize window_size() const { return m_window_size; }
|
||||
|
||||
private:
|
||||
Vector<Gfx::Rect, 32> m_rects;
|
||||
Gfx::Size m_window_size;
|
||||
Vector<Gfx::IntRect, 32> m_rects;
|
||||
Gfx::IntSize m_window_size;
|
||||
};
|
||||
|
||||
class PaintEvent final : public Event {
|
||||
public:
|
||||
explicit PaintEvent(const Gfx::Rect& rect, const Gfx::Size& window_size = {})
|
||||
explicit PaintEvent(const Gfx::IntRect& rect, const Gfx::IntSize& window_size = {})
|
||||
: Event(Event::Paint)
|
||||
, m_rect(rect)
|
||||
, m_window_size(window_size)
|
||||
{
|
||||
}
|
||||
|
||||
Gfx::Rect rect() const { return m_rect; }
|
||||
Gfx::Size window_size() const { return m_window_size; }
|
||||
Gfx::IntRect rect() const { return m_rect; }
|
||||
Gfx::IntSize window_size() const { return m_window_size; }
|
||||
|
||||
private:
|
||||
Gfx::Rect m_rect;
|
||||
Gfx::Size m_window_size;
|
||||
Gfx::IntRect m_rect;
|
||||
Gfx::IntSize m_window_size;
|
||||
};
|
||||
|
||||
class ResizeEvent final : public Event {
|
||||
public:
|
||||
explicit ResizeEvent(const Gfx::Size& old_size, const Gfx::Size& size)
|
||||
explicit ResizeEvent(const Gfx::IntSize& old_size, const Gfx::IntSize& size)
|
||||
: Event(Event::Resize)
|
||||
, m_old_size(old_size)
|
||||
, m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
const Gfx::Size& old_size() const { return m_old_size; }
|
||||
const Gfx::Size& size() const { return m_size; }
|
||||
const Gfx::IntSize& old_size() const { return m_old_size; }
|
||||
const Gfx::IntSize& size() const { return m_size; }
|
||||
|
||||
private:
|
||||
Gfx::Size m_old_size;
|
||||
Gfx::Size m_size;
|
||||
Gfx::IntSize m_old_size;
|
||||
Gfx::IntSize m_size;
|
||||
};
|
||||
|
||||
class ContextMenuEvent final : public Event {
|
||||
public:
|
||||
explicit ContextMenuEvent(const Gfx::Point& position, const Gfx::Point& screen_position)
|
||||
explicit ContextMenuEvent(const Gfx::IntPoint& position, const Gfx::IntPoint& screen_position)
|
||||
: Event(Event::ContextMenu)
|
||||
, m_position(position)
|
||||
, m_screen_position(screen_position)
|
||||
{
|
||||
}
|
||||
|
||||
const Gfx::Point& position() const { return m_position; }
|
||||
const Gfx::Point& screen_position() const { return m_screen_position; }
|
||||
const Gfx::IntPoint& position() const { return m_position; }
|
||||
const Gfx::IntPoint& screen_position() const { return m_screen_position; }
|
||||
|
||||
private:
|
||||
Gfx::Point m_position;
|
||||
Gfx::Point m_screen_position;
|
||||
Gfx::IntPoint m_position;
|
||||
Gfx::IntPoint m_screen_position;
|
||||
};
|
||||
|
||||
class ShowEvent final : public Event {
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
|
||||
class MouseEvent final : public Event {
|
||||
public:
|
||||
MouseEvent(Type type, const Gfx::Point& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta)
|
||||
MouseEvent(Type type, const Gfx::IntPoint& position, unsigned buttons, MouseButton button, unsigned modifiers, int wheel_delta)
|
||||
: Event(type)
|
||||
, m_position(position)
|
||||
, m_buttons(buttons)
|
||||
|
@ -306,7 +306,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Gfx::Point position() const { return m_position; }
|
||||
Gfx::IntPoint position() const { return m_position; }
|
||||
int x() const { return m_position.x(); }
|
||||
int y() const { return m_position.y(); }
|
||||
MouseButton button() const { return m_button; }
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
int wheel_delta() const { return m_wheel_delta; }
|
||||
|
||||
private:
|
||||
Gfx::Point m_position;
|
||||
Gfx::IntPoint m_position;
|
||||
unsigned m_buttons { 0 };
|
||||
MouseButton m_button { MouseButton::None };
|
||||
unsigned m_modifiers { 0 };
|
||||
|
@ -324,33 +324,33 @@ private:
|
|||
|
||||
class DragEvent final : public Event {
|
||||
public:
|
||||
DragEvent(Type type, const Gfx::Point& position, const String& data_type)
|
||||
DragEvent(Type type, const Gfx::IntPoint& position, const String& data_type)
|
||||
: Event(type)
|
||||
, m_position(position)
|
||||
, m_data_type(data_type)
|
||||
{
|
||||
}
|
||||
|
||||
const Gfx::Point& position() const { return m_position; }
|
||||
const Gfx::IntPoint& position() const { return m_position; }
|
||||
const String& data_type() const { return m_data_type; }
|
||||
|
||||
private:
|
||||
Gfx::Point m_position;
|
||||
Gfx::IntPoint m_position;
|
||||
String m_data_type;
|
||||
};
|
||||
|
||||
class DropEvent final : public Event {
|
||||
public:
|
||||
DropEvent(const Gfx::Point&, const String& text, NonnullRefPtr<Core::MimeData> mime_data);
|
||||
DropEvent(const Gfx::IntPoint&, const String& text, NonnullRefPtr<Core::MimeData> mime_data);
|
||||
|
||||
~DropEvent();
|
||||
|
||||
const Gfx::Point& position() const { return m_position; }
|
||||
const Gfx::IntPoint& position() const { return m_position; }
|
||||
const String& text() const { return m_text; }
|
||||
const Core::MimeData& mime_data() const { return m_mime_data; }
|
||||
|
||||
private:
|
||||
Gfx::Point m_position;
|
||||
Gfx::IntPoint m_position;
|
||||
String m_text;
|
||||
NonnullRefPtr<Core::MimeData> m_mime_data;
|
||||
};
|
||||
|
|
|
@ -482,7 +482,7 @@ static RefPtr<Gfx::Bitmap> render_thumbnail(const StringView& path)
|
|||
double scale = min(32 / (double)png_bitmap->width(), 32 / (double)png_bitmap->height());
|
||||
|
||||
auto thumbnail = Gfx::Bitmap::create(png_bitmap->format(), { 32, 32 });
|
||||
Gfx::Rect destination = Gfx::Rect(0, 0, (int)(png_bitmap->width() * scale), (int)(png_bitmap->height() * scale));
|
||||
Gfx::IntRect destination = Gfx::IntRect(0, 0, (int)(png_bitmap->width() * scale), (int)(png_bitmap->height() * scale));
|
||||
destination.center_within(thumbnail->rect());
|
||||
|
||||
Painter painter(*thumbnail);
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
Gfx::FrameShape frame_shape() const { return m_shape; }
|
||||
void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; }
|
||||
|
||||
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 }; }
|
||||
Gfx::Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
|
||||
Gfx::IntRect frame_inner_rect_for_size(const Gfx::IntSize& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; }
|
||||
Gfx::IntRect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
|
||||
|
||||
protected:
|
||||
Frame();
|
||||
|
|
|
@ -46,13 +46,13 @@ void GroupBox::paint_event(PaintEvent& event)
|
|||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
Gfx::Rect frame_rect {
|
||||
Gfx::IntRect frame_rect {
|
||||
0, 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::Rect text_rect { 4, 0, font().width(m_title) + 6, font().glyph_height() };
|
||||
Gfx::IntRect text_rect { 4, 0, font().width(m_title) + 6, font().glyph_height() };
|
||||
painter.fill_rect(text_rect, palette().button());
|
||||
painter.draw_text(text_rect, m_title, Gfx::TextAlignment::Center, palette().button_text());
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ void IconView::update_content_size()
|
|||
set_content_size({ content_width, content_height });
|
||||
}
|
||||
|
||||
Gfx::Rect IconView::item_rect(int item_index) const
|
||||
Gfx::IntRect IconView::item_rect(int item_index) const
|
||||
{
|
||||
if (!m_visual_row_count || !m_visual_column_count)
|
||||
return {};
|
||||
|
@ -107,14 +107,14 @@ Gfx::Rect IconView::item_rect(int item_index) const
|
|||
};
|
||||
}
|
||||
|
||||
Vector<int> IconView::items_intersecting_rect(const Gfx::Rect& rect) const
|
||||
Vector<int> IconView::items_intersecting_rect(const Gfx::IntRect& rect) const
|
||||
{
|
||||
ASSERT(model());
|
||||
Vector<int> item_indexes;
|
||||
for (int item_index = 0; item_index < item_count(); ++item_index) {
|
||||
Gfx::Rect item_rect;
|
||||
Gfx::Rect icon_rect;
|
||||
Gfx::Rect text_rect;
|
||||
Gfx::IntRect item_rect;
|
||||
Gfx::IntRect icon_rect;
|
||||
Gfx::IntRect text_rect;
|
||||
auto index = model()->index(item_index, model_column());
|
||||
auto item_text = model()->data(index);
|
||||
get_item_rects(item_index, font_for_index(index), item_text, item_rect, icon_rect, text_rect);
|
||||
|
@ -124,16 +124,16 @@ Vector<int> IconView::items_intersecting_rect(const Gfx::Rect& rect) const
|
|||
return item_indexes;
|
||||
}
|
||||
|
||||
ModelIndex IconView::index_at_event_position(const Gfx::Point& position) const
|
||||
ModelIndex IconView::index_at_event_position(const Gfx::IntPoint& position) const
|
||||
{
|
||||
ASSERT(model());
|
||||
// FIXME: Since all items are the same size, just compute the clicked item index
|
||||
// instead of iterating over everything.
|
||||
auto adjusted_position = this->adjusted_position(position);
|
||||
for (int item_index = 0; item_index < item_count(); ++item_index) {
|
||||
Gfx::Rect item_rect;
|
||||
Gfx::Rect icon_rect;
|
||||
Gfx::Rect text_rect;
|
||||
Gfx::IntRect item_rect;
|
||||
Gfx::IntRect icon_rect;
|
||||
Gfx::IntRect text_rect;
|
||||
auto index = model()->index(item_index, model_column());
|
||||
auto item_text = model()->data(index);
|
||||
get_item_rects(item_index, font_for_index(index), item_text, item_rect, icon_rect, text_rect);
|
||||
|
@ -143,7 +143,7 @@ ModelIndex IconView::index_at_event_position(const Gfx::Point& position) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Gfx::Point IconView::adjusted_position(const Gfx::Point& position) const
|
||||
Gfx::IntPoint IconView::adjusted_position(const Gfx::IntPoint& position) const
|
||||
{
|
||||
return position.translated(0, vertical_scrollbar().value());
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ void IconView::mousemove_event(MouseEvent& event)
|
|||
auto adjusted_position = this->adjusted_position(event.position());
|
||||
if (m_rubber_band_current != adjusted_position) {
|
||||
m_rubber_band_current = adjusted_position;
|
||||
auto rubber_band_rect = Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current);
|
||||
auto rubber_band_rect = Gfx::IntRect::from_two_points(m_rubber_band_origin, m_rubber_band_current);
|
||||
selection().clear();
|
||||
for (auto item_index : items_intersecting_rect(rubber_band_rect)) {
|
||||
selection().add(model()->index(item_index, model_column()));
|
||||
|
@ -236,7 +236,7 @@ void IconView::mousemove_event(MouseEvent& event)
|
|||
AbstractView::mousemove_event(event);
|
||||
}
|
||||
|
||||
void IconView::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
|
||||
void IconView::get_item_rects(int item_index, const Gfx::Font& font, const Variant& item_text, Gfx::IntRect& item_rect, Gfx::IntRect& icon_rect, Gfx::IntRect& text_rect) const
|
||||
{
|
||||
item_rect = this->item_rect(item_index);
|
||||
icon_rect = { 0, 0, 32, 32 };
|
||||
|
@ -258,7 +258,7 @@ void IconView::second_paint_event(PaintEvent& event)
|
|||
painter.translate(frame_thickness(), frame_thickness());
|
||||
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
||||
auto rubber_band_rect = Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current);
|
||||
auto rubber_band_rect = Gfx::IntRect::from_two_points(m_rubber_band_origin, m_rubber_band_current);
|
||||
painter.fill_rect(rubber_band_rect, palette().rubber_band_fill());
|
||||
painter.draw_rect(rubber_band_rect, palette().rubber_band_border());
|
||||
}
|
||||
|
@ -289,14 +289,14 @@ void IconView::paint_event(PaintEvent& event)
|
|||
auto icon = model()->data(model_index, Model::Role::Icon);
|
||||
auto item_text = model()->data(model_index, Model::Role::Display);
|
||||
|
||||
Gfx::Rect item_rect;
|
||||
Gfx::Rect icon_rect;
|
||||
Gfx::Rect text_rect;
|
||||
Gfx::IntRect item_rect;
|
||||
Gfx::IntRect icon_rect;
|
||||
Gfx::IntRect text_rect;
|
||||
get_item_rects(item_index, font_for_index(model_index), item_text, item_rect, icon_rect, text_rect);
|
||||
|
||||
if (icon.is_icon()) {
|
||||
if (auto bitmap = icon.as_icon().bitmap_for_size(icon_rect.width())) {
|
||||
Gfx::Rect destination = bitmap->rect();
|
||||
Gfx::IntRect destination = bitmap->rect();
|
||||
destination.center_within(icon_rect);
|
||||
|
||||
if (m_hovered_index.is_valid() && m_hovered_index == model_index) {
|
||||
|
|
|
@ -40,13 +40,13 @@ public:
|
|||
int horizontal_padding() const { return m_horizontal_padding; }
|
||||
|
||||
void scroll_into_view(const ModelIndex&, Orientation);
|
||||
Gfx::Size effective_item_size() const { return m_effective_item_size; }
|
||||
Gfx::IntSize effective_item_size() const { return m_effective_item_size; }
|
||||
|
||||
int model_column() const { return m_model_column; }
|
||||
void set_model_column(int column) { m_model_column = column; }
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
Gfx::Point adjusted_position(const Gfx::Point&) const;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
|
||||
Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const;
|
||||
|
||||
virtual void select_all() override;
|
||||
private:
|
||||
|
@ -63,21 +63,21 @@ private:
|
|||
virtual void drag_move_event(DragEvent&) override;
|
||||
|
||||
int item_count() const;
|
||||
Gfx::Rect item_rect(int item_index) const;
|
||||
Vector<int> items_intersecting_rect(const Gfx::Rect&) const;
|
||||
Gfx::IntRect item_rect(int item_index) const;
|
||||
Vector<int> items_intersecting_rect(const Gfx::IntRect&) const;
|
||||
void update_content_size();
|
||||
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;
|
||||
void get_item_rects(int item_index, const Gfx::Font&, const Variant& item_text, Gfx::IntRect& item_rect, Gfx::IntRect& icon_rect, Gfx::IntRect& text_rect) const;
|
||||
|
||||
int m_horizontal_padding { 5 };
|
||||
int m_model_column { 0 };
|
||||
int m_visual_column_count { 0 };
|
||||
int m_visual_row_count { 0 };
|
||||
|
||||
Gfx::Size m_effective_item_size { 80, 80 };
|
||||
Gfx::IntSize m_effective_item_size { 80, 80 };
|
||||
|
||||
bool m_rubber_banding { false };
|
||||
Gfx::Point m_rubber_band_origin;
|
||||
Gfx::Point m_rubber_band_current;
|
||||
Gfx::IntPoint m_rubber_band_origin;
|
||||
Gfx::IntPoint m_rubber_band_current;
|
||||
Vector<ModelIndex> m_rubber_band_remembered_selection;
|
||||
|
||||
ModelIndex m_drop_candidate_index;
|
||||
|
|
|
@ -83,17 +83,17 @@ void ListView::did_update_model(unsigned flags)
|
|||
update();
|
||||
}
|
||||
|
||||
Gfx::Rect ListView::content_rect(int row) const
|
||||
Gfx::IntRect ListView::content_rect(int row) const
|
||||
{
|
||||
return { 0, row * item_height(), content_width(), item_height() };
|
||||
}
|
||||
|
||||
Gfx::Rect ListView::content_rect(const ModelIndex& index) const
|
||||
Gfx::IntRect ListView::content_rect(const ModelIndex& index) const
|
||||
{
|
||||
return content_rect(index.row());
|
||||
}
|
||||
|
||||
ModelIndex ListView::index_at_event_position(const Gfx::Point& point) const
|
||||
ModelIndex ListView::index_at_event_position(const Gfx::IntPoint& point) const
|
||||
{
|
||||
ASSERT(model());
|
||||
|
||||
|
@ -106,7 +106,7 @@ ModelIndex ListView::index_at_event_position(const Gfx::Point& point) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Gfx::Point ListView::adjusted_position(const Gfx::Point& position) const
|
||||
Gfx::IntPoint ListView::adjusted_position(const Gfx::IntPoint& position) const
|
||||
{
|
||||
return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ void ListView::paint_event(PaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
Gfx::Rect row_rect(0, y, content_width(), item_height());
|
||||
Gfx::IntRect row_rect(0, y, content_width(), item_height());
|
||||
painter.fill_rect(row_rect, background_color);
|
||||
auto index = model()->index(row_index, m_model_column);
|
||||
auto data = model()->data(index);
|
||||
|
@ -169,7 +169,7 @@ void ListView::paint_event(PaintEvent& event)
|
|||
++painted_item_index;
|
||||
};
|
||||
|
||||
Gfx::Rect unpainted_rect(0, painted_item_index * item_height(), exposed_width, height());
|
||||
Gfx::IntRect unpainted_rect(0, painted_item_index * item_height(), exposed_width, height());
|
||||
if (fill_with_background_color())
|
||||
painter.fill_rect(unpainted_rect, palette().color(background_role()));
|
||||
}
|
||||
|
|
|
@ -44,10 +44,10 @@ public:
|
|||
|
||||
void scroll_into_view(const ModelIndex&, Orientation);
|
||||
|
||||
Gfx::Point adjusted_position(const Gfx::Point&) const;
|
||||
Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const;
|
||||
|
||||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
virtual Gfx::Rect content_rect(const ModelIndex&) const override;
|
||||
virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;
|
||||
virtual Gfx::IntRect content_rect(const ModelIndex&) const override;
|
||||
|
||||
int model_column() const { return m_model_column; }
|
||||
void set_model_column(int column) { m_model_column = column; }
|
||||
|
@ -65,7 +65,7 @@ private:
|
|||
virtual void keydown_event(KeyEvent&) override;
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
||||
Gfx::Rect content_rect(int row) const;
|
||||
Gfx::IntRect content_rect(int row) const;
|
||||
int item_count() const;
|
||||
void update_content_size();
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ void Menu::realize_if_needed()
|
|||
realize_menu();
|
||||
}
|
||||
|
||||
void Menu::popup(const Gfx::Point& screen_position)
|
||||
void Menu::popup(const Gfx::IntPoint& screen_position)
|
||||
{
|
||||
realize_if_needed();
|
||||
WindowServerConnection::the().post_message(Messages::WindowServer::PopupMenu(m_menu_id, screen_position));
|
||||
|
@ -129,7 +129,7 @@ int Menu::realize_menu()
|
|||
int icon_buffer_id = -1;
|
||||
if (action.icon()) {
|
||||
ASSERT(action.icon()->format() == Gfx::BitmapFormat::RGBA32);
|
||||
ASSERT(action.icon()->size() == Gfx::Size(16, 16));
|
||||
ASSERT(action.icon()->size() == Gfx::IntSize(16, 16));
|
||||
if (action.icon()->shbuf_id() == -1) {
|
||||
auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes());
|
||||
ASSERT(shared_buffer);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue