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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-07-11 14:37:38 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-07-11 14:37:38 +0400
commit6e6dd576a8a0ad902cc152bcac558659c27671e0 (patch)
tree19c8a1225caccbc7f6594555c6c972b737646048
parent35b6f41f4651992bc6a1726fc3d123f7bc54d32d (diff)
Operator to move mask layers up and down in the list
-rw-r--r--release/scripts/startup/bl_ui/space_clip.py24
-rw-r--r--source/blender/editors/mask/mask_edit.c3
-rw-r--r--source/blender/editors/mask/mask_intern.h2
-rw-r--r--source/blender/editors/mask/mask_ops.c71
4 files changed, 93 insertions, 7 deletions
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 374588939e2..a590a6cea94 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -677,26 +677,36 @@ class CLIP_PT_mask_layers(Panel):
sc = context.space_data
mask = sc.mask
+ active_layer = mask.layers.active
+
+ rows = 5 if active_layer else 2
row = layout.row()
row.template_list(mask, "layers",
- mask, "active_layer_index", rows=3)
+ mask, "active_layer_index", rows=rows)
sub = row.column(align=True)
sub.operator("mask.layer_new", icon='ZOOMIN', text="")
sub.operator("mask.layer_remove", icon='ZOOMOUT', text="")
- active = mask.layers.active
- if active:
- layout.prop(active, "name")
+ if active_layer:
+ sub.separator()
+
+ props = sub.operator("mask.layer_move", icon='TRIA_UP', text="")
+ props.direction = 'UP'
+
+ props = sub.operator("mask.layer_move", icon='TRIA_DOWN', text="")
+ props.direction = 'DOWN'
+
+ layout.prop(active_layer, "name")
# blending
row = layout.row(align=True)
- row.prop(active, "alpha")
- row.prop(active, "invert", text="", icon='IMAGE_ALPHA')
+ row.prop(active_layer, "alpha")
+ row.prop(active_layer, "invert", text="", icon='IMAGE_ALPHA')
- layout.prop(active, "blend")
+ layout.prop(active_layer, "blend")
class CLIP_PT_active_mask_spline(Panel):
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index cce7e26115e..b9522540e67 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -238,6 +238,9 @@ void ED_operatortypes_mask(void)
WM_operatortype_append(MASK_OT_shape_key_clear);
WM_operatortype_append(MASK_OT_shape_key_feather_reset);
WM_operatortype_append(MASK_OT_shape_key_rekey);
+
+ /* layers */
+ WM_operatortype_append(MASK_OT_layer_move);
}
void ED_keymap_mask(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index f1d72f59078..bad0a9c28a8 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -70,6 +70,8 @@ struct MaskSplinePoint *ED_mask_point_find_nearest(
struct MaskLayer **masklay_r, struct MaskSpline **spline_r, int *is_handle_r,
float *score);
+void MASK_OT_layer_move(struct wmOperatorType *ot);
+
/* mask_relationships.c */
void MASK_OT_parent_set(struct wmOperatorType *ot);
void MASK_OT_parent_clear(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 91ba05c1ab2..902d065e87b 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -1341,3 +1341,74 @@ void MASK_OT_feather_weight_clear(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+/******************** move mask layer operator *********************/
+
+static int mask_layer_move_poll(bContext *C)
+{
+ if (ED_maskedit_mask_poll(C)) {
+ Mask *mask = CTX_data_edit_mask(C);
+
+ return mask->masklay_tot > 0;
+ }
+
+ return FALSE;
+}
+
+static int mask_layer_move_exec(bContext *C, wmOperator *op)
+{
+ Mask *mask = CTX_data_edit_mask(C);
+ MaskLayer *mask_layer = BLI_findlink(&mask->masklayers, mask->masklay_act);
+ MaskLayer *mask_layer_other;
+ int direction = RNA_enum_get(op->ptr, "direction");
+
+ if (!mask_layer)
+ return OPERATOR_CANCELLED;
+
+ if (direction == -1) {
+ mask_layer_other = mask_layer->prev;
+
+ if (!mask_layer_other)
+ return OPERATOR_CANCELLED;
+
+ BLI_remlink(&mask->masklayers, mask_layer);
+ BLI_insertlinkbefore(&mask->masklayers, mask_layer_other, mask_layer);
+ mask->masklay_act--;
+ }
+ else if (direction == 1) {
+ mask_layer_other = mask_layer->next;
+
+ if (!mask_layer_other)
+ return OPERATOR_CANCELLED;
+
+ BLI_remlink(&mask->masklayers, mask_layer);
+ BLI_insertlinkafter(&mask->masklayers, mask_layer_other, mask_layer);
+ mask->masklay_act++;
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void MASK_OT_layer_move(wmOperatorType *ot)
+{
+ static EnumPropertyItem direction_items[] = {
+ {-1, "UP", 0, "Up", ""},
+ {1, "DOWN", 0, "Down", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name = "Move Layer";
+ ot->description = "Move the active layer up/down in the list";
+ ot->idname = "MASK_OT_layer_move";
+
+ /* api callbacks */
+ ot->exec = mask_layer_move_exec;
+ ot->poll = mask_layer_move_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to move the active layer");
+}