mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
Take account for the pop up button border in the register.
If the pop up button border is specified in CSS, the default size of the button needs to change so retrieve the border and add it to the default button size. Also only add the button margin when cells have the button.
This commit is contained in:
parent
ff10aa24f1
commit
28718689dc
@ -56,7 +56,7 @@ enum
|
||||
TARGET_COMPOUND_TEXT
|
||||
};
|
||||
|
||||
#define MIN_BUTT_WIDTH 22 // minimum size for a button
|
||||
#define MIN_BUTT_WIDTH 20 // minimum size for a button excluding border
|
||||
|
||||
static GtkBoxClass *gnc_item_edit_parent_class;
|
||||
|
||||
@ -113,11 +113,17 @@ gnc_item_edit_tb_get_preferred_width (GtkWidget *widget,
|
||||
{
|
||||
GncItemEditTb *tb = GNC_ITEM_EDIT_TB (widget);
|
||||
GncItemEdit *item_edit = GNC_ITEM_EDIT(tb->sheet->item_editor);
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(tb));
|
||||
GtkBorder border;
|
||||
gint x, y, w, h = 2, width = 0;
|
||||
gnc_item_edit_get_pixel_coords (GNC_ITEM_EDIT (item_edit), &x, &y, &w, &h);
|
||||
width = ((h - 2)*2)/3;
|
||||
if (width < MIN_BUTT_WIDTH)
|
||||
width = MIN_BUTT_WIDTH;
|
||||
|
||||
gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
|
||||
|
||||
if (width < MIN_BUTT_WIDTH + border.left + border.right)
|
||||
width = MIN_BUTT_WIDTH + border.left + border.right;
|
||||
|
||||
*minimal_width = *natural_width = width;
|
||||
item_edit->button_width = width;
|
||||
}
|
||||
@ -806,9 +812,19 @@ gint
|
||||
gnc_item_edit_get_button_width (GncItemEdit *item_edit)
|
||||
{
|
||||
if (item_edit)
|
||||
return item_edit->button_width;
|
||||
else
|
||||
return MIN_BUTT_WIDTH;
|
||||
{
|
||||
if (gtk_widget_is_visible (GTK_WIDGET(item_edit->popup_toggle.tbutton)))
|
||||
return item_edit->button_width;
|
||||
else
|
||||
{
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET(item_edit->popup_toggle.tbutton));
|
||||
GtkBorder border;
|
||||
|
||||
gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
|
||||
return MIN_BUTT_WIDTH + border.left + border.right;
|
||||
}
|
||||
}
|
||||
return MIN_BUTT_WIDTH + 2; // add the default border
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -2288,6 +2288,7 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
|
||||
continue;
|
||||
|
||||
if (cell_col < style->ncols)
|
||||
{
|
||||
for (cell_row = 0; cell_row < style->nrows; cell_row++)
|
||||
{
|
||||
VirtualLocation virt_loc;
|
||||
@ -2320,15 +2321,16 @@ gnucash_sheet_col_max_width (GnucashSheet *sheet, gint virt_col, gint cell_col)
|
||||
if ((g_strcmp0 (type_name, DATE_CELL_TYPE_NAME) == 0)
|
||||
|| (g_strcmp0 (type_name, COMBO_CELL_TYPE_NAME) == 0))
|
||||
{
|
||||
width += gnc_item_edit_get_button_width (item_edit);
|
||||
width += gnc_item_edit_get_button_width (item_edit) + 2; // add 2 for the button margin
|
||||
}
|
||||
max = MAX (max, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (layout);
|
||||
|
||||
return max + 1; // add 1 for the border
|
||||
return max;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -207,7 +207,13 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
|
||||
pango_layout_get_pixel_size (layout, &width, &cd->pixel_height);
|
||||
g_object_unref (layout);
|
||||
width += gnc_item_edit_get_margin (item_edit, left_right) +
|
||||
gnc_item_edit_get_padding_border (item_edit, left_right) + 2;
|
||||
gnc_item_edit_get_padding_border (item_edit, left_right);
|
||||
|
||||
// This is used on new popup cells to get the default
|
||||
// width of text plus toggle button.
|
||||
if (cell && cell->is_popup)
|
||||
width += gnc_item_edit_get_button_width (item_edit) + 2; // + 2 for the button margin
|
||||
|
||||
cd->pixel_height += gnc_item_edit_get_margin (item_edit, top_bottom) +
|
||||
gnc_item_edit_get_padding_border (item_edit, top_bottom);
|
||||
}
|
||||
@ -223,11 +229,6 @@ set_dimensions_pass_one (GnucashSheet *sheet, CellBlock *cursor,
|
||||
if (cd->pixel_width > 0)
|
||||
continue;
|
||||
|
||||
// This is used on new account popup cells to get the default
|
||||
// width of text plus toggle button.
|
||||
if (cell && cell->is_popup)
|
||||
width += gnc_item_edit_get_button_width (item_edit);
|
||||
|
||||
cd->pixel_width = MAX (cd->pixel_width, width);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user