From 998c6b056db8db30a950790bd05f9bad3f03e3d4 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 28 Jul 2022 03:27:56 +0300 Subject: [PATCH 7/7] gtk3: Fix cropping of unit icons on left panel See osdn #45254 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/gui_main.c | 9 +++++++-- client/gui-gtk-3.0/mapview.c | 8 ++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/client/gui-gtk-3.0/gui_main.c b/client/gui-gtk-3.0/gui_main.c index 9ade825e43..200c6b00e3 100644 --- a/client/gui-gtk-3.0/gui_main.c +++ b/client/gui-gtk-3.0/gui_main.c @@ -881,18 +881,20 @@ static void populate_unit_image_table(void) int i, width; GtkWidget *table = unit_image_table; GdkPixbuf *pix; + int ttw; /* get width of the overview window */ width = (overview_canvas_store_width > GUI_GTK_OVERVIEW_MIN_XSIZE) ? overview_canvas_store_width : GUI_GTK_OVERVIEW_MIN_XSIZE; + ttw = tileset_tile_width(tileset); if (gui_options.gui_gtk3_small_display_layout) { /* We want arrow to appear if there is other units in addition to active one in tile. Active unit is not counted, so there can be 0 other units to not to display arrow. */ num_units_below = 1 - 1; } else { - num_units_below = width / (int) tileset_tile_width(tileset); + num_units_below = width / (int) ttw; num_units_below = CLIP(1, num_units_below, MAX_NUM_UNITS_BELOW); } @@ -903,6 +905,7 @@ static void populate_unit_image_table(void) gtk_widget_add_events(unit_image, GDK_BUTTON_PRESS_MASK); g_object_ref(unit_image); unit_image_button = gtk_event_box_new(); + gtk_widget_set_size_request(unit_image_button, ttw, -1); gtk_event_box_set_visible_window(GTK_EVENT_BOX(unit_image_button), FALSE); g_object_ref(unit_image_button); gtk_container_add(GTK_CONTAINER(unit_image_button), unit_image); @@ -919,7 +922,9 @@ static void populate_unit_image_table(void) gtk_widget_add_events(unit_below_image[i], GDK_BUTTON_PRESS_MASK); unit_below_image_button[i] = gtk_event_box_new(); g_object_ref(unit_below_image_button[i]); - gtk_event_box_set_visible_window(GTK_EVENT_BOX(unit_below_image_button[i]), FALSE); + gtk_widget_set_size_request(unit_below_image_button[i], ttw, -1); + gtk_event_box_set_visible_window(GTK_EVENT_BOX(unit_below_image_button[i]), + FALSE); gtk_container_add(GTK_CONTAINER(unit_below_image_button[i]), unit_below_image[i]); g_signal_connect(unit_below_image_button[i], diff --git a/client/gui-gtk-3.0/mapview.c b/client/gui-gtk-3.0/mapview.c index e00b4cf4a9..22b980b0ac 100644 --- a/client/gui-gtk-3.0/mapview.c +++ b/client/gui-gtk-3.0/mapview.c @@ -493,13 +493,9 @@ void put_unit_image(struct unit *punit, GtkImage *p, int height) int width; if (height <= 0) { - struct sprite *spr; - - spr = get_unittype_sprite(tileset, unit_type_get(punit), punit->facing, FALSE); - get_sprite_dimensions(spr, &width, &height); - } else { - width = tileset_full_tile_width(tileset); + height = tileset_full_tile_height(tileset); } + width = tileset_full_tile_width(tileset); store.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); -- 2.35.1