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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-08-13 11:37:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-08-13 11:37:41 +0400
commitd916c25616b4f5038d9b17fb3eae9de377a2a9e5 (patch)
tree7950951cce9c469d40a67d4a121aa7452fa61643 /source/blender/editors/interface
parent127f19cac4378142dfcf1edd18e0e014f248270c (diff)
- moved unit settings from user prefs into the scene.
- use the scene context for the unit settings since there isn't a better place for it currently. - added 'chain' to imperial units - set more rna props to be distances and angles.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 2fe3ac720b6..a8703868ad1 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1144,7 +1144,8 @@ int ui_is_but_float(uiBut *but)
int ui_is_but_unit(uiBut *but)
{
- if(U.unit_system == USER_UNIT_NONE)
+ Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
+ if(scene->unit.system == USER_UNIT_NONE)
return 0;
if(but->rnaprop==NULL)
@@ -1324,13 +1325,13 @@ int ui_get_but_string_max_length(uiBut *but)
static double ui_get_but_scale_unit(uiBut *but, double value)
{
+ Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
int subtype= RNA_property_subtype(but->rnaprop);
if(subtype & PROP_UNIT_LENGTH) {
- return value * U.unit_scale_length;
+ return value * scene->unit.scale_length;
}
else if(subtype & PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
- Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
return FRA2TIME(value);
}
else {
@@ -1340,23 +1341,27 @@ static double ui_get_but_scale_unit(uiBut *but, double value)
static void ui_get_but_string_unit(uiBut *but, char *str, double value, int pad)
{
- int do_split= U.unit_flag & USER_UNIT_OPT_SPLIT ? 1:0;
+ Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
+ int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT;
int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
int precission= but->a2;
+ if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions
+
/* Sanity checks */
if(precission>4) precission= 4;
else if(precission==0) precission= 2;
- bUnit_AsString(str, ui_get_but_scale_unit(but, value), precission, U.unit_system, unit_type, do_split, pad);
+ bUnit_AsString(str, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad);
}
static float ui_get_but_step_unit(uiBut *but, double value, float step_default)
{
+ Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
float step;
- step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), U.unit_system, unit_type);
+ step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, value), scene->unit.system, unit_type);
if(step > 0.0) { /* -1 is an error value */
return (step/ui_get_but_scale_unit(but, 1.0))*100;
@@ -1502,10 +1507,12 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
{
char str_unit_convert[256];
int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
+ Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
+
- if(U.unit_system != USER_UNIT_NONE && unit_type) {
+ if(scene->unit.system != USER_UNIT_NONE && unit_type) {
/* 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, str, but->drawstr, ui_get_but_scale_unit(but, 1.0), U.unit_system, unit_type);
+ bUnit_ReplaceString(str_unit_convert, str, but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type);
}
else {
strcpy(str_unit_convert, str);
@@ -1865,9 +1872,6 @@ void ui_check_but(uiBut *but)
/* support length type buttons */
else if(ui_is_but_unit(but)) {
char new_str[256];
-
- if(U.unit_scale_length<0.0001) U.unit_scale_length= 1.0; // XXX do_versions
-
ui_get_but_string_unit(but, new_str, value, TRUE);
sprintf(but->drawstr, "%s%s", but->str, new_str);
}