Clip editor mode selection: show menu with modes on TAB

This seems to be the only straightforward way to switch fast between
modes without keeping bunch of shortcuts and current mode in head.
This commit is contained in:
Sergey Sharybin 2012-07-12 12:06:40 +00:00
parent 5a878c50eb
commit 8ef23c6743
5 changed files with 27 additions and 34 deletions

@ -1301,6 +1301,17 @@ class CLIP_MT_mask(Menu):
layout.menu("CLIP_MT_mask_animation")
class CLIP_MT_select_mode(Menu):
bl_label = "Select Mode"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator_enum("clip.mode_set", "mode")
class CLIP_MT_mask_visibility(Menu):
bl_label = "Show/Hide"

@ -62,6 +62,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "UI_view2d.h"
@ -1074,15 +1075,8 @@ static int mode_set_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc = CTX_wm_space_clip(C);
int mode = RNA_enum_get(op->ptr, "mode");
int toggle = RNA_boolean_get(op->ptr, "toggle");
if (sc->mode == mode) {
if (toggle)
sc->mode = SC_MODE_TRACKING;
}
else {
sc->mode = mode;
}
sc->mode = mode;
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL);
@ -1091,13 +1085,6 @@ static int mode_set_exec(bContext *C, wmOperator *op)
void CLIP_OT_mode_set(wmOperatorType *ot)
{
static EnumPropertyItem mode_items[] = {
{SC_MODE_TRACKING, "TRACKING", 0, "Tracking", "Show tracking and solving tools"},
{SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", 0, "Reconstruction", "Show tracking/reconstruction tools"},
{SC_MODE_DISTORTION, "DISTORTION", 0, "Distortion", "Show distortion tools"},
{0, NULL, 0, NULL, NULL}};
/* identifiers */
ot->name = "Set Clip Mode";
ot->description = "Set the clip interaction mode";
@ -1109,8 +1096,7 @@ void CLIP_OT_mode_set(wmOperatorType *ot)
ot->poll = ED_space_clip_poll;
/* properties */
RNA_def_enum(ot->srna, "mode", mode_items, SC_MODE_TRACKING, "Mode", "");
RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "");
RNA_def_enum(ot->srna, "mode", clip_editor_mode_items, SC_MODE_TRACKING, "Mode", "");
}
/********************** macroses *********************/

@ -559,13 +559,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "sequence", TRUE);
/* mode */
kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "mode", SC_MODE_RECONSTRUCTION);
RNA_boolean_set(kmi->ptr, "toggle", TRUE);
kmi = WM_keymap_add_item(keymap, "CLIP_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "mode", SC_MODE_DISTORTION);
RNA_boolean_set(kmi->ptr, "toggle", TRUE);
WM_keymap_add_menu(keymap, "CLIP_MT_select_mode", TABKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0);

@ -127,6 +127,8 @@ extern EnumPropertyItem ramp_blend_items[];
extern EnumPropertyItem prop_dynamicpaint_type_items[];
extern EnumPropertyItem clip_editor_mode_items[];
struct bContext;
struct PointerRNA;
struct PropertyRNA;

@ -118,6 +118,15 @@ EnumPropertyItem viewport_shade_items[] = {
{0, NULL, 0, NULL, NULL}
};
EnumPropertyItem clip_editor_mode_items[] = {
{SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"},
{SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction",
"Show tracking/reconstruction tools"},
{SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"},
{SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"},
{0, NULL, 0, NULL, NULL}
};
#ifdef RNA_RUNTIME
#include "DNA_anim_types.h"
@ -3011,15 +3020,6 @@ static void rna_def_space_clip(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem mode_items[] = {
{SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"},
{SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", ICON_SNAP_FACE, "Reconstruction",
"Show tracking/reconstruction tools"},
{SC_MODE_DISTORTION, "DISTORTION", ICON_GRID, "Distortion", "Show distortion tools"},
{SC_MODE_MASKEDIT, "MASKEDIT", ICON_MOD_MASK, "Mask editing", "Show mask editing tools"},
{0, NULL, 0, NULL, NULL}
};
static EnumPropertyItem view_items[] = {
{SC_VIEW_CLIP, "CLIP", ICON_SEQUENCE, "Clip", "Show editing clip preview"},
{SC_VIEW_GRAPH, "GRAPH", ICON_IPO, "Graph", "Show graph view for active element"},
@ -3086,7 +3086,7 @@ static void rna_def_space_clip(BlenderRNA *brna)
/* mode */
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mode");
RNA_def_property_enum_items(prop, mode_items);
RNA_def_property_enum_items(prop, clip_editor_mode_items);
RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_clip_mode_update");