Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-09-10 10:05:19 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-09-10 10:05:19 +0400
commit1a22503cba0336c148f969e63e5709d7a2df8aa1 (patch)
tree272980c7812a100365ce87c40ab2f79a27e3c4c3 /source
parent35faf9615a448c84c2e1cc676960a7c696ce821a (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h106
-rw-r--r--source/blender/editors/interface/interface.c8
-rw-r--r--source/blender/editors/interface/interface_handlers.c13
-rw-r--r--source/blender/editors/interface/interface_intern.h5
4 files changed, 75 insertions, 57 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 513a9edc3ec..2b4ee325e46 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -199,58 +199,60 @@ typedef struct uiLayout uiLayout;
#define BUTPOIN (FLO | SHO | CHA)
/* assigned to but->type, OR'd with the flags above when passing args */
-#define BUT (1 << 9)
-#define ROW (2 << 9)
-#define TOG (3 << 9)
-#define SLI (4 << 9)
-#define NUM (5 << 9)
-#define TEX (6 << 9)
-#define TOG3 (7 << 9)
-#define TOGR (8 << 9)
-#define TOGN (9 << 9)
-#define LABEL (10 << 9)
-#define MENU (11 << 9)
-#define ICONROW (12 << 9)
-#define ICONTOG (13 << 9)
-#define NUMSLI (14 << 9)
-#define COL (15 << 9)
-#define IDPOIN (16 << 9)
-#define HSVSLI (17 << 9)
-#define SCROLL (18 << 9)
-#define BLOCK (19 << 9)
-#define BUTM (20 << 9)
-#define SEPR (21 << 9)
-#define LINK (22 << 9)
-#define INLINK (23 << 9)
-#define KEYEVT (24 << 9)
-#define ICONTEXTROW (25 << 9)
-#define HSVCUBE (26 << 9)
-#define PULLDOWN (27 << 9)
-#define ROUNDBOX (28 << 9)
-#define CHARTAB (29 << 9)
-#define BUT_COLORBAND (30 << 9)
-#define BUT_NORMAL (31 << 9)
-#define BUT_CURVE (32 << 9)
-#define BUT_TOGDUAL (33 << 9)
-#define ICONTOGN (34 << 9)
-#define FTPREVIEW (35 << 9)
-#define NUMABS (36 << 9)
-#define TOGBUT (37 << 9)
-#define OPTION (38 << 9)
-#define OPTIONN (39 << 9)
-#define TRACKPREVIEW (40 << 9)
-/* buttons with value >= SEARCH_MENU don't get undo pushes */
-#define SEARCH_MENU (41 << 9)
-#define BUT_EXTRA (42 << 9)
-#define HSVCIRCLE (43 << 9)
-#define LISTBOX (44 << 9)
-#define LISTROW (45 << 9)
-#define HOTKEYEVT (46 << 9)
-#define BUT_IMAGE (47 << 9)
-#define HISTOGRAM (48 << 9)
-#define WAVEFORM (49 << 9)
-#define VECTORSCOPE (50 << 9)
-#define PROGRESSBAR (51 << 9)
+typedef enum {
+ BUT = (1 << 9),
+ ROW = (2 << 9),
+ TOG = (3 << 9),
+ SLI = (4 << 9),
+ NUM = (5 << 9),
+ TEX = (6 << 9),
+ TOG3 = (7 << 9),
+ TOGR = (8 << 9),
+ TOGN = (9 << 9),
+ LABEL = (10 << 9),
+ MENU = (11 << 9),
+ ICONROW = (12 << 9),
+ ICONTOG = (13 << 9),
+ NUMSLI = (14 << 9),
+ COL = (15 << 9),
+ IDPOIN = (16 << 9),
+ HSVSLI = (17 << 9),
+ SCROLL = (18 << 9),
+ BLOCK = (19 << 9),
+ BUTM = (20 << 9),
+ SEPR = (21 << 9),
+ LINK = (22 << 9),
+ INLINK = (23 << 9),
+ KEYEVT = (24 << 9),
+ ICONTEXTROW = (25 << 9),
+ HSVCUBE = (26 << 9),
+ PULLDOWN = (27 << 9),
+ ROUNDBOX = (28 << 9),
+ CHARTAB = (29 << 9),
+ BUT_COLORBAND = (30 << 9),
+ BUT_NORMAL = (31 << 9),
+ BUT_CURVE = (32 << 9),
+ BUT_TOGDUAL = (33 << 9),
+ ICONTOGN = (34 << 9),
+ /* FTPREVIEW = (35 << 9), */ /* UNUSED */
+ NUMABS = (36 << 9),
+ TOGBUT = (37 << 9),
+ OPTION = (38 << 9),
+ OPTIONN = (39 << 9),
+ TRACKPREVIEW = (40 << 9),
+ /* buttons with value >= SEARCH_MENU don't get undo pushes */
+ SEARCH_MENU = (41 << 9),
+ BUT_EXTRA = (42 << 9),
+ HSVCIRCLE = (43 << 9),
+ LISTBOX = (44 << 9),
+ LISTROW = (45 << 9),
+ HOTKEYEVT = (46 << 9),
+ BUT_IMAGE = (47 << 9),
+ HISTOGRAM = (48 << 9),
+ WAVEFORM = (49 << 9),
+ VECTORSCOPE = (50 << 9),
+ PROGRESSBAR = (51 << 9)
+} eButType;
#define BUTTYPE (63 << 9)
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 515db9559ae..e98b7cddfa6 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2215,6 +2215,10 @@ void ui_check_but(uiBut *but)
but->iconadd = (int)value - (int)(but->hardmin);
}
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.
*/
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)
{
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 */
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 but->flag |= UI_BUT_UNDO;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 1f11ae6a97b..6b8ed5fd997 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2100,6 +2100,10 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
handlefunc = ui_block_func_COL;
arg = but;
break;
+
+ /* quiet warnings for unhandled types */
+ default:
+ break;
}
if (func || handlefunc) {
@@ -4929,6 +4933,10 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
case CHARTAB:
retval = ui_do_but_CHARTAB(C, block, but, data, event);
break;
+#else
+ /* do nothing */
+ case CHARTAB:
+ break;
#endif
case LINK:
@@ -4938,6 +4946,11 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
case TRACKPREVIEW:
retval = ui_do_but_TRACKPREVIEW(C, block, but, data, event);
break;
+
+ /* quiet warnings for unhandled types */
+ case SEPR:
+ case BUT_EXTRA:
+ break;
}
return retval;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index e728c861933..e242df54b90 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -159,8 +159,8 @@ typedef struct {
struct uiBut {
struct uiBut *next, *prev;
int flag, drawflag;
- short type, pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend, alignnr;
- short pad1;
+ eButType type;
+ short pointype, bit, bitnr, retval, strwidth, ofs, pos, selsta, selend, alignnr;
char *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);
#endif
-