Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
zisoft authored and TurboGit committed Jan 26, 2024
1 parent 9b710bf commit 6a86f99
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/dtgtk/thumbtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,31 +1047,29 @@ static gboolean _event_scroll_compressed(gpointer user_data)
{
if (!user_data) return FALSE;
dt_thumbtable_t *table = (dt_thumbtable_t *)user_data;
if (table->scroll_value == 0)
{
table->scroll_timeout_id = 0;
return FALSE;
}

float delta = table->scroll_value;
if (table->scroll_value != 0)
{
float delta = table->scroll_value;

// starting from here, all further scroll event will count for the next round
table->scroll_value = 0;
// starting from here, all further scroll event will count for the next round
table->scroll_value = 0;

// for filemanager and filmstrip, scrolled = move for
// filemanager we ensure to fallback to show full row (can be
// half shown if scrollbar used)
int move = table->thumb_size * delta;
// if we scroll up and the thumb is half visible, then realign first
if(delta < 0 && table->thumbs_area.y != 0)
move += table->thumb_size -table->thumbs_area.y;
// for filemanager and filmstrip, scrolled = move for
// filemanager we ensure to fallback to show full row (can be
// half shown if scrollbar used)
int move = table->thumb_size * delta;
// if we scroll up and the thumb is half visible, then realign first
if(delta < 0 && table->thumbs_area.y != 0)
move += table->thumb_size -table->thumbs_area.y;

_move(table, 0, -move, TRUE);
_move(table, 0, -move, TRUE);

// ensure the hovered image is the right one
dt_thumbnail_t *th = _thumb_get_under_mouse(table);
if(th)
dt_control_set_mouse_over_id(th->imgid);
// ensure the hovered image is the right one
dt_thumbnail_t *th = _thumb_get_under_mouse(table);
if(th)
dt_control_set_mouse_over_id(th->imgid);
}

// we reset the id value at the end, to ensure we don't get more
// than 1 pending scroll
Expand Down

0 comments on commit 6a86f99

Please sign in to comment.