Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_gesture_ops.c
| Context not available. | |||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "ED_select_utils.h" | #include "ED_select_utils.h" | ||||
| #include "ED_view3d.h" | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| Context not available. | |||||
| int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event) | int WM_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| ToolSettings *ts = scene->toolsettings; | |||||
| const ARegion *region = CTX_wm_region(C); | const ARegion *region = CTX_wm_region(C); | ||||
| const bool wait_for_input = !WM_event_is_mouse_drag_or_press(event) && | const bool wait_for_input = !WM_event_is_mouse_drag_or_press(event) && | ||||
| RNA_boolean_get(op->ptr, "wait_for_input"); | RNA_boolean_get(op->ptr, "wait_for_input"); | ||||
| const bool auto_xray = v3d->shading.xray_mode_type == | |||||
| V3D_SHADING_XRAY_AUTOMATIC && | |||||
| ts->box_auto_xray; | |||||
| const bool xray_reset = ts->auto_xray_reset; | |||||
| if (auto_xray) { | |||||
| if (!XRAY_FLAG_ENABLED(v3d)) { | |||||
| wmOperatorType *ot = WM_operatortype_find("VIEW3D_OT_toggle_xray", true); | |||||
| BLI_assert(ot); | |||||
| PointerRNA ptr; | |||||
| WM_operator_properties_create_ptr(&ptr, ot); | |||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); | |||||
| WM_operator_properties_free(&ptr); | |||||
| if (!xray_reset) { | |||||
| ts->auto_xray_reset ^= true; | |||||
| } | |||||
| } | |||||
| else if (xray_reset) { | |||||
| ts->auto_xray_reset ^= true; | |||||
| } | |||||
| } | |||||
| if (wait_for_input) { | if (wait_for_input) { | ||||
| op->customdata = WM_gesture_new(win, region, event, WM_GESTURE_CROSS_RECT); | op->customdata = WM_gesture_new(win, region, event, WM_GESTURE_CROSS_RECT); | ||||
| Context not available. | |||||
| int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event) | int WM_gesture_box_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| ToolSettings *ts = scene->toolsettings; | |||||
| wmGesture *gesture = op->customdata; | wmGesture *gesture = op->customdata; | ||||
| rcti *rect = gesture->customdata; | rcti *rect = gesture->customdata; | ||||
| const bool xray_reset = v3d->shading.xray_mode_type == V3D_SHADING_XRAY_AUTOMATIC && | |||||
| ts->box_auto_xray && ts->auto_xray_reset; | |||||
| if (event->type == EVT_MODAL_MAP) { | if (event->type == EVT_MODAL_MAP) { | ||||
| switch (event->val) { | switch (event->val) { | ||||
| Context not available. | |||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| case GESTURE_MODAL_CANCEL: { | case GESTURE_MODAL_CANCEL: { | ||||
| if (xray_reset) { | |||||
| wmOperatorType *ot = WM_operatortype_find("VIEW3D_OT_toggle_xray", true); | |||||
| BLI_assert(ot); | |||||
| PointerRNA ptr; | |||||
| WM_operator_properties_create_ptr(&ptr, ot); | |||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); | |||||
| WM_operator_properties_free(&ptr); | |||||
| } | |||||
| gesture_modal_end(C, op); | gesture_modal_end(C, op); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Context not available. | |||||
| int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event) | int WM_gesture_circle_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| ToolSettings *ts = scene->toolsettings; | |||||
| const bool auto_xray = v3d->shading.xray_mode_type == V3D_SHADING_XRAY_AUTOMATIC && | |||||
| ts->circle_auto_xray; | |||||
| const bool xray_reset = ts->auto_xray_reset; | |||||
| const bool wait_for_input = !WM_event_is_mouse_drag_or_press(event) && | const bool wait_for_input = !WM_event_is_mouse_drag_or_press(event) && | ||||
| RNA_boolean_get(op->ptr, "wait_for_input"); | RNA_boolean_get(op->ptr, "wait_for_input"); | ||||
| if (auto_xray) { | |||||
| if (XRAY_FLAG_ENABLED(v3d)) { | |||||
| if (xray_reset) { | |||||
| ts->auto_xray_reset ^= true; | |||||
| } | |||||
| } | |||||
| else { | |||||
| wmOperatorType *ot = WM_operatortype_find("VIEW3D_OT_toggle_xray", true); | |||||
| BLI_assert(ot); | |||||
| PointerRNA ptr; | |||||
| WM_operator_properties_create_ptr(&ptr, ot); | |||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); | |||||
| WM_operator_properties_free(&ptr); | |||||
| if (!xray_reset) { | |||||
| ts->auto_xray_reset ^= true; | |||||
| } | |||||
| } | |||||
| } | |||||
| op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_CIRCLE); | op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_CIRCLE); | ||||
| wmGesture *gesture = op->customdata; | wmGesture *gesture = op->customdata; | ||||
| rcti *rect = gesture->customdata; | rcti *rect = gesture->customdata; | ||||
| Context not available. | |||||
| int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) | int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| wmGesture *gesture = op->customdata; | wmGesture *gesture = op->customdata; | ||||
| rcti *rect = gesture->customdata; | rcti *rect = gesture->customdata; | ||||
| ToolSettings *ts = scene->toolsettings; | |||||
| const bool xray_reset = v3d->shading.xray_mode_type == V3D_SHADING_XRAY_AUTOMATIC && | |||||
| ts->circle_auto_xray && ts->auto_xray_reset; | |||||
| if (event->type == MOUSEMOVE) { | if (event->type == MOUSEMOVE) { | ||||
| rect->xmin = event->xy[0] - gesture->winrct.xmin; | rect->xmin = event->xy[0] - gesture->winrct.xmin; | ||||
| rect->ymin = event->xy[1] - gesture->winrct.ymin; | rect->ymin = event->xy[1] - gesture->winrct.ymin; | ||||
| Context not available. | |||||
| } | } | ||||
| if (is_finished) { | if (is_finished) { | ||||
| if (xray_reset) { | |||||
| wmOperatorType *ot = WM_operatortype_find("VIEW3D_OT_toggle_xray", true); | |||||
| BLI_assert(ot); | |||||
| PointerRNA ptr; | |||||
| WM_operator_properties_create_ptr(&ptr, ot); | |||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); | |||||
| WM_operator_properties_free(&ptr); | |||||
| } | |||||
| gesture_modal_end(C, op); | gesture_modal_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 */ | ||||
| } | } | ||||
| Context not available. | |||||
| int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event) | int WM_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| ToolSettings *ts = scene->toolsettings; | |||||
| const bool auto_xray = v3d->shading.xray_mode_type == V3D_SHADING_XRAY_AUTOMATIC && | |||||
| ts->lasso_auto_xray; | |||||
| const bool xray_reset = ts->auto_xray_reset; | |||||
| if (auto_xray) { | |||||
| if (!XRAY_FLAG_ENABLED(v3d)) { | |||||
| wmOperatorType *ot = WM_operatortype_find("VIEW3D_OT_toggle_xray", true); | |||||
| BLI_assert(ot); | |||||
| PointerRNA ptr; | |||||
| WM_operator_properties_create_ptr(&ptr, ot); | |||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); | |||||
| WM_operator_properties_free(&ptr); | |||||
| if (!xray_reset) { | |||||
| ts->auto_xray_reset ^= true; | |||||
| } | |||||
| } | |||||
| else if (xray_reset) { | |||||
| ts->auto_xray_reset ^= true; | |||||
| } | |||||
| } | |||||
| op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_LASSO); | op->customdata = WM_gesture_new(win, CTX_wm_region(C), event, WM_GESTURE_LASSO); | ||||
| Context not available. | |||||
| int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event) | int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| wmGesture *gesture = op->customdata; | wmGesture *gesture = op->customdata; | ||||
| View3D *v3d = CTX_wm_view3d(C); | |||||
| Scene *scene = CTX_data_scene(C); | |||||
| ToolSettings *ts = scene->toolsettings; | |||||
| const bool xray_reset = v3d->shading.xray_mode_type == V3D_SHADING_XRAY_AUTOMATIC && | |||||
| ts->circle_auto_xray && ts->auto_xray_reset; | |||||
| if (event->type == EVT_MODAL_MAP) { | if (event->type == EVT_MODAL_MAP) { | ||||
| switch (event->val) { | switch (event->val) { | ||||
| Context not available. | |||||
| break; | break; | ||||
| } | } | ||||
| case EVT_ESCKEY: { | case EVT_ESCKEY: { | ||||
| if (xray_reset) { | |||||
| wmOperatorType *ot = WM_operatortype_find("VIEW3D_OT_toggle_xray", true); | |||||
| BLI_assert(ot); | |||||
| PointerRNA ptr; | |||||
| WM_operator_properties_create_ptr(&ptr, ot); | |||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr); | |||||
| WM_operator_properties_free(&ptr); | |||||
| } | |||||
| gesture_modal_end(C, op); | gesture_modal_end(C, op); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Context not available. | |||||