emoji: Improve section scrolling

Leave some space above the section heading when scrolling.

This is a part of https://gitlab.gnome.org/GNOME/gtk/merge_requests/143
by Julian Sperber.
This commit is contained in:
Matthias Clasen 2018-05-17 16:37:26 +01:00
parent f1d9ccd6c7
commit a628e03042

View File

@ -35,6 +35,8 @@
#include "gtkintl.h" #include "gtkintl.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#define BOX_SPACE 6
typedef struct { typedef struct {
GtkWidget *box; GtkWidget *box;
GtkWidget *heading; GtkWidget *heading;
@ -124,7 +126,7 @@ scroll_to_section (GtkButton *button,
if (section->heading) if (section->heading)
gtk_widget_get_allocation (section->heading, &alloc); gtk_widget_get_allocation (section->heading, &alloc);
gtk_adjustment_animate_to_value (adj, alloc.y); gtk_adjustment_animate_to_value (adj, alloc.y - BOX_SPACE);
} }
static void static void
@ -493,7 +495,7 @@ adj_value_changed (GtkAdjustment *adj,
else else
gtk_widget_get_allocation (section->box, &alloc); gtk_widget_get_allocation (section->box, &alloc);
if (value < alloc.y) if (value < alloc.y - BOX_SPACE)
break; break;
select_section = section; select_section = section;