Fix enum icon button size for fractional UI scale.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 18 Dec 2018 14:28:24 +0000 (15:28 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 18 Dec 2018 14:30:19 +0000 (15:30 +0100)
Err on the side of too much padding.

source/blender/editors/interface/interface_layout.c
source/blender/editors/space_view3d/view3d_header.c

index 7778444435e596b9d41e64f23a55190f7594246e..9e9c244cfafac529b4d86b00bc7ab0d08904db13 100644 (file)
@@ -721,7 +721,7 @@ static void ui_item_enum_expand_exec(
                if (icon && name[0] && !icon_only)
                        but = uiDefIconTextButR_prop(block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
                else if (icon)
-                       but = uiDefIconButR_prop(block, but_type, 0, icon, 0, 0, (is_first) ? itemw : itemw - UI_DPI_FAC, h, ptr, prop, -1, 0, value, -1, -1, NULL);
+                       but = uiDefIconButR_prop(block, but_type, 0, icon, 0, 0, (is_first) ? itemw : ceilf(itemw - UI_DPI_FAC), h, ptr, prop, -1, 0, value, -1, -1, NULL);
                else
                        but = uiDefButR_prop(block, but_type, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
 
index 954a528ce9da4fc2419c718b9a0f7727f506f3e5..7ed7d399df484adeb7b79be0b30fa4d8639c5c42 100644 (file)
@@ -36,6 +36,7 @@
 #include "DNA_object_types.h"
 #include "DNA_gpencil_types.h"
 
+#include "BLI_math_base.h"
 #include "BLI_utildefines.h"
 
 #include "BLT_translation.h"
@@ -142,10 +143,10 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
                                 0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
                                 TIP_("Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection"));
                uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL,
-                                0, 0, UI_UNIT_X - UI_DPI_FAC, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
+                                0, 0, ceilf(UI_UNIT_X - UI_DPI_FAC), UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
                                 TIP_("Edge select - Shift-Click for multiple modes, Ctrl-Click expands/contracts selection"));
                uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL,
-                                0, 0, UI_UNIT_X - UI_DPI_FAC, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
+                                0, 0, ceilf(UI_UNIT_X - UI_DPI_FAC), UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
                                 TIP_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection"));
        }
 }