[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43250] branches/soc-2011-onion-uv-tools/ source/blender/editors: Add operator to quickly toggle Uv Sculpt on/off.
Campbell Barton
ideasman42 at gmail.com
Tue Jan 10 02:28:58 CET 2012
For these kinds of keybingins you can use the existing operator:
WM_OT_context_toggle
On Tue, Jan 10, 2012 at 10:53 AM, Antony Riakiotakis <kalast at gmail.com> wrote:
> Revision: 43250
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43250
> Author: psy-fi
> Date: 2012-01-09 23:53:35 +0000 (Mon, 09 Jan 2012)
> Log Message:
> -----------
> Add operator to quickly toggle Uv Sculpt on/off. Default key is Q
>
> Modified Paths:
> --------------
> branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/paint_ops.c
> branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
>
> Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/paint_ops.c
> ===================================================================
> --- branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/paint_ops.c 2012-01-09 22:18:04 UTC (rev 43249)
> +++ branches/soc-2011-onion-uv-tools/source/blender/editors/sculpt_paint/paint_ops.c 2012-01-09 23:53:35 UTC (rev 43250)
> @@ -694,6 +694,8 @@
> keymap= WM_keymap_find(keyconf, "UV Sculpt", 0, 0);
> keymap->poll= uv_sculpt_poll;
>
> + WM_keymap_add_item(keymap, "UV_OT_toggle_uv_sculpt", QKEY, KM_PRESS, 0, 0);
> +
> WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
> RNA_boolean_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
>
>
> Modified: branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c
> ===================================================================
> --- branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2012-01-09 22:18:04 UTC (rev 43249)
> +++ branches/soc-2011-onion-uv-tools/source/blender/editors/uvedit/uvedit_ops.c 2012-01-09 23:53:35 UTC (rev 43250)
> @@ -3296,6 +3296,31 @@
> ot->poll= ED_operator_uvedit;
> }
>
> +
> +static int toggle_uv_sculpt_exec(bContext *C, wmOperator *UNUSED(op)){
> + ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings;
> + toolsettings->use_uv_sculpt = !toolsettings->use_uv_sculpt;
> +
> + ED_space_image_uv_sculpt_update(CTX_data_main(C)->wm.first, toolsettings);
> + ED_region_tag_redraw(CTX_wm_region(C));
> + return OPERATOR_FINISHED;
> +}
> +
> +static void UV_OT_toggle_uv_sculpt(wmOperatorType *ot)
> +{
> + /* identifiers */
> + ot->name = "Toggle Uv Sculpt";
> + ot->description = "Turn Uv Svulpting On and Off";
> + ot->idname = "UV_OT_toggle_uv_sculpt";
> +
> + /* flags */
> + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
> +
> + /* api callbacks */
> + ot->exec = toggle_uv_sculpt_exec;
> + ot->poll = ED_operator_uvedit;
> +}
> +
> /* ************************** registration **********************************/
>
> void ED_operatortypes_uvedit(void)
> @@ -3335,6 +3360,8 @@
>
> WM_operatortype_append(UV_OT_cursor_set);
> WM_operatortype_append(UV_OT_tile_set);
> +
> + WM_operatortype_append(UV_OT_toggle_uv_sculpt);
> }
>
> void ED_keymap_uvedit(wmKeyConfig *keyconf)
> @@ -3345,6 +3372,9 @@
> keymap= WM_keymap_find(keyconf, "UV Editor", 0, 0);
> keymap->poll= ED_operator_uvedit_can_uv_sculpt;
>
> + /* Uv sculpt toggle */
> + WM_keymap_add_item(keymap, "UV_OT_toggle_uv_sculpt", QKEY, KM_PRESS, 0, 0);
> +
> /* Mark edge seam */
> WM_keymap_add_item(keymap, "UV_OT_mark_seam_uv", EKEY, KM_PRESS, KM_CTRL, 0);
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
--
- Campbell
More information about the Bf-committers
mailing list