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:
-rw-r--r--source/blender/blenkernel/BKE_unit.h2
-rw-r--r--source/blender/blenkernel/intern/unit.c4
-rw-r--r--source/blender/editors/include/UI_interface.h3
-rw-r--r--source/blender/editors/interface/interface.c55
-rw-r--r--source/blender/editors/interface/interface_handlers.c2
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_regions.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c24
-rw-r--r--source/blender/imbuf/intern/util.c1
9 files changed, 59 insertions, 37 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index f8ffd1cd188..5708766432f 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -67,7 +67,7 @@ double bUnit_GetScaler(void *usys_pt, int index);
#define B_UNIT_TIME 6
#define B_UNIT_VELOCITY 7
#define B_UNIT_ACCELERATION 8
-#define B_UNIT_MAXDEF 9
+#define B_UNIT_TYPE_TOT 9
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 69a43ac60f0..1b04589c1f2 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
+#include <assert.h>
#include "BKE_unit.h"
#include "BLI_math.h"
@@ -274,6 +275,7 @@ static struct bUnitCollection *bUnitSystems[][9] = {
/* internal, has some option not exposed */
static bUnitCollection *unit_get_system(int system, int type)
{
+ assert((system > -1) && (system < UNIT_SYSTEM_TOT) && (type > -1) && (type < B_UNIT_TYPE_TOT));
return bUnitSystems[system][type]; /* select system to use, metric/imperial/other? */
}
@@ -738,7 +740,7 @@ double bUnit_BaseScalar(int system, int type)
/* external access */
int bUnit_IsValid(int system, int type)
{
- return !(type < 0 || type >= B_UNIT_MAXDEF || system < 0 || system > UNIT_SYSTEM_TOT);
+ return !(system < 0 || system > UNIT_SYSTEM_TOT || type < 0 || type > B_UNIT_TYPE_TOT);
}
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index a60354a085f..ef74052f217 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -441,6 +441,9 @@ uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcon
/* for passing inputs to ButO buttons */
struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but);
+void uiButSetUnitType(uiBut *but, const int unit_type);
+int uiButGetUnitType(uiBut *but);
+
/* Special Buttons
*
* Butons with a more specific purpose:
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index bc1133313ee..8d803ef130a 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1246,12 +1246,10 @@ int ui_is_but_float(uiBut *but)
int ui_is_but_unit(uiBut *but)
{
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
- int unit_type;
-
- if(but->rnaprop==NULL)
- return 0;
+ int unit_type= uiButGetUnitType(but);
- unit_type = RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
+ if(unit_type == PROP_UNIT_NONE)
+ return 0;
#if 1 // removed so angle buttons get correct snapping
if (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION)
@@ -1267,9 +1265,6 @@ int ui_is_but_unit(uiBut *but)
return 0;
}
- if(unit_type == PROP_UNIT_NONE)
- return 0;
-
return 1;
}
@@ -1449,18 +1444,18 @@ 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_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
+ int unit_type= uiButGetUnitType(but);
- if(subtype == PROP_UNIT_LENGTH) {
+ if(unit_type == PROP_UNIT_LENGTH) {
return value * scene->unit.scale_length;
}
- else if(subtype == PROP_UNIT_AREA) {
+ else if(unit_type == PROP_UNIT_AREA) {
return value * pow(scene->unit.scale_length, 2);
}
- else if(subtype == PROP_UNIT_VOLUME) {
+ else if(unit_type == PROP_UNIT_VOLUME) {
return value * pow(scene->unit.scale_length, 3);
}
- else if(subtype == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
+ else if(unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
return FRA2TIME(value);
}
else {
@@ -1472,14 +1467,14 @@ static double ui_get_but_scale_unit(uiBut *but, double value)
void ui_convert_to_unit_alt_name(uiBut *but, char *str, int maxlen)
{
if(ui_is_but_unit(but)) {
- int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
+ int unit_type= uiButGetUnitType(but);
char *orig_str;
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
orig_str= MEM_callocN(sizeof(char)*maxlen + 1, "textedit sub str");
memcpy(orig_str, str, maxlen);
- bUnit_ToUnitAltName(str, maxlen, orig_str, scene->unit.system, unit_type);
+ bUnit_ToUnitAltName(str, maxlen, orig_str, scene->unit.system, unit_type>>16);
MEM_freeN(orig_str);
}
@@ -1489,7 +1484,7 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va
{
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 unit_type= uiButGetUnitType(but);
int precision= but->a2;
if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions
@@ -1498,13 +1493,13 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va
if(precision>4) precision= 4;
else if(precision==0) precision= 2;
- bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, scene->unit.system, unit_type, do_split, pad);
+ bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, scene->unit.system, unit_type>>16, do_split, pad);
}
static float ui_get_but_step_unit(uiBut *but, 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));
+ int unit_type= uiButGetUnitType(but)>>16;
float step;
step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), scene->unit.system, unit_type);
@@ -1655,19 +1650,14 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
#ifdef WITH_PYTHON
{
char str_unit_convert[256];
- int unit_type;
+ int unit_type= uiButGetUnitType(but);
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
- if(but->rnaprop)
- unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
- else
- unit_type= 0;
-
BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert));
if(ui_is_but_unit(but)) {
/* 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), scene->unit.system, unit_type);
+ bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type>>16);
}
if(BPY_eval_button(C, str_unit_convert, &value)) {
@@ -3183,6 +3173,21 @@ PointerRNA *uiButGetOperatorPtrRNA(uiBut *but)
return but->opptr;
}
+void uiButSetUnitType(uiBut *but, const int unit_type)
+{
+ but->unit_type= (unsigned char)(unit_type>>16);
+}
+
+int uiButGetUnitType(uiBut *but)
+{
+ if(but->rnaprop) {
+ return RNA_property_subtype(but->rnaprop);
+ }
+ else {
+ return ((int)but->unit_type)<<16;
+ }
+}
+
void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg)
{
block->handle_func= func;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 66ea2ebc265..499d1d62c76 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2210,7 +2210,7 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
if(ui_is_but_unit(but)) {
Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
- int unit_type = RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop));
+ int unit_type= uiButGetUnitType(but)>>16;
if(bUnit_IsValid(scene->unit.system, unit_type)) {
fac= (float)bUnit_BaseScalar(scene->unit.system, unit_type);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 0573026bf56..a7c03a6b95d 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -209,7 +209,8 @@ struct uiBut {
BIFIconID icon;
char lock;
char dt;
- short changed; /* could be made into a single flag */
+ char changed; /* could be made into a single flag */
+ unsigned char unit_type; /* so buttons can support unit systems which are not RNA */
short modifier_key;
short iconadd;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index df2ebd44c9c..2230042fb1f 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -384,7 +384,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
if(but->rnaprop) {
- int unit_type = RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
+ int unit_type= uiButGetUnitType(but);
if (unit_type == PROP_UNIT_ROTATION) {
if (RNA_property_type(but->rnaprop) == PROP_FLOAT) {
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index bb0ea9f0b63..eb6965932a2 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -291,12 +291,17 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float
uiBlockBeginAlign(block);
if(tot==1) {
+ uiBut *but;
uiDefBut(block, LABEL, 0, "Vertex:", 0, 130, 200, 20, 0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "X:", 0, 110, 200, 20, &(tfp->ve_median[0]), -lim, lim, 10, 3, "");
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Y:", 0, 90, 200, 20, &(tfp->ve_median[1]), -lim, lim, 10, 3, "");
- uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Z:", 0, 70, 200, 20, &(tfp->ve_median[2]), -lim, lim, 10, 3, "");
-
+
+ but= uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "X:", 0, 110, 200, 20, &(tfp->ve_median[0]), -lim, lim, 10, 3, "");
+ uiButSetUnitType(but, PROP_UNIT_LENGTH);
+ but= uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Y:", 0, 90, 200, 20, &(tfp->ve_median[1]), -lim, lim, 10, 3, "");
+ uiButSetUnitType(but, PROP_UNIT_LENGTH);
+ but= uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "Z:", 0, 70, 200, 20, &(tfp->ve_median[2]), -lim, lim, 10, 3, "");
+ uiButSetUnitType(but, PROP_UNIT_LENGTH);
+
if(totw==1) {
uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, "W:", 0, 50, 200, 20, &(tfp->ve_median[3]), 0.01, 100.0, 10, 3, "");
uiBlockBeginAlign(block);
@@ -803,6 +808,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob)
PointerRNA pchanptr;
uiLayout *col;
// uiLayout *row;
+// uiBut *but;
pchan= get_active_posechannel(ob);
@@ -841,9 +847,13 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob)
uiDefBut(block, LABEL, 0, "Location:", 0, 240, 100, 20, 0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
- uiDefButF(block, NUM, B_ARMATUREPANEL2, "X:", 0, 220, 120, 19, pchan->loc, -lim, lim, 100, 3, "");
- uiDefButF(block, NUM, B_ARMATUREPANEL2, "Y:", 0, 200, 120, 19, pchan->loc+1, -lim, lim, 100, 3, "");
- uiDefButF(block, NUM, B_ARMATUREPANEL2, "Z:", 0, 180, 120, 19, pchan->loc+2, -lim, lim, 100, 3, "");
+
+ but= uiDefButF(block, NUM, B_ARMATUREPANEL2, "X:", 0, 220, 120, 19, pchan->loc, -lim, lim, 100, 3, "");
+ uiButSetUnitType(but, PROP_UNIT_LENGTH);
+ but= uiDefButF(block, NUM, B_ARMATUREPANEL2, "Y:", 0, 200, 120, 19, pchan->loc+1, -lim, lim, 100, 3, "");
+ uiButSetUnitType(but, PROP_UNIT_LENGTH);
+ but= uiDefButF(block, NUM, B_ARMATUREPANEL2, "Z:", 0, 180, 120, 19, pchan->loc+2, -lim, lim, 100, 3, "");
+ uiButSetUnitType(but, PROP_UNIT_LENGTH);
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index bd3bc7f2a3f..1e50e2997d1 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -126,6 +126,7 @@ const char *imb_ext_movie[] = {
".flv",
".divx",
".xvid",
+ ".mxf",
NULL};
/* sort of wrong being here... */