[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50540] trunk/blender/source/blender/ editors: code cleanup: changing the INT define to an enum conflicts with INT typedef on windows, use more verbose names for button pointer types.
Campbell Barton
ideasman42 at gmail.com
Wed Sep 12 02:32:34 CEST 2012
Revision: 50540
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50540
Author: campbellbarton
Date: 2012-09-12 00:32:33 +0000 (Wed, 12 Sep 2012)
Log Message:
-----------
code cleanup: changing the INT define to an enum conflicts with INT typedef on windows, use more verbose names for button pointer types. also removed some redundant flags from buttons.
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_handlers.c
trunk/blender/source/blender/editors/interface/interface_regions.c
trunk/blender/source/blender/editors/interface/interface_widgets.c
trunk/blender/source/blender/editors/space_logic/logic_window.c
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2012-09-11 23:37:17 UTC (rev 50539)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2012-09-12 00:32:33 UTC (rev 50540)
@@ -188,16 +188,16 @@
* - bit 9-15: button type (now 6 bits, 64 types)
* */
typedef enum {
- CHA = 32,
- SHO = 64,
- INT = 96,
- FLO = 128,
-/* FUN = 192, */ /*UNUSED*/
- BIT = 256
+ UI_BUT_POIN_CHAR = 32,
+ UI_BUT_POIN_SHORT = 64,
+ UI_BUT_POIN_INT = 96,
+ UI_BUT_POIN_FLOAT = 128,
+/* UI_BUT_POIN_FUNCTION = 192, */ /*UNUSED*/
+ UI_BUT_POIN_BIT = 256 /* OR'd with a bit index*/
} eButPointerType;
-/* button reqyires a pointer */
-#define BUTPOIN (FLO | SHO | CHA)
+/* button requires a pointer */
+#define UI_BUT_POIN_TYPES (UI_BUT_POIN_FLOAT | UI_BUT_POIN_SHORT | UI_BUT_POIN_CHAR)
/* assigned to but->type, OR'd with the flags above when passing args */
typedef enum {
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2012-09-11 23:37:17 UTC (rev 50539)
+++ trunk/blender/source/blender/editors/interface/interface.c 2012-09-12 00:32:33 UTC (rev 50540)
@@ -1309,13 +1309,13 @@
vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a);
}
}
- else if (but->pointype == CHA) {
+ else if (but->pointype == UI_BUT_POIN_CHAR) {
char *cp = (char *)but->poin;
vec[0] = ((float)cp[0]) / 255.0f;
vec[1] = ((float)cp[1]) / 255.0f;
vec[2] = ((float)cp[2]) / 255.0f;
}
- else if (but->pointype == FLO) {
+ else if (but->pointype == UI_BUT_POIN_FLOAT) {
float *fp = (float *)but->poin;
copy_v3_v3(vec, fp);
}
@@ -1355,13 +1355,13 @@
}
}
}
- else if (but->pointype == CHA) {
+ else if (but->pointype == UI_BUT_POIN_CHAR) {
char *cp = (char *)but->poin;
cp[0] = (char)(0.5f + vec[0] * 255.0f);
cp[1] = (char)(0.5f + vec[1] * 255.0f);
cp[2] = (char)(0.5f + vec[2] * 255.0f);
}
- else if (but->pointype == FLO) {
+ else if (but->pointype == UI_BUT_POIN_FLOAT) {
float *fp = (float *)but->poin;
copy_v3_v3(fp, vec);
}
@@ -1369,7 +1369,7 @@
int ui_is_but_float(uiBut *but)
{
- if (but->pointype == FLO && but->poin)
+ if (but->pointype == UI_BUT_POIN_FLOAT && but->poin)
return 1;
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT)
@@ -1465,16 +1465,16 @@
case 'V': value = hsv[2]; break;
}
}
- else if (but->pointype == CHA) {
+ else if (but->pointype == UI_BUT_POIN_CHAR) {
value = *(char *)but->poin;
}
- else if (but->pointype == SHO) {
+ else if (but->pointype == UI_BUT_POIN_SHORT) {
value = *(short *)but->poin;
}
- else if (but->pointype == INT) {
+ else if (but->pointype == UI_BUT_POIN_INT) {
value = *(int *)but->poin;
}
- else if (but->pointype == FLO) {
+ else if (but->pointype == UI_BUT_POIN_FLOAT) {
value = *(float *)but->poin;
}
@@ -1546,9 +1546,10 @@
}
else {
/* first do rounding */
- if (but->pointype == CHA)
+ if (but->pointype == UI_BUT_POIN_CHAR) {
value = (char)floor(value + 0.5);
- else if (but->pointype == SHO) {
+ }
+ else if (but->pointype == UI_BUT_POIN_SHORT) {
/* gcc 3.2.1 seems to have problems
* casting a double like 32772.0 to
* a short so we cast to an int, then
@@ -1562,9 +1563,9 @@
gcckludge = (int) floor(value + 0.5);
value = (short)gcckludge;
}
- else if (but->pointype == INT)
+ else if (but->pointype == UI_BUT_POIN_INT)
value = (int)floor(value + 0.5);
- else if (but->pointype == FLO) {
+ else if (but->pointype == UI_BUT_POIN_FLOAT) {
float fval = (float)value;
if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f; /* prevent negative zero */
value = fval;
@@ -1573,13 +1574,13 @@
/* then set value with possible edit override */
if (but->editval)
value = *but->editval = value;
- else if (but->pointype == CHA)
+ else if (but->pointype == UI_BUT_POIN_CHAR)
value = *((char *)but->poin) = (char)value;
- else if (but->pointype == SHO)
+ else if (but->pointype == UI_BUT_POIN_SHORT)
value = *((short *)but->poin) = (short)value;
- else if (but->pointype == INT)
+ else if (but->pointype == UI_BUT_POIN_INT)
value = *((int *)but->poin) = (int)value;
- else if (but->pointype == FLO)
+ else if (but->pointype == UI_BUT_POIN_FLOAT)
value = *((float *)but->poin) = (float)value;
}
@@ -2592,7 +2593,7 @@
uiBut *but;
int slen;
- if (type & BUTPOIN) { /* a pointer is required */
+ if (type & UI_BUT_POIN_TYPES) { /* a pointer is required */
if (poin == NULL)
return NULL;
}
@@ -2600,8 +2601,8 @@
but = MEM_callocN(sizeof(uiBut), "uiBut");
but->type = type & BUTTYPE;
- but->pointype = type & BUTPOIN;
- but->bit = type & BIT;
+ but->pointype = type & UI_BUT_POIN_TYPES;
+ but->bit = type & UI_BUT_POIN_BIT;
but->bitnr = type & 31;
but->icon = ICON_NONE;
but->iconadd = 0;
@@ -3074,40 +3075,40 @@
return NULL;
}
else {
- return uiDefBut(block, type | BIT | bitIdx, retval, str, x, y, width, height, poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | UI_BUT_POIN_BIT | bitIdx, retval, str, x, y, width, height, poin, min, max, a1, a2, tip);
}
}
uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type | FLO, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | UI_BUT_POIN_FLOAT, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type | FLO, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | UI_BUT_POIN_FLOAT, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type | INT, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | UI_BUT_POIN_INT, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type | INT, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | UI_BUT_POIN_INT, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type | SHO, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | UI_BUT_POIN_SHORT, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type | SHO, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | UI_BUT_POIN_SHORT, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type | CHA, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | UI_BUT_POIN_CHAR, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type | CHA, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | UI_BUT_POIN_CHAR, bit, retval, str, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip)
{
@@ -3159,41 +3160,41 @@
return NULL;
}
else {
- return uiDefIconBut(block, type | BIT | bitIdx, retval, icon, x, y, width, height, poin, min, max, a1, a2, tip);
+ return uiDefIconBut(block, type | UI_BUT_POIN_BIT | bitIdx, retval, icon, x, y, width, height, poin, min, max, a1, a2, tip);
}
}
uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconBut(block, type | FLO, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefIconBut(block, type | UI_BUT_POIN_FLOAT, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconButBit(block, type | FLO, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
+ return uiDefIconButBit(block, type | UI_BUT_POIN_FLOAT, bit, retval, icon, x, y, width, height, (void *) poin, min, max, a1, a2, tip);
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list