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:
authorJoshua Leung <aligorith@gmail.com>2009-07-03 05:57:38 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-03 05:57:38 +0400
commit5e92ddece3a7367ca7687e762226d639389e5517 (patch)
treeba8437a82874057138ff5e9f07b446fa6d2ff044 /source/blender/editors
parent28d371d1178642e17f5dfc300f1500a132ce7149 (diff)
parentfb5f9273eba4b30e1aa0573388367592b18bdbba (diff)
NLA SoC: Merge from 2.5
21301 to 21329
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/CMakeLists.txt4
-rw-r--r--source/blender/editors/animation/anim_draw.c2
-rw-r--r--source/blender/editors/animation/anim_markers.c2
-rw-r--r--source/blender/editors/include/ED_fluidsim.h2
-rw-r--r--source/blender/editors/include/ED_markers.h2
-rw-r--r--source/blender/editors/include/ED_object.h3
-rw-r--r--source/blender/editors/include/ED_physics.h (renamed from source/blender/editors/include/ED_pointcache.h)2
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/include/UI_view2d.h6
-rw-r--r--source/blender/editors/interface/interface_intern.h1
-rw-r--r--source/blender/editors/interface/interface_layout.c49
-rw-r--r--source/blender/editors/interface/interface_panel.c2
-rw-r--r--source/blender/editors/interface/interface_templates.c238
-rw-r--r--source/blender/editors/interface/interface_widgets.c103
-rw-r--r--source/blender/editors/interface/view2d.c307
-rw-r--r--source/blender/editors/interface/view2d_ops.c15
-rw-r--r--source/blender/editors/object/object_intern.h6
-rw-r--r--source/blender/editors/object/object_modifier.c292
-rw-r--r--source/blender/editors/object/object_ops.c6
-rw-r--r--source/blender/editors/physics/ed_fluidsim.c113
-rw-r--r--source/blender/editors/physics/ed_pointcache.c2
-rw-r--r--source/blender/editors/screen/area.c1
-rw-r--r--source/blender/editors/space_api/spacetypes.c9
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c15
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c5
-rw-r--r--source/blender/editors/space_graph/graph_intern.h2
-rw-r--r--source/blender/editors/space_graph/space_graph.c4
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c70
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c98
31 files changed, 802 insertions, 568 deletions
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index 914fdaa4bc6..b7a868ad537 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -64,6 +64,10 @@ IF(WITH_FFMPEG)
ADD_DEFINITIONS(-DWITH_FFMPEG)
ENDIF(WITH_FFMPEG)
+IF(NOT WITH_ELBEEM)
+ ADD_DEFINITIONS(-DDISABLE_ELBEEM)
+ENDIF(NOT WITH_ELBEEM)
+
IF(WITH_PYTHON)
SET(INC ${INC} ${PYTHON_INC})
ELSE(WITH_PYTHON)
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index f7702379645..6c39e670f5c 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -167,7 +167,7 @@ void ANIM_draw_cfra (const bContext *C, View2D *v2d, short flag)
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
- vec[1]= v2d->cur.ymin;
+ vec[1]= v2d->cur.ymin-500.0f; /* XXX arbitrary... want it go to bottom */
glVertex2fv(vec);
vec[1]= v2d->cur.ymax;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 2abec6b831c..d6543b41f47 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -976,7 +976,7 @@ static void MARKER_OT_delete(wmOperatorType *ot)
/* ************************** registration **********************************/
/* called in screen_ops.c:ED_operatortypes_screen() */
-void ED_marker_operatortypes(void)
+void ED_operatortypes_marker(void)
{
WM_operatortype_append(MARKER_OT_add);
WM_operatortype_append(MARKER_OT_move);
diff --git a/source/blender/editors/include/ED_fluidsim.h b/source/blender/editors/include/ED_fluidsim.h
index 586f16f42aa..2859ec897bf 100644
--- a/source/blender/editors/include/ED_fluidsim.h
+++ b/source/blender/editors/include/ED_fluidsim.h
@@ -46,6 +46,8 @@ void fluidsimSettingsFree(struct FluidsimSettings* sb);
/* duplicate internal data */
struct FluidsimSettings* fluidsimSettingsCopy(struct FluidsimSettings* sb);
+/* memory estimate */
+void fluidsimEstimateMemory(struct Object *ob, struct FluidsimSettings *fs, char *value);
#endif /* ED_FLUIDSIM_H */
diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h
index 048bbbd7463..4b7a2954206 100644
--- a/source/blender/editors/include/ED_markers.h
+++ b/source/blender/editors/include/ED_markers.h
@@ -54,7 +54,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short sel);
/* Operators ------------------------------ */
/* called in screen_ops.c:ED_operatortypes_screen() */
-void ED_marker_operatortypes(void);
+void ED_operatortypes_marker(void);
/* called in screen_ops.c:ED_keymap_screen() */
void ED_marker_keymap(struct wmWindowManager *wm);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index e4e4b1d0486..9dcdc30a691 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -103,7 +103,8 @@ void key_to_curve(struct KeyBlock *kb, struct Curve *cu, struct ListBase *nurb)
void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb);
/* object_modifier.c */
-int ED_object_modifier_delete(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
+int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, int type);
+int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
int ED_object_modifier_convert(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
diff --git a/source/blender/editors/include/ED_pointcache.h b/source/blender/editors/include/ED_physics.h
index dc50e274fa9..b04bfb992dc 100644
--- a/source/blender/editors/include/ED_pointcache.h
+++ b/source/blender/editors/include/ED_physics.h
@@ -31,7 +31,9 @@
#define ED_PHYSICS_H
/* operators */
+
void ED_operatortypes_pointcache(void);
+void ED_operatortypes_fluid(void);
//void ED_keymap_pointcache(struct wmWindowManager *wm);
#endif /* ED_PHYSICS_H */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index cc8b936b04f..c0612c3524e 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -635,6 +635,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct ID
void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle);
void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle);
void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value);
+void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value);
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname);
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 50283113b62..84148047795 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -99,9 +99,9 @@ enum {
/* ------ Defines for Scrollers ----- */
-/* scroller thickness */
-#define V2D_SCROLL_HEIGHT 16
-#define V2D_SCROLL_WIDTH 16
+/* scroller area */
+#define V2D_SCROLL_HEIGHT 17
+#define V2D_SCROLL_WIDTH 17
/* half the size (in pixels) of scroller 'handles' */
#define V2D_SCROLLER_HANDLE_SIZE 5
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 1b16155c7e6..b2ba6fb38a8 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -420,6 +420,7 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y
void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect);
void ui_draw_link_bezier(rcti *rect);
+void widget_scroll_draw(struct uiWidgetColors *wcol, rcti *rect, rcti *slider, int state);
extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect);
/* theme color init */
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index f9816235b88..2e30c5f1cb7 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -615,14 +615,13 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch
/* for getting the enum */
PropertyRNA *prop;
const EnumPropertyItem *item;
- int totitem;
int value;
WM_operator_properties_create(&ptr, opname);
/* enum lookup */
if((prop= RNA_struct_find_property(&ptr, propname))) {
- RNA_property_enum_items(&ptr, prop, &item, &totitem);
+ RNA_property_enum_items(&ptr, prop, &item, NULL);
if(RNA_enum_value_from_id(item, value_str, &value)==0) {
printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
return;
@@ -695,14 +694,17 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
PropertySubType subtype;
int len, w, h;
- w= ui_text_icon_width(layout, name, icon);
- h= UI_UNIT_Y;
-
/* arbitrary extended width by type */
type= RNA_property_type(prop);
subtype= RNA_property_subtype(prop);
len= RNA_property_array_length(prop);
+ if(type == PROP_STRING && strcmp(name, "") == 0)
+ name= "non-empty";
+
+ w= ui_text_icon_width(layout, name, icon);
+ h= UI_UNIT_Y;
+
/* increase height for arrays */
if(index == RNA_NO_INDEX && len > 0) {
if(strcmp(name, "") == 0 && icon == 0)
@@ -827,15 +829,48 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
prop= RNA_struct_find_property(ptr, propname);
- if(!prop) {
+ if(!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
- printf("uiItemEnumR: property not found: %s\n", propname);
+ printf("uiItemEnumR: enum property not found: %s\n", propname);
return;
}
uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0);
}
+void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value)
+{
+ PropertyRNA *prop;
+ const EnumPropertyItem *item;
+ int ivalue, a;
+
+ 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);
+ return;
+ }
+
+ RNA_property_enum_items(ptr, prop, &item, NULL);
+
+ if(!RNA_enum_value_from_id(item, value, &ivalue)) {
+ ui_item_disabled(layout, propname);
+ printf("uiItemEnumR: enum property value not found: %s\n", value);
+ return;
+ }
+
+ for(a=0; item[a].identifier; a++) {
+ if(item[a].value == ivalue) {
+ uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, 0, 0);
+ break;
+ }
+ }
+}
+
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
{
PropertyRNA *prop;
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index a20884a61a3..319e69a40e4 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -106,7 +106,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
}
else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
return BUT_VERTICAL;
- else if(ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS))
+ else if(ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
return BUT_VERTICAL;
return 0;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 8f1d57b28ed..d9bc2d4d426 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -320,134 +320,6 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname
#include "ED_object.h"
-static void modifiers_del(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_delete(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Delete modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_activate(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
-
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-}
-
-static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_move_up(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Move modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_move_down(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Move modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= obv;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_convert(&reports, scene, obv, mdv)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Convert particles to mesh object(s).");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= obv;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_apply(&reports, scene, obv, mdv)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
- ED_undo_push(C, "Apply modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
-static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
-{
- Scene *scene= CTX_data_scene(C);
- Object *ob= ob_v;
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_STORE);
-
- if(ED_object_modifier_copy(&reports, ob_v, md_v)) {
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
- ED_undo_push(C, "Copy modifier");
- }
- else
- uiPupMenuReports(C, &reports);
-
- BKE_reports_clear(&reports);
-}
-
static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
{
Scene *scene= CTX_data_scene(C);
@@ -490,15 +362,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
static int modifier_can_delete(ModifierData *md)
{
- // deletion over the deflection panel
// fluid particle modifier can't be deleted here
-
- if(md->type==eModifierType_Fluidsim)
- return 0;
- if(md->type==eModifierType_Collision)
- return 0;
- if(md->type==eModifierType_Surface)
- return 0;
if(md->type == eModifierType_ParticleSystem)
if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
return 0;
@@ -512,12 +376,12 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
PointerRNA ptr;
uiBut *but;
uiBlock *block;
- uiLayout *column, *row, *subrow, *result= NULL;
- int isVirtual = md->mode&eModifierMode_Virtual;
+ uiLayout *column, *row, *result= NULL;
+ int isVirtual = md->mode & eModifierMode_Virtual;
// XXX short color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
- short width = 295, buttonWidth = width-120-10;
char str[128];
+ /* create RNA pointer */
RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
column= uiLayoutColumn(layout, 1);
@@ -528,57 +392,57 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
/* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
row= uiLayoutRow(uiLayoutBox(column), 0);
- block= uiLayoutGetBlock(row);
+ uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
- subrow= uiLayoutRow(row, 0);
- uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
+ block= uiLayoutGetBlock(row);
//uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0,
- // (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, "");
+ // (!isVirtual && (md->mode & eModifierMode_Expanded))?3:15, 20, "");
/* XXX uiBlockSetCol(block, TH_AUTO); */
/* open/close icon */
- if (!isVirtual) {
+ if(!isVirtual) {
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
}
/* modifier-type icon */
- uiDefIconBut(block, BUT, 0, RNA_struct_ui_icon(ptr.type), 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Current Modifier Type");
+ uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
uiBlockSetEmboss(block, UI_EMBOSS);
- if (isVirtual) {
+ if(isVirtual) {
+ /* virtual modifier */
sprintf(str, "%s parent deform", md->name);
uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name");
but = uiDefBut(block, BUT, 0, "Make Real", 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
uiButSetFunc(but, modifiers_convertToReal, ob, md);
- } else {
+ }
+ else {
+ /* real modifier */
uiBlockBeginAlign(block);
- uiDefBut(block, TEX, 0, "", 0, 0, buttonWidth-40, UI_UNIT_Y, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name");
+ uiItemR(row, "", 0, &ptr, "name", 0, 0, 0);
/* Softbody not allowed in this situation, enforce! */
- if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
- uiDefIconButBitI(block, TOG, eModifierMode_Render, 0, ICON_SCENE, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
- but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, 0, ICON_VIEW3D, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
- uiButSetFunc(but, modifiers_activate, ob, md);
- if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
- but= uiDefIconButBitI(block, TOG, eModifierMode_Editmode, 0, ICON_EDITMODE_HLT, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
- uiButSetFunc(but, modifiers_activate, ob, md);
- }
+ if(((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
+ uiItemR(row, "", ICON_SCENE, &ptr, "render", 0, 0, 0);
+ uiItemR(row, "", ICON_VIEW3D, &ptr, "realtime", 0, 0, 0);
+
+ if(mti->flags & eModifierTypeFlag_SupportsEditmode)
+ uiItemR(row, "", ICON_VIEW3D, &ptr, "editmode", 0, 0, 0);
}
uiBlockEndAlign(block);
/* XXX uiBlockSetEmboss(block, UI_EMBOSSR); */
- if (ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
+ if(ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
int icon; //, color;
- if (index==cageIndex) {
+ if(index==cageIndex) {
// XXX color = TH_BUT_SETTING;
icon = VICON_EDITMODE_HLT;
- } else if (index<cageIndex) {
+ } else if(index<cageIndex) {
// XXX color = TH_BUT_NEUTRAL;
icon = VICON_EDITMODE_DEHLT;
} else {
@@ -592,67 +456,55 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
}
}
- subrow= uiLayoutRow(row, 0);
- uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
-
+ /* up/down/delete */
if(!isVirtual) {
/* XXX uiBlockSetCol(block, TH_BUT_ACTION); */
-
- but = uiDefIconBut(block, BUT, 0, VICON_MOVE_UP, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
- uiButSetFunc(but, modifiers_moveUp, ob, md);
-
- but = uiDefIconBut(block, BUT, 0, VICON_MOVE_DOWN, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
- uiButSetFunc(but, modifiers_moveDown, ob, md);
+ uiItemO(row, "", VICON_MOVE_UP, "OBJECT_OT_modifier_move_up");
+ uiItemO(row, "", VICON_MOVE_DOWN, "OBJECT_OT_modifier_move_down");
uiBlockSetEmboss(block, UI_EMBOSSN);
-
- if(modifier_can_delete(md)) {
- but = uiDefIconBut(block, BUT, 0, VICON_X, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
- uiButSetFunc(but, modifiers_del, ob, md);
- }
+
+ if(modifier_can_delete(md))
+ uiItemO(row, "", VICON_X, "OBJECT_OT_modifier_remove");
+
/* XXX uiBlockSetCol(block, TH_AUTO); */
}
uiBlockSetEmboss(block, UI_EMBOSS);
- if(!isVirtual && (md->mode&eModifierMode_Expanded)) {
+ if(!isVirtual && (md->mode & eModifierMode_Expanded)) {
+ /* apply/convert/copy */
uiLayout *box;
box= uiLayoutBox(column);
row= uiLayoutRow(box, 1);
- if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
- uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */
+ if(!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
+ /* only here obdata, the rest of modifiers is ob level */
+ uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if (md->type==eModifierType_ParticleSystem) {
+ if(md->type==eModifierType_ParticleSystem) {
ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys;
- if(!(G.f & G_PARTICLEEDIT)) {
- if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) {
- but = uiDefBut(block, BUT, 0, "Convert", 0,0,60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
- uiButSetFunc(but, modifiers_convertParticles, ob, md);
- }
- }
- }
- else{
- but = uiDefBut(block, BUT, 0, "Apply", 0,0,60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
- uiButSetFunc(but, modifiers_applyModifier, ob, md);
+ if(!(G.f & G_PARTICLEEDIT))
+ if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache)
+ uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert");
}
+ else
+ uiItemO(row, "Apply", 0, "OBJECT_OT_modifier_apply");
uiBlockClearButLock(block);
uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
- if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) {
- but = uiDefBut(block, BUT, 0, "Copy", 0,0,60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
- uiButSetFunc(but, modifiers_copyModifier, ob, md);
- }
+ if(!ELEM4(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth))
+ uiItemO(row, "Copy", 0, "OBJECT_OT_modifier_copy");
}
result= uiLayoutColumn(box, 0);
block= uiLayoutFreeBlock(box);
}
- if (md->error) {
+ if(md->error) {
row = uiLayoutRow(uiLayoutBox(column), 0);
/* XXX uiBlockSetCol(block, color); */
@@ -694,7 +546,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr)
for(i=0; vmd; i++, vmd=vmd->next) {
if(md == vmd)
return draw_modifier(layout, ob, md, i, cageIndex, lastCageIndex);
- else if(vmd->mode&eModifierMode_Virtual)
+ else if(vmd->mode & eModifierMode_Virtual)
i--;
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ed2d00cb00d..751a09ede49 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -293,13 +293,15 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
float maxyi= maxy - 1.0f;
float facxi= 1.0f/(maxxi-minxi); /* for uv */
float facyi= 1.0f/(maxyi-minyi);
- int a, tot= 0;
+ int a, tot= 0, minsize;
- if(2.0f*rad > rect->ymax-rect->ymin)
- rad= 0.5f*(rect->ymax-rect->ymin);
+ minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin);
+
+ if(2.0f*rad > minsize)
+ rad= 0.5f*minsize;
- if(2.0f*(radi+1.0f) > rect->ymax-rect->ymin)
- radi= 0.5f*(rect->ymax-rect->ymin) - 1.0f;
+ if(2.0f*(radi+1.0f) > minsize)
+ radi= 0.5f*minsize - 1.0f;
/* mult */
for(a=0; a<9; a++) {
@@ -525,7 +527,7 @@ static void shadecolors4(char *coltop, char *coldown, char *color, short shadeto
coldown[0]= CLAMPIS(color[0]+shadedown, 0, 255);
coldown[1]= CLAMPIS(color[1]+shadedown, 0, 255);
coldown[2]= CLAMPIS(color[2]+shadedown, 0, 255);
- coldown[3]= color[3];
+ coldown[3]= color[3];
}
static void round_box_shade_col4(char *col1, char *col2, float fac)
@@ -1104,16 +1106,16 @@ static struct uiWidgetColors wcol_toggle= {
};
static struct uiWidgetColors wcol_scroll= {
- {25, 25, 25, 255},
+ {50, 50, 50, 180},
+ {80, 80, 80, 180},
+ {100, 100, 100, 180},
{180, 180, 180, 255},
- {153, 153, 153, 255},
- {90, 90, 90, 255},
{0, 0, 0, 255},
{255, 255, 255, 255},
1,
- 0, -20
+ 10, -20
};
/* free wcol struct to play with */
@@ -1204,6 +1206,10 @@ static void widget_state_label(uiWidgetType *wt, int state)
}
+static void widget_state_nothing(uiWidgetType *wt, int state)
+{
+ wt->wcol= *(wt->wcol_theme);
+}
/* special case, button that calls pulldown */
static void widget_state_pulldown(uiWidgetType *wt, int state)
@@ -1632,44 +1638,64 @@ void ui_draw_link_bezier(rcti *rect)
}
}
-static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+/* function in use for buttons and for view2d sliders */
+void widget_scroll_draw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int state)
{
uiWidgetBase wtb;
- rcti rect1;
- double value;
- char inner[3];
- float fac, size, rad;
+ float rad;
int horizontal;
+ widget_init(&wtb);
+
/* determine horizontal/vertical */
horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
-
+
if(horizontal)
rad= 0.5f*(rect->ymax - rect->ymin);
else
rad= 0.5f*(rect->xmax - rect->xmin);
-
- widget_init(&wtb);
+
wtb.shadedir= (horizontal)? 1: 0;
-
+
/* draw back part, colors swapped and shading inverted */
- VECCOPY(inner, wcol->inner);
- VECCOPY(wcol->inner, wcol->item);
if(horizontal)
SWAP(short, wcol->shadetop, wcol->shadedown);
- if(state & UI_SELECT)
- SWAP(short, wcol->shadetop, wcol->shadedown);
- round_box_edges(&wtb, roundboxalign, rect, rad); /* XXX vertical gradient is wrong */
+ round_box_edges(&wtb, 15, rect, rad);
widgetbase_draw(&wtb, wcol);
-
- VECCOPY(wcol->inner, inner);
- if(horizontal)
- SWAP(short, wcol->shadetop, wcol->shadedown);
- if(state & UI_SELECT)
- SWAP(short, wcol->shadetop, wcol->shadedown);
- /* front part */
+ /* slider */
+ if(slider->xmax-slider->xmin<2 || slider->ymax-slider->ymin<2);
+ else {
+
+ SWAP(short, wcol->shadetop, wcol->shadedown);
+
+ QUATCOPY(wcol->inner, wcol->item);
+
+ if(wcol->shadetop>wcol->shadedown)
+ wcol->shadetop+= 20; /* XXX violates themes... */
+ else wcol->shadedown+= 20;
+
+ if(state & UI_SELECT)
+ SWAP(short, wcol->shadetop, wcol->shadedown);
+
+ /* draw */
+ wtb.emboss= 0; /* only emboss once */
+
+ round_box_edges(&wtb, 15, slider, rad);
+ widgetbase_draw(&wtb, wcol);
+
+ }
+}
+
+static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+{
+ rcti rect1;
+ double value;
+ float fac, size;
+ int horizontal;
+
+ /* calculate slider part */
value= ui_get_but_val(but);
size= (but->softmax + but->a1 - but->softmin);
@@ -1678,6 +1704,9 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
/* position */
rect1= *rect;
+ /* determine horizontal/vertical */
+ horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
+
if(horizontal) {
fac= (rect->xmax - rect->xmin)/(size);
rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin));
@@ -1689,17 +1718,8 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin));
}
- /* draw */
- wtb.emboss= 0; /* only emboss once */
-
- if(!horizontal)
- SWAP(short, wcol->shadetop, wcol->shadedown);
+ widget_scroll_draw(wcol, rect, &rect1, state);
- round_box_edges(&wtb, roundboxalign, &rect1, rad); /* XXX vertical gradient is wrong */
- widgetbase_draw(&wtb, wcol);
-
- if(!horizontal)
- SWAP(short, wcol->shadetop, wcol->shadedown);
}
static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
@@ -2101,6 +2121,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
case UI_WTYPE_SCROLL:
wt.wcol_theme= &btheme->tui.wcol_scroll;
+ wt.state= widget_state_nothing;
wt.custom= widget_scroll;
break;
}
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index c32c8c817fb..e54f22b5ae6 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -34,6 +34,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
#include "DNA_view2d_types.h"
#include "BLI_blenlib.h"
@@ -918,7 +919,14 @@ void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis)
/* Restore view matrices after drawing */
void UI_view2d_view_restore(const bContext *C)
{
- ED_region_pixelspace(CTX_wm_region(C));
+ ARegion *ar= CTX_wm_region(C);
+ int width= ar->winrct.xmax-ar->winrct.xmin+1;
+ int height= ar->winrct.ymax-ar->winrct.ymin+1;
+
+ wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
+ wmLoadIdentity();
+
+ // ED_region_pixelspace(CTX_wm_region(C));
}
/* *********************************************************************** */
@@ -1215,7 +1223,10 @@ void UI_view2d_grid_free(View2DGrid *grid)
* WARNING: the start of this struct must not change, as view2d_ops.c uses this too.
* For now, we don't need to have a separate (internal) header for structs like this...
*/
-struct View2DScrollers {
+struct View2DScrollers {
+ rcti hor, vert; /* exact size of slider backdrop */
+ int horfull, vertfull; /* set if sliders are full, we don't draw them */
+
/* focus bubbles */
int vert_min, vert_max; /* vertical scrollbar */
int hor_min, hor_max; /* horizontal scrollbar */
@@ -1231,14 +1242,33 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
{
View2DScrollers *scrollers;
rcti vert, hor;
- float fac, totsize, scrollsize;
+ float fac1, fac2, totsize, scrollsize;
int scroll= view2d_scroll_mapped(v2d->scroll);
+ /* scrollers is allocated here... */
+ scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
+
vert= v2d->vert;
hor= v2d->hor;
- /* scrollers is allocated here... */
- scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
+ /* slider rects smaller than region */
+ hor.xmin+=4;
+ hor.xmax-=4;
+ if (scroll & V2D_SCROLL_BOTTOM)
+ hor.ymin+=4;
+ else
+ hor.ymax-=4;
+
+ if (scroll & V2D_SCROLL_LEFT)
+ vert.xmin+=4;
+ else
+ vert.xmax-=4;
+ vert.ymin+=4;
+ vert.ymax-=4;
+
+ /* store in scrollers, used for drawing */
+ scrollers->vert= vert;
+ scrollers->hor= hor;
/* scroller 'buttons':
* - These should always remain within the visible region of the scrollbar
@@ -1251,14 +1281,23 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
totsize= v2d->tot.xmax - v2d->tot.xmin;
scrollsize= (float)(hor.xmax - hor.xmin);
- fac= (v2d->cur.xmin - v2d->tot.xmin) / totsize;
- scrollers->hor_min= (int)(hor.xmin + (fac * scrollsize));
+ fac1= (v2d->cur.xmin - v2d->tot.xmin) / totsize;
+ if(fac1<=0.0f)
+ scrollers->hor_min= hor.xmin;
+ else
+ scrollers->hor_min= (int)(hor.xmin + (fac1 * scrollsize));
- fac= (v2d->cur.xmax - v2d->tot.xmin) / totsize;
- scrollers->hor_max= (int)(hor.xmin + (fac * scrollsize));
+ fac2= (v2d->cur.xmax - v2d->tot.xmin) / totsize;
+ if(fac2>=1.0f)
+ scrollers->hor_max= hor.xmax;
+ else
+ scrollers->hor_max= (int)(hor.xmin + (fac2 * scrollsize));
if (scrollers->hor_min > scrollers->hor_max)
scrollers->hor_min= scrollers->hor_max;
+
+ if(fac1 <= 0.0f && fac2 >= 1.0f)
+ scrollers->horfull= 1;
}
/* vertical scrollers */
@@ -1267,14 +1306,23 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
totsize= v2d->tot.ymax - v2d->tot.ymin;
scrollsize= (float)(vert.ymax - vert.ymin);
- fac= (v2d->cur.ymin- v2d->tot.ymin) / totsize;
- scrollers->vert_min= (int)(vert.ymin + (fac * scrollsize));
+ fac1= (v2d->cur.ymin- v2d->tot.ymin) / totsize;
+ if(fac1<=0.0f)
+ scrollers->vert_min= vert.ymin;
+ else
+ scrollers->vert_min= (int)(vert.ymin + (fac1 * scrollsize));
- fac= (v2d->cur.ymax - v2d->tot.ymin) / totsize;
- scrollers->vert_max= (int)(vert.ymin + (fac * scrollsize));
+ fac2= (v2d->cur.ymax - v2d->tot.ymin) / totsize;
+ if(fac2>=1.0f)
+ scrollers->vert_max= vert.ymax;
+ else
+ scrollers->vert_max= (int)(vert.ymin + (fac2 * scrollsize));
if (scrollers->vert_min > scrollers->vert_max)
scrollers->vert_min= scrollers->vert_max;
+
+ if(fac1 <= 0.0f && fac2 >= 1.0f)
+ scrollers->vertfull= 1;
}
/* grid markings on scrollbars */
@@ -1304,7 +1352,7 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f
* rotation values (hence 'degrees') are divided by 10 to
* be able to show the curves at the same time
*/
- if ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME) {
+ if (ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME)) {
power += 1;
val *= 10;
}
@@ -1410,81 +1458,27 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f
void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs)
{
Scene *scene= CTX_data_scene(C);
- const short darker= -50, dark= -10, light= 20, lighter= 50;
- rcti vert, hor, corner;
+ rcti vert, hor;
int scroll= view2d_scroll_mapped(v2d->scroll);
/* make copies of rects for less typing */
- vert= v2d->vert;
- hor= v2d->hor;
+ vert= vs->vert;
+ hor= vs->hor;
/* horizontal scrollbar */
if (scroll & V2D_SCROLL_HORIZONTAL) {
- /* scroller backdrop */
- UI_ThemeColorShade(TH_SHADE1, light);
- glRecti(hor.xmin, hor.ymin, hor.xmax, hor.ymax);
-
- /* scroller 'button'
- * - if view is zoomable in x, draw handles too
- * - handles are drawn darker
- * - no slider when view is > total for non-zoomable views
- * (otherwise, zoomable ones tend to flicker)
- */
- if ( (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) ||
- ((v2d->tot.xmax - v2d->tot.xmin) > (v2d->cur.xmax - v2d->cur.xmin)) )
- {
- if (v2d->keepzoom & V2D_LOCKZOOM_X) {
- /* draw base bar as rounded shape */
- UI_ThemeColorShade(TH_SHADE1, dark);
- uiSetRoundBox(15);
-
- /* check that box is large enough for round drawing */
- if ((vs->hor_max - vs->hor_min) < (V2D_SCROLLCAP_RAD * 2)) {
- /* Rounded box still gets drawn at the minimum size limit
- * This doesn't represent extreme scaling well, but looks nicer...
- */
- float mid= 0.5f * (vs->hor_max + vs->hor_min);
-
- gl_round_box_shade(GL_POLYGON,
- mid-V2D_SCROLLCAP_RAD, (float)hor.ymin+2,
- mid+V2D_SCROLLCAP_RAD, (float)hor.ymax-2,
- V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
- }
- else {
- /* draw rounded box as per normal */
- gl_round_box_shade(GL_POLYGON,
- (float)vs->hor_min, (float)hor.ymin+2,
- (float)vs->hor_max, (float)hor.ymax-2,
- V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
- }
- }
- else {
- /* base bar drawn as shaded rect */
- UI_ThemeColorShade(TH_SHADE1, dark);
- uiSetRoundBox(0);
- gl_round_box_shade(GL_POLYGON,
- (float)vs->hor_min, (float)hor.ymin+2,
- (float)vs->hor_max, (float)hor.ymax-2,
- V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-
- /* 'minimum' handle */
- uiSetRoundBox(9);
- UI_ThemeColorShade(TH_SHADE1, darker);
-
- gl_round_box_shade(GL_POLYGON,
- (float)vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2,
- (float)vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2,
- V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
-
- /* maximum handle */
- uiSetRoundBox(6);
- UI_ThemeColorShade(TH_SHADE1, darker);
-
- gl_round_box_shade(GL_POLYGON,
- (float)vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2,
- (float)vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2,
- V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
- }
+
+ if(vs->horfull==0) {
+ bTheme *btheme= U.themes.first;
+ uiWidgetColors wcol= btheme->tui.wcol_scroll;
+ rcti slider;
+
+ slider.xmin= vs->hor_min;
+ slider.xmax= vs->hor_max;
+ slider.ymin= hor.ymin;
+ slider.ymax= hor.ymax;
+
+ widget_scroll_draw(&wcol, &hor, &slider, (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE)?UI_SELECT:0);
}
/* scale indicators */
@@ -1519,19 +1513,26 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* draw numbers in the appropriate range */
if (dfac > 0.0f) {
- for (; fac < hor.xmax; fac+=dfac, val+=grid->dx) {
+ float h= 2.0f+(float)(hor.ymin);
+
+ for (; fac < hor.xmax-10; fac+=dfac, val+=grid->dx) {
+
+ /* make prints look nicer for scrollers */
+ if(fac < hor.xmin+10)
+ continue;
+
switch (vs->xunits) {
case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
- scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMES, 'h');
+ scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h');
break;
case V2D_UNIT_FRAMESCALE: /* frames (not always as whole numbers) */
- scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h');
+ scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h');
break;
case V2D_UNIT_SECONDS: /* seconds */
fac2= val/(float)FPS;
- scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
+ scroll_printstr(vs, scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
break;
case V2D_UNIT_SECONDSSEQ: /* seconds with special calculations (only used for sequencer only) */
@@ -1542,96 +1543,37 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
time= (float)floor(fac2);
fac2= fac2-time;
- scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
+ scroll_printstr(vs, scene, fac, h, time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
}
break;
case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */
/* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */
- scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_DEGREES, 'v');
+ scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v');
break;
}
}
}
}
-
- /* decoration outer bevel line */
- UI_ThemeColorShade(TH_SHADE1, lighter);
- if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
- sdrawline(hor.xmin, hor.ymax, hor.xmax, hor.ymax);
- else if (scroll & V2D_SCROLL_TOP)
- sdrawline(hor.xmin, hor.ymin, hor.xmax, hor.ymin);
}
/* vertical scrollbar */
if (scroll & V2D_SCROLL_VERTICAL) {
- /* scroller backdrop */
- UI_ThemeColorShade(TH_SHADE1, light);
- glRecti(vert.xmin, vert.ymin, vert.xmax, vert.ymax);
-
- /* scroller 'button'
- * - if view is zoomable in y, draw handles too
- * - handles are drawn darker
- * - no slider when view is > total for non-zoomable views
- * (otherwise, zoomable ones tend to flicker)
- */
- if ( (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) ||
- ((v2d->tot.ymax - v2d->tot.ymin) > (v2d->cur.ymax - v2d->cur.ymin)) )
- {
- if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
- /* draw base bar as rounded shape */
- UI_ThemeColorShade(TH_SHADE1, dark);
- uiSetRoundBox(15);
-
- /* check that box is large enough for round drawing */
- if ((vs->vert_max - vs->vert_min) < (V2D_SCROLLCAP_RAD * 2)) {
- /* Rounded box still gets drawn at the minimum size limit
- * This doesn't represent extreme scaling well, but looks nicer...
- */
- float mid= 0.5f * (vs->vert_max + vs->vert_min);
-
- gl_round_box_vertical_shade(GL_POLYGON,
- (float)vert.xmin+2, mid-V2D_SCROLLCAP_RAD,
- (float)vert.xmax-2, mid+V2D_SCROLLCAP_RAD,
- V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
- }
- else {
- /* draw rounded box as per normal */
- gl_round_box_vertical_shade(GL_POLYGON,
- (float)vert.xmin+2, (float)vs->vert_min,
- (float)vert.xmax-2, (float)vs->vert_max,
- V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
- }
- }
- else {
- /* base bar drawn as shaded rect */
- UI_ThemeColorShade(TH_SHADE1, dark);
- uiSetRoundBox(0);
- gl_round_box_vertical_shade(GL_POLYGON,
- (float)vert.xmin+2, (float)vs->vert_min,
- (float)vert.xmax-2, (float)vs->vert_max,
- V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-
- /* 'minimum' handle */
- UI_ThemeColorShade(TH_SHADE1, darker);
- uiSetRoundBox(12);
-
- gl_round_box_vertical_shade(GL_POLYGON,
- (float)vert.xmin+2, (float)vs->vert_min-V2D_SCROLLER_HANDLE_SIZE,
- (float)vert.xmax-2, (float)vs->vert_min+V2D_SCROLLER_HANDLE_SIZE,
- V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
-
- /* maximum handle */
- UI_ThemeColorShade(TH_SHADE1, darker);
- uiSetRoundBox(3);
-
- gl_round_box_vertical_shade(GL_POLYGON,
- (float)vert.xmin+2, (float)vs->vert_max-V2D_SCROLLER_HANDLE_SIZE,
- (float)vert.xmax-2, (float)vs->vert_max+V2D_SCROLLER_HANDLE_SIZE,
- V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
- }
+
+ if(vs->vertfull==0) {
+ bTheme *btheme= U.themes.first;
+ uiWidgetColors wcol= btheme->tui.wcol_scroll;
+ rcti slider;
+
+ slider.xmin= vert.xmin;
+ slider.xmax= vert.xmax;
+ slider.ymin= vs->vert_min;
+ slider.ymax= vs->vert_max;
+
+ widget_scroll_draw(&wcol, &vert, &slider, (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE)?UI_SELECT:0);
}
+
/* scale indiators */
// XXX will need to update the font drawing when the new stuff comes in
if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
@@ -1661,42 +1603,23 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* draw vertical steps */
if (dfac > 0.0f) {
- for (; fac < vert.ymax; fac+= dfac, val += grid->dy) {
- scroll_printstr(vs, scene, (float)(vert.xmax)-14.0f, fac, val, grid->powery, vs->yunits, 'v');
+
+ BLF_default_rotation(90.0f);
+
+ for (; fac < vert.ymax-10; fac+= dfac, val += grid->dy) {
+
+ /* make prints look nicer for scrollers */
+ if(fac < vert.ymin+10)
+ continue;
+
+ scroll_printstr(vs, scene, (float)(vert.xmax)-2.0f, fac, val, grid->powery, vs->yunits, 'v');
}
+
+ BLF_default_rotation(0.0f);
}
}
-
- /* decoration outer bevel line */
- UI_ThemeColorShade(TH_SHADE1, lighter);
- if (scroll & V2D_SCROLL_RIGHT)
- sdrawline(vert.xmin, vert.ymin, vert.xmin, vert.ymax);
- else if (scroll & V2D_SCROLL_LEFT)
- sdrawline(vert.xmax, vert.ymin, vert.xmax, vert.ymax);
}
- /* draw a 'sunken square' to cover up any overlapping corners resulting from intersection of overflowing scroller data */
- if ((scroll & V2D_SCROLL_VERTICAL) && (scroll & V2D_SCROLL_HORIZONTAL)) {
- /* set bounds (these should be right) */
- corner.xmin= vert.xmin;
- corner.xmax= vert.xmax;
- corner.ymin= hor.ymin;
- corner.ymax= hor.ymax;
-
- /* firstly, draw using background color to cover up any overlapping junk */
- UI_ThemeColor(TH_SHADE1);
- glRecti(corner.xmin, corner.ymin, corner.xmax, corner.ymax);
-
- /* now, draw suggestive highlighting... */
- /* first, dark lines on top to suggest scrollers overlap box */
- UI_ThemeColorShade(TH_SHADE1, darker);
- sdrawline(corner.xmin, corner.ymin, corner.xmin, corner.ymax);
- sdrawline(corner.xmin, corner.ymax, corner.xmax, corner.ymax);
- /* now, light lines on bottom to show box is sunken in */
- UI_ThemeColorShade(TH_SHADE1, lighter);
- sdrawline(corner.xmax, corner.ymin, corner.xmax, corner.ymax);
- sdrawline(corner.xmin, corner.ymin, corner.xmax, corner.ymin);
- }
}
/* free temporary memory used for drawing scrollers */
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index bd1c734b870..ae89e215a03 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1095,15 +1095,23 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
}
}
+
UI_view2d_scrollers_free(scrollers);
+ ED_region_tag_redraw(ar);
}
/* cleanup temp customdata */
static void scroller_activate_exit(bContext *C, wmOperator *op)
{
if (op->customdata) {
+ v2dScrollerMove *vsm= op->customdata;
+
+ vsm->v2d->scroll_ui &= ~(V2D_SCROLL_H_ACTIVE|V2D_SCROLL_V_ACTIVE);
+
MEM_freeN(op->customdata);
- op->customdata= NULL;
+ op->customdata= NULL;
+
+ ED_region_tag_redraw(CTX_wm_region(C));
}
}
@@ -1240,6 +1248,11 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
+ if(vsm->scroller=='h')
+ v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE;
+ else
+ v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE;
+
/* still ok, so can add */
WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index a52acdd4e1e..6ec5f029148 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -86,6 +86,12 @@ void GROUP_OT_objects_remove_active(struct wmOperatorType *ot);
/* object_modifier.c */
void OBJECT_OT_modifier_add(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_remove(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_move_up(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_move_down(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_apply(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_convert(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_copy(struct wmOperatorType *ot);
void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot);
void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 4bcfcc4d5ab..bda3e4e8f79 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -25,6 +25,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@@ -35,6 +36,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
+#include "DNA_object_force.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
@@ -44,6 +46,7 @@
#include "BKE_depsgraph.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_lattice.h"
#include "BKE_mesh.h"
@@ -52,6 +55,7 @@
#include "BKE_report.h"
#include "BKE_object.h"
#include "BKE_particle.h"
+#include "BKE_softbody.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -67,31 +71,97 @@
/******************************** API ****************************/
-int ED_object_modifier_delete(ReportList *reports, Object *ob, ModifierData *md)
+int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type)
+{
+ ModifierData *md;
+ ModifierTypeInfo *mti = modifierType_getInfo(type);
+
+ if(mti->flags&eModifierTypeFlag_Single) {
+ if(modifiers_findByType(ob, type)) {
+ BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed.");
+ return 0;
+ }
+ }
+
+ if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
+ md = ob->modifiers.first;
+
+ while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
+ md = md->next;
+
+ BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
+ }
+ else
+ BLI_addtail(&ob->modifiers, modifier_new(type));
+
+ /* special cases */
+ if(type == eModifierType_Softbody) {
+ if(!ob->soft) {
+ ob->soft= sbNew(scene);
+ ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
+ }
+ }
+ else if(type == eModifierType_Collision) {
+ if(!ob->pd)
+ ob->pd= object_add_collision_fields();
+
+ ob->pd->deflect= 1;
+ DAG_scene_sort(scene);
+ }
+ else if(type == eModifierType_Surface)
+ DAG_scene_sort(scene);
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
+ return 1;
+}
+
+int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)
{
ModifierData *obmd;
/* It seems on rapid delete it is possible to
* get called twice on same modifier, so make
* sure it is in list. */
- for (obmd=ob->modifiers.first; obmd; obmd=obmd->next)
- if (obmd==md)
+ for(obmd=ob->modifiers.first; obmd; obmd=obmd->next)
+ if(obmd==md)
break;
- if (!obmd)
+ if(!obmd)
return 0;
+ /* special cases */
if(md->type == eModifierType_ParticleSystem) {
ParticleSystemModifierData *psmd=(ParticleSystemModifierData*)md;
BLI_remlink(&ob->particlesystem, psmd->psys);
psys_free(ob, psmd->psys);
}
+ else if(md->type == eModifierType_Softbody) {
+ if(ob->soft) {
+ sbFree(ob->soft);
+ ob->soft= NULL;
+ ob->softflag= 0;
+ }
+ }
+ else if(md->type == eModifierType_Collision) {
+ if(ob->pd)
+ ob->pd->deflect= 0;
- BLI_remlink(&ob->modifiers, md);
+ DAG_scene_sort(scene);
+ }
+ else if(md->type == eModifierType_Surface) {
+ if(ob->pd)
+ ob->pd->flag &= ~PFIELD_SURFACE;
+ DAG_scene_sort(scene);
+ }
+
+ BLI_remlink(&ob->modifiers, md);
modifier_free(md);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
return 1;
}
@@ -103,9 +173,10 @@ int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md
if(mti->type!=eModifierTypeType_OnlyDeform) {
ModifierTypeInfo *nmti = modifierType_getInfo(md->prev->type);
- if(nmti->flags&eModifierTypeFlag_RequiresOriginalData)
+ if(nmti->flags&eModifierTypeFlag_RequiresOriginalData) {
BKE_report(reports, RPT_WARNING, "Cannot move above a modifier requiring original data.");
return 0;
+ }
}
BLI_remlink(&ob->modifiers, md);
@@ -329,22 +400,11 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
- ModifierData *md;
int type= RNA_enum_get(op->ptr, "type");
- ModifierTypeInfo *mti = modifierType_getInfo(type);
- if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
- md = ob->modifiers.first;
+ if(!ED_object_modifier_add(op->reports, scene, ob, type))
+ return OPERATOR_CANCELLED;
- while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
- md = md->next;
-
- BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
- }
- else
- BLI_addtail(&ob->modifiers, modifier_new(type));
-
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
return OPERATOR_FINISHED;
@@ -370,13 +430,198 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", modifier_type_items, 0, "Type", "");
}
+/************************ remove modifier operator *********************/
+
+static int modifier_remove_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md))
+ return OPERATOR_CANCELLED;
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_remove(wmOperatorType *ot)
+{
+ ot->name= "Remove Modifier";
+ ot->description= "Remove a modifier from the active object.";
+ ot->idname= "OBJECT_OT_modifier_remove";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_remove_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ move up modifier operator *********************/
+
+static int modifier_move_up_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
+{
+ ot->name= "Move Up Modifier";
+ ot->description= "Move modifier up in the stack.";
+ ot->idname= "OBJECT_OT_modifier_move_up";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_move_up_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ move down modifier operator *********************/
+
+static int modifier_move_down_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
+{
+ ot->name= "Move Down Modifier";
+ ot->description= "Move modifier down in the stack.";
+ ot->idname= "OBJECT_OT_modifier_move_down";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_move_down_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ apply modifier operator *********************/
+
+static int modifier_apply_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_apply(wmOperatorType *ot)
+{
+ ot->name= "Apply Modifier";
+ ot->description= "Apply modifier and remove from the stack.";
+ ot->idname= "OBJECT_OT_modifier_apply";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_apply_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ convert modifier operator *********************/
+
+static int modifier_convert_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_convert(op->reports, scene, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_convert(wmOperatorType *ot)
+{
+ ot->name= "Convert Modifier";
+ ot->description= "Convert particles to a mesh object.";
+ ot->idname= "OBJECT_OT_modifier_convert";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_convert_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ copy modifier operator *********************/
+
+static int modifier_copy_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+ Object *ob= ptr.id.data;
+ ModifierData *md= ptr.data;
+
+ if(!ob || !md || !ED_object_modifier_copy(op->reports, ob, md))
+ return OPERATOR_CANCELLED;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_copy(wmOperatorType *ot)
+{
+ ot->name= "Copy Modifier";
+ ot->description= "Duplicate modifier at the same position in the stack.";
+ ot->idname= "OBJECT_OT_modifier_copy";
+ ot->poll= ED_operator_object_active;
+
+ ot->exec= modifier_copy_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/****************** multires subdivide operator *********************/
static int multires_subdivide_exec(bContext *C, wmOperator *op)
{
- Object *ob = CTX_data_active_object(C);
- PointerRNA ptr = CTX_data_pointer_get(C, "modifier");
- MultiresModifierData *mmd = (RNA_struct_is_a(ptr.type, &RNA_Modifier))? ptr.data: NULL;
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_MultiresModifier);
+ Object *ob= ptr.id.data;
+ MultiresModifierData *mmd= ptr.data;
if(mmd) {
multiresModifier_subdivide(mmd, ob, 1, 0, mmd->simple);
@@ -403,8 +648,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
static int modifier_mdef_bind_poll(bContext *C)
{
- PointerRNA ptr= CTX_data_pointer_get(C, "modifier");
- return RNA_struct_is_a(ptr.type, &RNA_MeshDeformModifier);
+ return CTX_data_pointer_get_type(C, "modifier", &RNA_MeshDeformModifier).data != NULL;
}
static int modifier_mdef_bind_exec(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 6fa78a53840..6248d826ad4 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -100,6 +100,12 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_primitive_add);
WM_operatortype_append(OBJECT_OT_modifier_add);
+ WM_operatortype_append(OBJECT_OT_modifier_remove);
+ WM_operatortype_append(OBJECT_OT_modifier_move_up);
+ WM_operatortype_append(OBJECT_OT_modifier_move_down);
+ WM_operatortype_append(OBJECT_OT_modifier_apply);
+ WM_operatortype_append(OBJECT_OT_modifier_convert);
+ WM_operatortype_append(OBJECT_OT_modifier_copy);
WM_operatortype_append(OBJECT_OT_multires_subdivide);
WM_operatortype_append(OBJECT_OT_modifier_mdef_bind);
diff --git a/source/blender/editors/physics/ed_fluidsim.c b/source/blender/editors/physics/ed_fluidsim.c
index 215a72d6927..3990521bd1b 100644
--- a/source/blender/editors/physics/ed_fluidsim.c
+++ b/source/blender/editors/physics/ed_fluidsim.c
@@ -67,18 +67,19 @@
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
+#include "BKE_DerivedMesh.h"
#include "BKE_displist.h"
#include "BKE_effect.h"
#include "BKE_fluidsim.h"
#include "BKE_global.h"
-#include "BKE_modifier.h"
-#include "BKE_main.h"
+#include "BKE_ipo.h"
#include "BKE_key.h"
-#include "BKE_scene.h"
+#include "BKE_main.h"
+#include "BKE_modifier.h"
#include "BKE_object.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
#include "BKE_softbody.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_ipo.h"
#include "PIL_time.h"
@@ -89,6 +90,9 @@
#include "ED_fluidsim.h"
#include "ED_screen.h"
+#include "WM_api.h"
+#include "WM_types.h"
+
/* XXX */
/* from header info.c */
static int start_progress_bar(void) {return 0;};
@@ -124,7 +128,7 @@ char* fluidsimViscosityPresetString[6] = {
/* ********************** fluid sim settings struct functions ********************** */
/* helper function */
-void fluidsimGetGeometryObjFilename(struct Object *ob, char *dst) { //, char *srcname) {
+void fluidsimGetGeometryObjFilename(Object *ob, char *dst) { //, char *srcname) {
//snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name);
snprintf(dst,FILE_MAXFILE, "fluidcfgdata_%s.bobj.gz", ob->id.name);
}
@@ -337,14 +341,14 @@ int runSimulationCallback(void *data, int status, int frame) {
/* ********************** write fluidsim config to file ************************* */
/* ******************************************************************************** */
-void fluidsimBake(bContext *C, struct Object *ob)
+int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
{
Scene *scene= CTX_data_scene(C);
FILE *fileCfg;
int i;
- struct Object *fsDomain = NULL;
+ Object *fsDomain = NULL;
FluidsimSettings *domainSettings;
- struct Object *obit = NULL; /* object iterator */
+ Object *obit = NULL; /* object iterator */
Base *base;
int origFrame = scene->r.cfra;
char debugStrBuffer[256];
@@ -412,8 +416,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
// old: noFrames = scene->r.efra - scene->r.sfra +1;
noFrames = scene->r.efra - 0;
if(noFrames<=0) {
- pupmenu("Fluidsim Bake Error%t|No frames to export - check your animation range settings. Aborted%x0");
- return;
+ BKE_report(reports, RPT_ERROR, "No frames to export - check your animation range settings.");
+ return 0;
}
/* no object pointer, find in selected ones.. */
@@ -434,7 +438,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
}
}
// no domains found?
- if(!ob) return;
+ if(!ob) return 0;
}
channelObjCount = 0;
@@ -452,8 +456,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
}
if (channelObjCount>=255) {
- pupmenu("Fluidsim Bake Error%t|Cannot bake with more then 256 objects");
- return;
+ BKE_report(reports, RPT_ERROR, "Cannot bake with more then 256 objects.");
+ return 0;
}
/* check if there's another domain... */
@@ -467,8 +471,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
{
if(obit != ob)
{
- pupmenu("Fluidsim Bake Error%t|There should be only one domain object! Aborted%x0");
- return;
+ BKE_report(reports, RPT_ERROR, "There should be only one domain object.");
+ return 0;
}
}
}
@@ -490,8 +494,8 @@ void fluidsimBake(bContext *C, struct Object *ob)
}
}
if(!haveSomeFluid) {
- pupmenu("Fluidsim Bake Error%t|No fluid objects in scene... Aborted%x0");
- return;
+ BKE_report(reports, RPT_ERROR, "No fluid objects in scene.");
+ return 0;
}
/* these both have to be valid, otherwise we wouldnt be here */
@@ -585,7 +589,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
// ask user if thats what he/she wants...
selection = pupmenu(dispmsg);
- if(selection<1) return; // 0 from menu, or -1 aborted
+ if(selection<1) return 0; // 0 from menu, or -1 aborted
strcpy(targetDir, newSurfdataPath);
strncpy(domainSettings->surfdataPath, newSurfdataPath, FILE_MAXDIR);
BLI_convertstringcode(targetDir, G.sce); // fixed #frame-no
@@ -710,6 +714,10 @@ void fluidsimBake(bContext *C, struct Object *ob)
// check & init loc,rot,size
for(j=0; j<3; j++) {
for(k=0; k<3; k++) {
+ // XXX prevent invalid memory access until this works
+ icuex[j][k]= NULL;
+ icudex[j][k]= NULL;
+
// XXX icuex[j][k] = find_ipocurve(obit->ipo, icuIds[j][k] );
// XXX icudex[j][k] = find_ipocurve(obit->ipo, icudIds[j][k] );
// XXX lines below were already disabled!
@@ -812,12 +820,12 @@ void fluidsimBake(bContext *C, struct Object *ob)
if(!Mat4Invert(invDomMat, domainMat)) {
snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n");
elbeemDebugOut(debugStrBuffer);
+ BKE_report(reports, RPT_ERROR, "Invalid object matrix.");
// FIXME add fatal msg
FS_FREE_CHANNELS;
- return;
+ return 0;
}
-
// --------------------------------------------------------------------------------------------
// start writing / exporting
strcpy(targetFile, targetDir);
@@ -1001,7 +1009,6 @@ void fluidsimBake(bContext *C, struct Object *ob)
} // valid mesh
} // objects
//domainSettings->type = OB_FLUIDSIM_DOMAIN; // enable for bake display again
- //fsDomain->fluidsimFlag = OB_FLUIDSIM_ENABLE; // disable during bake
// set to neutral, -1 means user abort, -2 means init error
globalBakeState = 0;
@@ -1080,7 +1087,7 @@ void fluidsimBake(bContext *C, struct Object *ob)
// --------------------------------------------------------------------------------------------
else
{ // write config file to be run with command line simulator
- pupmenu("Fluidsim Bake Message%t|Config file export not supported.%x0");
+ BKE_report(reports, RPT_WARNING, "Config file export not supported.");
} // config file export done!
// --------------------------------------------------------------------------------------------
@@ -1099,51 +1106,81 @@ void fluidsimBake(bContext *C, struct Object *ob)
ED_update_for_newframe(C, 1);
if(!simAborted) {
- char fsmessage[512];
char elbeemerr[256];
- strcpy(fsmessage,"Fluidsim Bake Error: ");
+
// check if some error occurred
if(globalBakeState==-2) {
- strcat(fsmessage,"Failed to initialize [Msg: ");
-
elbeemGetErrorString(elbeemerr);
- strcat(fsmessage,elbeemerr);
-
- strcat(fsmessage,"] |OK%x0");
- pupmenu(fsmessage);
+ BKE_reportf(reports, RPT_ERROR, "Failed to initialize [Msg: %s]", elbeemerr);
+ return 0;
} // init error
}
// elbeemFree();
+ return 1;
}
-void fluidsimFreeBake(struct Object *ob)
+void fluidsimFreeBake(Object *ob)
{
/* not implemented yet */
}
-
#else /* DISABLE_ELBEEM */
/* compile dummy functions for disabled fluid sim */
-FluidsimSettings *fluidsimSettingsNew(struct Object *srcob) {
+FluidsimSettings *fluidsimSettingsNew(Object *srcob)
+{
return NULL;
}
-void fluidsimSettingsFree(FluidsimSettings *fss) {
+void fluidsimSettingsFree(FluidsimSettings *fss)
+{
}
-FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *fss) {
+FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *fss)
+{
return NULL;
}
/* only compile dummy functions */
-void fluidsimBake(bContext *C, struct Object *ob) {
+int fluidsimBake(bContext *C, ReportList *reports, Object *ob)
+{
+ return 0;
}
-void fluidsimFreeBake(struct Object *ob) {
+void fluidsimFreeBake(Object *ob)
+{
}
#endif /* DISABLE_ELBEEM */
+/***************************** Operators ******************************/
+
+static int fluid_bake_exec(bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+
+ // XXX TODO redraw, escape, non-blocking, ..
+ if(!fluidsimBake(C, op->reports, ob))
+ return OPERATOR_CANCELLED;
+
+ return OPERATOR_FINISHED;
+}
+
+void FLUID_OT_bake(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Fluid Simulation Bake";
+ ot->idname= "FLUID_OT_bake";
+
+ /* api callbacks */
+ ot->exec= fluid_bake_exec;
+ ot->poll= ED_operator_object_active;
+}
+
+void ED_operatortypes_fluid(void)
+{
+ WM_operatortype_append(FLUID_OT_bake);
+}
+
diff --git a/source/blender/editors/physics/ed_pointcache.c b/source/blender/editors/physics/ed_pointcache.c
index 893c59a521d..edd668b46bb 100644
--- a/source/blender/editors/physics/ed_pointcache.c
+++ b/source/blender/editors/physics/ed_pointcache.c
@@ -45,7 +45,7 @@
#include "BLI_blenlib.h"
#include "ED_screen.h"
-#include "ED_pointcache.h"
+#include "ED_physics.h"
#include "UI_interface.h"
#include "UI_resources.h"
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 535e99ccfef..dd8efd68604 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -261,6 +261,7 @@ static void region_scissor_winrct(ARegion *ar, rcti *winrct)
if(BLI_isect_rcti(winrct, &ar->winrct, NULL)) {
if(ar->flag & RGN_FLAG_HIDDEN);
+ else if(ar->alignment & RGN_SPLIT_PREV);
else if(ar->alignment==RGN_OVERLAP_LEFT) {
winrct->xmin= ar->winrct.xmax + 1;
}
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 510103895f4..c8df9bb9741 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -42,15 +42,15 @@
#include "ED_anim_api.h"
#include "ED_armature.h"
#include "ED_curve.h"
-#include "ED_mesh.h"
#include "ED_markers.h"
+#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_particle.h"
-#include "ED_sculpt.h"
+#include "ED_physics.h"
#include "ED_screen.h"
+#include "ED_sculpt.h"
#include "ED_space_api.h"
#include "ED_uvedit.h"
-#include "ED_pointcache.h"
/* only call once on startup, storage is global in BKE kernel listbase */
void ED_spacetypes_init(void)
@@ -89,8 +89,9 @@ void ED_spacetypes_init(void)
ED_operatortypes_particle();
ED_operatortypes_curve();
ED_operatortypes_armature();
- ED_marker_operatortypes();
+ ED_operatortypes_marker();
ED_operatortypes_pointcache();
+ ED_operatortypes_fluid();
ui_view2d_operatortypes();
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 01794d1bba8..02179f347f5 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -497,7 +497,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
"world", "object", "meshe", "armature", "lattice", "curve",
"meta_ball", "lamp", "camera", "material", "material_slot",
"texture", "texture_slot", "bone", "edit_bone", "particle_system",
- "cloth", "soft_body", "fluid", NULL};
+ "cloth", "soft_body", "fluid", "collision", NULL};
CTX_data_dir_set(result, dir);
return 1;
@@ -615,7 +615,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
if(ptr && ptr->data) {
Object *ob= ptr->data;
- CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodySettings, ob->soft);
+ ModifierData *md= modifiers_findByType(ob, eModifierType_Softbody);
+ CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md);
return 1;
}
}
@@ -629,6 +630,16 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
return 1;
}
}
+ else if(CTX_data_equals(member, "collision")) {
+ PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
+
+ if(ptr && ptr->data) {
+ Object *ob= ptr->data;
+ ModifierData *md= modifiers_findByType(ob, eModifierType_Collision);
+ CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md);
+ return 1;
+ }
+ }
return 0;
}
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index df3e8c62d37..2bc3bdaa613 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -41,6 +41,7 @@
#include "BKE_depsgraph.h"
#include "BKE_font.h"
#include "BKE_library.h"
+#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_particle.h"
#include "BKE_texture.h"
@@ -471,6 +472,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot)
static int new_particle_settings_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
+ Main *bmain= CTX_data_main(C);
ParticleSettings *part= CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings).data;
Object *ob;
PointerRNA ptr;
@@ -479,7 +481,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op)
if(part)
part= psys_copy_settings(part);
else
- part= psys_new_settings("PSys", NULL);
+ part= psys_new_settings("PSys", bmain);
/* attempt to assign to material slot */
ptr= CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 2cade676817..28b6f0b4ab6 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -96,14 +96,15 @@
/* *************************** Calculate Range ************************** */
/* Get the min/max keyframes*/
-static void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax)
+/* note: it should return total boundbox, filter for selection only can be argument... */
+void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
/* get data to filter, from Dopesheet */
- filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* set large values to try to override */
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index 86e5451122d..697c31eaa98 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -84,6 +84,8 @@ enum {
/* ***************************************** */
/* graph_edit.c */
+void get_graph_keyframe_extents (struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax);
+
void GRAPH_OT_previewrange_set(struct wmOperatorType *ot);
void GRAPH_OT_view_all(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index ef42b009bd4..b17861dc679 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -243,6 +243,10 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
/* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */
graph_draw_curves(&ac, sipo, ar, grid, 0);
graph_draw_curves(&ac, sipo, ar, grid, 1);
+
+ /* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
+ get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax);
+
}
/* only free grid after drawing data, as we need to use it to determine sampling rate */
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index e9bba7a83c6..c387bb74ad8 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -97,29 +97,45 @@ ARegion *view3d_has_buttons_region(ScrArea *sa)
ARegion *view3d_has_tools_region(ScrArea *sa)
{
- ARegion *ar, *arnew;
+ ARegion *ar, *artool=NULL, *arprops=NULL, *arhead;
- for(ar= sa->regionbase.first; ar; ar= ar->next)
+ for(ar= sa->regionbase.first; ar; ar= ar->next) {
if(ar->regiontype==RGN_TYPE_TOOLS)
- return ar;
-
- /* add subdiv level; after header */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
- if(ar->regiontype==RGN_TYPE_HEADER)
- break;
-
- /* is error! */
- if(ar==NULL) return NULL;
-
- arnew= MEM_callocN(sizeof(ARegion), "tools for view3d");
+ artool= ar;
+ if(ar->regiontype==RGN_TYPE_TOOL_PROPS)
+ arprops= ar;
+ }
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
- arnew->regiontype= RGN_TYPE_TOOLS;
- arnew->alignment= RGN_OVERLAP_LEFT;
+ /* tool region hide/unhide also hides props */
+ if(arprops && artool) return artool;
- arnew->flag = RGN_FLAG_HIDDEN;
+ if(artool==NULL) {
+ /* add subdiv level; after header */
+ for(arhead= sa->regionbase.first; arhead; arhead= arhead->next)
+ if(arhead->regiontype==RGN_TYPE_HEADER)
+ break;
+
+ /* is error! */
+ if(arhead==NULL) return NULL;
+
+ artool= MEM_callocN(sizeof(ARegion), "tools for view3d");
+
+ BLI_insertlinkafter(&sa->regionbase, arhead, artool);
+ artool->regiontype= RGN_TYPE_TOOLS;
+ artool->alignment= RGN_OVERLAP_LEFT;
+ artool->flag = RGN_FLAG_HIDDEN;
+ }
+
+ if(arprops==NULL) {
+ /* add extra subdivided region for tool properties */
+ arprops= MEM_callocN(sizeof(ARegion), "tool props for view3d");
+
+ BLI_insertlinkafter(&sa->regionbase, artool, arprops);
+ arprops->regiontype= RGN_TYPE_TOOL_PROPS;
+ arprops->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
+ }
- return arnew;
+ return artool;
}
/* ****************************************************** */
@@ -558,9 +574,11 @@ static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
+
+
static void view3d_tools_area_draw(const bContext *C, ARegion *ar)
{
- ED_region_panels(C, ar, 1, NULL);
+ ED_region_panels(C, ar, 1, view3d_context_string(C));
}
/*
@@ -859,6 +877,20 @@ void ED_spacetype_view3d(void)
BLI_addhead(&st->regiontypes, art);
view3d_toolbar_register(art);
+
+ /* regions: tool properties */
+ art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
+ art->regionid = RGN_TYPE_TOOL_PROPS;
+ art->minsizex= 0;
+ art->minsizey= 120;
+ art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
+ art->listener= view3d_buttons_area_listener;
+ art->init= view3d_tools_area_init;
+ art->draw= view3d_tools_area_draw;
+ BLI_addhead(&st->regiontypes, art);
+
+ view3d_tool_props_register(art);
+
/* regions: header */
art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region");
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 6dbd99c67be..65040b4238f 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -136,9 +136,11 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d);
void VIEW3D_OT_properties(struct wmOperatorType *ot);
void view3d_buttons_register(struct ARegionType *art);
-/* view3d_buttons.c */
+/* view3d_toolbar.c */
void VIEW3D_OT_toolbar(struct wmOperatorType *ot);
void view3d_toolbar_register(struct ARegionType *art);
+void view3d_tool_props_register(struct ARegionType *art);
+char *view3d_context_string(const struct bContext *C);
/* view3d_snap.c */
int minmax_verts(Object *obedit, float *min, float *max);
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index ea365d59ac7..8aba8e11d43 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -150,9 +150,46 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
/* ******************* */
+char *view3d_context_string(const bContext *C)
+{
+ Object *obedit= CTX_data_edit_object(C);
+
+ if(obedit) {
+ switch(obedit->type) {
+ case OB_MESH:
+ return "editmode_mesh";
+ case OB_CURVE:
+ return "editmode_curve";
+ case OB_SURF:
+ return "editmode_surface";
+ case OB_FONT:
+ return "editmode_text";
+ case OB_ARMATURE:
+ return "editmode_armature";
+ case OB_MBALL:
+ return "editmode_mball";
+ case OB_LATTICE:
+ return "editmode_lattice";
+ }
+ }
+ else {
+ Object *ob = CTX_data_active_object(C);
+
+ if(ob && (ob->flag & OB_POSEMODE)) return "posemode";
+ else if (G.f & G_SCULPTMODE) return "sculptmode";
+ else if (G.f & G_WEIGHTPAINT) return "weightpaint";
+ else if (G.f & G_VERTEXPAINT) return "vertexpaint";
+ else if (G.f & G_TEXTUREPAINT) return "texturepaint";
+ else if(G.f & G_PARTICLEEDIT) return "particlemode";
+ }
+
+ return "objectmode";
+}
+
typedef struct CustomTool {
struct CustomTool *next, *prev;
char opname[OP_MAX_TYPENAME];
+ char context[OP_MAX_TYPENAME];
} CustomTool;
static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2)
@@ -164,6 +201,7 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2)
BLI_addtail(arg_listbase, ct);
BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME);
+ BLI_strncpy(ct->context, view3d_context_string(C), OP_MAX_TYPENAME);
}
}
@@ -221,43 +259,28 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase)
}
-static void view3d_panel_tools(const bContext *C, Panel *pa)
+static void view3d_panel_tool_shelf(const bContext *C, Panel *pa)
{
- static ListBase tools= {NULL, NULL};
- Object *obedit= CTX_data_edit_object(C);
-// Object *obact = CTX_data_active_object(C);
+ SpaceLink *sl= CTX_wm_space_data(C);
+ SpaceType *st= NULL;
uiLayout *col;
+ const char *context= view3d_context_string(C);
- if(obedit) {
- if(obedit->type==OB_MESH) {
-
- col= uiLayoutColumn(pa->layout, 1);
- uiItemFullO(col, NULL, 0, "MESH_OT_spin", NULL, WM_OP_INVOKE_REGION_WIN);
- uiItemFullO(col, NULL, 0, "MESH_OT_screw", NULL, WM_OP_INVOKE_REGION_WIN);
-
- if(tools.first) {
- CustomTool *ct;
-
- for(ct= tools.first; ct; ct= ct->next) {
- col= uiLayoutColumn(pa->layout, 1);
- uiItemFullO(col, NULL, 0, ct->opname, NULL, WM_OP_INVOKE_REGION_WIN);
- }
+ if(sl)
+ st= BKE_spacetype_from_id(sl->spacetype);
+
+ if(st && st->toolshelf.first) {
+ CustomTool *ct;
+
+ for(ct= st->toolshelf.first; ct; ct= ct->next) {
+ if(0==strncmp(context, ct->context, OP_MAX_TYPENAME)) {
+ col= uiLayoutColumn(pa->layout, 1);
+ uiItemFullO(col, NULL, 0, ct->opname, NULL, WM_OP_INVOKE_REGION_WIN);
}
- col= uiLayoutColumn(pa->layout, 1);
- uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &tools, "Add Operator", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add tool");
}
}
- else {
-
- col= uiLayoutColumn(pa->layout, 1);
- uiItemFullO(col, NULL, 0, "OBJECT_OT_delete", NULL, WM_OP_INVOKE_REGION_WIN);
- uiItemFullO(col, NULL, 0, "OBJECT_OT_primitive_add", NULL, WM_OP_INVOKE_REGION_WIN);
-
- col= uiLayoutColumn(pa->layout, 1);
- uiItemFullO(col, NULL, 0, "OBJECT_OT_parent_set", NULL, WM_OP_INVOKE_REGION_WIN);
- uiItemFullO(col, NULL, 0, "OBJECT_OT_parent_clear", NULL, WM_OP_INVOKE_REGION_WIN);
-
- }
+ col= uiLayoutColumn(pa->layout, 1);
+ uiDefBlockBut(uiLayoutGetBlock(pa->layout), tool_search_menu, &st->toolshelf, "Add Tool", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Add Tool in shelf, gets saved in files");
}
@@ -266,10 +289,15 @@ void view3d_toolbar_register(ARegionType *art)
PanelType *pt;
pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel tools");
- strcpy(pt->idname, "VIEW3D_PT_tools");
- strcpy(pt->label, "Tools");
- pt->draw= view3d_panel_tools;
+ strcpy(pt->idname, "VIEW3D_PT_tool_shelf");
+ strcpy(pt->label, "Tool Shelf");
+ pt->draw= view3d_panel_tool_shelf;
BLI_addtail(&art->paneltypes, pt);
+}
+
+void view3d_tool_props_register(ARegionType *art)
+{
+ PanelType *pt;
pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator");
strcpy(pt->idname, "VIEW3D_PT_last_operator");
@@ -278,6 +306,8 @@ void view3d_toolbar_register(ARegionType *art)
BLI_addtail(&art->paneltypes, pt);
}
+/* ********** operator to open/close toolbar region */
+
static int view3d_toolbar(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);