2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-11-24 18:59:59 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-11-24 18:59:59 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-11-24 18:59:59 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edanimation
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
#include <math.h>
|
2008-11-24 18:59:59 +00:00
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2010-03-02 17:17:34 +00:00
|
|
|
#include "DNA_object_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_scene_types.h"
|
2008-11-24 18:59:59 +00:00
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2017-02-10 00:00:21 +01:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2016-05-14 10:00:52 +02:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2009-05-08 12:51:36 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2017-04-21 14:28:23 +02:00
|
|
|
#include "BKE_layer.h"
|
2010-01-13 14:39:08 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_report.h"
|
2010-03-02 16:57:39 +00:00
|
|
|
#include "BKE_scene.h"
|
2011-07-04 15:09:02 +00:00
|
|
|
#include "BKE_screen.h"
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "BKE_unit.h"
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2013-03-07 02:44:55 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
|
|
2008-11-24 18:59:59 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2017-02-14 11:10:51 +01:00
|
|
|
#include "GPU_immediate.h"
|
2017-03-21 16:08:14 -04:00
|
|
|
#include "GPU_matrix.h"
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_state.h"
|
2017-02-14 11:10:51 +01:00
|
|
|
|
2008-11-24 18:59:59 +00:00
|
|
|
#include "UI_interface.h"
|
2008-11-27 17:58:46 +00:00
|
|
|
#include "UI_interface_icons.h"
|
2008-11-24 18:59:59 +00:00
|
|
|
#include "UI_resources.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "UI_view2d.h"
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2011-01-10 22:31:34 +00:00
|
|
|
#include "ED_anim_api.h"
|
2008-11-24 18:59:59 +00:00
|
|
|
#include "ED_markers.h"
|
2010-02-20 20:29:09 +00:00
|
|
|
#include "ED_numinput.h"
|
2010-03-02 16:57:39 +00:00
|
|
|
#include "ED_object.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_screen.h"
|
|
|
|
|
#include "ED_select_utils.h"
|
2011-03-14 10:45:42 +00:00
|
|
|
#include "ED_transform.h"
|
2010-03-30 11:38:06 +00:00
|
|
|
#include "ED_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_util.h"
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2018-06-13 15:26:59 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* ************* Marker API **************** */
|
|
|
|
|
|
2011-01-10 22:31:34 +00:00
|
|
|
/* helper function for getting the list of markers to work on */
|
2020-04-03 13:25:03 +02:00
|
|
|
static ListBase *context_get_markers(Scene *scene, ScrArea *area)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* local marker sets... */
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area) {
|
|
|
|
|
if (area->spacetype == SPACE_ACTION) {
|
|
|
|
|
SpaceAction *saction = (SpaceAction *)area->spacedata.first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* local markers can only be shown when there's only a single active action to grab them from
|
|
|
|
|
* - flag only takes effect when there's an action, otherwise it can get too confusing?
|
|
|
|
|
*/
|
|
|
|
|
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && (saction->action)) {
|
|
|
|
|
if (saction->flag & SACTION_POSEMARKERS_SHOW) {
|
|
|
|
|
return &saction->action->markers;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* default to using the scene's markers */
|
|
|
|
|
return &scene->markers;
|
2011-01-10 22:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ............. */
|
|
|
|
|
|
|
|
|
|
/* public API for getting markers from context */
|
|
|
|
|
ListBase *ED_context_get_markers(const bContext *C)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return context_get_markers(CTX_data_scene(C), CTX_wm_area(C));
|
2011-01-10 22:31:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* public API for getting markers from "animation" context */
|
|
|
|
|
ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
|
|
|
|
|
{
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ac) {
|
2020-04-03 13:25:03 +02:00
|
|
|
return context_get_markers(ac->scene, ac->area);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
/* --------------------------------- */
|
|
|
|
|
|
2014-05-29 21:16:04 +10:00
|
|
|
/**
|
|
|
|
|
* Apply some transformation to markers after the fact
|
|
|
|
|
*
|
2019-04-22 00:18:34 +10:00
|
|
|
* \param markers: List of markers to affect - this may or may not be the scene markers list,
|
|
|
|
|
* so don't assume anything.
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param scene: Current scene (for getting current frame)
|
|
|
|
|
* \param mode: (TfmMode) transform mode that this transform is for
|
|
|
|
|
* \param value: From the transform code, this is ``t->vec[0]``
|
2014-05-29 21:16:04 +10:00
|
|
|
* (which is delta transform for grab/extend, and scale factor for scale)
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param side: (B/L/R) for 'extend' functionality, which side of current frame to use
|
2011-03-14 10:45:42 +00:00
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
int ED_markers_post_apply_transform(
|
|
|
|
|
ListBase *markers, Scene *scene, int mode, float value, char side)
|
2011-03-14 10:45:42 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker;
|
|
|
|
|
float cfra = (float)CFRA;
|
|
|
|
|
int changed_tot = 0;
|
|
|
|
|
|
|
|
|
|
/* sanity check - no markers, or locked markers */
|
|
|
|
|
if ((scene->toolsettings->lock_markers) || (markers == NULL)) {
|
|
|
|
|
return changed_tot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* affect selected markers - it's unlikely that we will want to affect all in this way? */
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
switch (mode) {
|
|
|
|
|
case TFM_TIME_TRANSLATE:
|
|
|
|
|
case TFM_TIME_EXTEND: {
|
|
|
|
|
/* apply delta if marker is on the right side of the current frame */
|
|
|
|
|
if ((side == 'B') || (side == 'L' && marker->frame < cfra) ||
|
|
|
|
|
(side == 'R' && marker->frame >= cfra)) {
|
|
|
|
|
marker->frame += round_fl_to_int(value);
|
|
|
|
|
changed_tot++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case TFM_TIME_SCALE: {
|
|
|
|
|
/* rescale the distance between the marker and the current frame */
|
|
|
|
|
marker->frame = cfra + round_fl_to_int((float)(marker->frame - cfra) * value);
|
|
|
|
|
changed_tot++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed_tot;
|
2011-03-14 10:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* --------------------------------- */
|
|
|
|
|
|
2009-05-08 12:51:36 +00:00
|
|
|
/* Get the marker that is closest to this point */
|
2009-07-26 12:52:39 +00:00
|
|
|
/* XXX for select, the min_dist should be small */
|
2012-05-08 15:30:00 +00:00
|
|
|
TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x)
|
2009-05-08 12:51:36 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker, *nearest = NULL;
|
|
|
|
|
float dist, min_dist = 1000000;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (markers) {
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
dist = fabsf((float)marker->frame - x);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (dist < min_dist) {
|
|
|
|
|
min_dist = dist;
|
|
|
|
|
nearest = marker;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return nearest;
|
2009-05-08 12:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the time of the marker that occurs on a frame closest to the given time */
|
2012-04-29 17:11:40 +00:00
|
|
|
int ED_markers_find_nearest_marker_time(ListBase *markers, float x)
|
2009-05-08 12:51:36 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *nearest = ED_markers_find_nearest_marker(markers, x);
|
|
|
|
|
return (nearest) ? (nearest->frame) : round_fl_to_int(x);
|
2009-05-08 12:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-25 17:58:58 +11:00
|
|
|
void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float *r_last)
|
2009-05-08 12:51:36 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker;
|
|
|
|
|
float min, max;
|
|
|
|
|
|
|
|
|
|
/* sanity check */
|
2019-05-01 11:09:22 +10:00
|
|
|
// printf("markers = %p - %p, %p\n", markers, markers->first, markers->last);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ELEM(NULL, markers, markers->first, markers->last)) {
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_first = 0.0f;
|
|
|
|
|
*r_last = 0.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
min = FLT_MAX;
|
|
|
|
|
max = -FLT_MAX;
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (!sel || (marker->flag & SELECT)) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (marker->frame < min) {
|
2019-04-17 06:17:24 +02:00
|
|
|
min = (float)marker->frame;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
if (marker->frame > max) {
|
2019-04-17 06:17:24 +02:00
|
|
|
max = (float)marker->frame;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set the min/max values */
|
2020-03-25 17:58:58 +11:00
|
|
|
*r_first = min;
|
|
|
|
|
*r_last = max;
|
2009-05-08 12:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-30 17:03:22 +11:00
|
|
|
/**
|
|
|
|
|
* 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)
|
|
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
if (area == NULL) {
|
2020-03-26 12:49:10 +11:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-11-30 17:03:22 +11:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
switch (area->spacetype) {
|
2019-11-30 17:03:22 +11:00
|
|
|
case SPACE_ACTION: {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceAction *saction = area->spacedata.first;
|
2019-11-30 17:03:22 +11:00
|
|
|
if (saction->flag & SACTION_SHOW_MARKERS) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_GRAPH: {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceGraph *sipo = area->spacedata.first;
|
2019-11-30 17:03:22 +11:00
|
|
|
if (sipo->mode != SIPO_MODE_DRIVERS && sipo->flag & SIPO_SHOW_MARKERS) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_NLA: {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceNla *snla = area->spacedata.first;
|
2019-11-30 17:03:22 +11:00
|
|
|
if (snla->flag & SNLA_SHOW_MARKERS) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case SPACE_SEQ: {
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceSeq *seq = area->spacedata.first;
|
2019-11-30 17:03:22 +11:00
|
|
|
if (seq->flag & SEQ_SHOW_MARKERS) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-03 11:37:47 +02:00
|
|
|
static bool region_position_is_over_marker(View2D *v2d, ListBase *markers, float region_x)
|
|
|
|
|
{
|
|
|
|
|
if (markers == NULL || BLI_listbase_is_empty(markers)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float frame_at_position = UI_view2d_region_to_view_x(v2d, region_x);
|
|
|
|
|
TimeMarker *nearest_marker = ED_markers_find_nearest_marker(markers, frame_at_position);
|
|
|
|
|
float pixel_distance = UI_view2d_scale_get_x(v2d) *
|
|
|
|
|
fabsf(nearest_marker->frame - frame_at_position);
|
|
|
|
|
|
|
|
|
|
return pixel_distance <= UI_DPI_ICON_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
/* --------------------------------- */
|
|
|
|
|
|
2009-05-08 12:51:36 +00:00
|
|
|
/* Adds a marker to list of cfra elems */
|
2011-02-13 10:52:18 +00:00
|
|
|
static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only_sel)
|
2009-05-08 12:51:36 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
CfraElem *ce, *cen;
|
|
|
|
|
|
|
|
|
|
/* should this one only be considered if it is selected? */
|
2019-04-22 09:19:45 +10:00
|
|
|
if ((only_sel) && ((marker->flag & SELECT) == 0)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* insertion sort - try to find a previous cfra elem */
|
|
|
|
|
for (ce = lb->first; ce; ce = ce->next) {
|
|
|
|
|
if (ce->cfra == marker->frame) {
|
|
|
|
|
/* do because of double keys */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (marker->flag & SELECT) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ce->sel = marker->flag;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (ce->cfra > marker->frame) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
|
2019-04-22 09:19:45 +10:00
|
|
|
if (ce) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_insertlinkbefore(lb, ce, cen);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(lb, cen);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
cen->cfra = marker->frame;
|
|
|
|
|
cen->sel = marker->flag;
|
2009-05-08 12:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function makes a list of all the markers. The only_sel
|
|
|
|
|
* argument is used to specify whether only the selected markers
|
|
|
|
|
* are added.
|
|
|
|
|
*/
|
|
|
|
|
void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker;
|
|
|
|
|
|
|
|
|
|
if (lb) {
|
|
|
|
|
/* Clear the list first, since callers have no way of knowing
|
|
|
|
|
* whether this terminated early otherwise. This may lead
|
|
|
|
|
* to crashes if the user didn't clear the memory first.
|
|
|
|
|
*/
|
|
|
|
|
lb->first = lb->last = NULL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (markers == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
2019-04-17 06:17:24 +02:00
|
|
|
add_marker_to_cfra_elem(lb, marker, only_sel);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2009-05-08 12:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-07 20:33:57 +11:00
|
|
|
void ED_markers_deselect_all(ListBase *markers, int action)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (action == SEL_TOGGLE) {
|
|
|
|
|
action = ED_markers_get_first_selected(markers) ? SEL_DESELECT : SEL_SELECT;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (action == SEL_SELECT) {
|
|
|
|
|
marker->flag |= SELECT;
|
|
|
|
|
}
|
|
|
|
|
else if (action == SEL_DESELECT) {
|
|
|
|
|
marker->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
else if (action == SEL_INVERT) {
|
|
|
|
|
marker->flag ^= SELECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-07 20:33:57 +11:00
|
|
|
}
|
|
|
|
|
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
/* --------------------------------- */
|
|
|
|
|
|
2011-01-06 03:10:41 +00:00
|
|
|
/* Get the first selected marker */
|
|
|
|
|
TimeMarker *ED_markers_get_first_selected(ListBase *markers)
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (markers) {
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (marker->flag & SELECT) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return marker;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-09 01:05:40 +00:00
|
|
|
/* --------------------------------- */
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* Print debugging prints of list of markers
|
2019-04-22 00:18:34 +10:00
|
|
|
* BSI's: do NOT make static or put in if-defs as "unused code".
|
|
|
|
|
* That's too much trouble when we need to use for quick debugging!
|
2011-02-09 01:05:40 +00:00
|
|
|
*/
|
2011-02-14 03:15:55 +00:00
|
|
|
void debug_markers_print_list(ListBase *markers)
|
2011-02-09 01:05:40 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (markers == NULL) {
|
|
|
|
|
printf("No markers list to print debug for\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("List of markers follows: -----\n");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
printf(
|
|
|
|
|
"\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag);
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
printf("End of list ------------------\n");
|
2011-02-09 01:05:40 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-24 18:59:59 +00:00
|
|
|
/* ************* Marker Drawing ************ */
|
|
|
|
|
|
2020-02-25 15:09:30 +01:00
|
|
|
static void marker_color_get(const TimeMarker *marker, uchar *r_text_color, uchar *r_line_color)
|
2018-04-24 18:10:19 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (marker->flag & SELECT) {
|
2020-02-25 15:09:30 +01:00
|
|
|
UI_GetThemeColor4ubv(TH_TEXT_HI, r_text_color);
|
|
|
|
|
UI_GetThemeColor4ubv(TH_TIME_MARKER_LINE_SELECTED, r_line_color);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2020-02-25 15:09:30 +01:00
|
|
|
UI_GetThemeColor4ubv(TH_TEXT, r_text_color);
|
|
|
|
|
UI_GetThemeColor4ubv(TH_TIME_MARKER_LINE, r_line_color);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-30 14:17:53 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-25 15:09:30 +01:00
|
|
|
static void draw_marker_name(const uchar *text_color,
|
|
|
|
|
const uiFontStyle *fstyle,
|
2019-04-30 14:17:53 +02:00
|
|
|
TimeMarker *marker,
|
|
|
|
|
float marker_x,
|
|
|
|
|
float text_y)
|
|
|
|
|
{
|
|
|
|
|
const char *name = marker->name;
|
2020-02-25 15:09:30 +01:00
|
|
|
uchar final_text_color[4];
|
|
|
|
|
|
|
|
|
|
copy_v4_v4_uchar(final_text_color, text_color);
|
2018-04-24 18:10:19 +02:00
|
|
|
|
|
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-30 14:17:53 +02:00
|
|
|
if (marker->camera) {
|
|
|
|
|
Object *camera = marker->camera;
|
|
|
|
|
name = camera->id.name + 2;
|
|
|
|
|
if (camera->restrictflag & OB_RESTRICT_RENDER) {
|
2020-02-25 15:09:30 +01:00
|
|
|
final_text_color[3] = 100;
|
2019-04-30 14:17:53 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-04-24 18:10:19 +02:00
|
|
|
#endif
|
|
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
int name_x = marker_x + UI_DPI_ICON_SIZE * 0.6;
|
2020-02-25 15:09:30 +01:00
|
|
|
UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, final_text_color);
|
2018-04-24 18:10:19 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-25 15:09:30 +01:00
|
|
|
static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax)
|
2019-02-26 17:24:36 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2019-02-26 17:24:36 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
2019-02-26 17:24:36 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
float viewport_size[4];
|
|
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
|
|
|
|
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
2019-02-26 17:24:36 +01:00
|
|
|
|
2020-02-25 15:09:30 +01:00
|
|
|
immUniformColor4ubv(color);
|
2019-04-17 06:17:24 +02:00
|
|
|
immUniform1i("colors_len", 0); /* "simple" mode */
|
|
|
|
|
immUniform1f("dash_width", 6.0f);
|
|
|
|
|
immUniform1f("dash_factor", 0.5f);
|
2019-02-26 17:24:36 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 2);
|
2019-11-30 17:03:22 +11:00
|
|
|
immVertex2f(pos, xpos, ymin);
|
|
|
|
|
immVertex2f(pos, xpos, ymax);
|
2019-04-17 06:17:24 +02:00
|
|
|
immEnd();
|
2019-02-26 17:24:36 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
immUnbindProgram();
|
2019-02-26 17:24:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
static int marker_get_icon_id(TimeMarker *marker, int flag)
|
2008-11-24 18:59:59 +00:00
|
|
|
{
|
2019-04-30 14:17:53 +02:00
|
|
|
if (flag & DRAW_MARKERS_LOCAL) {
|
|
|
|
|
return (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
|
|
|
|
|
(marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
|
|
|
|
|
}
|
2018-04-24 18:10:19 +02:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-30 14:17:53 +02:00
|
|
|
else if (marker->camera) {
|
|
|
|
|
return (marker->flag & SELECT) ? ICON_OUTLINER_OB_CAMERA : ICON_CAMERA_DATA;
|
|
|
|
|
}
|
2018-04-24 18:10:19 +02:00
|
|
|
#endif
|
2019-04-30 14:17:53 +02:00
|
|
|
else {
|
|
|
|
|
return (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-24 18:10:19 +02:00
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
static void draw_marker(
|
2019-07-31 16:15:07 +02:00
|
|
|
const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height)
|
2019-04-30 14:17:53 +02:00
|
|
|
{
|
2020-02-25 15:09:30 +01:00
|
|
|
uchar line_color[4], text_color[4];
|
|
|
|
|
|
|
|
|
|
marker_color_get(marker, text_color, line_color);
|
|
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
GPU_blend(true);
|
|
|
|
|
GPU_blend_set_func_separate(
|
|
|
|
|
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
2020-02-25 15:09:30 +01:00
|
|
|
draw_marker_line(line_color, xpos, UI_DPI_FAC * 20, region_height);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
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);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
GPU_blend(false);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
float name_y = UI_DPI_FAC * 18;
|
2019-07-31 16:15:07 +02:00
|
|
|
/* Give an offset to the marker name when selected,
|
|
|
|
|
* or when near the current frame (5 frames range, starting from the current one). */
|
2019-09-14 16:52:56 +02:00
|
|
|
if ((marker->flag & SELECT) || (cfra - 4 <= marker->frame && marker->frame <= cfra)) {
|
2019-04-30 14:17:53 +02:00
|
|
|
name_y += UI_DPI_FAC * 10;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-02-25 15:09:30 +01:00
|
|
|
draw_marker_name(text_color, fstyle, marker, xpos, name_y);
|
2019-04-30 14:17:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void draw_markers_background(rctf *rect)
|
|
|
|
|
{
|
|
|
|
|
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
|
|
|
|
|
2020-04-03 16:21:24 +11:00
|
|
|
uchar shade[4];
|
2019-05-28 16:17:15 +10:00
|
|
|
UI_GetThemeColor4ubv(TH_TIME_SCRUB_BACKGROUND, shade);
|
2019-05-07 15:56:12 +02:00
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
immUniformColor4ubv(shade);
|
|
|
|
|
|
|
|
|
|
GPU_blend(true);
|
|
|
|
|
GPU_blend_set_func_separate(
|
|
|
|
|
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
|
|
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
|
|
|
|
|
|
|
|
|
|
GPU_blend(false);
|
|
|
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool marker_is_in_frame_range(TimeMarker *marker, int frame_range[2])
|
|
|
|
|
{
|
|
|
|
|
if (marker->frame < frame_range[0]) {
|
|
|
|
|
return false;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-30 14:17:53 +02:00
|
|
|
if (marker->frame > frame_range[1]) {
|
|
|
|
|
return false;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-30 14:17:53 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void get_marker_region_rect(View2D *v2d, rctf *rect)
|
|
|
|
|
{
|
|
|
|
|
rect->xmin = v2d->cur.xmin;
|
|
|
|
|
rect->xmax = v2d->cur.xmax;
|
|
|
|
|
rect->ymin = 0;
|
|
|
|
|
rect->ymax = UI_MARKER_MARGIN_Y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2])
|
|
|
|
|
{
|
|
|
|
|
float font_width_max = (10 * UI_DPI_FAC) / xscale;
|
|
|
|
|
r_range[0] = v2d->cur.xmin - sizeof(((TimeMarker *)NULL)->name) * font_width_max;
|
|
|
|
|
r_range[1] = v2d->cur.xmax + font_width_max;
|
2008-11-24 18:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* Draw Scene-Markers in time window */
|
2014-10-28 19:03:13 +01:00
|
|
|
void ED_markers_draw(const bContext *C, int flag)
|
2008-11-24 18:59:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
if (markers == NULL || BLI_listbase_is_empty(markers)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-30 14:17:53 +02:00
|
|
|
View2D *v2d = UI_view2d_fromcontext(C);
|
2019-07-31 16:15:07 +02:00
|
|
|
int cfra = CTX_data_scene(C)->r.cfra;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
rctf markers_region_rect;
|
|
|
|
|
get_marker_region_rect(v2d, &markers_region_rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
draw_markers_background(&markers_region_rect);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* no time correction for framelen! space is drawn with old values */
|
2019-04-30 14:17:53 +02:00
|
|
|
float xscale, dummy;
|
|
|
|
|
UI_view2d_scale_get(v2d, &xscale, &dummy);
|
2019-04-17 06:17:24 +02:00
|
|
|
GPU_matrix_push();
|
|
|
|
|
GPU_matrix_scale_2f(1.0f / xscale, 1.0f);
|
|
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
int clip_frame_range[2];
|
|
|
|
|
get_marker_clip_frame_range(v2d, xscale, clip_frame_range);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-30 14:17:53 +02:00
|
|
|
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
|
|
|
|
|
|
2019-07-31 16:15:07 +02:00
|
|
|
/* Separate loops in order to draw selected markers on top */
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
|
2019-04-30 14:17:53 +02:00
|
|
|
if ((marker->flag & SELECT) == 0) {
|
|
|
|
|
if (marker_is_in_frame_range(marker, clip_frame_range)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
|
2019-04-30 14:17:53 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
|
2019-04-30 14:17:53 +02:00
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
if (marker_is_in_frame_range(marker, clip_frame_range)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_matrix_pop();
|
2008-11-24 18:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
/* ************************ Marker Wrappers API ********************* */
|
2018-06-04 09:31:30 +02:00
|
|
|
/* These wrappers allow marker operators to function within the confines
|
2018-06-01 18:19:39 +02:00
|
|
|
* of standard animation editors, such that they can coexist with the
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
* primary operations of those editors.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* ------------------------ */
|
|
|
|
|
|
|
|
|
|
/* special poll() which checks if there are selected markers first */
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool ed_markers_poll_selected_markers(bContext *C)
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-11-30 17:03:22 +11:00
|
|
|
if (!ED_operator_markers_region_active(C)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* check if some marker is selected */
|
|
|
|
|
return ED_markers_get_first_selected(markers) != NULL;
|
== Long-Standing 2.5 Todo - Markers fully working again in all
animation editors (DopeSheet, Graph Editor, NLA, Sequencer) ==
=== Usage Notes ===
In animation editors, marker operators will only be considered while
the mouse is hovering near/over the horizontal scrollbar (i.e. where
the markers usually appear). That means, in order to do something to
the markers, just position your cursor in line with the row of
markers, and then use the same hotkeys you'd use in the TimeLine (so,
unlike in 2.4x, no more need to hold down extra modifier keys for this
case). In the TimeLine, nothing changes, so you don't need to worry
about mouse placement there :)
=== Technical Details ===
Since early 2.5 versions, this functionality has been disabled, as the
markers were always getting evaluated first, and hence "swallowing"
all the events before the editor's own keymaps could access them.
In order to get this working again, I've had to give every marker
operator a "wrapper" invoke callback which performs some checking to
ensure that the mouse is close to the markers (vertically) before the
operator will try to be run. This wrapper also makes sure that once
the operator has finished running, that if it didn't manage to do
anything, then the editor's own keymaps get to have a go.
The vertical tolerance used is currently 30 pixels (as was used for
the borderselect operator).
=== Other Assorted Changes ===
* Gave marker operators dependent on having selected markers to
operate on suitable poll() callbacks. These new poll callbacks ensure
that there are selected markers for the operator to operate on,
further cutting down the number of places where markers may override
standard hotkeys (and avoiding calls to the wrappers too)
* Simplified some of the selection code
* Made some formatting tweaks for consistency, and in one case so that
my text editor's function-list display doesn't get confused
2011-01-06 02:35:12 +00:00
|
|
|
}
|
2011-02-02 03:12:39 +00:00
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool ed_markers_poll_selected_no_locked_markers(bContext *C)
|
2015-04-14 12:11:24 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
ToolSettings *ts = CTX_data_tool_settings(C);
|
2015-04-14 12:11:24 +02:00
|
|
|
|
2019-11-30 17:03:22 +11:00
|
|
|
if (ts->lock_markers || !ED_operator_markers_region_active(C)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2015-04-14 12:11:24 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* check if some marker is selected */
|
|
|
|
|
return ED_markers_get_first_selected(markers) != NULL;
|
2015-04-14 12:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-22 19:37:30 +02:00
|
|
|
/* special poll() which checks if there are any markers at all first */
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool ed_markers_poll_markers_exist(bContext *C)
|
2015-06-22 19:37:30 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
ToolSettings *ts = CTX_data_tool_settings(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-11-30 17:03:22 +11:00
|
|
|
if (ts->lock_markers || !ED_operator_markers_region_active(C)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* list of markers must exist, as well as some markers in it! */
|
|
|
|
|
return (markers && markers->first);
|
2015-06-22 19:37:30 +02:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* ************************** add markers *************************** */
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2018-09-27 15:35:22 +02:00
|
|
|
/* add TimeMarker at current frame */
|
2013-07-28 17:06:31 +00:00
|
|
|
static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op))
|
2008-11-24 18:59:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
TimeMarker *marker;
|
|
|
|
|
int frame = CTX_data_scene(C)->r.cfra;
|
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (markers == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* prefer not having 2 markers at the same place,
|
|
|
|
|
* though the user can move them to overlap once added */
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
2019-04-22 09:19:45 +10:00
|
|
|
if (marker->frame == frame) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* deselect all */
|
2019-04-22 09:19:45 +10:00
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
2019-04-17 06:17:24 +02:00
|
|
|
marker->flag &= ~SELECT;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
|
|
|
|
|
marker->flag = SELECT;
|
|
|
|
|
marker->frame = frame;
|
|
|
|
|
BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); // XXX - temp code only
|
|
|
|
|
BLI_addtail(markers, marker);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2008-11-24 18:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-26 11:33:41 +00:00
|
|
|
static void MARKER_OT_add(wmOperatorType *ot)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Add Time Marker";
|
|
|
|
|
ot->description = "Add a new time marker";
|
|
|
|
|
ot->idname = "MARKER_OT_add";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_marker_add_exec;
|
2019-11-30 17:03:22 +11:00
|
|
|
ot->poll = ED_operator_markers_region_active;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* ************************** transform markers *************************** */
|
|
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* operator state vars used:
|
2012-03-03 16:31:46 +00:00
|
|
|
* frs: delta movement
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* functions:
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* init() check selection, add customdata with old values and some lookups
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* apply() do the actual movement
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* exit() cleanup, send notifier
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* cancel() to escape from modal
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* callbacks:
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
|
|
|
|
* exec() calls init, apply, exit
|
|
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* invoke() calls init, adds modal handler
|
2018-06-01 18:19:39 +02:00
|
|
|
*
|
2012-03-03 16:31:46 +00:00
|
|
|
* modal() accept modal events while doing it, ends with apply and exit, or cancel
|
|
|
|
|
*/
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
|
|
|
|
typedef struct MarkerMove {
|
2019-04-17 06:17:24 +02:00
|
|
|
SpaceLink *slink;
|
|
|
|
|
ListBase *markers;
|
|
|
|
|
int event_type; /* store invoke-event, to verify */
|
|
|
|
|
int *oldframe, evtx, firstx;
|
|
|
|
|
NumInput num;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
} MarkerMove;
|
|
|
|
|
|
2014-08-25 20:18:43 +02:00
|
|
|
static bool ed_marker_move_use_time(MarkerMove *mm)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (((mm->slink->spacetype == SPACE_SEQ) && !(((SpaceSeq *)mm->slink)->flag & SEQ_DRAWFRAMES)) ||
|
|
|
|
|
((mm->slink->spacetype == SPACE_ACTION) &&
|
|
|
|
|
(((SpaceAction *)mm->slink)->flag & SACTION_DRAWTIME)) ||
|
|
|
|
|
((mm->slink->spacetype == SPACE_GRAPH) &&
|
|
|
|
|
!(((SpaceGraph *)mm->slink)->flag & SIPO_DRAWTIME)) ||
|
|
|
|
|
((mm->slink->spacetype == SPACE_NLA) && !(((SpaceNla *)mm->slink)->flag & SNLA_DRAWTIME))) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2014-08-25 20:18:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ed_marker_move_update_header(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
MarkerMove *mm = op->customdata;
|
|
|
|
|
TimeMarker *marker, *selmarker = NULL;
|
|
|
|
|
const int offs = RNA_int_get(op->ptr, "frames");
|
|
|
|
|
char str[UI_MAX_DRAW_STR];
|
|
|
|
|
char str_offs[NUM_STR_REP_LEN];
|
|
|
|
|
int totmark;
|
|
|
|
|
const bool use_time = ed_marker_move_use_time(mm);
|
|
|
|
|
|
|
|
|
|
for (totmark = 0, marker = mm->markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
selmarker = marker;
|
|
|
|
|
totmark++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hasNumInput(&mm->num)) {
|
|
|
|
|
outputNumInput(&mm->num, str_offs, &scene->unit);
|
|
|
|
|
}
|
|
|
|
|
else if (use_time) {
|
|
|
|
|
BLI_snprintf(str_offs, sizeof(str_offs), "%.2f", FRA2TIME(offs));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_snprintf(str_offs, sizeof(str_offs), "%d", offs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totmark == 1 && selmarker) {
|
|
|
|
|
/* we print current marker value */
|
|
|
|
|
if (use_time) {
|
|
|
|
|
BLI_snprintf(
|
2019-06-11 22:25:01 +02:00
|
|
|
str, sizeof(str), TIP_("Marker %.2f offset %s"), FRA2TIME(selmarker->frame), str_offs);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2019-06-11 22:25:01 +02:00
|
|
|
BLI_snprintf(str, sizeof(str), TIP_("Marker %d offset %s"), selmarker->frame, str_offs);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2019-06-11 22:25:01 +02:00
|
|
|
BLI_snprintf(str, sizeof(str), TIP_("Marker offset %s"), str_offs);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ED_area_status_text(CTX_wm_area(C), str);
|
2014-08-25 20:18:43 +02:00
|
|
|
}
|
|
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* copy selection to temp buffer */
|
|
|
|
|
/* return 0 if not OK */
|
2014-08-25 20:18:43 +02:00
|
|
|
static bool ed_marker_move_init(bContext *C, wmOperator *op)
|
2008-11-24 18:59:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
MarkerMove *mm;
|
|
|
|
|
TimeMarker *marker;
|
|
|
|
|
int a, totmark;
|
|
|
|
|
|
|
|
|
|
if (markers == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (totmark = 0, marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
totmark++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (totmark == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
op->customdata = mm = MEM_callocN(sizeof(MarkerMove), "Markermove");
|
|
|
|
|
mm->slink = CTX_wm_space_data(C);
|
|
|
|
|
mm->markers = markers;
|
|
|
|
|
mm->oldframe = MEM_callocN(totmark * sizeof(int), "MarkerMove oldframe");
|
|
|
|
|
|
|
|
|
|
initNumInput(&mm->num);
|
|
|
|
|
mm->num.idx_max = 0; /* one axis */
|
|
|
|
|
mm->num.val_flag[0] |= NUM_NO_FRACTION;
|
|
|
|
|
mm->num.unit_sys = scene->unit.system;
|
|
|
|
|
/* No time unit supporting frames currently... */
|
|
|
|
|
mm->num.unit_type[0] = ed_marker_move_use_time(mm) ? B_UNIT_TIME : B_UNIT_NONE;
|
|
|
|
|
|
|
|
|
|
for (a = 0, marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
mm->oldframe[a] = marker->frame;
|
|
|
|
|
a++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free stuff */
|
|
|
|
|
static void ed_marker_move_exit(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
MarkerMove *mm = op->customdata;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* free data */
|
|
|
|
|
MEM_freeN(mm->oldframe);
|
|
|
|
|
MEM_freeN(op->customdata);
|
|
|
|
|
op->customdata = NULL;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* clear custom header prints */
|
|
|
|
|
ED_area_status_text(CTX_wm_area(C), NULL);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-06-03 11:37:47 +02:00
|
|
|
bool tweak = RNA_boolean_get(op->ptr, "tweak");
|
|
|
|
|
if (tweak) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
|
|
|
|
View2D *v2d = ®ion->v2d;
|
2019-06-03 11:37:47 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
if (!region_position_is_over_marker(v2d, markers, event->x - region->winrct.xmin)) {
|
2019-06-03 11:37:47 +02:00
|
|
|
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ed_marker_move_init(C, op)) {
|
|
|
|
|
MarkerMove *mm = op->customdata;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
mm->evtx = event->x;
|
|
|
|
|
mm->firstx = event->x;
|
|
|
|
|
mm->event_type = event->type;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* add temp handler */
|
|
|
|
|
WM_event_add_modal_handler(C, op);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* reset frs delta */
|
|
|
|
|
RNA_int_set(op->ptr, "frames", 0);
|
2014-08-25 20:18:43 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ed_marker_move_update_header(C, op);
|
2014-08-25 20:18:43 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2018-09-27 15:35:22 +02:00
|
|
|
/* note, init has to be called successfully */
|
2012-11-25 16:52:42 +00:00
|
|
|
static void ed_marker_move_apply(bContext *C, wmOperator *op)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2012-11-25 16:52:42 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2020-04-03 14:23:21 +02:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
Object *camera = scene->camera;
|
2012-11-25 16:52:42 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
MarkerMove *mm = op->customdata;
|
|
|
|
|
TimeMarker *marker;
|
|
|
|
|
int a, offs;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
offs = RNA_int_get(op->ptr, "frames");
|
|
|
|
|
for (a = 0, marker = mm->markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
marker->frame = mm->oldframe[a] + offs;
|
|
|
|
|
a++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-25 16:52:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-11-25 16:52:42 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-17 06:17:24 +02:00
|
|
|
/* so we get view3d redraws */
|
|
|
|
|
BKE_scene_camera_switch_update(scene);
|
2012-11-25 16:52:42 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (camera != scene->camera) {
|
2020-04-03 14:23:21 +02:00
|
|
|
BKE_screen_view3d_scene_sync(screen, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
|
|
|
|
|
}
|
2012-11-25 16:52:42 +00:00
|
|
|
#endif
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* only for modal */
|
2013-10-30 23:08:53 +00:00
|
|
|
static void ed_marker_move_cancel(bContext *C, wmOperator *op)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
RNA_int_set(op->ptr, "frames", 0);
|
|
|
|
|
ed_marker_move_apply(C, op);
|
|
|
|
|
ed_marker_move_exit(C, op);
|
2008-11-24 18:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
MarkerMove *mm = op->customdata;
|
|
|
|
|
View2D *v2d = UI_view2d_fromcontext(C);
|
|
|
|
|
const bool has_numinput = hasNumInput(&mm->num);
|
|
|
|
|
const bool use_time = ed_marker_move_use_time(mm);
|
|
|
|
|
|
|
|
|
|
/* Modal numinput active, try to handle numeric inputs first... */
|
|
|
|
|
if (event->val == KM_PRESS && has_numinput && handleNumInput(C, &mm->num, event)) {
|
|
|
|
|
float value = (float)RNA_int_get(op->ptr, "frames");
|
|
|
|
|
|
|
|
|
|
applyNumInput(&mm->num, &value);
|
|
|
|
|
if (use_time) {
|
|
|
|
|
value = TIME2FRA(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_int_set(op->ptr, "frames", (int)value);
|
|
|
|
|
ed_marker_move_apply(C, op);
|
|
|
|
|
ed_marker_move_update_header(C, op);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
bool handled = false;
|
|
|
|
|
switch (event->type) {
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_ESCKEY:
|
2019-04-17 06:17:24 +02:00
|
|
|
ed_marker_move_cancel(C, op);
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
case RIGHTMOUSE:
|
|
|
|
|
/* press = user manually demands transform to be canceled */
|
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
|
ed_marker_move_cancel(C, op);
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
/* else continue; <--- see if release event should be caught for tweak-end */
|
|
|
|
|
ATTR_FALLTHROUGH;
|
|
|
|
|
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_RETKEY:
|
|
|
|
|
case EVT_PADENTER:
|
2019-04-17 06:17:24 +02:00
|
|
|
case LEFTMOUSE:
|
|
|
|
|
case MIDDLEMOUSE:
|
|
|
|
|
if (WM_event_is_modal_tweak_exit(event, mm->event_type)) {
|
|
|
|
|
ed_marker_move_exit(C, op);
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MOUSEMOVE:
|
|
|
|
|
if (!has_numinput) {
|
|
|
|
|
float dx;
|
|
|
|
|
|
|
|
|
|
dx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
|
|
|
|
|
|
|
|
|
|
if (event->x != mm->evtx) { /* XXX maybe init for first time */
|
|
|
|
|
float fac;
|
|
|
|
|
|
|
|
|
|
mm->evtx = event->x;
|
|
|
|
|
fac = ((float)(event->x - mm->firstx) * dx);
|
|
|
|
|
|
2020-01-05 15:55:54 +01:00
|
|
|
apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, FPS, 0.1 * FPS, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
RNA_int_set(op->ptr, "frames", (int)fac);
|
|
|
|
|
ed_marker_move_apply(C, op);
|
|
|
|
|
ed_marker_move_update_header(C, op);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!handled && event->val == KM_PRESS && handleNumInput(C, &mm->num, event)) {
|
|
|
|
|
float value = (float)RNA_int_get(op->ptr, "frames");
|
|
|
|
|
|
|
|
|
|
applyNumInput(&mm->num, &value);
|
|
|
|
|
if (use_time) {
|
|
|
|
|
value = TIME2FRA(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_int_set(op->ptr, "frames", (int)value);
|
|
|
|
|
ed_marker_move_apply(C, op);
|
|
|
|
|
ed_marker_move_update_header(C, op);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ed_marker_move_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ed_marker_move_init(C, op)) {
|
|
|
|
|
ed_marker_move_apply(C, op);
|
|
|
|
|
ed_marker_move_exit(C, op);
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
return OPERATOR_PASS_THROUGH;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-26 11:33:41 +00:00
|
|
|
static void MARKER_OT_move(wmOperatorType *ot)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Move Time Marker";
|
|
|
|
|
ot->description = "Move selected time marker(s)";
|
|
|
|
|
ot->idname = "MARKER_OT_move";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_marker_move_exec;
|
2019-05-29 11:50:34 +02:00
|
|
|
ot->invoke = ed_marker_move_invoke;
|
2019-04-17 06:17:24 +02:00
|
|
|
ot->modal = ed_marker_move_modal;
|
|
|
|
|
ot->poll = ed_markers_poll_selected_no_locked_markers;
|
|
|
|
|
ot->cancel = ed_marker_move_cancel;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
2019-05-29 00:48:48 +10:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* rna storage */
|
|
|
|
|
RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX);
|
2019-06-03 11:37:47 +02:00
|
|
|
PropertyRNA *prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "tweak", 0, "Tweak", "Operator has been activated using a tweak event");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************** duplicate markers *************************** */
|
|
|
|
|
|
2012-03-03 16:31:46 +00:00
|
|
|
/* operator state vars used:
|
|
|
|
|
* frs: delta movement
|
|
|
|
|
*
|
|
|
|
|
* functions:
|
|
|
|
|
*
|
|
|
|
|
* apply() do the actual duplicate
|
|
|
|
|
*
|
|
|
|
|
* callbacks:
|
|
|
|
|
*
|
|
|
|
|
* exec() calls apply, move_exec
|
|
|
|
|
*
|
|
|
|
|
* invoke() calls apply, move_invoke
|
|
|
|
|
*
|
|
|
|
|
* modal() uses move_modal
|
|
|
|
|
*/
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2008-11-24 18:59:59 +00:00
|
|
|
/* duplicate selected TimeMarkers */
|
2010-10-16 14:32:17 +00:00
|
|
|
static void ed_marker_duplicate_apply(bContext *C)
|
2008-11-24 18:59:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
TimeMarker *marker, *newmarker;
|
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (markers == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* go through the list of markers, duplicate selected markers and add duplicated copies
|
|
|
|
|
* to the beginning of the list (unselect original markers)
|
|
|
|
|
*/
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
/* unselect selected marker */
|
|
|
|
|
marker->flag &= ~SELECT;
|
|
|
|
|
|
|
|
|
|
/* create and set up new marker */
|
|
|
|
|
newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
|
|
|
|
|
newmarker->flag = SELECT;
|
|
|
|
|
newmarker->frame = marker->frame;
|
|
|
|
|
BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-16 19:49:33 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-17 06:17:24 +02:00
|
|
|
newmarker->camera = marker->camera;
|
2009-12-16 19:49:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* new marker is added to the beginning of list */
|
|
|
|
|
// FIXME: bad ordering!
|
|
|
|
|
BLI_addhead(markers, newmarker);
|
|
|
|
|
}
|
|
|
|
|
}
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int ed_marker_duplicate_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ed_marker_duplicate_apply(C);
|
|
|
|
|
ed_marker_move_exec(C, op); /* assumes frs delta set */
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_FINISHED;
|
2008-11-24 18:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-13 09:03:46 +00:00
|
|
|
static int ed_marker_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ed_marker_duplicate_apply(C);
|
|
|
|
|
return ed_marker_move_invoke(C, op, event);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-26 11:33:41 +00:00
|
|
|
static void MARKER_OT_duplicate(wmOperatorType *ot)
|
2008-11-24 18:59:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Duplicate Time Marker";
|
|
|
|
|
ot->description = "Duplicate selected time marker(s)";
|
|
|
|
|
ot->idname = "MARKER_OT_duplicate";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_marker_duplicate_exec;
|
2019-05-29 11:50:34 +02:00
|
|
|
ot->invoke = ed_marker_duplicate_invoke;
|
2019-04-17 06:17:24 +02:00
|
|
|
ot->modal = ed_marker_move_modal;
|
|
|
|
|
ot->poll = ed_markers_poll_selected_no_locked_markers;
|
|
|
|
|
ot->cancel = ed_marker_move_cancel;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
/* rna storage */
|
|
|
|
|
RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX);
|
2008-11-24 18:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* ************************** selection ************************************/
|
|
|
|
|
|
2019-06-03 11:37:47 +02:00
|
|
|
static void deselect_markers(ListBase *markers)
|
|
|
|
|
{
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
|
2019-06-03 11:37:47 +02:00
|
|
|
marker->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
/* select/deselect TimeMarker at current frame */
|
2019-10-04 16:45:01 +02:00
|
|
|
static int select_timeline_marker_frame(ListBase *markers,
|
|
|
|
|
int frame,
|
|
|
|
|
bool extend,
|
|
|
|
|
bool wait_to_deselect_others)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-10-04 16:45:01 +02:00
|
|
|
TimeMarker *marker, *marker_selected = NULL;
|
|
|
|
|
int ret_val = OPERATOR_FINISHED;
|
|
|
|
|
|
|
|
|
|
if (extend) {
|
|
|
|
|
wait_to_deselect_others = false;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* support for selection cycling */
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->frame == frame) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
2019-10-04 16:45:01 +02:00
|
|
|
marker_selected = marker->next;
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-04 16:45:01 +02:00
|
|
|
if (wait_to_deselect_others && marker_selected) {
|
|
|
|
|
ret_val = OPERATOR_RUNNING_MODAL;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-10-04 16:45:01 +02:00
|
|
|
/* if extend is not set, then deselect markers */
|
|
|
|
|
else {
|
|
|
|
|
if (extend == false) {
|
|
|
|
|
deselect_markers(markers);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-10-04 16:45:01 +02:00
|
|
|
LISTBASE_CIRCULAR_FORWARD_BEGIN (markers, marker, marker_selected) {
|
|
|
|
|
/* this way a not-extend select will always give 1 selected marker */
|
2019-10-12 09:45:20 +11:00
|
|
|
if (marker->frame == frame) {
|
2019-10-04 16:45:01 +02:00
|
|
|
marker->flag ^= SELECT;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-10-04 16:45:01 +02:00
|
|
|
LISTBASE_CIRCULAR_FORWARD_END(markers, marker, marker_selected);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-10-04 16:45:01 +02:00
|
|
|
|
|
|
|
|
return ret_val;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2019-06-03 11:37:47 +02:00
|
|
|
static void select_marker_camera_switch(
|
|
|
|
|
bContext *C, bool camera, bool extend, ListBase *markers, int cfra)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2010-03-02 16:57:39 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-17 06:17:24 +02:00
|
|
|
if (camera) {
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
|
Base *base;
|
|
|
|
|
TimeMarker *marker;
|
|
|
|
|
int sel = 0;
|
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!extend) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_view_layer_base_deselect_all(view_layer);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->frame == cfra) {
|
|
|
|
|
sel = (marker->flag & SELECT);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->camera) {
|
|
|
|
|
if (marker->frame == cfra) {
|
|
|
|
|
base = BKE_view_layer_base_find(view_layer, marker->camera);
|
|
|
|
|
if (base) {
|
|
|
|
|
ED_object_base_select(base, sel);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (sel) {
|
2019-04-17 06:17:24 +02:00
|
|
|
ED_object_base_activate(C, base);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
|
|
|
|
}
|
2011-11-05 14:26:18 +00:00
|
|
|
#else
|
2019-04-17 06:17:24 +02:00
|
|
|
(void)camera;
|
2010-03-02 16:57:39 +00:00
|
|
|
#endif
|
2019-06-03 11:37:47 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-04 16:45:01 +02:00
|
|
|
static int ed_marker_select(
|
|
|
|
|
bContext *C, const int mval[2], bool extend, bool camera, bool wait_to_deselect_others)
|
2019-06-03 11:37:47 +02:00
|
|
|
{
|
|
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
View2D *v2d = UI_view2d_fromcontext(C);
|
2019-10-04 16:45:01 +02:00
|
|
|
int ret_val = OPERATOR_FINISHED;
|
2019-06-03 11:37:47 +02:00
|
|
|
|
2019-10-04 16:45:01 +02:00
|
|
|
if (region_position_is_over_marker(v2d, markers, mval[0])) {
|
|
|
|
|
float frame_at_mouse_position = UI_view2d_region_to_view_x(v2d, mval[0]);
|
2019-06-03 11:37:47 +02:00
|
|
|
int cfra = ED_markers_find_nearest_marker_time(markers, frame_at_mouse_position);
|
2019-10-04 16:45:01 +02:00
|
|
|
ret_val = select_timeline_marker_frame(markers, cfra, extend, wait_to_deselect_others);
|
2019-06-03 11:37:47 +02:00
|
|
|
|
|
|
|
|
select_marker_camera_switch(C, camera, extend, markers, cfra);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
deselect_markers(markers);
|
|
|
|
|
}
|
2010-03-02 16:57:39 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* allowing tweaks, but needs OPERATOR_FINISHED, otherwise renaming fails... [#25987] */
|
2019-10-04 16:45:01 +02:00
|
|
|
return ret_val | OPERATOR_PASS_THROUGH;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-04 16:45:01 +02:00
|
|
|
static int ed_marker_select_exec(bContext *C, wmOperator *op)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const bool extend = RNA_boolean_get(op->ptr, "extend");
|
2019-10-04 16:45:01 +02:00
|
|
|
const bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
|
2019-04-17 06:17:24 +02:00
|
|
|
bool camera = false;
|
2010-03-02 16:57:39 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-17 06:17:24 +02:00
|
|
|
camera = RNA_boolean_get(op->ptr, "camera");
|
2010-03-02 16:57:39 +00:00
|
|
|
#endif
|
2019-10-04 16:45:01 +02:00
|
|
|
int mval[2];
|
|
|
|
|
mval[0] = RNA_int_get(op->ptr, "mouse_x");
|
|
|
|
|
mval[1] = RNA_int_get(op->ptr, "mouse_y");
|
|
|
|
|
|
|
|
|
|
return ed_marker_select(C, mval, extend, camera, wait_to_deselect_others);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-29 02:15:13 +00:00
|
|
|
static void MARKER_OT_select(wmOperatorType *ot)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
PropertyRNA *prop;
|
2017-04-04 19:36:07 -04:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Select Time Marker";
|
|
|
|
|
ot->description = "Select time marker(s)";
|
|
|
|
|
ot->idname = "MARKER_OT_select";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->poll = ed_markers_poll_markers_exist;
|
2019-10-04 16:45:01 +02:00
|
|
|
ot->exec = ed_marker_select_exec;
|
|
|
|
|
ot->invoke = WM_generic_select_invoke;
|
|
|
|
|
ot->modal = WM_generic_select_modal;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2019-10-04 16:45:01 +02:00
|
|
|
WM_operator_properties_generic_select(ot);
|
2019-04-17 06:17:24 +02:00
|
|
|
prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2010-03-02 16:57:39 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-17 06:17:24 +02:00
|
|
|
prop = RNA_def_boolean(ot->srna, "camera", 0, "Camera", "Select the camera");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2010-03-02 16:57:39 +00:00
|
|
|
#endif
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
/* *************************** box select markers **************** */
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2018-06-04 09:31:30 +02:00
|
|
|
/* operator state vars used: (added by default WM callbacks)
|
2012-03-03 16:31:46 +00:00
|
|
|
* xmin, ymin
|
|
|
|
|
* xmax, ymax
|
|
|
|
|
*
|
|
|
|
|
* customdata: the wmGesture pointer, with subwindow
|
|
|
|
|
*
|
|
|
|
|
* callbacks:
|
|
|
|
|
*
|
2019-04-17 06:17:24 +02:00
|
|
|
* exec() has to be filled in by user
|
2012-03-03 16:31:46 +00:00
|
|
|
*
|
2012-05-08 15:30:00 +00:00
|
|
|
* invoke() default WM function
|
|
|
|
|
* adds modal handler
|
2012-03-03 16:31:46 +00:00
|
|
|
*
|
2019-04-17 06:17:24 +02:00
|
|
|
* modal() default WM function
|
2012-05-08 15:30:00 +00:00
|
|
|
* accept modal events while doing it, calls exec(), handles ESC and border drawing
|
2012-03-03 16:31:46 +00:00
|
|
|
*
|
2019-04-17 06:17:24 +02:00
|
|
|
* poll() has to be filled in by user for context
|
2012-03-03 16:31:46 +00:00
|
|
|
*/
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2019-06-03 11:37:47 +02:00
|
|
|
static int ed_marker_box_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
|
|
|
|
View2D *v2d = ®ion->v2d;
|
2019-06-03 11:37:47 +02:00
|
|
|
|
|
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
bool over_marker = region_position_is_over_marker(v2d, markers, event->x - region->winrct.xmin);
|
2019-06-03 11:37:47 +02:00
|
|
|
|
|
|
|
|
bool tweak = RNA_boolean_get(op->ptr, "tweak");
|
|
|
|
|
if (tweak && over_marker) {
|
|
|
|
|
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return WM_gesture_box_invoke(C, op, event);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
View2D *v2d = UI_view2d_fromcontext(C);
|
|
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
rctf rect;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_operator_properties_border_to_rctf(op, &rect);
|
|
|
|
|
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (markers == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
|
|
|
|
|
const bool select = (sel_op != SEL_OP_SUB);
|
|
|
|
|
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
|
|
|
|
|
ED_markers_deselect_all(markers, SEL_DESELECT);
|
|
|
|
|
}
|
2019-03-07 20:33:57 +11:00
|
|
|
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, markers) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (BLI_rctf_isect_x(&rect, marker->frame)) {
|
|
|
|
|
SET_FLAG_FROM_TEST(marker->flag, select, SELECT);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return 1;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-05 10:27:04 +10:00
|
|
|
static void MARKER_OT_select_box(wmOperatorType *ot)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Marker Box Select";
|
|
|
|
|
ot->description = "Select all time markers using box selection";
|
|
|
|
|
ot->idname = "MARKER_OT_select_box";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_marker_box_select_exec;
|
2019-06-03 11:37:47 +02:00
|
|
|
ot->invoke = ed_marker_box_select_invoke;
|
2019-04-17 06:17:24 +02:00
|
|
|
ot->modal = WM_gesture_box_modal;
|
|
|
|
|
ot->cancel = WM_gesture_box_cancel;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
ot->poll = ed_markers_poll_markers_exist;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* properties */
|
|
|
|
|
WM_operator_properties_gesture_box(ot);
|
|
|
|
|
WM_operator_properties_select_operation_simple(ot);
|
2019-06-03 11:37:47 +02:00
|
|
|
|
|
|
|
|
PropertyRNA *prop = RNA_def_boolean(
|
|
|
|
|
ot->srna, "tweak", 0, "Tweak", "Operator has been activated using a tweak event");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *********************** (de)select all ***************** */
|
|
|
|
|
|
|
|
|
|
static int ed_marker_select_all_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
if (markers == NULL) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
int action = RNA_enum_get(op->ptr, "action");
|
|
|
|
|
ED_markers_deselect_all(markers, action);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_FINISHED;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2009-11-29 22:16:29 +00:00
|
|
|
static void MARKER_OT_select_all(wmOperatorType *ot)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "(De)select all Markers";
|
|
|
|
|
ot->description = "Change selection of all time markers";
|
|
|
|
|
ot->idname = "MARKER_OT_select_all";
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_marker_select_all_exec;
|
|
|
|
|
ot->poll = ed_markers_poll_markers_exist;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* rna */
|
|
|
|
|
WM_operator_properties_select_all(ot);
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2011-01-06 03:10:41 +00:00
|
|
|
/* ***************** remove marker *********************** */
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
|
|
|
|
|
/* remove selected TimeMarkers */
|
2010-10-15 01:36:14 +00:00
|
|
|
static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
TimeMarker *marker, *nmarker;
|
|
|
|
|
bool changed = false;
|
|
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (markers == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
for (marker = markers->first; marker; marker = nmarker) {
|
|
|
|
|
nmarker = marker->next;
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
BLI_freelinkN(markers, marker);
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-26 11:33:41 +00:00
|
|
|
static void MARKER_OT_delete(wmOperatorType *ot)
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Delete Markers";
|
|
|
|
|
ot->description = "Delete selected time marker(s)";
|
|
|
|
|
ot->idname = "MARKER_OT_delete";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
2019-05-29 11:50:34 +02:00
|
|
|
ot->invoke = WM_operator_confirm;
|
2019-04-17 06:17:24 +02:00
|
|
|
ot->exec = ed_marker_delete_exec;
|
|
|
|
|
ot->poll = ed_markers_poll_selected_no_locked_markers;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-01-06 03:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* **************** rename marker ***************** */
|
|
|
|
|
|
|
|
|
|
/* rename first selected TimeMarker */
|
|
|
|
|
static int ed_marker_rename_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C));
|
2011-01-06 04:35:57 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (marker) {
|
|
|
|
|
RNA_string_get(op->ptr, "name", marker->name);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2011-01-06 03:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-29 11:50:34 +02:00
|
|
|
static int ed_marker_rename_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
2011-01-06 03:10:41 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* must initialize the marker name first if there is a marker selected */
|
|
|
|
|
TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C));
|
2019-04-22 09:19:45 +10:00
|
|
|
if (marker) {
|
2019-04-17 06:17:24 +02:00
|
|
|
RNA_string_set(op->ptr, "name", marker->name);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-05-29 12:30:30 +02:00
|
|
|
return WM_operator_props_popup_confirm(C, op, event);
|
2011-01-06 03:10:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MARKER_OT_rename(wmOperatorType *ot)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Rename Marker";
|
|
|
|
|
ot->description = "Rename first selected time marker";
|
|
|
|
|
ot->idname = "MARKER_OT_rename";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
2019-05-29 11:50:34 +02:00
|
|
|
ot->invoke = ed_marker_rename_invoke;
|
2019-04-17 06:17:24 +02:00
|
|
|
ot->exec = ed_marker_rename_exec;
|
|
|
|
|
ot->poll = ed_markers_poll_selected_no_locked_markers;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
ot->prop = RNA_def_string(ot->srna,
|
|
|
|
|
"name",
|
|
|
|
|
"RenamedMarker",
|
|
|
|
|
sizeof(((TimeMarker *)NULL)->name),
|
|
|
|
|
"Name",
|
|
|
|
|
"New name for marker");
|
2019-04-22 00:18:34 +10:00
|
|
|
#if 0
|
|
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"ensure_unique",
|
|
|
|
|
0,
|
|
|
|
|
"Ensure Unique",
|
|
|
|
|
"Ensure that new name is unique within collection of markers");
|
|
|
|
|
#endif
|
2.5: work on bringing back SpaceTime options
- RMB select, also with SHIFT
- RMB tweak for translate
- SHIFT+D dupli
- BKEY border select/deselect
- AKEY (de)select all
- XKEY delete
- GKEY grab
Added some XXX comments for future todos, especially for when other
spaces come back with time markers.
Also added ED_util for putting in all to-be-cleaned cruft
Context conflict: input methods for Markers can conflict with other
spacetypes. It was solved in pre-2.5 with manually tweaking it all over,
but I would prefer one keymap for all marker stuff. Needs some thinking...
could be solved with a boundbox check for bottom part of 2d window.
Tweak issue: both tweak styles are possible:
- Hold mouse button, move, operator ends on mouse release
- Hold mouse button, move, operator ends on mouse click
Problem is that modally handled operators use fixed keymaps... like ESC,
SPACE, ENTER, or press/release mousebutton for 'assign'. There's a lot
to say for making this all consistant, or become part of 1 general keymap?
Should also be possibe to define 'tweak' defaults for Tablet different
than for mouse...
2008-11-29 15:10:31 +00:00
|
|
|
}
|
2008-11-24 18:59:59 +00:00
|
|
|
|
2011-01-05 11:15:57 +00:00
|
|
|
/* **************** make links to scene ***************** */
|
|
|
|
|
|
2010-01-13 14:39:08 +00:00
|
|
|
static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2020-02-19 15:06:14 +11:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
2020-02-19 15:06:14 +11:00
|
|
|
Scene *scene_to = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"));
|
2019-04-17 06:17:24 +02:00
|
|
|
TimeMarker *marker, *marker_new;
|
|
|
|
|
|
|
|
|
|
if (scene_to == NULL) {
|
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Scene not found");
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scene_to == CTX_data_scene(C)) {
|
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Cannot re-link markers into the same scene");
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scene_to->toolsettings->lock_markers) {
|
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Target scene has locked markers");
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* copy markers */
|
|
|
|
|
for (marker = markers->first; marker; marker = marker->next) {
|
|
|
|
|
if (marker->flag & SELECT) {
|
|
|
|
|
marker_new = MEM_dupallocN(marker);
|
|
|
|
|
marker_new->prev = marker_new->next = NULL;
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&scene_to->markers, marker_new);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2010-01-13 14:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MARKER_OT_make_links_scene(wmOperatorType *ot)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Make Links to Scene";
|
|
|
|
|
ot->description = "Copy selected markers to another scene";
|
|
|
|
|
ot->idname = "MARKER_OT_make_links_scene";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_marker_make_links_scene_exec;
|
2019-05-29 11:50:34 +02:00
|
|
|
ot->invoke = WM_menu_invoke;
|
2019-04-17 06:17:24 +02:00
|
|
|
ot->poll = ed_markers_poll_selected_markers;
|
|
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", "");
|
|
|
|
|
RNA_def_enum_funcs(prop, RNA_scene_itemf);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE);
|
|
|
|
|
ot->prop = prop;
|
2010-01-13 14:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-16 19:49:33 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
|
|
|
|
/* ******************************* camera bind marker ***************** */
|
|
|
|
|
|
2018-04-24 18:10:19 +02:00
|
|
|
static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
|
2009-12-16 19:49:33 +00:00
|
|
|
{
|
2020-04-03 14:23:21 +02:00
|
|
|
bScreen *screen = CTX_wm_screen(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
|
|
|
|
ListBase *markers = ED_context_get_markers(C);
|
|
|
|
|
TimeMarker *marker;
|
|
|
|
|
|
|
|
|
|
/* Don't do anything if we don't have a camera selected */
|
|
|
|
|
if (ob == NULL) {
|
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Select a camera to bind to a marker on this frame");
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add new marker, unless we already have one on this frame, in which case, replace it */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (markers == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
marker = ED_markers_find_nearest_marker(markers, CFRA);
|
|
|
|
|
if ((marker == NULL) || (marker->frame != CFRA)) {
|
|
|
|
|
marker = MEM_callocN(sizeof(TimeMarker), "Camera TimeMarker");
|
|
|
|
|
marker->flag = SELECT;
|
|
|
|
|
marker->frame = CFRA;
|
|
|
|
|
BLI_addtail(markers, marker);
|
|
|
|
|
|
|
|
|
|
/* deselect all others, so that the user can then move it without problems */
|
2020-04-03 19:15:01 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, m, markers) {
|
2019-04-17 06:17:24 +02:00
|
|
|
if (m != marker) {
|
|
|
|
|
m->flag &= ~SELECT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* bind to the nominated camera (as set in operator props) */
|
|
|
|
|
marker->camera = ob;
|
|
|
|
|
|
|
|
|
|
/* camera may have changes */
|
|
|
|
|
BKE_scene_camera_switch_update(scene);
|
2020-04-03 14:23:21 +02:00
|
|
|
BKE_screen_view3d_scene_sync(screen, scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
|
|
|
|
|
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); /* so we get view3d redraws */
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2009-12-16 19:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void MARKER_OT_camera_bind(wmOperatorType *ot)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Bind Camera to Markers";
|
|
|
|
|
ot->description = "Bind the selected camera to a marker on the current frame";
|
|
|
|
|
ot->idname = "MARKER_OT_camera_bind";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = ed_marker_camera_bind_exec;
|
2019-11-30 17:03:22 +11:00
|
|
|
ot->poll = ED_operator_markers_region_active;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2009-12-16 19:49:33 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-11-24 18:59:59 +00:00
|
|
|
/* ************************** registration **********************************/
|
|
|
|
|
|
2008-12-17 15:38:40 +00:00
|
|
|
/* called in screen_ops.c:ED_operatortypes_screen() */
|
2009-07-02 19:41:31 +00:00
|
|
|
void ED_operatortypes_marker(void)
|
2008-11-24 18:59:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_operatortype_append(MARKER_OT_add);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_move);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_duplicate);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_select);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_select_box);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_select_all);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_delete);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_rename);
|
|
|
|
|
WM_operatortype_append(MARKER_OT_make_links_scene);
|
2009-12-16 19:49:33 +00:00
|
|
|
#ifdef DURIAN_CAMERA_SWITCH
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_operatortype_append(MARKER_OT_camera_bind);
|
2009-12-16 19:49:33 +00:00
|
|
|
#endif
|
2008-11-24 18:59:59 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-17 15:38:40 +00:00
|
|
|
/* called in screen_ops.c:ED_keymap_screen() */
|
2014-03-16 22:11:14 +11:00
|
|
|
void ED_keymap_marker(wmKeyConfig *keyconf)
|
2008-12-17 15:38:40 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_keymap_ensure(keyconf, "Markers", 0, 0);
|
2011-06-01 06:26:54 +00:00
|
|
|
}
|