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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-16 22:47:42 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-16 22:47:42 +0400
commit3a6bf17b3ef696c572207d5af3381c6327fe6a92 (patch)
treeb95e5d5b869fc2c16a77e0a2ef1142899a6cb6e4
parentde59f34be0a2da17a90950aef1c87a0bb6c74052 (diff)
UI
* Fix problem with curve mapping / color ramps not updating things like previews propertly. Now it uses the RNA update of the pointer from the material/texture/.. so each of those can define their own update, but still share the RNA struct. * Code for these templates is now in interface_templates.c * Fix exception for "axis" property, now it always shows normal widget with the PROP_DIRECTION subtype. * Remove context from uiBlockLayoutResolve, no longer needed.
-rw-r--r--release/ui/buttons_data_lamp.py2
-rw-r--r--release/ui/buttons_material.py6
-rw-r--r--release/ui/buttons_scene.py3
-rw-r--r--release/ui/buttons_texture.py8
-rw-r--r--release/ui/space_userpref.py2
-rw-r--r--release/ui/space_view3d_toolbar.py4
-rw-r--r--source/blender/editors/include/UI_interface.h8
-rw-r--r--source/blender/editors/interface/interface.c24
-rw-r--r--source/blender/editors/interface/interface_handlers.c8
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_layout.c48
-rw-r--r--source/blender/editors/interface/interface_regions.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c505
-rw-r--r--source/blender/editors/screen/area.c6
-rw-r--r--source/blender/editors/space_action/action_header.c2
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c8
16 files changed, 546 insertions, 93 deletions
diff --git a/release/ui/buttons_data_lamp.py b/release/ui/buttons_data_lamp.py
index d5aaa5ad679..0dbda46bccf 100644
--- a/release/ui/buttons_data_lamp.py
+++ b/release/ui/buttons_data_lamp.py
@@ -301,7 +301,7 @@ class DATA_PT_falloff_curve(DataButtonsPanel):
def draw(self, context):
lamp = context.lamp
- self.layout.template_curve_mapping(lamp.falloff_curve)
+ self.layout.template_curve_mapping(lamp, "falloff_curve")
bpy.types.register(DATA_PT_context_lamp)
bpy.types.register(DATA_PT_preview)
diff --git a/release/ui/buttons_material.py b/release/ui/buttons_material.py
index dc11731d7a9..9f1c216c36b 100644
--- a/release/ui/buttons_material.py
+++ b/release/ui/buttons_material.py
@@ -28,7 +28,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
# this manages materials for all engine types
engine = context.scene.render_data.engine
- return (context.object) and (engine in self.COMPAT_ENGINES)
+ return (context.material or context.object) and (engine in self.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
@@ -282,7 +282,7 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
if mat.use_diffuse_ramp:
layout.itemS()
- layout.template_color_ramp(mat.diffuse_ramp, expand=True)
+ layout.template_color_ramp(mat, "diffuse_ramp", expand=True)
layout.itemS()
row = layout.row()
split = row.split(percentage=0.3)
@@ -334,7 +334,7 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
if mat.use_specular_ramp:
layout.itemS()
- layout.template_color_ramp(mat.specular_ramp, expand=True)
+ layout.template_color_ramp(mat, "specular_ramp", expand=True)
layout.itemS()
row = layout.row()
split = row.split(percentage=0.3)
diff --git a/release/ui/buttons_scene.py b/release/ui/buttons_scene.py
index 3c321f11f6e..c25e6352aaf 100644
--- a/release/ui/buttons_scene.py
+++ b/release/ui/buttons_scene.py
@@ -240,7 +240,8 @@ class SCENE_PT_output(RenderButtonsPanel):
split = layout.split()
col = split.column()
- col.itemR(rd, "exr_codec")
+ col.itemL(text="Codec:")
+ col.itemR(rd, "exr_codec", text="")
subsplit = split.split()
col = subsplit.column()
diff --git a/release/ui/buttons_texture.py b/release/ui/buttons_texture.py
index 3cea47a236e..c595e2b1cc2 100644
--- a/release/ui/buttons_texture.py
+++ b/release/ui/buttons_texture.py
@@ -96,7 +96,7 @@ class TEXTURE_PT_colors(TextureButtonsPanel):
layout.itemR(tex, "use_color_ramp", text="Ramp")
if tex.use_color_ramp:
- layout.template_color_ramp(tex.color_ramp, expand=True)
+ layout.template_color_ramp(tex, "color_ramp", expand=True)
split = layout.split()
@@ -410,10 +410,10 @@ class TEXTURE_PT_image(TextureTypePanel):
def draw(self, context):
layout = self.layout
-
+
tex = context.texture
- layout.template_texture_image(tex)
+ layout.template_image(tex, "image", tex.image_user)
class TEXTURE_PT_image_sampling(TextureTypePanel):
__label__ = "Image Sampling"
@@ -689,7 +689,7 @@ class TEXTURE_PT_pointdensity(TextureButtonsPanel):
if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_VELOCITY'):
col.itemR(pd, "speed_scale")
if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_AGE'):
- layout.template_color_ramp(pd.color_ramp, expand=True)
+ layout.template_color_ramp(pd, "color_ramp", expand=True)
col = split.column()
col.itemL()
diff --git a/release/ui/space_userpref.py b/release/ui/space_userpref.py
index cfdabadcee1..267a0b4a78b 100644
--- a/release/ui/space_userpref.py
+++ b/release/ui/space_userpref.py
@@ -264,7 +264,7 @@ class USERPREF_PT_system(bpy.types.Panel):
sub2 = sub1.column()
sub2.active = system.use_weight_color_range
- sub2.template_color_ramp(system.weight_color_range, expand=True)
+ sub2.template_color_ramp(system, "weight_color_range", expand=True)
sub1.itemS()
sub1.itemS()
diff --git a/release/ui/space_view3d_toolbar.py b/release/ui/space_view3d_toolbar.py
index fe0f4ca5a21..f177c81b7b7 100644
--- a/release/ui/space_view3d_toolbar.py
+++ b/release/ui/space_view3d_toolbar.py
@@ -422,7 +422,7 @@ class VIEW3D_PT_tools_brush(PaintPanel):
row.itemR(brush, "strength", slider=True)
row.itemR(brush, "strength_pressure", toggle=True, text="")
- col.itemR(brush, "blend")
+ col.itemR(brush, "blend", text="Blend")
# Weight Paint Mode #
@@ -508,7 +508,7 @@ class VIEW3D_PT_tools_brush_curve(PaintPanel):
settings = self.paint_settings(context)
brush = settings.brush
- layout.template_curve_mapping(brush.curve)
+ layout.template_curve_mapping(brush, "curve")
layout.item_menu_enumO("brush.curve_preset", property="shape")
class VIEW3D_PT_sculpt_options(PaintPanel):
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 77c4e4d3475..f475dd16057 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -487,6 +487,7 @@ int uiSearchBoxhHeight(void);
void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg);
void uiBlockSetButmFunc (uiBlock *block, uiMenuHandleFunc func, void *arg);
void uiBlockSetFunc (uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2);
+void uiBlockSetNFunc (uiBlock *block, uiButHandleFunc func, void *argN, void *arg2);
void uiButSetRenameFunc (uiBut *but, uiButHandleRenameFunc func, void *arg1);
void uiButSetFunc (uiBut *but, uiButHandleFunc func, void *arg1, void *arg2);
@@ -596,7 +597,7 @@ void UI_exit(void);
uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
-void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y);
+void uiBlockLayoutResolve(uiBlock *block, int *x, int *y);
uiBlock *uiLayoutGetBlock(uiLayout *layout);
@@ -641,10 +642,11 @@ void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr,
uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent, struct MTex *slot);
-void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
-void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type, int compact);
+void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand);
+void uiTemplateCurveMapping(uiLayout *layout, struct PointerRNA *ptr, char *propname, int type, int levels);
void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname);
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
+void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *userptr, int compact);
void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
void uiTemplateOperatorSearch(uiLayout *layout);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 221618b340e..2d4b2caa845 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -622,7 +622,7 @@ void uiEndBlock(const bContext *C, uiBlock *block)
}
/* handle pending stuff */
- if(block->layouts.first) uiBlockLayoutResolve(C, block, NULL, NULL);
+ if(block->layouts.first) uiBlockLayoutResolve(block, NULL, NULL);
ui_block_do_align(block);
if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block);
@@ -1684,6 +1684,9 @@ void uiFreeBlock(const bContext *C, uiBlock *block)
ui_free_but(C, but);
}
+ if(block->func_argN)
+ MEM_freeN(block->func_argN);
+
CTX_store_free_list(&block->contexts);
BLI_freelistN(&block->saferct);
@@ -2232,6 +2235,10 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
but->func= block->func;
but->func_arg1= block->func_arg1;
but->func_arg2= block->func_arg2;
+
+ but->funcN= block->funcN;
+ if(block->func_argN)
+ but->func_argN= MEM_dupallocN(block->func_argN);
but->pos= -1; /* cursor invisible */
@@ -2945,6 +2952,16 @@ void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2
block->func_arg2= arg2;
}
+void uiBlockSetNFunc(uiBlock *block, uiButHandleFunc func, void *argN, void *arg2)
+{
+ if(block->func_argN)
+ MEM_freeN(block->func_argN);
+
+ block->funcN= func;
+ block->func_argN= argN;
+ block->func_arg2= arg2;
+}
+
void uiButSetRenameFunc(uiBut *but, uiButHandleRenameFunc func, void *arg1)
{
but->rename_func= func;
@@ -2967,6 +2984,9 @@ void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2)
void uiButSetNFunc(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2)
{
+ if(but->func_argN)
+ MEM_freeN(but->func_argN);
+
but->funcN= funcN;
but->func_argN= argN;
but->func_arg2= arg2;
@@ -3003,6 +3023,8 @@ uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *
{
uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip);
but->block_create_func= func;
+ if(but->func_argN)
+ MEM_freeN(but->func_argN);
but->func_argN= argN;
ui_check_but(but);
return but;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 1041418b059..dbf5669b326 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -246,7 +246,13 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
if(but->func || but->funcN || block->handle_func || but->rename_func || (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) {
after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
- after->func= but->func;
+ if(ELEM(but, but->func_arg1, but->func_arg2)) {
+ /* exception, this will crash due to removed button otherwise */
+ but->func(C, but->func_arg1, but->func_arg2);
+ }
+ else
+ after->func= but->func;
+
after->func_arg1= but->func_arg1;
after->func_arg2= but->func_arg2;
after->func_arg3= but->func_arg3;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 2e623114fe9..7ab99a83c4b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -263,6 +263,9 @@ struct uiBlock {
void *func_arg1;
void *func_arg2;
+ uiButHandleNFunc funcN;
+ void *func_argN;
+
uiMenuHandleFunc butm_func;
void *butm_func_arg;
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b6afc4daa9b..b957ff83650 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -481,6 +481,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
{
uiLayout *sub;
uiBut *but;
+ PropertyType type;
PropertySubType subtype;
int labelw;
@@ -496,6 +497,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
w= w-labelw;
}
+ type= RNA_property_type(prop);
subtype= RNA_property_subtype(prop);
if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
@@ -505,8 +507,10 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
/* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */
but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, "Browse for file or directory.");
}
+ else if(subtype == PROP_DIRECTION)
+ uiDefButR(block, BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL);
else
- but= uiDefAutoButR(block, ptr, prop, index, (!icon_only)? "": NULL, icon, x, y, w, h);
+ but= uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !icon_only)? NULL: "", icon, x, y, w, h);
uiBlockSetCurLayout(block, layout);
return but;
@@ -840,9 +844,6 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
char namestr[UI_MAX_NAME_STR];
int len, w, h, slider, toggle, expand, icon_only;
- if(!ptr->data || !prop)
- return;
-
uiBlockSetCurLayout(block, layout);
/* retrieve info */
@@ -913,12 +914,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int flag)
{
- PropertyRNA *prop;
-
- if(!ptr->data || !propname)
- return;
-
- prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
ui_item_disabled(layout, propname);
@@ -931,12 +927,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop
void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value)
{
- PropertyRNA *prop;
-
- if(!ptr->data || !propname)
- return;
-
- prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
@@ -949,15 +940,10 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value)
{
- PropertyRNA *prop;
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
EnumPropertyItem *item;
int ivalue, a, free;
- if(!ptr->data || !propname)
- return;
-
- prop= RNA_struct_find_property(ptr, propname);
-
if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
printf("uiItemEnumR: enum property not found: %s\n", propname);
@@ -1123,9 +1109,6 @@ void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *p
int w, h;
/* validate arguments */
- if(!ptr->data || !searchptr->data)
- return;
-
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
@@ -2227,18 +2210,13 @@ static void ui_item_layout(uiItem *item)
}
}
-static void ui_layout_items(const bContext *C, uiBlock *block, uiLayout *layout)
-{
- ui_item_estimate(&layout->item);
- ui_item_layout(&layout->item);
-}
-
-static void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y)
+static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y)
{
if(layout->root->handlefunc)
uiBlockSetButmFunc(block, layout->root->handlefunc, layout->root->argv);
- ui_layout_items(C, block, layout);
+ ui_item_estimate(&layout->item);
+ ui_item_layout(&layout->item);
if(x) *x= layout->x;
if(y) *y= layout->y;
@@ -2346,7 +2324,7 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
layout->root->argv= argv;
}
-void uiBlockLayoutResolve(const bContext *C, uiBlock *block, int *x, int *y)
+void uiBlockLayoutResolve(uiBlock *block, int *x, int *y)
{
uiLayoutRoot *root;
@@ -2357,7 +2335,7 @@ void uiBlockLayoutResolve(const bContext *C, uiBlock *block, int *x, int *y)
for(root=block->layouts.first; root; root=root->next) {
/* NULL in advance so we don't interfere when adding button */
- ui_layout_end(C, block, root->layout, x, y);
+ ui_layout_end(block, root->layout, x, y);
ui_layout_free(root->layout);
}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index dfcdea59f68..95305819e2b 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -2192,7 +2192,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
block->direction= direction;
- uiBlockLayoutResolve(C, block, NULL, NULL);
+ uiBlockLayoutResolve(block, NULL, NULL);
if(pup->popup) {
uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 2b7d6f383bf..1c7e757fbb2 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -36,6 +36,7 @@
#include "BKE_icons.h"
#include "BKE_global.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_utildefines.h"
#include "ED_screen.h"
@@ -75,7 +76,7 @@ typedef struct TemplateID {
} TemplateID;
/* Search browse menu, assign */
-static void id_search_call_cb(struct bContext *C, void *arg_template, void *item)
+static void id_search_call_cb(bContext *C, void *arg_template, void *item)
{
TemplateID *template= (TemplateID*)arg_template;
@@ -90,7 +91,7 @@ static void id_search_call_cb(struct bContext *C, void *arg_template, void *item
}
/* ID Search browse menu, do the search */
-static void id_search_cb(const struct bContext *C, void *arg_template, char *str, uiSearchItems *items)
+static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSearchItems *items)
{
TemplateID *template= (TemplateID*)arg_template;
Scene *scene= CTX_data_scene(C);
@@ -291,7 +292,7 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc
int w= id?UI_UNIT_X: (flag & UI_ID_OPEN)? UI_UNIT_X*3: UI_UNIT_X*6;
if(newop) {
- but= uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, (id)? "": "New", 0, 0, w, UI_UNIT_Y, NULL);
+ but= uiDefIconTextButO(block, BUT, newop, WM_OP_EXEC_REGION_WIN, ICON_ZOOMIN, (id)? "": "New", 0, 0, w, UI_UNIT_Y, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
else {
@@ -344,9 +345,6 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname
StructRNA *type;
int flag;
- if(!ptr->data)
- return;
-
prop= RNA_struct_find_property(ptr, propname);
if(!prop || RNA_property_type(prop) != PROP_POINTER) {
@@ -1241,54 +1239,499 @@ void uiTemplatePreview(uiLayout *layout, ID *id, ID *parent, MTex *slot)
/********************** ColorRamp Template **************************/
-void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand)
+#include "BKE_texture.h"
+
+typedef struct RNAUpdateCb {
+ PointerRNA ptr;
+ PropertyRNA *prop;
+} RNAUpdateCb;
+
+static void rna_update_cb(bContext *C, void *arg_cb, void *arg_unused)
+{
+ RNAUpdateCb *cb= (RNAUpdateCb*)arg_cb;
+
+ /* we call update here on the pointer property, this way the
+ owner of the curve mapping can still define it's own update
+ and notifier, even if the CurveMapping struct is shared. */
+ RNA_property_update(C, &cb->ptr, cb->prop);
+}
+
+#define B_BANDCOL 1
+
+static int vergcband(const void *a1, const void *a2)
+{
+ const CBData *x1=a1, *x2=a2;
+
+ if( x1->pos > x2->pos ) return 1;
+ else if( x1->pos < x2->pos) return -1;
+ return 0;
+}
+
+static void colorband_pos_cb(bContext *C, void *cb_v, void *coba_v)
+{
+ ColorBand *coba= coba_v;
+ int a;
+
+ if(coba->tot<2) return;
+
+ for(a=0; a<coba->tot; a++) coba->data[a].cur= a;
+ qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
+ for(a=0; a<coba->tot; a++) {
+ if(coba->data[a].cur==coba->cur) {
+ coba->cur= a;
+ break;
+ }
+ }
+
+ rna_update_cb(C, cb_v, NULL);
+}
+
+static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
+{
+ ColorBand *coba= coba_v;
+
+ if(coba->tot < MAXCOLORBAND-1) coba->tot++;
+ coba->cur= coba->tot-1;
+
+ colorband_pos_cb(C, cb_v, coba_v);
+
+ ED_undo_push(C, "Add colorband");
+}
+
+static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
+{
+ ColorBand *coba= coba_v;
+ int a;
+
+ if(coba->tot<2) return;
+
+ for(a=coba->cur; a<coba->tot; a++) {
+ coba->data[a]= coba->data[a+1];
+ }
+ if(coba->cur) coba->cur--;
+ coba->tot--;
+
+ ED_undo_push(C, "Delete colorband");
+
+ rna_update_cb(C, cb_v, NULL);
+}
+
+
+/* offset aligns from bottom, standard width 300, height 115 */
+static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs, int yoffs, RNAUpdateCb *cb)
+{
+ CBData *cbd;
+ uiBut *bt;
+
+ if(coba==NULL) return;
+
+ bt= uiDefBut(block, BUT, 0, "Add", 0+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Add a new color stop to the colorband");
+ uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
+
+ bt= uiDefBut(block, BUT, 0, "Delete", 60+xoffs,100+yoffs,50,20, 0, 0, 0, 0, 0, "Delete the active position");
+ uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
+
+ uiDefButS(block, NUM, 0, "", 120+xoffs,100+yoffs,80, 20, &coba->cur, 0.0, (float)(coba->tot-1), 0, 0, "Choose active color stop");
+
+ bt= uiDefButS(block, MENU, 0, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
+ 210+xoffs, 100+yoffs, 90, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Set interpolation between color stops");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+ uiBlockEndAlign(block);
+
+ bt= uiDefBut(block, BUT_COLORBAND, 0, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ cbd= coba->data + coba->cur;
+
+ bt= uiDefButF(block, NUM, 0, "Pos:", 0+xoffs,40+yoffs,100, 20, &cbd->pos, 0.0, 1.0, 10, 0, "The position of the active color stop");
+ uiButSetNFunc(bt, colorband_pos_cb, MEM_dupallocN(cb), coba);
+ bt= uiDefButF(block, COL, 0, "", 110+xoffs,40+yoffs,80,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+ bt= uiDefButF(block, NUMSLI, 0, "A ", 200+xoffs,40+yoffs,100,20, &cbd->a, 0.0, 1.0, 10, 0, "The alpha value of the active color stop");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+}
+
+static void colorband_buttons_small(uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb)
+{
+ CBData *cbd;
+ uiBut *bt;
+ float unit= (butr->xmax-butr->xmin)/14.0f;
+ float xs= butr->xmin;
+
+ cbd= coba->data + coba->cur;
+
+
+ bt= uiDefBut(block, BUT, 0, "Add", xs,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Add a new color stop to the colorband");
+ uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
+ bt= uiDefBut(block, BUT, 0, "Delete", xs+2.0f*unit,butr->ymin+20.0f,2.0f*unit,20, NULL, 0, 0, 0, 0, "Delete the active position");
+ uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
+
+ bt= uiDefButF(block, COL, 0, "", xs+4.0f*unit,butr->ymin+20.0f,2.0f*unit,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+ bt= uiDefButF(block, NUMSLI, 0, "A:", xs+6.0f*unit,butr->ymin+20.0f,4.0f*unit,20, &(cbd->a), 0.0f, 1.0f, 10, 2, "The alpha value of the active color stop");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ bt= uiDefButS(block, MENU, 0, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
+ xs+10.0f*unit, butr->ymin+20.0f, unit*4, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Set interpolation between color stops");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ bt= uiDefBut(block, BUT_COLORBAND, 0, "", xs,butr->ymin,butr->xmax-butr->xmin,20.0f, coba, 0, 0, 0, 0, "");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ uiBlockEndAlign(block);
+}
+
+static void colorband_buttons_layout(uiBlock *block, ColorBand *coba, rctf *butr, int small, RNAUpdateCb *cb)
+{
+ if(small)
+ colorband_buttons_small(block, coba, butr, cb);
+ else
+ colorband_buttons_large(block, coba, 0, 0, cb);
+}
+
+void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, char *propname, int expand)
{
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PointerRNA cptr;
+ RNAUpdateCb *cb;
uiBlock *block;
rctf rect;
- if(coba) {
- rect.xmin= 0; rect.xmax= 200;
- rect.ymin= 0; rect.ymax= 190;
-
- block= uiLayoutFreeBlock(layout);
- colorband_buttons(block, coba, &rect, !expand);
- }
+ if(!prop || RNA_property_type(prop) != PROP_POINTER)
+ return;
+
+ cptr= RNA_property_pointer_get(ptr, prop);
+ if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp))
+ return;
+
+ cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr= *ptr;
+ cb->prop= prop;
+
+ rect.xmin= 0; rect.xmax= 200;
+ rect.ymin= 0; rect.ymax= 190;
+
+ block= uiLayoutFreeBlock(layout);
+ colorband_buttons_layout(block, cptr.data, &rect, !expand, cb);
+
+ MEM_freeN(cb);
}
/********************* CurveMapping Template ************************/
#include "DNA_color_types.h"
+#include "BKE_colortools.h"
-void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type, int compact)
+static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *unused)
{
- rctf rect;
+ CurveMapping *cumap = cumap_v;
+ float d;
+
+ /* we allow 20 times zoom */
+ if( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
+ d= 0.1154f*(cumap->curr.xmax - cumap->curr.xmin);
+ cumap->curr.xmin+= d;
+ cumap->curr.xmax-= d;
+ d= 0.1154f*(cumap->curr.ymax - cumap->curr.ymin);
+ cumap->curr.ymin+= d;
+ cumap->curr.ymax-= d;
+ }
+
+ ED_region_tag_redraw(CTX_wm_region(C));
+}
+
+static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *unused)
+{
+ CurveMapping *cumap = cumap_v;
+ float d, d1;
+
+ /* we allow 20 times zoom, but dont view outside clip */
+ if( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
+ d= d1= 0.15f*(cumap->curr.xmax - cumap->curr.xmin);
+
+ if(cumap->flag & CUMA_DO_CLIP)
+ if(cumap->curr.xmin-d < cumap->clipr.xmin)
+ d1= cumap->curr.xmin - cumap->clipr.xmin;
+ cumap->curr.xmin-= d1;
+
+ d1= d;
+ if(cumap->flag & CUMA_DO_CLIP)
+ if(cumap->curr.xmax+d > cumap->clipr.xmax)
+ d1= -cumap->curr.xmax + cumap->clipr.xmax;
+ cumap->curr.xmax+= d1;
+
+ d= d1= 0.15f*(cumap->curr.ymax - cumap->curr.ymin);
+
+ if(cumap->flag & CUMA_DO_CLIP)
+ if(cumap->curr.ymin-d < cumap->clipr.ymin)
+ d1= cumap->curr.ymin - cumap->clipr.ymin;
+ cumap->curr.ymin-= d1;
+
+ d1= d;
+ if(cumap->flag & CUMA_DO_CLIP)
+ if(cumap->curr.ymax+d > cumap->clipr.ymax)
+ d1= -cumap->curr.ymax + cumap->clipr.ymax;
+ cumap->curr.ymax+= d1;
+ }
+
+ ED_region_tag_redraw(CTX_wm_region(C));
+}
+
+static void curvemap_buttons_setclip(bContext *C, void *cumap_v, void *unused)
+{
+ CurveMapping *cumap = cumap_v;
+
+ curvemapping_changed(cumap, 0);
+}
+
+static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
+{
+ CurveMapping *cumap = cumap_v;
+
+ curvemap_remove(cumap->cm+cumap->cur, SELECT);
+ curvemapping_changed(cumap, 0);
+
+ rna_update_cb(C, cb_v, NULL);
+}
+
+/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
+static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cumap_v)
+{
+ CurveMapping *cumap = cumap_v;
+ uiBlock *block;
+ uiBut *bt;
+
+ block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS);
+
+ /* use this for a fake extra empy space around the buttons */
+ uiDefBut(block, LABEL, 0, "", -4, 16, 128, 106, NULL, 0, 0, 0, 0, "");
+
+ bt= uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping",
+ 0,100,120,18, &cumap->flag, 0.0, 0.0, 10, 0, "");
+ uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL);
+
+ uiBlockBeginAlign(block);
+ uiDefButF(block, NUM, 0, "Min X ", 0,74,120,18, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, "");
+ uiDefButF(block, NUM, 0, "Min Y ", 0,56,120,18, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, "");
+ uiDefButF(block, NUM, 0, "Max X ", 0,38,120,18, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, "");
+ uiDefButF(block, NUM, 0, "Max Y ", 0,20,120,18, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, "");
+
+ uiBlockSetDirection(block, UI_RIGHT);
+
+ uiEndBlock(C, block);
+ return block;
+}
+
+static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
+{
+ CurveMapping *cumap = cumap_v;
+ CurveMap *cuma= cumap->cm+cumap->cur;
+
+ switch(event) {
+ case 0:
+ curvemap_reset(cuma, &cumap->clipr);
+ curvemapping_changed(cumap, 0);
+ break;
+ case 1:
+ cumap->curr= cumap->clipr;
+ break;
+ case 2: /* set vector */
+ curvemap_sethandle(cuma, 1);
+ curvemapping_changed(cumap, 0);
+ break;
+ case 3: /* set auto */
+ curvemap_sethandle(cuma, 0);
+ curvemapping_changed(cumap, 0);
+ break;
+ case 4: /* extend horiz */
+ cuma->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
+ curvemapping_changed(cumap, 0);
+ break;
+ case 5: /* extend extrapolate */
+ cuma->flag |= CUMA_EXTEND_EXTRAPOLATE;
+ curvemapping_changed(cumap, 0);
+ break;
+ }
+ ED_region_tag_redraw(CTX_wm_region(C));
+}
+
+static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap_v)
+{
+ uiBlock *block;
+ short yco= 0, menuwidth=120;
+
+ block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS);
+ uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v);
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset View", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Vector Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Auto Handle", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Horizontal", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Extrapolated", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Curve", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiBlockSetDirection(block, UI_RIGHT);
+ uiTextBoundsBlock(block, 50);
+
+ uiEndBlock(C, block);
+ return block;
+}
+
+static void curvemap_buttons_redraw(bContext *C, void *arg1, void *arg2)
+{
+ ED_region_tag_redraw(CTX_wm_region(C));
+}
+
+static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
+{
+ CurveMapping *cumap = cumap_v;
+ int a;
+
+ for(a=0; a<CM_TOT; a++)
+ curvemap_reset(cumap->cm+a, &cumap->clipr);
+
+ cumap->black[0]=cumap->black[1]=cumap->black[2]= 0.0f;
+ cumap->white[0]=cumap->white[1]=cumap->white[2]= 1.0f;
+ curvemapping_set_black_white(cumap, NULL, NULL);
+
+ curvemapping_changed(cumap, 0);
+
+ rna_update_cb(C, cb_v, NULL);
+}
+
+/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
+static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels, RNAUpdateCb *cb)
+{
+ CurveMapping *cumap= ptr->data;
+ uiLayout *row, *sub, *split;
+ uiBlock *block;
+ uiBut *bt;
+ float dx= UI_UNIT_X;
+ int icon, size;
- if(cumap) {
- if(compact) {
- rect.xmin= 0; rect.xmax= 150;
- rect.ymin= 0; rect.ymax= 140;
+ block= uiLayoutGetBlock(layout);
+
+ /* curve chooser */
+ row= uiLayoutRow(layout, 0);
+
+ if(labeltype=='v') {
+ /* vector */
+ sub= uiLayoutRow(row, 1);
+ uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
+
+ if(cumap->cm[0].curve) {
+ bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+ uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
- else {
- rect.xmin= 0; rect.xmax= 200;
- rect.ymin= 0; rect.ymax= 190;
+ if(cumap->cm[1].curve) {
+ bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+ uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
-
- curvemap_layout(layout, cumap, type, 0, 0, &rect);
+ if(cumap->cm[2].curve) {
+ bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+ uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+ }
+ }
+ else if(labeltype=='c') {
+ /* color */
+ sub= uiLayoutRow(row, 1);
+ uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
+
+ if(cumap->cm[3].curve) {
+ bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
+ uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+ }
+ if(cumap->cm[0].curve) {
+ bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+ uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+ }
+ if(cumap->cm[1].curve) {
+ bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+ uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+ }
+ if(cumap->cm[2].curve) {
+ bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+ uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
+ }
+ }
+ else
+ uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
+
+ /* operation buttons */
+ sub= uiLayoutRow(row, 1);
+
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+
+ bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom in");
+ uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL);
+
+ bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, 14, NULL, 0.0, 0.0, 0.0, 0.0, "Zoom out");
+ uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL);
+
+ bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, 18, "Tools");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT;
+ bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, 18, "Clipping Options");
+ uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points");
+ uiButSetNFunc(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap);
+
+ uiBlockSetEmboss(block, UI_EMBOSS);
+
+ uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);
+
+ /* curve itself */
+ size= uiLayoutGetWidth(layout);
+ row= uiLayoutRow(layout, 0);
+ uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, 0, 0, "");
+
+ /* black/white levels */
+ if(levels) {
+ split= uiLayoutSplit(layout, 0);
+ uiItemR(uiLayoutColumn(split, 0), NULL, 0, ptr, "black_level", UI_ITEM_R_EXPAND);
+ uiItemR(uiLayoutColumn(split, 0), NULL, 0, ptr, "white_level", UI_ITEM_R_EXPAND);
+
+ uiLayoutRow(layout, 0);
+ bt=uiDefBut(block, BUT, 0, "Reset", 0, 0, UI_UNIT_X*10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Reset Black/White point and curves");
+ uiButSetNFunc(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap);
}
+
+ uiBlockSetNFunc(block, NULL, NULL, NULL);
+}
+
+void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, char *propname, int type, int levels)
+{
+ RNAUpdateCb *cb;
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PointerRNA cptr;
+
+ if(!prop || RNA_property_type(prop) != PROP_POINTER)
+ return;
+
+ cptr= RNA_property_pointer_get(ptr, prop);
+ if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping))
+ return;
+
+ cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr= *ptr;
+ cb->prop= prop;
+
+ curvemap_buttons_layout(layout, &cptr, type, levels, cb);
+
+ MEM_freeN(cb);
}
/********************* TriColor (ThemeWireColorSet) Template ************************/
void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname)
{
+ PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
uiLayout *row;
- PropertyRNA *prop;
PointerRNA csPtr;
-
- if (!ptr->data)
- return;
-
- prop= RNA_struct_find_property(ptr, propname);
+
if (!prop) {
printf("uiTemplateTriColorSet: property not found: %s\n", propname);
return;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 8940f560677..07d0d1a85c5 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1254,7 +1254,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
pt->draw_header(C, panel);
- uiBlockLayoutResolve(C, block, &xco, &yco);
+ uiBlockLayoutResolve(block, &xco, &yco);
panel->labelofs= xco - triangle;
panel->layout= NULL;
}
@@ -1265,7 +1265,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
pt->draw(C, panel);
- uiBlockLayoutResolve(C, block, &xco, &yco);
+ uiBlockLayoutResolve(block, &xco, &yco);
panel->layout= NULL;
yco -= 2*style->panelspace;
@@ -1411,7 +1411,7 @@ void ED_region_header(const bContext *C, ARegion *ar)
maxco= xco;
}
- uiBlockLayoutResolve(C, block, &xco, &yco);
+ uiBlockLayoutResolve(block, &xco, &yco);
/* for view2d */
if(xco > maxco)
diff --git a/source/blender/editors/space_action/action_header.c b/source/blender/editors/space_action/action_header.c
index 57546d440b0..4cb02f3f233 100644
--- a/source/blender/editors/space_action/action_header.c
+++ b/source/blender/editors/space_action/action_header.c
@@ -362,7 +362,7 @@ void action_header_buttons(const bContext *C, ARegion *ar)
layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, 20+3, 20, 1, U.uistyles.first);
uiTemplateID(layout, (bContext*)C, &ptr, "action", "ACT_OT_new", NULL, NULL);
- uiBlockLayoutResolve(C, block, &xco, NULL);
+ uiBlockLayoutResolve(block, &xco, NULL);
xco += 8;
}
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 16bc988a54b..60994757b59 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -271,14 +271,12 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot.");
func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
- parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ api_ui_item_rna_common(func);
RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display.");
- RNA_def_boolean(func, "compact", 0, "", "Use more compact curve mapping.");
+ RNA_def_boolean(func, "levels", 0, "", "Show black/white levels.");
func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
- parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer.");
- RNA_def_property_flag(parm, PROP_REQUIRED);
+ api_ui_item_rna_common(func);
RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
func= RNA_def_function(srna, "template_layers", "uiTemplateLayers");