@@ -174,7 +174,7 @@ void GTreeView::traverse_in_paint_order(Callback callback) const
174
174
auto node_text = model.data (index, GModel::Role::Display).to_string ();
175
175
Rect rect = {
176
176
x_offset, y_offset,
177
- icon_size () + icon_spacing () + font ().width (node_text), item_height ()
177
+ toggle_size () + icon_spacing () + icon_size () + icon_spacing () + font ().width (node_text), item_height ()
178
178
};
179
179
if (rect.intersects (visible_content_rect)) {
180
180
if (callback (index, rect, indent_level) == IterationDecision::Abort)
@@ -219,7 +219,7 @@ void GTreeView::paint_event(GPaintEvent& event)
219
219
auto icon = model.data (index, GModel::Role::Icon);
220
220
if (icon.is_icon ()) {
221
221
if (auto * bitmap = icon.as_icon ().bitmap_for_size (icon_size ()))
222
- painter.blit (rect .location (), *bitmap, bitmap->rect ());
222
+ painter.blit (icon_rect .location (), *bitmap, bitmap->rect ());
223
223
}
224
224
Rect text_rect = {
225
225
icon_rect.right () + 1 + icon_spacing (), rect.y (),
@@ -245,6 +245,18 @@ void GTreeView::paint_event(GPaintEvent& event)
245
245
}
246
246
index_at_indent = parent_of_index_at_indent;
247
247
}
248
+
249
+ if (model.row_count (index) > 0 ) {
250
+ int toggle_x = indent_width_in_pixels () * indent_level - icon_size () / 2 - 3 ;
251
+ Rect toggle_rect = { toggle_x, rect.y (), toggle_size (), toggle_size () };
252
+ toggle_rect.center_vertically_within (rect);
253
+ auto & metadata = ensure_metadata_for_index (index);
254
+ if (metadata.open )
255
+ painter.blit (toggle_rect.location (), *m_collapse_bitmap, m_collapse_bitmap->rect ());
256
+ else
257
+ painter.blit (toggle_rect.location (), *m_expand_bitmap, m_expand_bitmap->rect ());
258
+ }
259
+
248
260
return IterationDecision::Continue;
249
261
});
250
262
}
0 commit comments