use ED_markers_get_first_selected() where possible, simplify ed_marker_rename_exec
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user