From bba20eb5ae5e20a1ce4dcf74fa50bf6971315423 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 Jan 2011 04:35:57 +0000 Subject: use ED_markers_get_first_selected() where possible, simplify ed_marker_rename_exec --- source/blender/editors/animation/anim_markers.c | 32 ++++++++-------------- .../blender/editors/gpencil/editaction_gpencil.c | 11 ++------ source/blender/editors/interface/interface_panel.c | 2 +- source/blender/editors/space_action/action_edit.c | 9 ++---- source/blender/editors/space_graph/graph_edit.c | 9 ++---- 5 files changed, 19 insertions(+), 44 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 924cd346865..4e77e15b282 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1192,29 +1192,19 @@ static void MARKER_OT_delete(wmOperatorType *ot) /* rename first selected TimeMarker */ static int ed_marker_rename_exec(bContext *C, wmOperator *op) { - ListBase *markers= context_get_markers(C); - TimeMarker *marker; - short changed= 0; - - if (markers == NULL) - return OPERATOR_CANCELLED; - - for (marker= markers->first; marker; marker= marker->next) { - if (marker->flag & SELECT) { - /* directly get new name */ - RNA_string_get(op->ptr, "name", marker->name); - - changed= 1; - break; - } - } - - if (changed) { + TimeMarker *marker= ED_markers_get_first_selected(context_get_markers(C)); + + if(marker) { + RNA_string_get(op->ptr, "name", marker->name); + WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; } - - return OPERATOR_FINISHED; } static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *evt) @@ -1244,7 +1234,7 @@ static void MARKER_OT_rename(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", 64, "Name", "New name for marker"); + ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", sizeof(((TimeMarker *)NULL)->name), "Name", "New name for marker"); //RNA_def_boolean(ot->srna, "ensure_unique", 0, "Ensure Unique", "Ensure that new name is unique within collection of markers"); } diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index d76e5fcf17c..0ee8b914205 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -668,15 +668,10 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) } else { /* try to find a marker */ - for (marker= scene->markers.first; marker; marker=marker->next) { - if (marker->flag & SELECT) { - initialised = 1; - break; - } + marker= ED_markers_get_first_selected(&scene->markers); + if(marker) { + initialised= 1; } - - if (initialised == 0) - marker = NULL; } } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d6cb8161916..88eabf7a8a2 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -798,7 +798,7 @@ void uiEndPanels(const bContext *C, ARegion *ar) if(block->active && block->panel) ui_offset_panel_block(block); - /* consistancy; are panels not made, whilst they have tabs */ + /* consistency; are panels not made, whilst they have tabs */ for(panot= ar->panels.first; panot; panot= panot->next) { if((panot->runtime_flag & PNL_ACTIVE)==0) { // not made diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index afda04d1c45..250ce37826b 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -57,6 +57,7 @@ #include "ED_keyframes_edit.h" #include "ED_screen.h" #include "ED_transform.h" +#include "ED_markers.h" #include "WM_api.h" #include "WM_types.h" @@ -1298,13 +1299,7 @@ static void mirror_action_keys(bAnimContext *ac, short mode) TimeMarker *marker= NULL; /* find first selected marker */ - if (ac->markers) { - for (marker= ac->markers->first; marker; marker=marker->next) { - if (marker->flag & SELECT) { - break; - } - } - } + marker= ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 3602977bfa3..c948cf6c20d 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -60,6 +60,7 @@ #include "ED_keyframes_edit.h" #include "ED_screen.h" #include "ED_transform.h" +#include "ED_markers.h" #include "WM_api.h" #include "WM_types.h" @@ -1769,13 +1770,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) TimeMarker *marker= NULL; /* find first selected marker */ - if (ac->markers) { - for (marker= ac->markers->first; marker; marker=marker->next) { - if (marker->flag & SELECT) { - break; - } - } - } + marker= ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) -- cgit v1.2.3