forked from bartvdbraak/blender
code cleanup:
use an enum typedef for button types. it was quite annoying debugging UI code since the defines are bit-shifted. GDB would show but->type as 13824 and blender define was (27 << 9). Now but->type shows as a humanly readable names.
This commit is contained in:
parent
35faf9615a
commit
1a22503cba
@ -199,58 +199,60 @@ typedef struct uiLayout uiLayout;
|
|||||||
#define BUTPOIN (FLO | SHO | CHA)
|
#define BUTPOIN (FLO | SHO | CHA)
|
||||||
|
|
||||||
/* assigned to but->type, OR'd with the flags above when passing args */
|
/* assigned to but->type, OR'd with the flags above when passing args */
|
||||||
#define BUT (1 << 9)
|
typedef enum {
|
||||||
#define ROW (2 << 9)
|
BUT = (1 << 9),
|
||||||
#define TOG (3 << 9)
|
ROW = (2 << 9),
|
||||||
#define SLI (4 << 9)
|
TOG = (3 << 9),
|
||||||
#define NUM (5 << 9)
|
SLI = (4 << 9),
|
||||||
#define TEX (6 << 9)
|
NUM = (5 << 9),
|
||||||
#define TOG3 (7 << 9)
|
TEX = (6 << 9),
|
||||||
#define TOGR (8 << 9)
|
TOG3 = (7 << 9),
|
||||||
#define TOGN (9 << 9)
|
TOGR = (8 << 9),
|
||||||
#define LABEL (10 << 9)
|
TOGN = (9 << 9),
|
||||||
#define MENU (11 << 9)
|
LABEL = (10 << 9),
|
||||||
#define ICONROW (12 << 9)
|
MENU = (11 << 9),
|
||||||
#define ICONTOG (13 << 9)
|
ICONROW = (12 << 9),
|
||||||
#define NUMSLI (14 << 9)
|
ICONTOG = (13 << 9),
|
||||||
#define COL (15 << 9)
|
NUMSLI = (14 << 9),
|
||||||
#define IDPOIN (16 << 9)
|
COL = (15 << 9),
|
||||||
#define HSVSLI (17 << 9)
|
IDPOIN = (16 << 9),
|
||||||
#define SCROLL (18 << 9)
|
HSVSLI = (17 << 9),
|
||||||
#define BLOCK (19 << 9)
|
SCROLL = (18 << 9),
|
||||||
#define BUTM (20 << 9)
|
BLOCK = (19 << 9),
|
||||||
#define SEPR (21 << 9)
|
BUTM = (20 << 9),
|
||||||
#define LINK (22 << 9)
|
SEPR = (21 << 9),
|
||||||
#define INLINK (23 << 9)
|
LINK = (22 << 9),
|
||||||
#define KEYEVT (24 << 9)
|
INLINK = (23 << 9),
|
||||||
#define ICONTEXTROW (25 << 9)
|
KEYEVT = (24 << 9),
|
||||||
#define HSVCUBE (26 << 9)
|
ICONTEXTROW = (25 << 9),
|
||||||
#define PULLDOWN (27 << 9)
|
HSVCUBE = (26 << 9),
|
||||||
#define ROUNDBOX (28 << 9)
|
PULLDOWN = (27 << 9),
|
||||||
#define CHARTAB (29 << 9)
|
ROUNDBOX = (28 << 9),
|
||||||
#define BUT_COLORBAND (30 << 9)
|
CHARTAB = (29 << 9),
|
||||||
#define BUT_NORMAL (31 << 9)
|
BUT_COLORBAND = (30 << 9),
|
||||||
#define BUT_CURVE (32 << 9)
|
BUT_NORMAL = (31 << 9),
|
||||||
#define BUT_TOGDUAL (33 << 9)
|
BUT_CURVE = (32 << 9),
|
||||||
#define ICONTOGN (34 << 9)
|
BUT_TOGDUAL = (33 << 9),
|
||||||
#define FTPREVIEW (35 << 9)
|
ICONTOGN = (34 << 9),
|
||||||
#define NUMABS (36 << 9)
|
/* FTPREVIEW = (35 << 9), */ /* UNUSED */
|
||||||
#define TOGBUT (37 << 9)
|
NUMABS = (36 << 9),
|
||||||
#define OPTION (38 << 9)
|
TOGBUT = (37 << 9),
|
||||||
#define OPTIONN (39 << 9)
|
OPTION = (38 << 9),
|
||||||
#define TRACKPREVIEW (40 << 9)
|
OPTIONN = (39 << 9),
|
||||||
/* buttons with value >= SEARCH_MENU don't get undo pushes */
|
TRACKPREVIEW = (40 << 9),
|
||||||
#define SEARCH_MENU (41 << 9)
|
/* buttons with value >= SEARCH_MENU don't get undo pushes */
|
||||||
#define BUT_EXTRA (42 << 9)
|
SEARCH_MENU = (41 << 9),
|
||||||
#define HSVCIRCLE (43 << 9)
|
BUT_EXTRA = (42 << 9),
|
||||||
#define LISTBOX (44 << 9)
|
HSVCIRCLE = (43 << 9),
|
||||||
#define LISTROW (45 << 9)
|
LISTBOX = (44 << 9),
|
||||||
#define HOTKEYEVT (46 << 9)
|
LISTROW = (45 << 9),
|
||||||
#define BUT_IMAGE (47 << 9)
|
HOTKEYEVT = (46 << 9),
|
||||||
#define HISTOGRAM (48 << 9)
|
BUT_IMAGE = (47 << 9),
|
||||||
#define WAVEFORM (49 << 9)
|
HISTOGRAM = (48 << 9),
|
||||||
#define VECTORSCOPE (50 << 9)
|
WAVEFORM = (49 << 9),
|
||||||
#define PROGRESSBAR (51 << 9)
|
VECTORSCOPE = (50 << 9),
|
||||||
|
PROGRESSBAR = (51 << 9)
|
||||||
|
} eButType;
|
||||||
|
|
||||||
#define BUTTYPE (63 << 9)
|
#define BUTTYPE (63 << 9)
|
||||||
|
|
||||||
|
@ -2215,6 +2215,10 @@ void ui_check_but(uiBut *but)
|
|||||||
but->iconadd = (int)value - (int)(but->hardmin);
|
but->iconadd = (int)value - (int)(but->hardmin);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* quiet warnings for unhandled types */
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2556,7 +2560,7 @@ void ui_block_do_align(uiBlock *block)
|
|||||||
* 1,2,3, and a maximum of 4, all greater values will be clamped to 4.
|
* 1,2,3, and a maximum of 4, all greater values will be clamped to 4.
|
||||||
*/
|
*/
|
||||||
static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
|
static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
|
||||||
int x, int y, short width, short height,
|
int x, int y, short width, short height,
|
||||||
void *poin, float min, float max, float a1, float a2, const char *tip)
|
void *poin, float min, float max, float a1, float a2, const char *tip)
|
||||||
{
|
{
|
||||||
uiBut *but;
|
uiBut *but;
|
||||||
@ -2648,7 +2652,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
|
|||||||
|
|
||||||
/* keep track of UI_interface.h */
|
/* keep track of UI_interface.h */
|
||||||
if (ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM)) ;
|
if (ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM)) ;
|
||||||
else if (ELEM3(but->type, SCROLL, SEPR, FTPREVIEW)) ;
|
else if (ELEM(but->type, SCROLL, SEPR /* , FTPREVIEW */ )) ;
|
||||||
else if (but->type >= SEARCH_MENU) ;
|
else if (but->type >= SEARCH_MENU) ;
|
||||||
else but->flag |= UI_BUT_UNDO;
|
else but->flag |= UI_BUT_UNDO;
|
||||||
|
|
||||||
|
@ -2100,6 +2100,10 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
|
|||||||
handlefunc = ui_block_func_COL;
|
handlefunc = ui_block_func_COL;
|
||||||
arg = but;
|
arg = but;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* quiet warnings for unhandled types */
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (func || handlefunc) {
|
if (func || handlefunc) {
|
||||||
@ -4929,6 +4933,10 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
|||||||
case CHARTAB:
|
case CHARTAB:
|
||||||
retval = ui_do_but_CHARTAB(C, block, but, data, event);
|
retval = ui_do_but_CHARTAB(C, block, but, data, event);
|
||||||
break;
|
break;
|
||||||
|
#else
|
||||||
|
/* do nothing */
|
||||||
|
case CHARTAB:
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case LINK:
|
case LINK:
|
||||||
@ -4938,6 +4946,11 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
|||||||
case TRACKPREVIEW:
|
case TRACKPREVIEW:
|
||||||
retval = ui_do_but_TRACKPREVIEW(C, block, but, data, event);
|
retval = ui_do_but_TRACKPREVIEW(C, block, but, data, event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* quiet warnings for unhandled types */
|
||||||
|
case SEPR:
|
||||||
|
case BUT_EXTRA:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -159,8 +159,8 @@ typedef struct {
|
|||||||
struct uiBut {
|
struct uiBut {
|
||||||
struct uiBut *next, *prev;
|
struct uiBut *next, *prev;
|
||||||
int flag, drawflag;
|
int flag, drawflag;
|
||||||
short type, pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend, alignnr;
|
eButType type;
|
||||||
short pad1;
|
short pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend, alignnr;
|
||||||
|
|
||||||
char *str;
|
char *str;
|
||||||
char strdata[UI_MAX_NAME_STR];
|
char strdata[UI_MAX_NAME_STR];
|
||||||
@ -529,4 +529,3 @@ int ui_but_anim_expression_create(uiBut *but, const char *str);
|
|||||||
void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra);
|
void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user