From 4f85dafa284c1ded1fe019bf8b85a03f8ec7b820 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Mon, 17 Oct 2022 07:39:25 +0300 Subject: [PATCH] fix listview selection bug --- src/ListView.cpp | 6 ++++-- src/Styles.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ListView.cpp b/src/ListView.cpp index 9c35f4a..71f48f0 100644 --- a/src/ListView.cpp +++ b/src/ListView.cpp @@ -33,10 +33,10 @@ void ListView::on_mouse_button(MouseButtonEvent &event) { if (event.was_left_button_pressed()) { for (unsigned int i = 0; i < elements.size(); i++) { auto element = elements[i]; - double item_y = m_item_height * i; + double item_y = rect().y() + m_item_height * i; double event_y = event.point().y() + m_scroll; - if (event_y > item_y && event_y < item_y + m_item_height) { + if (event_y >= item_y && event_y <= item_y + m_item_height) { set_active_element(i); break; } @@ -71,6 +71,8 @@ void ListView::on_paint() { { if (m_active_element == i) { painter()->source_rgb(style()->background_active()); + } else if ((i % 2) == 0) { + painter()->source_rgb(style()->background_focused()); } else { painter()->source_rgb(style()->background_norm()); } diff --git a/src/Styles.cpp b/src/Styles.cpp index 87874cc..d3f5c1b 100644 --- a/src/Styles.cpp +++ b/src/Styles.cpp @@ -117,7 +117,7 @@ GenericStyle flat_listview_style { pango_font_description_from_string("sans-serif"), black1, white2, - white0, + white1, accent2, 6.0, true,