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:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_operators.c')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c105
1 files changed, 41 insertions, 64 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index efd05114d9a..2311024827e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -30,6 +30,8 @@
#include <string.h>
#include <ctype.h>
#include <stdio.h>
+#include <stddef.h>
+
#include "DNA_ID.h"
#include "DNA_object_types.h"
@@ -61,7 +63,7 @@
#include "BKE_scene.h"
#include "BKE_screen.h" /* BKE_ST_MAXNAME */
#include "BKE_utildefines.h"
-#include "BKE_brush.h" // JW
+#include "BKE_idcode.h"
#include "BIF_gl.h"
#include "BIF_glutil.h" /* for paint cursor */
@@ -70,7 +72,6 @@
#include "ED_screen.h"
#include "ED_util.h"
-#include "ED_view3d.h" // JW
#include "RNA_access.h"
#include "RNA_define.h"
@@ -88,8 +89,6 @@
#include "wm_subwindow.h"
#include "wm_window.h"
-
-
static ListBase global_ops= {NULL, NULL};
/* ************ operator API, exported ********** */
@@ -101,11 +100,11 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet)
char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax
WM_operator_bl_idname(idname_bl, idname);
-
+
if (idname_bl[0]) {
- for(ot= global_ops.first; ot; ot= ot->next) {
- if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
- return ot;
+ ot= (wmOperatorType *)BLI_findstring_ptr(&global_ops, idname_bl, offsetof(wmOperatorType, idname));
+ if(ot) {
+ return ot;
}
}
@@ -115,22 +114,6 @@ wmOperatorType *WM_operatortype_find(const char *idname, int quiet)
return NULL;
}
-wmOperatorType *WM_operatortype_exists(const char *idname)
-{
- wmOperatorType *ot;
-
- char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax
- WM_operator_bl_idname(idname_bl, idname);
-
- if(idname_bl[0]) {
- for(ot= global_ops.first; ot; ot= ot->next) {
- if(strncmp(ot->idname, idname_bl, OP_MAX_TYPENAME)==0)
- return ot;
- }
- }
- return NULL;
-}
-
wmOperatorType *WM_operatortype_first(void)
{
return global_ops.first;
@@ -331,7 +314,7 @@ wmOperatorType *WM_operatortype_append_macro(char *idname, char *name, int flag)
{
wmOperatorType *ot;
- if(WM_operatortype_exists(idname)) {
+ if(WM_operatortype_find(idname, TRUE)) {
printf("Macro error: operator %s exists\n", idname);
return NULL;
}
@@ -1212,6 +1195,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *arg_unuse
split = uiLayoutSplit(layout, 0, 0);
col = uiLayoutColumn(split, 0);
uiItemL(col, "Links", 0);
+ uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/");
uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-250/");
uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:Manual");
uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/");
@@ -1584,7 +1568,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
scene_deselect_all(scene);
bh = BLO_blendhandle_from_file(libname);
- idcode = BLO_idcode_from_name(group);
+ idcode = BKE_idcode_from_name(group);
flag = wm_link_append_flag(op);
@@ -1628,8 +1612,8 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
flag_all_listbases_ids(LIB_PRE_EXISTING, 0);
/* recreate dependency graph to include new objects */
- DAG_scene_sort(scene);
- DAG_ids_flush_update(0);
+ DAG_scene_sort(bmain, scene);
+ DAG_ids_flush_update(bmain, 0);
BLO_blendhandle_close(bh);
@@ -1783,6 +1767,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
char path[FILE_MAX];
int fileflags;
+ int copy=0;
save_set_compress(op);
@@ -1793,6 +1778,9 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
untitled(path);
}
+ if(RNA_property_is_set(op->ptr, "copy"))
+ copy = RNA_boolean_get(op->ptr, "copy");
+
fileflags= G.fileflags;
/* set compression flag */
@@ -1801,7 +1789,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
if(RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP;
else fileflags &= ~G_FILE_RELATIVE_REMAP;
- if ( WM_write_file(C, path, fileflags, op->reports) != 0)
+ if ( WM_write_file(C, path, fileflags, op->reports, copy) != 0)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL);
@@ -1822,6 +1810,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file");
RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory");
+ RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active.");
}
/* *************** save file directly ******** */
@@ -1873,7 +1862,6 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory");
}
-
/* XXX: move these collada operators to a more appropriate place */
#ifdef WITH_COLLADA
@@ -2592,33 +2580,22 @@ const int WM_RADIAL_CONTROL_DISPLAY_SIZE = 200;
typedef struct wmRadialControl {
int mode;
float initial_value, value, max_value;
+ float col[4], tex_col[4];
int initial_mouse[2];
void *cursor;
GLuint tex;
} wmRadialControl;
-extern Paint *paint_get_active(Scene *sce);
-extern struct Brush *paint_brush(struct Paint *paint);
-
static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata)
{
wmRadialControl *rc = (wmRadialControl*)customdata;
ARegion *ar = CTX_wm_region(C);
float r1=0.0f, r2=0.0f, r3=0.0f, angle=0.0f;
- Paint *paint = paint_get_active(CTX_data_scene(C));
- Brush *brush = paint_brush(paint);
-
- ViewContext vc;
-
// int hit = 0;
-
- int flip;
- int sign;
-
- float* col;
-
- const float str = rc->mode == WM_RADIALCONTROL_STRENGTH ? (rc->value + 0.5) : (brush->texture_overlay_alpha / 100.0f);
+
+ if(rc->mode == WM_RADIALCONTROL_STRENGTH)
+ rc->tex_col[3]= (rc->value + 0.5);
if(rc->mode == WM_RADIALCONTROL_SIZE) {
r1= rc->value;
@@ -2636,18 +2613,6 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata)
x = rc->initial_mouse[0] - ar->winrct.xmin;
y = rc->initial_mouse[1] - ar->winrct.ymin;
- view3d_set_viewcontext(C, &vc);
-
- // XXX: no way currently to know state of pen flip or invert key modifier without starting a stroke
- flip = 1;
-
- sign = flip * ((brush->flag & BRUSH_DIR_IN)? -1 : 1);
-
- if (sign < 0 && ELEM4(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_PINCH))
- col = brush->sub_col;
- else
- col = brush->add_col;
-
glTranslatef((float)x, (float)y, 0.0f);
glEnable(GL_BLEND);
@@ -2664,7 +2629,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata)
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
- glColor4f(U.sculpt_paint_overlay_col[0],U.sculpt_paint_overlay_col[1],U.sculpt_paint_overlay_col[2], str);
+ glColor4f(rc->tex_col[0], rc->tex_col[1], rc->tex_col[2], rc->tex_col[3]);
glTexCoord2f(0,0);
glVertex2f(-r3, -r3);
glTexCoord2f(1,0);
@@ -2678,7 +2643,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata)
}
if(rc->mode == WM_RADIALCONTROL_ANGLE) {
- glColor4f(col[0], col[1], col[2], 0.5f);
+ glColor4f(rc->col[0], rc->col[1], rc->col[2], rc->col[3]);
glEnable(GL_LINE_SMOOTH);
glRotatef(-angle, 0, 0, 1);
fdrawline(0, 0, WM_RADIAL_CONTROL_DISPLAY_SIZE, 0);
@@ -2687,7 +2652,7 @@ static void wm_radial_control_paint(bContext *C, int x, int y, void *customdata)
glDisable(GL_LINE_SMOOTH);
}
- glColor4f(col[0], col[1], col[2], 0.5f);
+ glColor4f(rc->col[0], rc->col[1], rc->col[2], rc->col[3]);
glutil_draw_lined_arc(0.0, M_PI*2.0, r1, 40);
glutil_draw_lined_arc(0.0, M_PI*2.0, r2, 40);
glDisable(GL_BLEND);
@@ -2702,7 +2667,7 @@ int WM_radial_control_modal(bContext *C, wmOperator *op, wmEvent *event)
float dist;
double new_value = RNA_float_get(op->ptr, "new_value");
int ret = OPERATOR_RUNNING_MODAL;
- float initial_value = RNA_float_get(op->ptr, "initial_value");
+ // float initial_value = RNA_float_get(op->ptr, "initial_value");
mode = RNA_int_get(op->ptr, "mode");
RNA_int_get_array(op->ptr, "initial_mouse", initial_mouse);
@@ -2813,6 +2778,9 @@ int WM_radial_control_invoke(bContext *C, wmOperator *op, wmEvent *event)
MEM_freeN(im);
}
+ RNA_float_get_array(op->ptr, "color", rc->col);
+ RNA_float_get_array(op->ptr, "texture_color", rc->tex_col);
+
RNA_int_set_array(op->ptr, "initial_mouse", mouse);
RNA_float_set(op->ptr, "new_value", initial_value);
@@ -2857,6 +2825,8 @@ void WM_OT_radial_control_partial(wmOperatorType *ot)
{WM_RADIALCONTROL_STRENGTH, "STRENGTH", 0, "Strength", ""},
{WM_RADIALCONTROL_ANGLE, "ANGLE", 0, "Angle", ""},
{0, NULL, 0, NULL, NULL}};
+ static float color[4] = {1.0f, 1.0f, 1.0f, 0.5f};
+ static float tex_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
/* Should be set in custom invoke() */
RNA_def_float(ot->srna, "initial_value", 0, 0, FLT_MAX, "Initial Value", "", 0, FLT_MAX);
@@ -2868,7 +2838,10 @@ void WM_OT_radial_control_partial(wmOperatorType *ot)
RNA_def_enum(ot->srna, "mode", radial_mode_items, 0, "Mode", "");
/* Internal */
- RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "initial_mouse", "", INT_MIN, INT_MAX);
+ RNA_def_int_vector(ot->srna, "initial_mouse", 2, NULL, INT_MIN, INT_MAX, "Initial Mouse", "", INT_MIN, INT_MAX);
+
+ RNA_def_float_color(ot->srna, "color", 4, color, 0.0f, FLT_MAX, "Color", "Radial control color", 0.0f, 1.0f);
+ RNA_def_float_color(ot->srna, "texture_color", 4, tex_color, 0.0f, FLT_MAX, "Texture Color", "Radial control texture color", 0.0f, 1.0f);
}
/* ************************** timer for testing ***************** */
@@ -2949,15 +2922,17 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
redraw_timer_window_swap(C);
}
else if (type==4) {
+ Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
if(a & 1) scene->r.cfra--;
else scene->r.cfra++;
- scene_update_for_newframe(scene, scene->lay);
+ scene_update_for_newframe(bmain, scene, scene->lay);
}
else if (type==5) {
/* play anim, return on same frame as started with */
+ Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
int tot= (scene->r.efra - scene->r.sfra) + 1;
@@ -2967,7 +2942,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
if(scene->r.cfra > scene->r.efra)
scene->r.cfra= scene->r.sfra;
- scene_update_for_newframe(scene, scene->lay);
+ scene_update_for_newframe(bmain, scene, scene->lay);
redraw_timer_window_swap(C);
}
}
@@ -3263,6 +3238,8 @@ void wm_window_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "WM_OT_save_mainfile", WKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0);
+ kmi= WM_keymap_add_item(keymap, "WM_OT_save_as_mainfile", SKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
+ RNA_boolean_set(kmi->ptr, "copy", 1);
WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);