[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45500] trunk/blender/source/blender: code cleanup: replace (val >> 16) with macro RNA_SUBTYPE_UNIT_VALUE(val)
Campbell Barton
ideasman42 at gmail.com
Tue Apr 10 11:03:45 CEST 2012
Revision: 45500
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45500
Author: campbellbarton
Date: 2012-04-10 09:03:45 +0000 (Tue, 10 Apr 2012)
Log Message:
-----------
code cleanup: replace (val >> 16) with macro RNA_SUBTYPE_UNIT_VALUE(val)
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/interface/interface_handlers.c
trunk/blender/source/blender/makesrna/RNA_types.h
Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c 2012-04-10 08:33:30 UTC (rev 45499)
+++ trunk/blender/source/blender/editors/interface/interface.c 2012-04-10 09:03:45 UTC (rev 45500)
@@ -1588,7 +1588,7 @@
orig_str = MEM_callocN(sizeof(char) * maxlen + 1, "textedit sub str");
memcpy(orig_str, str, maxlen);
- bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, unit_type >> 16);
+ bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type));
MEM_freeN(orig_str);
}
@@ -1607,12 +1607,13 @@
if (precision > PRECISION_FLOAT_MAX) precision = PRECISION_FLOAT_MAX;
else if (precision == 0) precision = 2;
- bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, unit->system, unit_type >> 16, do_split, pad);
+ bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision,
+ unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type), do_split, pad);
}
static float ui_get_but_step_unit(uiBut *but, float step_default)
{
- int unit_type = uiButGetUnitType(but) >> 16;
+ int unit_type = RNA_SUBTYPE_UNIT_VALUE(uiButGetUnitType(but));
float step;
step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), but->block->unit->system, unit_type);
@@ -1707,8 +1708,10 @@
BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert));
- /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */
- bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), but->block->unit->system, unit_type >> 16);
+ /* ugly, use the draw string to get the value,
+ * this could cause problems if it includes some text which resolves to a unit */
+ bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr,
+ ui_get_but_scale_unit(but, 1.0), but->block->unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type));
return (BPY_button_exec(C, str_unit_convert, value, TRUE) != -1);
}
@@ -3388,7 +3391,7 @@
void uiButSetUnitType(uiBut *but, const int unit_type)
{
- but->unit_type = (unsigned char)(unit_type >> 16);
+ but->unit_type = (unsigned char)(RNA_SUBTYPE_UNIT_VALUE(unit_type));
}
int uiButGetUnitType(uiBut *but)
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c 2012-04-10 08:33:30 UTC (rev 45499)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c 2012-04-10 09:03:45 UTC (rev 45500)
@@ -2294,7 +2294,7 @@
if (ui_is_but_unit(but)) {
UnitSettings *unit = but->block->unit;
- int unit_type = uiButGetUnitType(but) >> 16;
+ int unit_type = RNA_SUBTYPE_UNIT_VALUE(uiButGetUnitType(but));
if (bUnit_IsValid(unit->system, unit_type)) {
fac = (float)bUnit_BaseScalar(unit->system, unit_type);
Modified: trunk/blender/source/blender/makesrna/RNA_types.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_types.h 2012-04-10 08:33:30 UTC (rev 45499)
+++ trunk/blender/source/blender/makesrna/RNA_types.h 2012-04-10 09:03:45 UTC (rev 45500)
@@ -91,9 +91,9 @@
PROP_UNIT_ACCELERATION = (8<<16) /* m/(s^2) */
} PropertyUnit;
-#define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
-#define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
-#define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype)>>16)
+#define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
+#define RNA_SUBTYPE_VALUE(subtype) ((subtype) & ~0x00FF0000)
+#define RNA_SUBTYPE_UNIT_VALUE(subtype) ((subtype) >> 16)
#define RNA_ENUM_BITFLAG_SIZE 32
More information about the Bf-blender-cvs
mailing list