mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 07:04:29 +00:00
menu: remove bottom attach
bottom attach is top attach + 1, so use that everywhere
This commit is contained in:
parent
31ccb7ca70
commit
5473d13470
@ -158,7 +158,6 @@ struct _GtkMenuPopdownData
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gint effective_top_attach;
|
gint effective_top_attach;
|
||||||
gint effective_bottom_attach;
|
|
||||||
} AttachInfo;
|
} AttachInfo;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -363,7 +362,6 @@ menu_ensure_layout (GtkMenu *menu)
|
|||||||
current_row++;
|
current_row++;
|
||||||
|
|
||||||
ai->effective_top_attach = current_row;
|
ai->effective_top_attach = current_row;
|
||||||
ai->effective_bottom_attach = current_row + 1;
|
|
||||||
|
|
||||||
current_row++;
|
current_row++;
|
||||||
}
|
}
|
||||||
@ -387,8 +385,7 @@ gtk_menu_get_n_rows (GtkMenu *menu)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
get_effective_child_attach (GtkWidget *child,
|
get_effective_child_attach (GtkWidget *child,
|
||||||
int *t,
|
int *t)
|
||||||
int *b)
|
|
||||||
{
|
{
|
||||||
GtkMenu *menu = GTK_MENU (gtk_widget_get_parent (child));
|
GtkMenu *menu = GTK_MENU (gtk_widget_get_parent (child));
|
||||||
AttachInfo *ai;
|
AttachInfo *ai;
|
||||||
@ -399,9 +396,6 @@ get_effective_child_attach (GtkWidget *child,
|
|||||||
|
|
||||||
if (t)
|
if (t)
|
||||||
*t = ai->effective_top_attach;
|
*t = ai->effective_top_attach;
|
||||||
if (b)
|
|
||||||
*b = ai->effective_bottom_attach;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2264,7 +2258,7 @@ calculate_line_heights (GtkMenu *menu,
|
|||||||
{
|
{
|
||||||
gint part;
|
gint part;
|
||||||
gint toggle_size;
|
gint toggle_size;
|
||||||
gint t, b;
|
gint t;
|
||||||
gint child_min, child_nat;
|
gint child_min, child_nat;
|
||||||
|
|
||||||
child = children->data;
|
child = children->data;
|
||||||
@ -2272,7 +2266,7 @@ calculate_line_heights (GtkMenu *menu,
|
|||||||
if (!gtk_widget_get_visible (child))
|
if (!gtk_widget_get_visible (child))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
get_effective_child_attach (child, &t, &b);
|
get_effective_child_attach (child, &t);
|
||||||
|
|
||||||
gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL,
|
gtk_widget_measure (child, GTK_ORIENTATION_VERTICAL,
|
||||||
avail_width,
|
avail_width,
|
||||||
@ -2281,10 +2275,10 @@ calculate_line_heights (GtkMenu *menu,
|
|||||||
|
|
||||||
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
|
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
|
||||||
|
|
||||||
part = MAX (child_min, toggle_size) / (b - t);
|
part = MAX (child_min, toggle_size);
|
||||||
min_heights[t] = MAX (min_heights[t], part);
|
min_heights[t] = MAX (min_heights[t], part);
|
||||||
|
|
||||||
part = MAX (child_nat, toggle_size) / (b - t);
|
part = MAX (child_nat, toggle_size);
|
||||||
nat_heights[t] = MAX (nat_heights[t], part);
|
nat_heights[t] = MAX (nat_heights[t], part);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2382,16 +2376,16 @@ gtk_menu_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
if (gtk_widget_get_visible (child))
|
if (gtk_widget_get_visible (child))
|
||||||
{
|
{
|
||||||
gint t, b;
|
gint t;
|
||||||
|
|
||||||
get_effective_child_attach (child, &t, &b);
|
get_effective_child_attach (child, &t);
|
||||||
|
|
||||||
child_allocation.width = base_width;
|
child_allocation.width = base_width;
|
||||||
child_allocation.height = 0;
|
child_allocation.height = 0;
|
||||||
child_allocation.x = 0;
|
child_allocation.x = 0;
|
||||||
child_allocation.y = - priv->scroll_offset;
|
child_allocation.y = - priv->scroll_offset;
|
||||||
|
|
||||||
for (i = 0; i < b; i++)
|
for (i = 0; i < t + 1; i++)
|
||||||
{
|
{
|
||||||
if (i < t)
|
if (i < t)
|
||||||
child_allocation.y += priv->heights[i];
|
child_allocation.y += priv->heights[i];
|
||||||
@ -2475,7 +2469,6 @@ static void gtk_menu_measure (GtkWidget *widget,
|
|||||||
while (children)
|
while (children)
|
||||||
{
|
{
|
||||||
gint toggle_size;
|
gint toggle_size;
|
||||||
gint t, b;
|
|
||||||
|
|
||||||
child = children->data;
|
child = children->data;
|
||||||
children = children->next;
|
children = children->next;
|
||||||
@ -2483,8 +2476,6 @@ static void gtk_menu_measure (GtkWidget *widget,
|
|||||||
if (! gtk_widget_get_visible (child))
|
if (! gtk_widget_get_visible (child))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
get_effective_child_attach (child, &t, &b);
|
|
||||||
|
|
||||||
/* It's important to size_request the child
|
/* It's important to size_request the child
|
||||||
* before doing the toggle size request, in
|
* before doing the toggle size request, in
|
||||||
* case the toggle size request depends on the size
|
* case the toggle size request depends on the size
|
||||||
@ -3528,7 +3519,7 @@ compute_child_offset (GtkMenu *menu,
|
|||||||
gint child_offset = 0;
|
gint child_offset = 0;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
get_effective_child_attach (menu_item, &item_top_attach, NULL);
|
get_effective_child_attach (menu_item, &item_top_attach);
|
||||||
|
|
||||||
/* there is a possibility that we get called before _size_request,
|
/* there is a possibility that we get called before _size_request,
|
||||||
* so check the height table for safety.
|
* so check the height table for safety.
|
||||||
|
Loading…
Reference in New Issue
Block a user