Squashed commit of the following:

commit b8b7180760b7c57f15b9930c29207febcf5fefb3
Author: Bastien Montagne <montagne29@wanadoo.fr>
Date:   Thu Nov 21 16:31:16 2013 +0100

    Code cleanup: replace "LISTLABEL" button type by an "UI_BUT_LIST_ITEM" button flag.

    Summary:
    Rationals:
    I) I was never that happy to have a full button type just to set custom colors to labels inside listitems!
    II) If we use (as planned) TEX buttons instead of labels to allow listitems click-rename, I'd like to be able to use listitems' theme color here as well, much easier witha flag than adding yet another button type!

    Note: related to D8

    Reviewers: brecht

    Differential Revision: http://developer.blender.org/D25
This commit is contained in:
Bastien Montagne 2013-11-21 16:51:29 +01:00
parent 254aa8f3a0
commit 904129fd9b
9 changed files with 31 additions and 31 deletions

@ -1 +1 @@
Subproject commit cb1967cc63a6d2d75d2b59cdf91c5f5645285aea
Subproject commit d3e0405103f9ccabb8e567a8c69e9d4015aaa3bb

@ -1 +1 @@
Subproject commit 48bdb7b52fe827cbc21d50cce3079223243414bd
Subproject commit 4d8cb6c294727ff10afeb548759f629b0c2169d6

@ -1 +1 @@
Subproject commit 31545d25c9cb41d271a3f3ef84d327708572290e
Subproject commit 4fe6a9e046f9578a0dadb1186269ac5e406a8c15

2
scons

@ -1 +1 @@
Subproject commit ccea0f01de1c3e9210086bd447df71bae353fa07
Subproject commit 2d6ebcb23909058b846aa232ecb2fee497924cf8

@ -170,12 +170,16 @@ enum {
UI_BUT_VEC_SIZE_LOCK = (1 << 22), /* used to flag if color hsv-circle should keep luminance */
UI_BUT_COLOR_CUBIC = (1 << 23), /* cubic saturation for the color wheel */
UI_BUT_LIST_ITEM = (1 << 24), /* This but is "inside" a list item (currently used to change theme colors). */
};
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
/* but->drawflag - these flags should only affect how the button is drawn. */
/* Note: currently, these flags _are not passed_ to the widget's state() or draw() functions
* (except for the 'align' ones)!
*/
enum {
/* draw enum-like up/down arrows for button */
UI_BUT_DRAW_ENUM_ARROWS = (1 << 0),
@ -263,7 +267,6 @@ typedef enum {
PROGRESSBAR = (51 << 9),
SEARCH_MENU_UNLINK = (52 << 9),
NODESOCKET = (53 << 9),
LISTLABEL = (54 << 9),
} eButType;
#define BUTTYPE (63 << 9)

@ -301,7 +301,7 @@ void ui_pan_to_scroll(const wmEvent *event, int *type, int *val)
static bool ui_but_editable(uiBut *but)
{
return ELEM6(but->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR);
}
static uiBut *ui_but_prev(uiBut *but)
@ -2097,7 +2097,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->next; but; but = but->next) {
@ -2125,7 +2125,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
if (ELEM5(actbut->type, LABEL, LISTLABEL, SEPR, ROUNDBOX, LISTBOX))
if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for (but = actbut->prev; but; but = but->prev) {
@ -5675,7 +5675,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
break;
case ROUNDBOX:
case LABEL:
case LISTLABEL:
case ROW:
case LISTROW:
case BUT_IMAGE:
@ -5888,7 +5887,7 @@ static bool ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
bool ui_is_but_interactive(uiBut *but)
{
/* note, LABEL is included for highlights, this allows drags */
if (ELEM(but->type, LABEL, LISTLABEL) && but->dragpoin == NULL)
if ((but->type == LABEL) && but->dragpoin == NULL)
return false;
if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
return false;
@ -7444,7 +7443,7 @@ static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockH
for (but = block->buttons.first; but; but = but->next) {
int doit = FALSE;
if (but->type != LABEL && but->type != LISTLABEL && but->type != SEPR)
if (!ELEM(but->type, LABEL, SEPR))
count++;
/* exception for rna layer buts */

@ -95,7 +95,6 @@ typedef enum {
UI_WTYPE_SCROLL,
UI_WTYPE_LISTITEM,
UI_WTYPE_PROGRESSBAR,
UI_WTYPE_LISTLABEL,
} uiWidgetTypeEnum;
/* menu scrolling */

@ -1687,7 +1687,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
/* Mark as a label inside a listbox. */
if (block->flag & UI_BLOCK_LIST_ITEM) {
but->type = LISTLABEL;
but->flag |= UI_BUT_LIST_ITEM;
}
return but;
@ -2457,7 +2457,7 @@ void ui_layout_list_set_labels_active(uiLayout *layout)
if (bitem->item.type != ITEM_BUTTON) {
ui_layout_list_set_labels_active((uiLayout *)(&bitem->item));
}
else if (bitem->but->type == LISTLABEL) {
else if (bitem->but->flag & UI_BUT_LIST_ITEM) {
uiButSetFlag(bitem->but, UI_SELECT);
}
}

@ -882,7 +882,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, const rcti
}
/* extra feature allows more alpha blending */
if (ELEM(but->type, LABEL, LISTLABEL) && but->a1 == 1.0f)
if ((but->type == LABEL) && but->a1 == 1.0f)
alpha *= but->a2;
glEnable(GL_BLEND);
@ -2866,6 +2866,14 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
/* labels use Editor theme colors for text */
static void widget_state_label(uiWidgetType *wt, int state)
{
if (state & UI_BUT_LIST_ITEM) {
/* Override default label theme's colors. */
bTheme *btheme = UI_GetTheme();
wt->wcol_theme = &btheme->tui.wcol_list_item;
/* call this for option button */
widget_state(wt, state);
}
else {
/* call this for option button */
widget_state(wt, state);
if (state & UI_SELECT)
@ -2873,6 +2881,7 @@ static void widget_state_label(uiWidgetType *wt, int state)
else
UI_GetThemeColor3ubv(TH_TEXT, (unsigned char *)wt->wcol.text);
}
}
static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
@ -2991,11 +3000,6 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
case UI_WTYPE_REGULAR:
break;
case UI_WTYPE_LISTLABEL:
wt.wcol_theme = &btheme->tui.wcol_list_item;
wt.draw = NULL;
/* Can't use usual label code. */
break;
case UI_WTYPE_LABEL:
wt.draw = NULL;
wt.state = widget_state_label;
@ -3246,11 +3250,6 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
}
break;
case LISTLABEL:
wt = widget_type(UI_WTYPE_LISTLABEL);
fstyle = &style->widgetlabel;
break;
case SEPR:
break;