Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_operators.c
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_ID.h" | #include "DNA_ID.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "DNA_windowmanager_types.h" | #include "DNA_windowmanager_types.h" | ||||
| #include "DNA_workspace_types.h" | |||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "PIL_time.h" | #include "PIL_time.h" | ||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_dial.h" | #include "BLI_dial.h" | ||||
| #include "BLI_dynstr.h" /*for WM_operator_pystring */ | #include "BLI_dynstr.h" /*for WM_operator_pystring */ | ||||
| ▲ Show 20 Lines • Show All 1,676 Lines • ▼ Show 20 Lines | static void WM_OT_operator_defaults(wmOperatorType *ot) | ||||
| ot->idname = "WM_OT_operator_defaults"; | ot->idname = "WM_OT_operator_defaults"; | ||||
| ot->description = "Set the active operator to its default values"; | ot->description = "Set the active operator to its default values"; | ||||
| ot->exec = wm_operator_defaults_exec; | ot->exec = wm_operator_defaults_exec; | ||||
| ot->flag = OPTYPE_INTERNAL; | ot->flag = OPTYPE_INTERNAL; | ||||
| } | } | ||||
| /* ***************** Set Active Tool ************************* */ | |||||
| static int wm_operator_tool_set_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| char idname[OP_MAX_TYPENAME]; | |||||
| RNA_string_get(op->ptr, "name", idname); | |||||
| /* NOTE: we may want to move this logic into a function. */ | |||||
| { | |||||
| BLI_strncpy(workspace->tool_active_keymap, idname, sizeof(workspace->tool_active_keymap)); | |||||
| workspace->tool_active_spacetype = sa->spacetype; | |||||
| } | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| static void WM_OT_operator_tool_set(wmOperatorType *ot) | |||||
| { | |||||
| ot->name = "Set Active Tool"; | |||||
| ot->idname = "WM_OT_operator_tool_set"; | |||||
| ot->description = "Set the active tool"; | |||||
| ot->exec = wm_operator_tool_set_exec; | |||||
| ot->flag = OPTYPE_INTERNAL; | |||||
| RNA_def_string(ot->srna, "name", NULL, OP_MAX_TYPENAME, "Name", "Name of the operator"); | |||||
| } | |||||
| /* ***************** Splash Screen ************************* */ | /* ***************** Splash Screen ************************* */ | ||||
| static void wm_block_splash_close(bContext *C, void *arg_block, void *UNUSED(arg)) | static void wm_block_splash_close(bContext *C, void *arg_block, void *UNUSED(arg)) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| UI_popup_block_close(C, win, arg_block); | UI_popup_block_close(C, win, arg_block); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 582 Lines • ▼ Show 20 Lines | static int border_apply(bContext *C, wmOperator *op, int gesture_mode) | ||||
| int retval; | int retval; | ||||
| if (!border_apply_rect(op)) | if (!border_apply_rect(op)) | ||||
| return 0; | return 0; | ||||
| /* XXX weak; border should be configured for this without reading event types */ | /* XXX weak; border should be configured for this without reading event types */ | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "gesture_mode"))) { | if ((prop = RNA_struct_find_property(op->ptr, "gesture_mode"))) { | ||||
| /* Allow caller to choose select/deselect. */ | |||||
| if (RNA_property_is_set(op->ptr, prop) == false) { | |||||
| RNA_property_int_set(op->ptr, prop, gesture_mode); | RNA_property_int_set(op->ptr, prop, gesture_mode); | ||||
| } | } | ||||
| } | |||||
| retval = op->type->exec(C, op); | retval = op->type->exec(C, op); | ||||
| OPERATOR_RETVAL_CHECK(retval); | OPERATOR_RETVAL_CHECK(retval); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| static void wm_gesture_end(bContext *C, wmOperator *op) | static void wm_gesture_end(bContext *C, wmOperator *op) | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
| /* **************** circle gesture *************** */ | /* **************** circle gesture *************** */ | ||||
| /* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */ | /* works now only for selection or modal paint stuff, calls exec while hold mouse, exit on release */ | ||||
| #ifdef GESTURE_MEMORY | #ifdef GESTURE_MEMORY | ||||
| int circle_select_size = 25; /* XXX - need some operator memory thing! */ | int circle_select_size = 25; /* XXX - need some operator memory thing! */ | ||||
| #endif | #endif | ||||
| static void gesture_circle_apply(bContext *C, wmOperator *op); | |||||
| int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event) | int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| op->customdata = WM_gesture_new(C, event, WM_GESTURE_CIRCLE); | op->customdata = WM_gesture_new(C, event, WM_GESTURE_CIRCLE); | ||||
| if (ISTWEAK(event->type) || ISMOUSE(event->type)) { | |||||
| wmGesture *gesture = op->customdata; | |||||
| gesture->mode = 1; | |||||
| gesture_circle_apply(C, op); | |||||
| } | |||||
| /* add modal handler */ | /* add modal handler */ | ||||
| WM_event_add_modal_handler(C, op); | WM_event_add_modal_handler(C, op); | ||||
| wm_gesture_tag_redraw(C); | wm_gesture_tag_redraw(C); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | switch (event->val) { | ||||
| case GESTURE_MODAL_CIRCLE_SUB: | case GESTURE_MODAL_CIRCLE_SUB: | ||||
| rect->xmax -= 2 + rect->xmax / 10; | rect->xmax -= 2 + rect->xmax / 10; | ||||
| if (rect->xmax < 1) rect->xmax = 1; | if (rect->xmax < 1) rect->xmax = 1; | ||||
| wm_gesture_tag_redraw(C); | wm_gesture_tag_redraw(C); | ||||
| break; | break; | ||||
| case GESTURE_MODAL_SELECT: | case GESTURE_MODAL_SELECT: | ||||
| case GESTURE_MODAL_DESELECT: | case GESTURE_MODAL_DESELECT: | ||||
| case GESTURE_MODAL_NOP: | case GESTURE_MODAL_NOP: | ||||
| if (RNA_struct_find_property(op->ptr, "gesture_mode")) | { | ||||
| RNA_int_set(op->ptr, "gesture_mode", event->val); | PropertyRNA *prop = RNA_struct_find_property(op->ptr, "gesture_mode"); | ||||
| /* If we start out with a mouse event, use once off click-drag-finish. */ | |||||
| if (event->val == GESTURE_MODAL_NOP && ISMOUSE(gesture->event_type)) { | |||||
| wm_gesture_end(C, op); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| if (prop != NULL) { | |||||
| RNA_property_int_set(op->ptr, prop, event->val); | |||||
| } | |||||
| if (event->val != GESTURE_MODAL_NOP) { | if (event->val != GESTURE_MODAL_NOP) { | ||||
| /* apply first click */ | /* apply first click */ | ||||
| gesture_circle_apply(C, op); | gesture_circle_apply(C, op); | ||||
| gesture->mode = 1; | gesture->mode = 1; | ||||
| wm_gesture_tag_redraw(C); | wm_gesture_tag_redraw(C); | ||||
| } | } | ||||
| break; | break; | ||||
| } | |||||
| case GESTURE_MODAL_CANCEL: | case GESTURE_MODAL_CANCEL: | ||||
| case GESTURE_MODAL_CONFIRM: | case GESTURE_MODAL_CONFIRM: | ||||
| wm_gesture_end(C, op); | wm_gesture_end(C, op); | ||||
| return OPERATOR_FINISHED; /* use finish or we don't get an undo */ | return OPERATOR_FINISHED; /* use finish or we don't get an undo */ | ||||
| } | } | ||||
| } | } | ||||
| #ifdef WITH_INPUT_NDOF | #ifdef WITH_INPUT_NDOF | ||||
| else if (event->type == NDOF_MOTION) { | else if (event->type == NDOF_MOTION) { | ||||
| ▲ Show 20 Lines • Show All 1,749 Lines • ▼ Show 20 Lines | void wm_operatortype_init(void) | ||||
| WM_operatortype_append(WM_OT_recover_last_session); | WM_operatortype_append(WM_OT_recover_last_session); | ||||
| WM_operatortype_append(WM_OT_recover_auto_save); | WM_operatortype_append(WM_OT_recover_auto_save); | ||||
| WM_operatortype_append(WM_OT_save_as_mainfile); | WM_operatortype_append(WM_OT_save_as_mainfile); | ||||
| WM_operatortype_append(WM_OT_save_mainfile); | WM_operatortype_append(WM_OT_save_mainfile); | ||||
| WM_operatortype_append(WM_OT_redraw_timer); | WM_operatortype_append(WM_OT_redraw_timer); | ||||
| WM_operatortype_append(WM_OT_memory_statistics); | WM_operatortype_append(WM_OT_memory_statistics); | ||||
| WM_operatortype_append(WM_OT_debug_menu); | WM_operatortype_append(WM_OT_debug_menu); | ||||
| WM_operatortype_append(WM_OT_operator_defaults); | WM_operatortype_append(WM_OT_operator_defaults); | ||||
| WM_operatortype_append(WM_OT_operator_tool_set); | |||||
| WM_operatortype_append(WM_OT_splash); | WM_operatortype_append(WM_OT_splash); | ||||
| WM_operatortype_append(WM_OT_search_menu); | WM_operatortype_append(WM_OT_search_menu); | ||||
| WM_operatortype_append(WM_OT_call_menu); | WM_operatortype_append(WM_OT_call_menu); | ||||
| WM_operatortype_append(WM_OT_call_menu_pie); | WM_operatortype_append(WM_OT_call_menu_pie); | ||||
| WM_operatortype_append(WM_OT_radial_control); | WM_operatortype_append(WM_OT_radial_control); | ||||
| WM_operatortype_append(WM_OT_stereo3d_set); | WM_operatortype_append(WM_OT_stereo3d_set); | ||||
| #if defined(WIN32) | #if defined(WIN32) | ||||
| WM_operatortype_append(WM_OT_console_toggle); | WM_operatortype_append(WM_OT_console_toggle); | ||||
| Show All 36 Lines | static void gesture_circle_modal_keymap(wmKeyConfig *keyconf) | ||||
| WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); | WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CANCEL); | ||||
| WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL); | WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, GESTURE_MODAL_CANCEL); | ||||
| WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CONFIRM); | WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, GESTURE_MODAL_CONFIRM); | ||||
| WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, 0, 0, GESTURE_MODAL_CONFIRM); | WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, 0, 0, GESTURE_MODAL_CONFIRM); | ||||
| WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_SELECT); | WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_SELECT); | ||||
| /* Note: use 'KM_ANY' for release, so the circle exits on any mouse release, | |||||
| * this is needed when circle select is activated as a tool. */ | |||||
| /* left mouse shift for deselect too */ | /* left mouse shift for deselect too */ | ||||
| WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_SHIFT, 0, GESTURE_MODAL_DESELECT); | WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_PRESS, KM_SHIFT, 0, GESTURE_MODAL_DESELECT); | ||||
| WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_SHIFT, 0, GESTURE_MODAL_NOP); | WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_NOP); | ||||
| WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_DESELECT); // default 2.4x | WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_DESELECT); // default 2.4x | ||||
| WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_NOP); // default 2.4x | WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, GESTURE_MODAL_NOP); // default 2.4x | ||||
| WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_RELEASE, 0, 0, GESTURE_MODAL_NOP); | |||||
| WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_SUB); | WM_modalkeymap_add_item(keymap, WHEELUPMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_SUB); | ||||
| WM_modalkeymap_add_item(keymap, PADMINUS, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_SUB); | WM_modalkeymap_add_item(keymap, PADMINUS, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_SUB); | ||||
| WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_ADD); | WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_ADD); | ||||
| WM_modalkeymap_add_item(keymap, PADPLUSKEY, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_ADD); | WM_modalkeymap_add_item(keymap, PADPLUSKEY, KM_PRESS, 0, 0, GESTURE_MODAL_CIRCLE_ADD); | ||||
| WM_modalkeymap_add_item(keymap, MOUSEPAN, 0, 0, 0, GESTURE_MODAL_CIRCLE_SIZE); | WM_modalkeymap_add_item(keymap, MOUSEPAN, 0, 0, 0, GESTURE_MODAL_CIRCLE_SIZE); | ||||
| /* assign map to operators */ | /* assign map to operators */ | ||||
| ▲ Show 20 Lines • Show All 337 Lines • Show Last 20 Lines | |||||