fix [#34804] Only timeline_markers[0] is selectable if multiple markers at same frame

also add macros for looping on listbases as if they were circular lists which is handy for cycling over items.
This commit is contained in:
Campbell Barton
2013-03-28 20:58:14 +00:00
parent 986bbbfe8a
commit 93deb27dd4
2 changed files with 56 additions and 14 deletions

View File

@@ -75,6 +75,37 @@ void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src);
/* create a generic list node containing link to provided data */
struct LinkData *BLI_genericNodeN(void *data);
/**
* Does a full loop on the list, with any value acting as first
* (handy for cycling items)
*
* \code{.c}
*
* LISTBASE_CIRCULAR_FORWARD_BEGIN (listbase, item, item_init) {
* ...operate on marker...
* }
* LISTBASE_CIRCULAR_FORWARD_END (listbase, item, item_init);
*
* \endcode
*/
#define LISTBASE_CIRCULAR_FORWARD_BEGIN(lb, lb_iter, lb_init) \
if ((lb)->first && (lb_init || (lb_init = (lb)->first))) { \
lb_iter = lb_init; \
do {
#define LISTBASE_CIRCULAR_FORWARD_END(lb, lb_iter, lb_init) \
} while ((lb_iter = (lb_iter)->next ? (lb_iter)->next : (lb)->first), \
(lb_iter != lb_init)); \
}
#define LISTBASE_CIRCULAR_BACKWARD_BEGIN(lb, lb_iter, lb_init) \
if ((lb)->last && (lb_init || (lb_init = (lb)->last))) { \
lb_iter = lb_init; \
do {
#define LISTBASE_CIRCULAR_BACKWARD_END(lb, lb_iter, lb_init) \
} while ((lb_iter = (lb_iter)->prev ? (lb_iter)->prev : (lb)->last), \
(lb_iter != lb_init)); \
}
#ifdef __cplusplus
}
#endif

View File

@@ -1017,24 +1017,35 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
/* ************************** selection ************************************/
/* select/deselect TimeMarker at current frame */
static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned char shift)
static void select_timeline_marker_frame(ListBase *markers, int frame, bool extend)
{
TimeMarker *marker;
int select = 0;
TimeMarker *marker, *marker_first = NULL;
/* support for selection cycling */
for (marker = markers->first; marker; marker = marker->next) {
/* if Shift is not set, then deselect Markers */
if (!shift) marker->flag &= ~SELECT;
/* this way a not-shift select will allways give 1 selected marker */
if ((marker->frame == frame) && (!select)) {
if (marker->flag & SELECT)
marker->flag &= ~SELECT;
else
marker->flag |= SELECT;
select = 1;
if (marker->frame == frame) {
if (marker->flag & SELECT) {
marker_first = marker->next;
break;
}
}
}
/* if extend is not set, then deselect markers */
if (extend == false) {
for (marker = markers->first; marker; marker = marker->next) {
marker->flag &= ~SELECT;
}
}
LISTBASE_CIRCULAR_FORWARD_BEGIN (markers, marker, marker_first) {
/* this way a not-extend select will allways give 1 selected marker */
if (marker->frame == frame) {
marker->flag ^= SELECT;
break;
}
}
LISTBASE_CIRCULAR_FORWARD_END (markers, marker, marker_first);
}
static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool camera)