From 4bef3a59e0f4489c8c3f26d114da26ebe5f3a3f7 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 1 Aug 2017 09:17:34 +0100 Subject: [PATCH] Fix the place the popup appears when above the row There may be more to do here after more testing. --- .../register-gnome/gnucash-item-edit.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/register/register-gnome/gnucash-item-edit.c b/src/register/register-gnome/gnucash-item-edit.c index 19222e987c..fbab6ce3c8 100644 --- a/src/register/register-gnome/gnucash-item-edit.c +++ b/src/register/register-gnome/gnucash-item-edit.c @@ -582,11 +582,11 @@ void gnc_item_edit_show_popup (GncItemEdit *item_edit) { GtkToggleButton *toggle; - GtkAdjustment *vadj; + GtkAdjustment *vadj, *hadj; GtkAllocation alloc; GnucashSheet *sheet; gint x, y, w, h; - gint y_offset; + gint y_offset, x_offset; gint popup_x, popup_y; gint popup_w; gint popup_h; @@ -609,8 +609,10 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit) view_width = alloc.width; vadj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(sheet)); + hadj = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(sheet)); y_offset = gtk_adjustment_get_value(vadj); + x_offset = gtk_adjustment_get_value(hadj); gnc_item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h); popup_x = x; @@ -620,7 +622,7 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit) if (up_height > down_height) { - popup_y = y_offset; + popup_y = y + y_offset; popup_h = up_height; } else @@ -629,7 +631,7 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit) popup_h = down_height; } - popup_max_width = view_width - popup_x; + popup_max_width = view_width - popup_x + x_offset; if (item_edit->get_popup_height) popup_h = item_edit->get_popup_height @@ -644,11 +646,13 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit) else popup_w = -1; + if (up_height > down_height) + popup_y = y - popup_h; + if (!gtk_widget_get_parent (item_edit->popup_item)) gtk_layout_put (GTK_LAYOUT(sheet), item_edit->popup_item, popup_x, popup_y); gtk_widget_set_size_request(item_edit->popup_item, popup_w, popup_h); - // FIXME what about the GtkAnchorType that the GNOME_CANVAS_ITEM used ? toggle = GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton); @@ -684,9 +688,11 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit) { popup_x -= popup_width - popup_max_width; popup_x = MAX (0, popup_x); - gtk_layout_move (GTK_LAYOUT(sheet), item_edit->popup_item, - popup_x, popup_y); } + else + popup_x = x; + + gtk_layout_move (GTK_LAYOUT(sheet), item_edit->popup_item, popup_x, popup_y); } }