[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52569] trunk/blender/source/blender: search box width's now scale with DPI setting.
Campbell Barton
ideasman42 at gmail.com
Mon Nov 26 14:23:39 CET 2012
Revision: 52569
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52569
Author: campbellbarton
Date: 2012-11-26 13:23:37 +0000 (Mon, 26 Nov 2012)
Log Message:
-----------
search box width's now scale with DPI setting.
was checking on: [#33294] too small place for material names
this helps in some cases but doesn't resolve issue with very long names.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/UI_interface.h
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_regions.c
trunk/blender/source/blender/editors/interface/interface_templates.c
trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2012-11-26 12:38:40 UTC (rev 52568)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2012-11-26 13:23:37 UTC (rev 52569)
@@ -615,7 +615,8 @@
/* bfunc gets search item *poin as arg2, or if NULL the old string */
void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg1, uiButHandleFunc bfunc, void *active);
/* height in pixels, it's using hardcoded values still */
-int uiSearchBoxhHeight(void);
+int uiSearchBoxHeight(void);
+int uiSearchBoxWidth(void);
void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
void uiBlockSetButmFunc(uiBlock *block, uiMenuHandleFunc func, void *arg);
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2012-11-26 12:38:40 UTC (rev 52568)
+++ trunk/blender/source/blender/editors/interface/interface.c 2012-11-26 13:23:37 UTC (rev 52569)
@@ -2826,6 +2826,7 @@
EnumPropertyItem *item;
int i, totitem, free;
+ /* TODO, translate after getting the item, saves many lookups */
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
for (i = 0; i < totitem; i++) {
if (item[i].identifier[0] && item[i].value == (int)max) {
Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c 2012-11-26 12:38:40 UTC (rev 52568)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c 2012-11-26 13:23:37 UTC (rev 52569)
@@ -826,11 +826,17 @@
return 1;
}
-int uiSearchBoxhHeight(void)
+int uiSearchBoxHeight(void)
{
return SEARCH_ITEMS * UI_UNIT_Y + 2 * MENU_TOP;
}
+int uiSearchBoxWidth(void)
+{
+ /* was hardcoded at 150 */
+ return 9 * UI_UNIT_X;
+}
+
/* ar is the search box itself */
static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step)
{
@@ -1191,10 +1197,11 @@
}
}
else {
+ const int searchbox_width = uiSearchBoxWidth();
rect_fl.xmin = but->rect.xmin - 5; /* align text with button */
rect_fl.xmax = but->rect.xmax + 5; /* symmetrical */
rect_fl.ymax = but->rect.ymin;
- rect_fl.ymin = rect_fl.ymax - uiSearchBoxhHeight();
+ rect_fl.ymin = rect_fl.ymax - uiSearchBoxHeight();
ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
@@ -1202,8 +1209,8 @@
BLI_rctf_translate(&rect_fl, ofsx, ofsy);
/* minimal width */
- if (BLI_rctf_size_x(&rect_fl) < 150) {
- rect_fl.xmax = rect_fl.xmin + 150; /* XXX arbitrary */
+ if (BLI_rctf_size_x(&rect_fl) < searchbox_width) {
+ rect_fl.xmax = rect_fl.xmin + searchbox_width;
}
/* copy to int, gets projected if possible too */
Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c 2012-11-26 12:38:40 UTC (rev 52568)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c 2012-11-26 13:23:37 UTC (rev 52569)
@@ -191,10 +191,12 @@
}
/* list view */
else {
+ const int searchbox_width = uiSearchBoxWidth();
+ const int searchbox_height = uiSearchBoxHeight();
/* fake button, it holds space for search items */
- uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+ uiDefBut(block, LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL);
- but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
+ but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, "");
uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data);
}
Modified: trunk/blender/source/blender/editors/space_outliner/outliner_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_draw.c 2012-11-26 12:38:40 UTC (rev 52568)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_draw.c 2012-11-26 13:23:37 UTC (rev 52569)
@@ -631,7 +631,7 @@
uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
/* fake button, it holds space for search items */
- uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+ uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, UI_UNIT_Y, 0, 0, "");
uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot);
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c 2012-11-26 12:38:40 UTC (rev 52568)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c 2012-11-26 13:23:37 UTC (rev 52569)
@@ -176,7 +176,7 @@
uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU);
/* fake button, it holds space for search items */
- uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+ uiDefBut(block, LABEL, 0, "", 10, 15, uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, "");
uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL);
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2012-11-26 12:38:40 UTC (rev 52568)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2012-11-26 13:23:37 UTC (rev 52569)
@@ -793,7 +793,7 @@
uiButSetSearchFunc(but, operator_enum_search_cb, op->type, operator_enum_call_cb, NULL);
/* fake button, it holds space for search items */
- uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9 * UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+ uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
uiEndBlock(C, block);
@@ -1566,7 +1566,7 @@
uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL);
/* fake button, it holds space for search items */
- uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxhHeight(), 9 * UI_UNIT_X, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL);
+ uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);
uiPopupBoundsBlock(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */
uiEndBlock(C, block);
More information about the Bf-blender-cvs
mailing list