Revision: 57760
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57760
Author: mont29
Date: 2013-06-26 07:28:55 +0000 (Wed, 26 Jun 2013)
Log Message:
-----------
Fix [#35750] list items in properties editor (text colors not following list
item theme).
Issue goes back since we stopped using LISTROW button to draw item's name (i.e.
since we have custom buttons in list items!).
This commit:
* Adds a new flag to uiBlock, UI_BLOCK_LIST_ITEM, to mark blocks used for each
list item.
* Adds a new button type, LISTLABEL, which basically behaves exactly as LABEL,
but uses wcol_list_item color set.
* When uiItemL is called, it checks whether current block has
UI_BLOCK_LIST_ITEM set, and if so, switch produced button to LISTLABEL type.
* Adds a new helper func, ui_layout_list_set_labels_active, called after the
active list item has been "drawn", to set all LISTLABEL buttons as UI_SELECT.
Note custom widget_state_label() was removed, in interface_widgets.c, as it did
nothing more than default widget_state().
Thanks to Brecht for the review and advices.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/UI_interface.h
trunk/blender/source/blender/editors/interface/interface_handlers.c
trunk/blender/source/blender/editors/interface/interface_intern.h
trunk/blender/source/blender/editors/interface/interface_layout.c
trunk/blender/source/blender/editors/interface/interface_templates.c
trunk/blender/source/blender/editors/interface/interface_widgets.c
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2013-06-26
06:16:39 UTC (rev 57759)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2013-06-26
07:28:55 UTC (rev 57760)
@@ -125,9 +125,11 @@
#define UI_BLOCK_POPUP_MEMORY (1 << 12)
#define UI_BLOCK_CLIP_EVENTS (1 << 13) /* stop handling mouse events */
-/* XXX This comment is no more valid! */
+/* XXX This comment is no more valid! Maybe it is now bits 14-17? */
/* block->flag bits 12-15 are identical to but->flag bits */
+#define UI_BLOCK_LIST_ITEM (1 << 19)
+
/* uiPopupBlockHandle->menuretval */
#define UI_RETURN_CANCEL (1 << 0) /* cancel all menus cascading */
#define UI_RETURN_OK (1 << 1) /* choice made */
@@ -251,7 +253,8 @@
VECTORSCOPE = (50 << 9),
PROGRESSBAR = (51 << 9),
SEARCH_MENU_UNLINK = (52 << 9),
- NODESOCKET = (53 << 9)
+ NODESOCKET = (53 << 9),
+ LISTLABEL = (54 << 9),
} eButType;
#define BUTTYPE (63 << 9)
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c
2013-06-26 06:16:39 UTC (rev 57759)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c
2013-06-26 07:28:55 UTC (rev 57760)
@@ -276,7 +276,7 @@
static bool ui_but_editable(uiBut *but)
{
- return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
+ return ELEM6(but->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX,
PROGRESSBAR);
}
static uiBut *ui_but_prev(uiBut *but)
@@ -2010,7 +2010,7 @@
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->next; but; but = but->next) {
@@ -2038,7 +2038,7 @@
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
+ if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->prev; but; but = but->prev) {
@@ -5361,6 +5361,7 @@
case ROUNDBOX:
case LISTBOX:
case LABEL:
+ case LISTLABEL:
case ROW:
case LISTROW:
case BUT_IMAGE:
@@ -5558,7 +5559,7 @@
bool ui_is_but_interactive(uiBut *but)
{
/* note, LABEL is included for highlights, this allows drags */
- if (but->type == LABEL && but->dragpoin == NULL)
+ if (ELEM(but->type, LABEL, LISTLABEL) && but->dragpoin == NULL)
return false;
if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
return false;
@@ -6995,7 +6996,7 @@
for (but =
block->buttons.first; but; but = but->next) {
int doit = FALSE;
- if (but->type != LABEL
&& but->type != SEPR)
+ if (but->type != LABEL
&& but->type != LISTLABEL && but->type != SEPR)
count++;
/* exception for rna
layer buts */
Modified: trunk/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_intern.h
2013-06-26 06:16:39 UTC (rev 57759)
+++ trunk/blender/source/blender/editors/interface/interface_intern.h
2013-06-26 07:28:55 UTC (rev 57760)
@@ -94,7 +94,8 @@
UI_WTYPE_BOX,
UI_WTYPE_SCROLL,
UI_WTYPE_LISTITEM,
- UI_WTYPE_PROGRESSBAR
+ UI_WTYPE_PROGRESSBAR,
+ UI_WTYPE_LISTLABEL,
} uiWidgetTypeEnum;
/* menu scrolling */
@@ -563,6 +564,7 @@
int ui_but_can_align(uiBut *but);
void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop,
PointerRNA *searchptr, PropertyRNA *searchprop);
void ui_but_add_shortcut(uiBut *but, const char *key_str, const bool do_strip);
+void ui_layout_list_set_labels_active(uiLayout *layout);
/* interface_anim.c */
void ui_but_anim_flag(uiBut *but, float cfra);
Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c
2013-06-26 06:16:39 UTC (rev 57759)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c
2013-06-26 07:28:55 UTC (rev 57760)
@@ -1632,7 +1632,7 @@
but = uiDefIconBut(block, LABEL, 0, icon, 0, 0, w, UI_UNIT_Y,
NULL, 0.0, 0.0, 0, 0, "");
else
but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL,
0.0, 0.0, 0, 0, "");
-
+
/* to compensate for string size padding in ui_text_icon_width,
* make text aligned right if the layout is aligned right.
*/
@@ -1640,7 +1640,12 @@
but->flag &= ~UI_TEXT_LEFT; /* default, needs to be unset */
but->flag |= UI_TEXT_RIGHT;
}
-
+
+ /* Mark as a label inside a listbox. */
+ if (block->flag & UI_BLOCK_LIST_ITEM) {
+ but->type = LISTLABEL;
+ }
+
return but;
}
@@ -2399,6 +2404,18 @@
return (uiLayout *)ui_layout_box(layout, ROUNDBOX);
}
+/* Check all buttons defined in this layout, and set labels as active/selected.
+ * Needed to handle correctly text colors of list items. */
+void ui_layout_list_set_labels_active(uiLayout *layout)
+{
+ uiButtonItem *bitem;
+ for (bitem = layout->items.first; bitem; bitem = bitem->item.next) {
+ if (bitem->item.type == ITEM_BUTTON && bitem->but->type ==
LISTLABEL) {
+ uiButSetFlag(bitem->but, UI_SELECT);
+ }
+ }
+}
+
uiLayout *uiLayoutListBox(uiLayout *layout, uiList *ui_list, PointerRNA *ptr,
PropertyRNA *prop, PointerRNA *actptr,
PropertyRNA *actprop)
{
Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c
2013-06-26 06:16:39 UTC (rev 57759)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c
2013-06-26 07:28:55 UTC (rev 57760)
@@ -2640,6 +2640,8 @@
subblock = uiLayoutGetBlock(col);
overlap = uiLayoutOverlap(col);
+ uiBlockSetFlag(subblock,
UI_BLOCK_LIST_ITEM);
+
/* list item behind label & other
buttons */
sub = uiLayoutRow(overlap, FALSE);
@@ -2653,6 +2655,11 @@
if (icon == ICON_DOT)
icon = ICON_NONE;
draw_item(ui_list, C, sub, dataptr,
&itemptr, icon, active_dataptr, active_propname, i);
+
+ /* If we are "drawing" active item, set
all labels as active. */
+ if (i == activei) {
+
ui_layout_list_set_labels_active(sub);
+ }
}
i++;
}
@@ -2721,6 +2728,8 @@
subblock = uiLayoutGetBlock(row);
overlap = uiLayoutOverlap(row);
+ uiBlockSetFlag(subblock, UI_BLOCK_LIST_ITEM);
+
/* list item behind label & other buttons */
sub = uiLayoutRow(overlap, FALSE);
@@ -2733,6 +2742,11 @@
icon = UI_rnaptr_icon_get(C, &itemptr, rnaicon,
false);
draw_item(ui_list, C, sub, dataptr, &itemptr,
icon, active_dataptr, active_propname, i);
+ /* If we are "drawing" active item, set all
labels as active. */
+ if (i == activei) {
+ ui_layout_list_set_labels_active(sub);
+ }
+
i++;
}
RNA_PROP_END;
Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c
2013-06-26 06:16:39 UTC (rev 57759)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c
2013-06-26 07:28:55 UTC (rev 57760)
@@ -883,7 +883,8 @@
}
/* extra feature allows more alpha blending */
- if (but->type == LABEL && but->a1 == 1.0f) alpha *= but->a2;
+ if (ELEM(but->type, LABEL, LISTLABEL) && but->a1 == 1.0f)
+ alpha *= but->a2;
glEnable(GL_BLEND);
@@ -1732,19 +1733,6 @@
}
/* labels use theme colors for text */
-static void widget_state_label(uiWidgetType *wt, int state)
-{
- /* call this for option button */
- widget_state(wt, state);
-
- if (state & UI_SELECT)
- UI_GetThemeColor3ubv(TH_TEXT_HI, (unsigned char
*)wt->wcol.text);
- else
- UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
-
-}
-
-/* labels use theme colors for text */
static void widget_state_option_menu(uiWidgetType *wt, int state)
{
@@ -2980,9 +2968,11 @@
case UI_WTYPE_REGULAR:
break;
+ case UI_WTYPE_LISTLABEL:
+ wt.wcol_theme = &btheme->tui.wcol_list_item;
+ /* No break, we use usual label code too. */
case UI_WTYPE_LABEL:
wt.draw = NULL;
- wt.state = widget_state_label;
break;
case UI_WTYPE_TOGGLE:
@@ -3230,6 +3220,11 @@
}
break;
+ case LISTLABEL:
+ wt = widget_type(UI_WTYPE_LISTLABEL);
+ fstyle = &style->widgetlabel;
+ break;
+
case SEPR:
break;
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs