From dc87d09b8b3249898e0f0d301fa22f03cff9d6d5 Mon Sep 17 00:00:00 2001 From: Alessio Monti di Sopra Date: Sat, 30 Nov 2019 17:03:22 +1100 Subject: UI: allow to hide markers region per editor Instead of having the option to show marker lines, make the marker region optional. - Added a Show Markers entry in the View menu of the animation editors. - If the markers region is not active then the Marker menu gets hidden. - Removed marker menu from the driver editor and don't allow to use marker operators. --- source/blender/editors/animation/anim_markers.c | 98 +++++++++++++--------- source/blender/editors/space_action/space_action.c | 8 +- source/blender/editors/space_graph/space_graph.c | 7 +- source/blender/editors/space_nla/space_nla.c | 7 +- .../editors/space_sequencer/sequencer_draw.c | 5 +- .../editors/space_sequencer/space_sequencer.c | 2 +- 6 files changed, 71 insertions(+), 56 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 36583ecf060..13358808a23 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -228,6 +228,47 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la *last = max; } +/** + * Function used in operator polls, checks whether the markers region is currently drawn in the + * editor in which the operator is called. + */ +static bool ED_operator_markers_region_active(bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + + switch (sa->spacetype) { + case SPACE_ACTION: { + SpaceAction *saction = sa->spacedata.first; + if (saction->flag & SACTION_SHOW_MARKERS) { + return true; + } + break; + } + case SPACE_GRAPH: { + SpaceGraph *sipo = sa->spacedata.first; + if (sipo->mode != SIPO_MODE_DRIVERS && sipo->flag & SIPO_SHOW_MARKERS) { + return true; + } + break; + } + case SPACE_NLA: { + SpaceNla *snla = sa->spacedata.first; + if (snla->flag & SNLA_SHOW_MARKERS) { + return true; + } + break; + } + case SPACE_SEQ: { + SpaceSeq *seq = sa->spacedata.first; + if (seq->flag & SEQ_SHOW_MARKERS) { + return true; + } + break; + } + } + return false; +} + static bool region_position_is_over_marker(View2D *v2d, ListBase *markers, float region_x) { if (markers == NULL || BLI_listbase_is_empty(markers)) { @@ -409,7 +450,7 @@ static void draw_marker_name(const uiFontStyle *fstyle, UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, text_color); } -static void draw_marker_line(const float color[4], float x, float ymin, float ymax) +static void draw_marker_line(const float color[4], int xpos, int ymin, int ymax) { GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -426,8 +467,8 @@ static void draw_marker_line(const float color[4], float x, float ymin, float ym immUniform1f("dash_factor", 0.5f); immBegin(GPU_PRIM_LINES, 2); - immVertex2f(pos, x, ymin); - immVertex2f(pos, x, ymax); + immVertex2f(pos, xpos, ymin); + immVertex2f(pos, xpos, ymax); immEnd(); immUnbindProgram(); @@ -449,26 +490,6 @@ static int marker_get_icon_id(TimeMarker *marker, int flag) } } -static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos, int height) -{ -#ifdef DURIAN_CAMERA_SWITCH - if ((marker->camera) || (flag & DRAW_MARKERS_LINES)) -#else - if (flag & DRAW_MARKERS_LINES) -#endif - { - float color[4]; - if (marker->flag & SELECT) { - copy_v4_fl4(color, 1.0f, 1.0f, 1.0f, 0.38f); - } - else { - copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f); - } - - draw_marker_line(color, xpos, UI_DPI_FAC * 20, height); - } -} - static void draw_marker( const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height) { @@ -476,7 +497,15 @@ static void draw_marker( GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - draw_marker_line_if_necessary(marker, flag, xpos, region_height); + float color[4]; + if (marker->flag & SELECT) { + copy_v4_fl4(color, 1.0f, 1.0f, 1.0f, 0.38f); + } + else { + copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f); + } + + draw_marker_line(color, xpos, UI_DPI_FAC * 20, region_height); int icon_id = marker_get_icon_id(marker, flag); UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id); @@ -599,8 +628,7 @@ static bool ed_markers_poll_selected_markers(bContext *C) { ListBase *markers = ED_context_get_markers(C); - /* first things first: markers can only exist in timeline views */ - if (ED_operator_animview_active(C) == 0) { + if (!ED_operator_markers_region_active(C)) { return 0; } @@ -613,12 +641,7 @@ static bool ed_markers_poll_selected_no_locked_markers(bContext *C) ListBase *markers = ED_context_get_markers(C); ToolSettings *ts = CTX_data_tool_settings(C); - if (ts->lock_markers) { - return 0; - } - - /* first things first: markers can only exist in timeline views */ - if (ED_operator_animview_active(C) == 0) { + if (ts->lock_markers || !ED_operator_markers_region_active(C)) { return 0; } @@ -632,12 +655,7 @@ static bool ed_markers_poll_markers_exist(bContext *C) ListBase *markers = ED_context_get_markers(C); ToolSettings *ts = CTX_data_tool_settings(C); - if (ts->lock_markers) { - return 0; - } - - /* first things first: markers can only exist in timeline views */ - if (ED_operator_animview_active(C) == 0) { + if (ts->lock_markers || !ED_operator_markers_region_active(C)) { return 0; } @@ -692,7 +710,7 @@ static void MARKER_OT_add(wmOperatorType *ot) /* api callbacks */ ot->exec = ed_marker_add_exec; - ot->poll = ED_operator_animview_active; + ot->poll = ED_operator_markers_region_active; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1661,7 +1679,7 @@ static void MARKER_OT_camera_bind(wmOperatorType *ot) /* api callbacks */ ot->exec = ed_marker_camera_bind_exec; - ot->poll = ED_operator_animview_active; + ot->poll = ED_operator_markers_region_active; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 1685852dd02..901efbdf0ff 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -71,7 +71,7 @@ static SpaceLink *action_new(const ScrArea *sa, const Scene *scene) saction->autosnap = SACTSNAP_FRAME; saction->mode = SACTCONT_DOPESHEET; saction->mode_prev = SACTCONT_DOPESHEET; - saction->flag = SACTION_SHOW_INTERPOLATION | SACTION_SHOW_MARKER_LINES; + saction->flag = SACTION_SHOW_INTERPOLATION | SACTION_SHOW_MARKERS; saction->ads.filterflag |= ADS_FILTER_SUMMARY; @@ -215,10 +215,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN; - if (saction->flag & SACTION_SHOW_MARKER_LINES) { - marker_flag |= DRAW_MARKERS_LINES; + + if (saction->flag & SACTION_SHOW_MARKERS) { + ED_markers_draw(C, marker_flag); } - ED_markers_draw(C, marker_flag); /* caches */ if (saction->mode == SACTCONT_TIMELINE) { diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index b8d9d3b791f..eb7ba480296 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -81,7 +81,7 @@ static SpaceLink *graph_new(const ScrArea *UNUSED(sa), const Scene *scene) /* settings for making it easier by default to just see what you're interested in tweaking */ sipo->ads->filterflag |= ADS_FILTER_ONLYSEL; - sipo->flag |= SIPO_SELVHANDLESONLY | SIPO_MARKER_LINES; + sipo->flag |= SIPO_SELVHANDLESONLY | SIPO_SHOW_MARKERS; /* header */ ar = MEM_callocN(sizeof(ARegion), "header for graphedit"); @@ -296,10 +296,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) if (sipo->mode != SIPO_MODE_DRIVERS) { UI_view2d_view_orthoSpecial(ar, v2d, 1); int marker_draw_flag = DRAW_MARKERS_MARGIN; - if (sipo->flag & SIPO_MARKER_LINES) { - marker_draw_flag |= DRAW_MARKERS_LINES; + if (sipo->flag & SIPO_SHOW_MARKERS) { + ED_markers_draw(C, marker_draw_flag); } - ED_markers_draw(C, marker_draw_flag); } /* preview range */ diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index f274f3c93ec..5cd2a86adf8 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -71,7 +71,7 @@ static SpaceLink *nla_new(const ScrArea *sa, const Scene *scene) /* set auto-snapping settings */ snla->autosnap = SACTSNAP_FRAME; - snla->flag = SNLA_SHOW_MARKER_LINES; + snla->flag = SNLA_SHOW_MARKERS; /* header */ ar = MEM_callocN(sizeof(ARegion), "header for nla"); @@ -274,10 +274,9 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar) /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); int marker_draw_flag = DRAW_MARKERS_MARGIN; - if (snla->flag & SNLA_SHOW_MARKER_LINES) { - marker_draw_flag |= DRAW_MARKERS_LINES; + if (snla->flag & SNLA_SHOW_MARKERS) { + ED_markers_draw(C, marker_draw_flag); } - ED_markers_draw(C, marker_draw_flag); /* preview range */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 5b2ea9d4793..e6f3a362487 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -2067,10 +2067,9 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); int marker_draw_flag = DRAW_MARKERS_MARGIN; - if (sseq->flag & SEQ_SHOW_MARKER_LINES) { - marker_draw_flag |= DRAW_MARKERS_LINES; + if (sseq->flag & SEQ_SHOW_MARKERS) { + ED_markers_draw(C, marker_draw_flag); } - ED_markers_draw(C, marker_draw_flag); UI_view2d_view_ortho(v2d); /* draw cache on top of markers area */ diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index e1cf6d00b90..6e1b9d62f0e 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -93,7 +93,7 @@ static SpaceLink *sequencer_new(const ScrArea *UNUSED(sa), const Scene *scene) sseq->chanshown = 0; sseq->view = SEQ_VIEW_SEQUENCE; sseq->mainb = SEQ_DRAW_IMG_IMBUF; - sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKER_LINES; + sseq->flag = SEQ_SHOW_GPENCIL | SEQ_USE_ALPHA | SEQ_SHOW_MARKERS; /* header */ ar = MEM_callocN(sizeof(ARegion), "header for sequencer"); -- cgit v1.2.3