fix listview selection bug
This commit is contained in:
parent
e178428742
commit
4f85dafa28
2 changed files with 5 additions and 3 deletions
|
@ -33,10 +33,10 @@ void ListView::on_mouse_button(MouseButtonEvent &event) {
|
||||||
if (event.was_left_button_pressed()) {
|
if (event.was_left_button_pressed()) {
|
||||||
for (unsigned int i = 0; i < elements.size(); i++) {
|
for (unsigned int i = 0; i < elements.size(); i++) {
|
||||||
auto element = elements[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;
|
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);
|
set_active_element(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,8 @@ void ListView::on_paint() {
|
||||||
{
|
{
|
||||||
if (m_active_element == i) {
|
if (m_active_element == i) {
|
||||||
painter()->source_rgb(style()->background_active());
|
painter()->source_rgb(style()->background_active());
|
||||||
|
} else if ((i % 2) == 0) {
|
||||||
|
painter()->source_rgb(style()->background_focused());
|
||||||
} else {
|
} else {
|
||||||
painter()->source_rgb(style()->background_norm());
|
painter()->source_rgb(style()->background_norm());
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ GenericStyle flat_listview_style {
|
||||||
pango_font_description_from_string("sans-serif"),
|
pango_font_description_from_string("sans-serif"),
|
||||||
black1,
|
black1,
|
||||||
white2,
|
white2,
|
||||||
white0,
|
white1,
|
||||||
accent2,
|
accent2,
|
||||||
6.0,
|
6.0,
|
||||||
true,
|
true,
|
||||||
|
|
Loading…
Reference in a new issue