use ED_markers_get_first_selected() where possible, simplify ed_marker_rename_exec
authorCampbell Barton <ideasman42@gmail.com>
Thu, 6 Jan 2011 04:35:57 +0000 (04:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 6 Jan 2011 04:35:57 +0000 (04:35 +0000)
source/blender/editors/animation/anim_markers.c
source/blender/editors/gpencil/editaction_gpencil.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_graph/graph_edit.c

index 924cd346865cc8e8d282b493ed5e4ebe225b8bbd..4e77e15b2822ac9113ad39f95496ec4f9fe98459 100644 (file)
@@ -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");
 }
 
index d76e5fcf17cbdd9b09a9a51d9e7b7db8372c8129..0ee8b914205882cf1d596f2f31aa7451b1b6104c 100644 (file)
@@ -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;
                }
        }
        
index d6cb81619166b3e24e4413fb412b6b363002cfab..88eabf7a8a2d694f4998e0a77ceb0483a3dd7561 100644 (file)
@@ -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
 
index afda04d1c456ba55c2290ef8ac4346a3f8011fd7..250ce37826bdc711cc02172886a1989cf8cc1126 100644 (file)
@@ -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)
index 3602977bfa333105e1974a488f9e634b1610532e..c948cf6c20d11c2afc0ed4d15fae5d298a6d796c 100644 (file)
@@ -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)