2.5: UI, tweaks to curve mapping template to fit better
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Aug 2009 20:48:38 +0000 (20:48 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Aug 2009 20:48:38 +0000 (20:48 +0000)
in 3d view panel, and resize properly.

source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_utils.c
source/blender/makesrna/intern/rna_ui_api.c

index 70fbad3216daed773a0f51709ce32531fbfbcaeb..4d6dfe993a6cee17a957190c1472a7a6075de74f 100644 (file)
@@ -545,6 +545,7 @@ void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v);
 
 struct rctf;
 void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
+void curvemap_layout(uiLayout *layout, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
 void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small);
 
 
@@ -630,7 +631,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
 void uiTemplatePreview(uiLayout *layout, struct ID *id, struct ID *parent);
 void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand);
-void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type);
+void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type, int compact);
 void uiTemplateTriColorSet(uiLayout *layout, struct PointerRNA *ptr, char *propname);
 void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
 void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
index 0b5edf54a25e4c78dddebaf2196b4efb0c3bd4c9..0217e9646faab58bc74aef553913397e4438fb7d 100644 (file)
@@ -1182,17 +1182,21 @@ void uiTemplateColorRamp(uiLayout *layout, ColorBand *coba, int expand)
 
 #include "DNA_color_types.h"
 
-void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type)
+void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type, int compact)
 {
-       uiBlock *block;
        rctf rect;
 
        if(cumap) {
-               rect.xmin= 0; rect.xmax= 200;
-               rect.ymin= 0; rect.ymax= 190;
+               if(compact) {
+                       rect.xmin= 0; rect.xmax= 150;
+                       rect.ymin= 0; rect.ymax= 140;
+               }
+               else {
+                       rect.xmin= 0; rect.xmax= 200;
+                       rect.ymin= 0; rect.ymax= 190;
+               }
                
-               block= uiLayoutFreeBlock(layout);
-               curvemap_buttons(block, cumap, type, 0, 0, &rect);
+               curvemap_layout(layout, cumap, type, 0, 0, &rect);
        }
 }
 
index 8ff9e8574075dcee0f9fba138b6a8546d8b7bfe4..f8578be1f332466fedce6a8118018f96523a8ef5 100644 (file)
@@ -945,6 +945,72 @@ void curvemap_buttons(uiBlock *block, CurveMapping *cumap, char labeltype, short
                          cumap, 0.0f, 1.0f, 0, 0, "");
 }
 
+/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
+void curvemap_layout(uiLayout *layout, CurveMapping *cumap, char labeltype, short event, short redraw, rctf *rect)
+{
+       uiLayout *row;
+       uiBlock *block;
+       uiBut *bt;
+       float dx, fy= rect->ymax-18.0f;
+       int icon;
+       
+       block= uiLayoutGetBlock(layout);
+       
+       /* curve choice options + tools/settings, 8 icons + spacer */
+       dx= UI_UNIT_X;
+       
+       row= uiLayoutRow(layout, 0);
+       uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
+
+       if(labeltype=='v') {    /* vector */
+               row= uiLayoutRow(layout, 1);
+
+               if(cumap->cm[0].curve)
+                       uiDefButI(block, ROW, redraw, "X", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+               if(cumap->cm[1].curve)
+                       uiDefButI(block, ROW, redraw, "Y", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+               if(cumap->cm[2].curve)
+                       uiDefButI(block, ROW, redraw, "Z", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+       }
+       else if(labeltype=='c') { /* color */
+               row= uiLayoutRow(layout, 1);
+
+               if(cumap->cm[3].curve)
+                       uiDefButI(block, ROW, redraw, "C", 0, 0, dx, 16, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
+               if(cumap->cm[0].curve)
+                       uiDefButI(block, ROW, redraw, "R", 0, 0, dx, 16, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+               if(cumap->cm[1].curve)
+                       uiDefButI(block, ROW, redraw, "G", 0, 0, dx, 16, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+               if(cumap->cm[2].curve)
+                       uiDefButI(block, ROW, redraw, "B", 0, 0, dx, 16, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+       }
+
+       row= uiLayoutRow(row, 1);
+
+       uiBlockSetEmboss(block, UI_EMBOSSN);
+       bt= uiDefIconBut(block, BUT, redraw, 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, redraw, 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, event, ICON_MODIFIER, 0, 0, dx, 18, "Tools");
+       
+       if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT;
+       bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, event, icon, 0, 0, dx, 18, "Clipping Options");
+       
+       bt= uiDefIconBut(block, BUT, event, ICON_X, 0, 0, dx, 18, NULL, 0.0, 0.0, 0.0, 0.0, "Delete points");
+       uiButSetFunc(bt, curvemap_buttons_delete, cumap, NULL);
+       
+       uiBlockSetEmboss(block, UI_EMBOSS);
+       
+       row= uiLayoutRow(layout, 0);
+       uiDefBut(block, BUT_CURVE, event, "", 
+                         rect->xmin, rect->ymin, rect->xmax-rect->xmin, fy-rect->ymin, 
+                         cumap, 0.0f, 1.0f, 0, 0, "");
+}
+
+
 #define B_BANDCOL 1
 
 static int vergcband(const void *a1, const void *a2)
index 67ade9998ed18647af79eb9300950187b4a81a1e..e788250e4071e94a890102dd7ddc0d9e1ebad773 100644 (file)
@@ -248,6 +248,7 @@ void RNA_api_ui_layout(StructRNA *srna)
        parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer.");
        RNA_def_property_flag(parm, PROP_REQUIRED);
        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.");
 
        func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
        parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer.");