summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/TreeView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibGUI/TreeView.cpp')
-rw-r--r--Libraries/LibGUI/TreeView.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp
index 016037d6cb..d21e571db4 100644
--- a/Libraries/LibGUI/TreeView.cpp
+++ b/Libraries/LibGUI/TreeView.cpp
@@ -65,14 +65,14 @@ TreeView::~TreeView()
{
}
-ModelIndex TreeView::index_at_event_position(const Gfx::Point& a_position, bool& is_toggle) const
+ModelIndex TreeView::index_at_event_position(const Gfx::IntPoint& a_position, bool& is_toggle) const
{
auto position = a_position.translated(0, -header_height()).translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness());
is_toggle = false;
if (!model())
return {};
ModelIndex result;
- traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect& toggle_rect, int) {
+ traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& rect, const Gfx::IntRect& toggle_rect, int) {
if (toggle_rect.contains(position)) {
result = index;
is_toggle = true;
@@ -165,11 +165,11 @@ void TreeView::traverse_in_paint_order(Callback callback) const
auto& metadata = ensure_metadata_for_index(index);
int x_offset = tree_column_x_offset + horizontal_padding() + indent_level * indent_width_in_pixels();
auto node_text = model.data(index, Model::Role::Display).to_string();
- Gfx::Rect rect = {
+ Gfx::IntRect rect = {
x_offset, y_offset,
icon_size() + icon_spacing() + text_padding() + font().width(node_text) + text_padding(), item_height()
};
- Gfx::Rect toggle_rect;
+ Gfx::IntRect toggle_rect;
if (row_count_at_index > 0) {
int toggle_x = tree_column_x_offset + horizontal_padding() + (indent_width_in_pixels() * indent_level) - (icon_size() / 2) - 4;
toggle_rect = { toggle_x, rect.y(), toggle_size(), toggle_size() };
@@ -223,7 +223,7 @@ void TreeView::paint_event(PaintEvent& event)
int painted_row_index = 0;
- traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& a_rect, const Gfx::Rect& a_toggle_rect, int indent_level) {
+ traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& a_rect, const Gfx::IntRect& a_toggle_rect, int indent_level) {
if (!a_rect.intersects_vertically(visible_content_rect))
return IterationDecision::Continue;
@@ -265,7 +265,7 @@ void TreeView::paint_event(PaintEvent& event)
row_width = frame_inner_rect().width();
}
- Gfx::Rect row_rect { 0, rect.y(), row_width, rect.height() };
+ Gfx::IntRect row_rect { 0, rect.y(), row_width, rect.height() };
painter.fill_rect(row_rect, background_color);
int x_offset = 0;
@@ -277,7 +277,7 @@ void TreeView::paint_event(PaintEvent& event)
painter.draw_rect(toggle_rect, text_color);
if (column_index != tree_column) {
- Gfx::Rect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height());
+ Gfx::IntRect cell_rect(horizontal_padding() + x_offset, rect.y(), column_width, item_height());
auto cell_index = model.sibling(index.row(), column_index, index.parent());
if (auto* delegate = column_data(column_index).cell_painting_delegate.ptr()) {
@@ -299,7 +299,7 @@ void TreeView::paint_event(PaintEvent& event)
}
} else {
// It's the tree column!
- Gfx::Rect icon_rect = { rect.x(), rect.y(), icon_size(), icon_size() };
+ Gfx::IntRect icon_rect = { rect.x(), rect.y(), icon_size(), icon_size() };
auto icon = model.data(index, Model::Role::Icon);
if (icon.is_icon()) {
if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) {
@@ -309,7 +309,7 @@ void TreeView::paint_event(PaintEvent& event)
painter.blit(icon_rect.location(), *bitmap, bitmap->rect());
}
}
- Gfx::Rect text_rect = {
+ Gfx::IntRect text_rect = {
icon_rect.right() + 1 + icon_spacing(), rect.y(),
rect.width() - icon_size() - icon_spacing(), rect.height()
};
@@ -319,16 +319,16 @@ void TreeView::paint_event(PaintEvent& event)
for (int i = indent_level; i > 0; --i) {
auto parent_of_index_at_indent = index_at_indent.parent();
bool index_at_indent_is_last_in_parent = index_at_indent.row() == model.row_count(parent_of_index_at_indent) - 1;
- Gfx::Point a { tree_column_x_offset + horizontal_padding() + indent_width_in_pixels() * i - icon_size() / 2, rect.y() - 2 };
- Gfx::Point b { a.x(), a.y() + item_height() - 1 };
+ Gfx::IntPoint a { tree_column_x_offset + horizontal_padding() + indent_width_in_pixels() * i - icon_size() / 2, rect.y() - 2 };
+ Gfx::IntPoint b { a.x(), a.y() + item_height() - 1 };
if (index_at_indent_is_last_in_parent)
b.set_y(rect.center().y());
if (!(i != indent_level && index_at_indent_is_last_in_parent))
painter.draw_line(a, b, Color::MidGray);
if (i == indent_level) {
- Gfx::Point c { a.x(), rect.center().y() };
- Gfx::Point d { c.x() + icon_size() / 2, c.y() };
+ Gfx::IntPoint c { a.x(), rect.center().y() };
+ Gfx::IntPoint d { c.x() + icon_size() / 2, c.y() };
painter.draw_line(c, d, Color::MidGray);
}
index_at_indent = parent_of_index_at_indent;
@@ -357,8 +357,8 @@ void TreeView::scroll_into_view(const ModelIndex& a_index, Orientation orientati
{
if (!a_index.is_valid())
return;
- Gfx::Rect found_rect;
- traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect& rect, const Gfx::Rect&, int) {
+ Gfx::IntRect found_rect;
+ traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect& rect, const Gfx::IntRect&, int) {
if (index == a_index) {
found_rect = rect;
return IterationDecision::Break;
@@ -414,7 +414,7 @@ void TreeView::keydown_event(KeyEvent& event)
if (event.key() == KeyCode::Key_Up) {
ModelIndex previous_index;
ModelIndex found_index;
- traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect&, const Gfx::Rect&, int) {
+ traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect&, const Gfx::IntRect&, int) {
if (index == cursor_index) {
found_index = previous_index;
return IterationDecision::Break;
@@ -432,7 +432,7 @@ void TreeView::keydown_event(KeyEvent& event)
if (event.key() == KeyCode::Key_Down) {
ModelIndex previous_index;
ModelIndex found_index;
- traverse_in_paint_order([&](const ModelIndex& index, const Gfx::Rect&, const Gfx::Rect&, int) {
+ traverse_in_paint_order([&](const ModelIndex& index, const Gfx::IntRect&, const Gfx::IntRect&, int) {
if (previous_index == cursor_index) {
found_index = index;
return IterationDecision::Break;
@@ -506,7 +506,7 @@ void TreeView::keydown_event(KeyEvent& event)
int TreeView::item_count() const
{
int count = 0;
- traverse_in_paint_order([&](const ModelIndex&, const Gfx::Rect&, const Gfx::Rect&, int) {
+ traverse_in_paint_order([&](const ModelIndex&, const Gfx::IntRect&, const Gfx::IntRect&, int) {
++count;
return IterationDecision::Continue;
});
@@ -552,7 +552,7 @@ void TreeView::update_column_sizes()
int tree_column_header_width = header_font().width(model.column_name(tree_column));
int tree_column_width = tree_column_header_width;
- traverse_in_paint_order([&](const ModelIndex&, const Gfx::Rect& rect, const Gfx::Rect&, int) {
+ traverse_in_paint_order([&](const ModelIndex&, const Gfx::IntRect& rect, const Gfx::IntRect&, int) {
tree_column_width = max(rect.right() - tree_column_x_offset, tree_column_width);
return IterationDecision::Continue;
});