2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-14 14:43:08 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 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-12-14 14:43:08 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_action/space_action.c
|
|
|
|
|
* \ingroup spaction
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include "DNA_action_types.h"
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
#include "DNA_group_types.h"
|
2018-04-19 18:03:15 +02:00
|
|
|
#include "DNA_object_types.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
|
2018-04-19 16:31:19 +02:00
|
|
|
#include "RNA_access.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
2018-04-19 16:31:19 +02:00
|
|
|
#include "WM_message.h"
|
|
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "ED_space_api.h"
|
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
2011-06-04 17:03:46 +00:00
|
|
|
#include "ED_screen.h"
|
2008-12-20 08:24:24 +00:00
|
|
|
#include "ED_anim_api.h"
|
2008-12-14 14:43:08 +00:00
|
|
|
#include "ED_markers.h"
|
|
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
#include "action_intern.h" /* own include */
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2016-05-08 14:38:30 +12:00
|
|
|
/* ******************** manage regions ********************* */
|
|
|
|
|
|
|
|
|
|
ARegion *action_has_buttons_region(ScrArea *sa)
|
|
|
|
|
{
|
|
|
|
|
ARegion *ar, *arnew;
|
|
|
|
|
|
|
|
|
|
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
|
|
|
|
|
if (ar) return ar;
|
|
|
|
|
|
|
|
|
|
/* add subdiv level; after main */
|
|
|
|
|
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
|
|
|
|
|
|
|
|
|
/* is error! */
|
|
|
|
|
if (ar == NULL) return NULL;
|
|
|
|
|
|
|
|
|
|
arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
|
|
|
|
|
|
|
|
|
|
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
|
|
|
|
|
arnew->regiontype = RGN_TYPE_UI;
|
|
|
|
|
arnew->alignment = RGN_ALIGN_RIGHT;
|
|
|
|
|
|
|
|
|
|
arnew->flag = RGN_FLAG_HIDDEN;
|
|
|
|
|
|
|
|
|
|
return arnew;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* ******************** default callbacks for action space ***************** */
|
|
|
|
|
|
2018-04-21 19:30:56 +02:00
|
|
|
static SpaceLink *action_new(const ScrArea *sa, const Scene *scene)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
|
|
|
|
SpaceAction *saction;
|
2008-12-27 05:24:03 +00:00
|
|
|
ARegion *ar;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
saction = MEM_callocN(sizeof(SpaceAction), "initaction");
|
|
|
|
|
saction->spacetype = SPACE_ACTION;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2009-02-09 04:39:25 +00:00
|
|
|
saction->autosnap = SACTSNAP_FRAME;
|
2012-05-08 16:02:13 +00:00
|
|
|
saction->mode = SACTCONT_DOPESHEET;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2011-08-14 04:55:52 +00:00
|
|
|
saction->ads.filterflag |= ADS_FILTER_SUMMARY;
|
|
|
|
|
|
2018-04-20 13:45:48 +02:00
|
|
|
/* enable all cache display */
|
|
|
|
|
saction->cache_display |= TIME_CACHE_DISPLAY;
|
|
|
|
|
saction->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
|
|
|
|
|
saction->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
|
|
|
|
|
saction->cache_display |= TIME_CACHE_RIGIDBODY;
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* header */
|
2012-05-08 16:02:13 +00:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "header for action");
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
BLI_addtail(&saction->regionbase, ar);
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->regiontype = RGN_TYPE_HEADER;
|
|
|
|
|
ar->alignment = RGN_ALIGN_BOTTOM;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2008-12-18 09:20:29 +00:00
|
|
|
/* channel list region */
|
2015-11-28 17:14:45 +01:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "channel region for action");
|
2008-12-18 09:20:29 +00:00
|
|
|
BLI_addtail(&saction->regionbase, ar);
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->regiontype = RGN_TYPE_CHANNELS;
|
|
|
|
|
ar->alignment = RGN_ALIGN_LEFT;
|
2008-12-18 09:20:29 +00:00
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
/* only need to set scroll settings, as this will use 'listview' v2d configuration */
|
2008-12-18 23:23:09 +00:00
|
|
|
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
|
2008-12-21 11:56:42 +00:00
|
|
|
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
2008-12-18 09:20:29 +00:00
|
|
|
|
2016-05-08 14:38:30 +12:00
|
|
|
/* ui buttons */
|
|
|
|
|
ar = MEM_callocN(sizeof(ARegion), "buttons region for action");
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&saction->regionbase, ar);
|
|
|
|
|
ar->regiontype = RGN_TYPE_UI;
|
|
|
|
|
ar->alignment = RGN_ALIGN_RIGHT;
|
|
|
|
|
ar->flag = RGN_FLAG_HIDDEN;
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* main region */
|
|
|
|
|
ar = MEM_callocN(sizeof(ARegion), "main region for action");
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
BLI_addtail(&saction->regionbase, ar);
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->regiontype = RGN_TYPE_WINDOW;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2016-01-23 01:50:11 +13:00
|
|
|
ar->v2d.tot.xmin = (float)(SFRA - 10);
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f;
|
2016-01-23 01:50:11 +13:00
|
|
|
ar->v2d.tot.xmax = (float)(EFRA + 10);
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->v2d.tot.ymax = 0.0f;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2009-01-01 08:08:55 +00:00
|
|
|
ar->v2d.cur = ar->v2d.tot;
|
2008-12-17 10:25:02 +00:00
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->v2d.min[0] = 0.0f;
|
|
|
|
|
ar->v2d.min[1] = 0.0f;
|
2008-12-17 10:25:02 +00:00
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->v2d.max[0] = MAXFRAMEF;
|
|
|
|
|
ar->v2d.max[1] = FLT_MAX;
|
2011-04-21 15:53:30 +00:00
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->v2d.minzoom = 0.01f;
|
|
|
|
|
ar->v2d.maxzoom = 50;
|
|
|
|
|
ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
|
2008-12-17 10:25:02 +00:00
|
|
|
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
2012-05-08 16:02:13 +00:00
|
|
|
ar->v2d.keepzoom = V2D_LOCKZOOM_Y;
|
|
|
|
|
ar->v2d.keepofs = V2D_KEEPOFS_Y;
|
|
|
|
|
ar->v2d.align = V2D_ALIGN_NO_POS_Y;
|
2008-12-21 11:56:42 +00:00
|
|
|
ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
return (SpaceLink *)saction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* not spacelink itself */
|
2010-10-16 08:03:28 +00:00
|
|
|
static void action_free(SpaceLink *UNUSED(sl))
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
2012-10-26 04:14:10 +00:00
|
|
|
// SpaceAction *saction = (SpaceAction *) sl;
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* spacetype; init callback */
|
2010-10-16 08:03:28 +00:00
|
|
|
static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
Added a new notifyer, NC_SPACE_CHANGED, to signal an editor that
replaces another so it can do updates (e.g. dopesheet editor can
sync channel selection).
Also coded a simple optimization for allocating small objects,
based on mempools. It's #ifdef'd out, you can enabled it by
defining OPTIMIZE_SMALL_BLOCKS (e.g. adding -DDOPTIMIZE_SMALL_BLOCKS to
your compiler flags).
We suffer from a great deal of performance loss from the system allocator
(vgroups, ghash, edgehash, the singly-linked list implementation in blenlib,
editmesh, and likely a great many areas I'm forgetting), and this is the
common solution for handling the many-small-objects problem. It's not
really production-ready yet (it's long-term memory consequencers need to
be profiled first, and the implementation tweaked as necassary), but for
people on systems with slow system allocators it's worth trying.
Note that since this creates a guardedalloc<->blenlib link, the build systems
need to be updated accordingly (I've already done this for scons, though I'm
not sure if the player builds).
2010-01-21 03:08:57 +00:00
|
|
|
SpaceAction *saction = sa->spacedata.first;
|
2018-04-19 16:04:26 +02:00
|
|
|
|
Added a new notifyer, NC_SPACE_CHANGED, to signal an editor that
replaces another so it can do updates (e.g. dopesheet editor can
sync channel selection).
Also coded a simple optimization for allocating small objects,
based on mempools. It's #ifdef'd out, you can enabled it by
defining OPTIMIZE_SMALL_BLOCKS (e.g. adding -DDOPTIMIZE_SMALL_BLOCKS to
your compiler flags).
We suffer from a great deal of performance loss from the system allocator
(vgroups, ghash, edgehash, the singly-linked list implementation in blenlib,
editmesh, and likely a great many areas I'm forgetting), and this is the
common solution for handling the many-small-objects problem. It's not
really production-ready yet (it's long-term memory consequencers need to
be profiled first, and the implementation tweaked as necassary), but for
people on systems with slow system allocators it's worth trying.
Note that since this creates a guardedalloc<->blenlib link, the build systems
need to be updated accordingly (I've already done this for scons, though I'm
not sure if the player builds).
2010-01-21 03:08:57 +00:00
|
|
|
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SpaceLink *action_duplicate(SpaceLink *sl)
|
|
|
|
|
{
|
2012-05-08 16:02:13 +00:00
|
|
|
SpaceAction *sactionn = MEM_dupallocN(sl);
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
/* clear or remove stuff from old */
|
|
|
|
|
|
|
|
|
|
return (SpaceLink *)sactionn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void action_main_region_init(wmWindowManager *wm, ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2008-12-17 10:25:02 +00:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
/* own keymap */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0);
|
2008-12-14 14:43:08 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2016-05-08 14:38:30 +12:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
|
|
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void action_main_region_draw(const bContext *C, ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
|
|
|
|
/* draw entirely, view changes should be handled here */
|
2012-05-08 16:02:13 +00:00
|
|
|
SpaceAction *saction = CTX_wm_space_action(C);
|
2018-04-19 18:03:15 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
Object *obact = CTX_data_active_object(C);
|
2008-12-22 09:43:54 +00:00
|
|
|
bAnimContext ac;
|
2012-05-08 16:02:13 +00:00
|
|
|
View2D *v2d = &ar->v2d;
|
2008-12-18 09:20:29 +00:00
|
|
|
View2DGrid *grid;
|
|
|
|
|
View2DScrollers *scrollers;
|
2018-04-24 19:18:22 +02:00
|
|
|
short marker_flag = 0;
|
|
|
|
|
short cfra_flag = 0;
|
|
|
|
|
short unit = 0;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
/* clear and setup matrix */
|
2010-04-06 07:02:16 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
2008-12-14 14:43:08 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2008-12-18 09:20:29 +00:00
|
|
|
/* time grid */
|
2012-05-08 16:02:13 +00:00
|
|
|
unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
|
|
|
|
|
grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
|
2008-12-18 09:20:29 +00:00
|
|
|
UI_view2d_grid_free(grid);
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2013-04-10 16:59:55 +00:00
|
|
|
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
|
2018-04-19 18:03:15 +02:00
|
|
|
|
|
|
|
|
/* start and end frame */
|
|
|
|
|
ANIM_draw_framerange(scene, v2d);
|
|
|
|
|
|
2008-12-22 08:13:25 +00:00
|
|
|
/* data */
|
2.5 - Action Editor: All Keyframe Selection Tools Ported
User Notes (for using tools whose behaviour has changed):
* Mouse Selection Tools:
1) Click on keyframe to modify its selection. Holding the 'Shift' modifier when doing so, will result in keyframe selection being toggled instead of replacing existing selections.
2) Click on either side of the current frame indicator while holding the 'Alt' modifier. This will select only all the keyframes on the relevant side of the current frame indicator.
3) Click on a keyframe while holding the 'Ctrl' modifier. This will select all the keyframes that fall on that frame.
* Borderselect Tools
1) BKEY selects all the keyframes within the specified range (as per normal)
2) ALT-BKEY will select either all the keyframes in the frame-range specified or the channel range specified, depending on which axis of the select region was larger. This method is prejudiced towards frame-range selection.
Code Notes:
* Finished porting over all of the remaining keyframe selection tools, and recoded the ported ones to make them easier to use (after running into some technical limitations)
* Simplified the way to check if 'animation context' is valid by moving a necessary check into that function.
* Refactored internal keyframe-looping tools to reduce the amount of code needed per tool to edit keyframes, removing a lot of the unnecessary bulk. Now, the ipo/icu_keys_bezier_loop functions recieve a few more arguments (1st arg is pointer to generic customdata, and another defines a validation callback which makes it easier to reuse some of the select callbacks).
* Added 'totrect' adjustment for number of channels being shown in Action Editor, so that scrolling will be limited to where there is data (and also so that scroller displays more relevant context info).
For this to work, filtering channels now returns the number of channels extracted. This may come into use for other tools if there's such a need.
* I still need to port over some code for markers, which is required for some of the tools which use them. For now, those tools do nothing.
* Grease-Pencil editing mode in Action Editor is currently non-functional (code is commented out due to missing dependencies). This is currently pending the re-implementation of Grease Pencil in 2.5
2008-12-26 10:55:07 +00:00
|
|
|
if (ANIM_animdata_get_context(C, &ac)) {
|
2008-12-22 09:43:54 +00:00
|
|
|
draw_channel_strips(&ac, saction, ar);
|
|
|
|
|
}
|
2008-12-22 08:13:25 +00:00
|
|
|
|
2008-12-20 08:24:24 +00:00
|
|
|
/* current frame */
|
2018-04-24 19:18:22 +02:00
|
|
|
if (saction->flag & SACTION_DRAWTIME) cfra_flag |= DRAWCFRA_UNIT_SECONDS;
|
|
|
|
|
ANIM_draw_cfra(C, v2d, cfra_flag);
|
2008-12-20 08:24:24 +00:00
|
|
|
|
2008-12-21 03:14:01 +00:00
|
|
|
/* markers */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_orthoSpecial(ar, v2d, 1);
|
2011-01-09 23:16:05 +00:00
|
|
|
|
2018-04-24 19:18:22 +02:00
|
|
|
marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN;
|
|
|
|
|
ED_markers_draw(C, marker_flag);
|
2008-12-21 03:14:01 +00:00
|
|
|
|
2018-04-19 16:04:26 +02:00
|
|
|
/* caches */
|
|
|
|
|
if (saction->mode == SACTCONT_TIMELINE) {
|
2018-04-19 18:03:15 +02:00
|
|
|
timeline_draw_cache(saction, obact, scene);
|
2018-04-19 16:04:26 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-20 08:24:24 +00:00
|
|
|
/* preview range */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2013-05-18 10:24:38 +00:00
|
|
|
ANIM_draw_previewrange(C, v2d, 0);
|
2013-04-10 16:59:55 +00:00
|
|
|
|
|
|
|
|
/* callback */
|
|
|
|
|
UI_view2d_view_ortho(v2d);
|
|
|
|
|
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
/* reset view matrix */
|
|
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
|
|
2008-12-18 09:20:29 +00:00
|
|
|
/* scrollers */
|
2012-05-08 16:02:13 +00:00
|
|
|
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
2008-12-18 09:20:29 +00:00
|
|
|
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
|
|
|
|
UI_view2d_scrollers_free(scrollers);
|
2018-04-24 19:18:22 +02:00
|
|
|
|
|
|
|
|
/* draw current frame number-indicator on top of scrollers */
|
|
|
|
|
if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) {
|
|
|
|
|
UI_view2d_view_orthoSpecial(ar, v2d, 1);
|
|
|
|
|
ANIM_draw_cfra_number(C, v2d, cfra_flag);
|
|
|
|
|
}
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-18 09:20:29 +00:00
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void action_channel_region_init(wmWindowManager *wm, ARegion *ar)
|
2008-12-18 09:20:29 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2008-12-18 09:20:29 +00:00
|
|
|
|
2012-12-26 13:05:39 +00:00
|
|
|
/* ensure the 2d view sync works - main region has bottom scroller */
|
|
|
|
|
ar->v2d.scroll = V2D_SCROLL_BOTTOM;
|
|
|
|
|
|
2008-12-18 09:20:29 +00:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
|
|
|
|
|
|
|
|
|
|
/* own keymap */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0);
|
2008-12-18 09:20:29 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2016-05-08 14:38:30 +12:00
|
|
|
|
|
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
|
|
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
2008-12-18 09:20:29 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void action_channel_region_draw(const bContext *C, ARegion *ar)
|
2008-12-18 09:20:29 +00:00
|
|
|
{
|
|
|
|
|
/* draw entirely, view changes should be handled here */
|
2008-12-22 09:43:54 +00:00
|
|
|
bAnimContext ac;
|
2012-05-08 16:02:13 +00:00
|
|
|
View2D *v2d = &ar->v2d;
|
2008-12-18 09:20:29 +00:00
|
|
|
|
|
|
|
|
/* clear and setup matrix */
|
2010-04-06 07:02:16 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
2008-12-18 09:20:29 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2008-12-18 09:20:29 +00:00
|
|
|
|
2008-12-22 08:13:25 +00:00
|
|
|
/* data */
|
2.5 - Action Editor: All Keyframe Selection Tools Ported
User Notes (for using tools whose behaviour has changed):
* Mouse Selection Tools:
1) Click on keyframe to modify its selection. Holding the 'Shift' modifier when doing so, will result in keyframe selection being toggled instead of replacing existing selections.
2) Click on either side of the current frame indicator while holding the 'Alt' modifier. This will select only all the keyframes on the relevant side of the current frame indicator.
3) Click on a keyframe while holding the 'Ctrl' modifier. This will select all the keyframes that fall on that frame.
* Borderselect Tools
1) BKEY selects all the keyframes within the specified range (as per normal)
2) ALT-BKEY will select either all the keyframes in the frame-range specified or the channel range specified, depending on which axis of the select region was larger. This method is prejudiced towards frame-range selection.
Code Notes:
* Finished porting over all of the remaining keyframe selection tools, and recoded the ported ones to make them easier to use (after running into some technical limitations)
* Simplified the way to check if 'animation context' is valid by moving a necessary check into that function.
* Refactored internal keyframe-looping tools to reduce the amount of code needed per tool to edit keyframes, removing a lot of the unnecessary bulk. Now, the ipo/icu_keys_bezier_loop functions recieve a few more arguments (1st arg is pointer to generic customdata, and another defines a validation callback which makes it easier to reuse some of the select callbacks).
* Added 'totrect' adjustment for number of channels being shown in Action Editor, so that scrolling will be limited to where there is data (and also so that scroller displays more relevant context info).
For this to work, filtering channels now returns the number of channels extracted. This may come into use for other tools if there's such a need.
* I still need to port over some code for markers, which is required for some of the tools which use them. For now, those tools do nothing.
* Grease-Pencil editing mode in Action Editor is currently non-functional (code is commented out due to missing dependencies). This is currently pending the re-implementation of Grease Pencil in 2.5
2008-12-26 10:55:07 +00:00
|
|
|
if (ANIM_animdata_get_context(C, &ac)) {
|
2010-10-16 08:03:28 +00:00
|
|
|
draw_channel_names((bContext *)C, &ac, ar);
|
2008-12-22 09:43:54 +00:00
|
|
|
}
|
2008-12-18 09:20:29 +00:00
|
|
|
|
|
|
|
|
/* reset view matrix */
|
|
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
|
|
2012-12-26 13:05:39 +00:00
|
|
|
/* no scrollers here */
|
2008-12-18 09:20:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2015-11-28 17:14:45 +01:00
|
|
|
static void action_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
2009-12-07 21:51:44 +00:00
|
|
|
ED_region_header_init(ar);
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
static void action_header_region_draw(const bContext *C, ARegion *ar)
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
2009-12-07 21:51:44 +00:00
|
|
|
ED_region_header(C, ar);
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-02 09:58:01 +10:00
|
|
|
static void action_channel_region_listener(
|
|
|
|
|
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
|
|
|
|
|
wmNotifier *wmn, const Scene *UNUSED(scene))
|
2009-01-05 09:54:39 +00:00
|
|
|
{
|
|
|
|
|
/* context changes */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->category) {
|
2009-07-10 10:48:25 +00:00
|
|
|
case NC_ANIMATION:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
2009-01-05 09:54:39 +00:00
|
|
|
case NC_SCENE:
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->data) {
|
2009-01-05 09:54:39 +00:00
|
|
|
case ND_OB_ACTIVE:
|
2009-08-24 04:31:13 +00:00
|
|
|
case ND_FRAME:
|
2009-01-05 09:54:39 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NC_OBJECT:
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->data) {
|
2009-01-05 09:54:39 +00:00
|
|
|
case ND_BONE_ACTIVE:
|
|
|
|
|
case ND_BONE_SELECT:
|
2009-02-09 10:04:11 +00:00
|
|
|
case ND_KEYS:
|
2009-01-05 09:54:39 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
2009-12-13 23:51:41 +00:00
|
|
|
case ND_MODIFIER:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->action == NA_RENAME)
|
2009-12-13 23:51:41 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2016-02-09 00:05:09 +13:00
|
|
|
case NC_GPENCIL:
|
2016-12-28 16:54:57 +13:00
|
|
|
if (ELEM(wmn->action, NA_RENAME, NA_SELECTED))
|
2016-02-09 00:05:09 +13:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
2009-12-10 09:58:10 +00:00
|
|
|
case NC_ID:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->action == NA_RENAME)
|
2009-12-13 23:51:41 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2009-12-10 09:58:10 +00:00
|
|
|
break;
|
2009-01-28 18:26:47 +00:00
|
|
|
default:
|
2012-05-08 16:02:13 +00:00
|
|
|
if (wmn->data == ND_KEYS)
|
2009-01-28 18:26:47 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2009-01-05 09:54:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 09:58:01 +10:00
|
|
|
static void action_main_region_listener(
|
|
|
|
|
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
|
|
|
|
|
wmNotifier *wmn, const Scene *UNUSED(scene))
|
2008-12-14 14:43:08 +00:00
|
|
|
{
|
|
|
|
|
/* context changes */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->category) {
|
2009-07-10 10:48:25 +00:00
|
|
|
case NC_ANIMATION:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
2008-12-27 16:09:56 +00:00
|
|
|
case NC_SCENE:
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->data) {
|
2009-09-19 12:36:22 +00:00
|
|
|
case ND_RENDER_OPTIONS:
|
2008-12-29 12:15:42 +00:00
|
|
|
case ND_OB_ACTIVE:
|
2008-12-27 16:09:56 +00:00
|
|
|
case ND_FRAME:
|
2018-04-19 16:31:19 +02:00
|
|
|
case ND_FRAME_RANGE:
|
2008-12-27 16:09:56 +00:00
|
|
|
case ND_MARKERS:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-12-23 11:02:39 +00:00
|
|
|
break;
|
2008-12-29 12:15:42 +00:00
|
|
|
case NC_OBJECT:
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->data) {
|
2010-01-25 19:42:33 +00:00
|
|
|
case ND_TRANSFORM:
|
|
|
|
|
/* moving object shouldn't need to redraw action */
|
|
|
|
|
break;
|
2008-12-29 12:15:42 +00:00
|
|
|
case ND_BONE_ACTIVE:
|
|
|
|
|
case ND_BONE_SELECT:
|
2009-01-28 18:26:47 +00:00
|
|
|
case ND_KEYS:
|
2008-12-29 12:15:42 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-11-11 09:11:21 +00:00
|
|
|
case NC_NODE:
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmn->action) {
|
2009-11-11 09:11:21 +00:00
|
|
|
case NA_EDITED:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-12-10 09:58:10 +00:00
|
|
|
case NC_ID:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->action == NA_RENAME)
|
2009-12-13 23:51:41 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2009-12-10 09:58:10 +00:00
|
|
|
break;
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
case NC_SCREEN:
|
|
|
|
|
if (ELEM(wmn->data, ND_LAYER)) {
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-01-28 18:26:47 +00:00
|
|
|
default:
|
2012-05-08 16:02:13 +00:00
|
|
|
if (wmn->data == ND_KEYS)
|
2009-01-28 18:26:47 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2008-12-23 11:02:39 +00:00
|
|
|
}
|
2008-12-14 14:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-19 16:31:19 +02:00
|
|
|
static void saction_main_region_message_subscribe(
|
|
|
|
|
const struct bContext *UNUSED(C),
|
|
|
|
|
struct WorkSpace *UNUSED(workspace), struct Scene *scene,
|
|
|
|
|
struct bScreen *screen, struct ScrArea *sa, struct ARegion *ar,
|
|
|
|
|
struct wmMsgBus *mbus)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr;
|
2018-04-20 17:08:06 +02:00
|
|
|
RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, sa->spacedata.first, &ptr);
|
2018-04-19 16:31:19 +02:00
|
|
|
|
|
|
|
|
wmMsgSubscribeValue msg_sub_value_region_tag_redraw = {
|
|
|
|
|
.owner = ar,
|
|
|
|
|
.user_data = ar,
|
|
|
|
|
.notify = ED_region_do_msg_notify_tag_redraw,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Timeline depends on scene properties. */
|
|
|
|
|
{
|
|
|
|
|
bool use_preview = (scene->r.flag & SCER_PRV_RANGE);
|
|
|
|
|
extern PropertyRNA rna_Scene_frame_start;
|
|
|
|
|
extern PropertyRNA rna_Scene_frame_end;
|
|
|
|
|
extern PropertyRNA rna_Scene_frame_preview_start;
|
|
|
|
|
extern PropertyRNA rna_Scene_frame_preview_end;
|
|
|
|
|
extern PropertyRNA rna_Scene_use_preview_range;
|
|
|
|
|
extern PropertyRNA rna_Scene_frame_current;
|
|
|
|
|
const PropertyRNA *props[] = {
|
|
|
|
|
use_preview ? &rna_Scene_frame_preview_start : &rna_Scene_frame_start,
|
|
|
|
|
use_preview ? &rna_Scene_frame_preview_end : &rna_Scene_frame_end,
|
|
|
|
|
&rna_Scene_use_preview_range,
|
|
|
|
|
&rna_Scene_frame_current,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PointerRNA idptr;
|
|
|
|
|
RNA_id_pointer_create(&scene->id, &idptr);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ARRAY_SIZE(props); i++) {
|
|
|
|
|
WM_msg_subscribe_rna(mbus, &idptr, props[i], &msg_sub_value_region_tag_redraw, __func__);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-04 17:45:54 +00:00
|
|
|
/* editor level listener */
|
2017-05-02 09:58:01 +10:00
|
|
|
static void action_listener(
|
2017-10-16 17:15:03 -02:00
|
|
|
bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
|
|
|
|
|
WorkSpace *UNUSED(workspace))
|
2009-01-04 17:45:54 +00:00
|
|
|
{
|
2012-05-08 16:02:13 +00:00
|
|
|
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
|
2009-12-23 11:22:30 +00:00
|
|
|
|
2009-01-04 17:45:54 +00:00
|
|
|
/* context changes */
|
2009-01-05 09:54:39 +00:00
|
|
|
switch (wmn->category) {
|
2012-10-05 19:51:11 +00:00
|
|
|
case NC_GPENCIL:
|
2016-12-28 16:54:57 +13:00
|
|
|
/* only handle these events in GPencil mode for performance considerations */
|
|
|
|
|
if (saction->mode == SACTCONT_GPENCIL) {
|
|
|
|
|
if (wmn->action == NA_EDITED) {
|
2011-01-10 22:10:28 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2016-12-28 16:54:57 +13:00
|
|
|
}
|
|
|
|
|
else if (wmn->action == NA_SELECTED) {
|
|
|
|
|
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
}
|
2011-01-10 22:10:28 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2009-07-10 10:48:25 +00:00
|
|
|
case NC_ANIMATION:
|
2011-04-19 13:17:16 +00:00
|
|
|
/* for NLA tweakmode enter/exit, need complete refresh */
|
|
|
|
|
if (wmn->data == ND_NLA_ACTCHANGE) {
|
|
|
|
|
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
}
|
2014-04-24 14:26:53 +12:00
|
|
|
/* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears
|
|
|
|
|
* (assume for now that if just adding these works, that will be fine)
|
|
|
|
|
*/
|
|
|
|
|
else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) ||
|
|
|
|
|
((wmn->data == ND_ANIMCHAN) && (wmn->action != NA_SELECTED)))
|
|
|
|
|
{
|
2009-12-23 11:22:30 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
2014-04-24 14:26:53 +12:00
|
|
|
}
|
|
|
|
|
/* for simple edits to the curve data though (or just plain selections), a simple redraw should work
|
|
|
|
|
* (see T39851 for an example of how this can go wrong)
|
|
|
|
|
*/
|
|
|
|
|
else {
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
}
|
2009-07-10 10:48:25 +00:00
|
|
|
break;
|
2009-01-04 17:45:54 +00:00
|
|
|
case NC_SCENE:
|
2018-04-19 16:31:19 +02:00
|
|
|
if (saction->mode == SACTCONT_TIMELINE) {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_RENDER_RESULT:
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
|
|
|
|
case ND_OB_ACTIVE:
|
|
|
|
|
case ND_FRAME:
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
break;
|
|
|
|
|
case ND_FRAME_RANGE:
|
|
|
|
|
{
|
|
|
|
|
ARegion *ar;
|
|
|
|
|
Scene *scene = wmn->reference;
|
|
|
|
|
|
|
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
|
|
|
|
if (ar->regiontype == RGN_TYPE_WINDOW) {
|
|
|
|
|
ar->v2d.tot.xmin = (float)(SFRA - 4);
|
|
|
|
|
ar->v2d.tot.xmax = (float)(EFRA + 4);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
|
|
|
|
|
case ND_OB_SELECT:
|
|
|
|
|
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: /* just redrawing the view will do */
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-12-21 09:52:43 +00:00
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
break;
|
|
|
|
|
case NC_OBJECT:
|
2009-12-21 09:52:43 +00:00
|
|
|
switch (wmn->data) {
|
2012-05-08 16:02:13 +00:00
|
|
|
case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
|
2009-01-05 09:54:39 +00:00
|
|
|
case ND_BONE_ACTIVE:
|
2009-12-23 11:22:30 +00:00
|
|
|
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
2009-01-05 09:54:39 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
break;
|
2010-01-25 19:42:33 +00:00
|
|
|
case ND_TRANSFORM:
|
|
|
|
|
/* moving object shouldn't need to redraw action */
|
|
|
|
|
break;
|
2018-04-19 16:31:19 +02:00
|
|
|
case ND_POINTCACHE:
|
|
|
|
|
case ND_MODIFIER:
|
|
|
|
|
case ND_PARTICLE:
|
|
|
|
|
/* only needed in timeline mode */
|
|
|
|
|
if (saction->mode == SACTCONT_TIMELINE) {
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-12-21 09:52:43 +00:00
|
|
|
default: /* just redrawing the view will do */
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
break;
|
2012-06-08 14:46:17 +00:00
|
|
|
case NC_MASK:
|
|
|
|
|
if (saction->mode == SACTCONT_MASK) {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_DATA:
|
|
|
|
|
ED_area_tag_refresh(sa);
|
2012-09-24 00:37:14 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2012-06-08 14:46:17 +00:00
|
|
|
break;
|
|
|
|
|
default: /* just redrawing the view will do */
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-06-27 04:24:59 +00:00
|
|
|
case NC_NODE:
|
|
|
|
|
if (wmn->action == NA_SELECTED) {
|
|
|
|
|
/* selection changed, so force refresh to flush (needs flag set to do syncing) */
|
|
|
|
|
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case NC_SPACE:
|
Added a new notifyer, NC_SPACE_CHANGED, to signal an editor that
replaces another so it can do updates (e.g. dopesheet editor can
sync channel selection).
Also coded a simple optimization for allocating small objects,
based on mempools. It's #ifdef'd out, you can enabled it by
defining OPTIMIZE_SMALL_BLOCKS (e.g. adding -DDOPTIMIZE_SMALL_BLOCKS to
your compiler flags).
We suffer from a great deal of performance loss from the system allocator
(vgroups, ghash, edgehash, the singly-linked list implementation in blenlib,
editmesh, and likely a great many areas I'm forgetting), and this is the
common solution for handling the many-small-objects problem. It's not
really production-ready yet (it's long-term memory consequencers need to
be profiled first, and the implementation tweaked as necassary), but for
people on systems with slow system allocators it's worth trying.
Note that since this creates a guardedalloc<->blenlib link, the build systems
need to be updated accordingly (I've already done this for scons, though I'm
not sure if the player builds).
2010-01-21 03:08:57 +00:00
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_SPACE_DOPESHEET:
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
2018-04-20 12:26:47 +02:00
|
|
|
case ND_SPACE_TIME:
|
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
|
break;
|
Added a new notifyer, NC_SPACE_CHANGED, to signal an editor that
replaces another so it can do updates (e.g. dopesheet editor can
sync channel selection).
Also coded a simple optimization for allocating small objects,
based on mempools. It's #ifdef'd out, you can enabled it by
defining OPTIMIZE_SMALL_BLOCKS (e.g. adding -DDOPTIMIZE_SMALL_BLOCKS to
your compiler flags).
We suffer from a great deal of performance loss from the system allocator
(vgroups, ghash, edgehash, the singly-linked list implementation in blenlib,
editmesh, and likely a great many areas I'm forgetting), and this is the
common solution for handling the many-small-objects problem. It's not
really production-ready yet (it's long-term memory consequencers need to
be profiled first, and the implementation tweaked as necassary), but for
people on systems with slow system allocators it's worth trying.
Note that since this creates a guardedalloc<->blenlib link, the build systems
need to be updated accordingly (I've already done this for scons, though I'm
not sure if the player builds).
2010-01-21 03:08:57 +00:00
|
|
|
case ND_SPACE_CHANGED:
|
|
|
|
|
saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
break;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
break;
|
2012-06-11 04:13:39 +00:00
|
|
|
case NC_WINDOW:
|
|
|
|
|
if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
|
|
|
|
|
/* force redraw/refresh after undo/redo - [#28962] */
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2018-04-19 16:31:19 +02:00
|
|
|
case NC_WM:
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_FILEREAD:
|
|
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2009-01-04 17:45:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 09:58:01 +10:00
|
|
|
static void action_header_region_listener(
|
2018-04-19 16:31:19 +02:00
|
|
|
bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar,
|
2017-05-02 09:58:01 +10:00
|
|
|
wmNotifier *wmn, const Scene *UNUSED(scene))
|
2010-01-20 15:44:37 +00:00
|
|
|
{
|
2018-04-19 16:31:19 +02:00
|
|
|
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
|
2014-01-08 17:50:25 +01:00
|
|
|
|
2010-01-20 15:44:37 +00:00
|
|
|
/* context changes */
|
2011-04-19 13:17:16 +00:00
|
|
|
switch (wmn->category) {
|
2018-04-19 16:31:19 +02:00
|
|
|
case NC_SCREEN:
|
|
|
|
|
if (saction->mode == SACTCONT_TIMELINE) {
|
|
|
|
|
if (wmn->data == ND_ANIMPLAY)
|
2010-01-20 15:44:37 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2018-04-19 16:31:19 +02:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NC_SCENE:
|
|
|
|
|
if (saction->mode == SACTCONT_TIMELINE) {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_RENDER_RESULT:
|
|
|
|
|
case ND_OB_SELECT:
|
|
|
|
|
case ND_FRAME:
|
|
|
|
|
case ND_FRAME_RANGE:
|
|
|
|
|
case ND_KEYINGSET:
|
|
|
|
|
case ND_RENDER_OPTIONS:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_OB_ACTIVE:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2010-01-20 15:44:37 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NC_ID:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->action == NA_RENAME)
|
2010-01-20 15:44:37 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
2014-01-08 17:50:25 +01:00
|
|
|
case NC_ANIMATION:
|
|
|
|
|
switch (wmn->data) {
|
2014-06-24 17:52:40 +12:00
|
|
|
case ND_ANIMCHAN: /* set of visible animchannels changed */
|
|
|
|
|
/* NOTE: for now, this should usually just mean that the filters changed
|
|
|
|
|
* It may be better if we had a dedicated flag for that though
|
|
|
|
|
*/
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ND_KEYFRAME: /* new keyframed added -> active action may have changed */
|
2014-04-24 14:26:53 +12:00
|
|
|
//saction->flag |= SACTION_TEMP_NEEDCHANSYNC;
|
2014-01-08 17:50:25 +01:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2010-01-20 15:44:37 +00:00
|
|
|
}
|
2014-01-08 17:50:25 +01:00
|
|
|
|
2010-01-20 15:44:37 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-08 14:38:30 +12:00
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
|
static void action_buttons_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
|
{
|
|
|
|
|
wmKeyMap *keymap;
|
|
|
|
|
|
|
|
|
|
ED_region_panels_init(wm, ar);
|
|
|
|
|
|
|
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0);
|
|
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void action_buttons_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
|
{
|
|
|
|
|
ED_region_panels(C, ar, NULL, -1, true);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 09:58:01 +10:00
|
|
|
static void action_region_listener(
|
|
|
|
|
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
|
|
|
|
|
wmNotifier *wmn, const Scene *UNUSED(scene))
|
2016-05-08 14:38:30 +12:00
|
|
|
{
|
|
|
|
|
/* context changes */
|
|
|
|
|
switch (wmn->category) {
|
|
|
|
|
case NC_ANIMATION:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
case NC_SCENE:
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_OB_ACTIVE:
|
|
|
|
|
case ND_FRAME:
|
|
|
|
|
case ND_MARKERS:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NC_OBJECT:
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_BONE_ACTIVE:
|
|
|
|
|
case ND_BONE_SELECT:
|
|
|
|
|
case ND_KEYS:
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (wmn->data == ND_KEYS)
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-04 17:45:54 +00:00
|
|
|
static void action_refresh(const bContext *C, ScrArea *sa)
|
|
|
|
|
{
|
2012-05-08 16:02:13 +00:00
|
|
|
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
|
2009-12-21 09:52:43 +00:00
|
|
|
|
2009-12-23 11:22:30 +00:00
|
|
|
/* update the state of the animchannels in response to changes from the data they represent
|
|
|
|
|
* NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled
|
|
|
|
|
*/
|
|
|
|
|
if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) {
|
2012-06-11 04:13:39 +00:00
|
|
|
ARegion *ar;
|
|
|
|
|
|
|
|
|
|
/* Perform syncing of channel state incl. selection
|
|
|
|
|
* Active action setting also occurs here (as part of anim channel filtering in anim_filter.c)
|
|
|
|
|
*/
|
2009-12-23 11:22:30 +00:00
|
|
|
ANIM_sync_animchannels_to_data(C);
|
|
|
|
|
saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC;
|
2012-06-11 04:13:39 +00:00
|
|
|
|
|
|
|
|
/* Tag everything for redraw
|
|
|
|
|
* - Regions (such as header) need to be manually tagged for redraw too
|
|
|
|
|
* or else they don't update [#28962]
|
|
|
|
|
*/
|
2010-12-20 19:09:22 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2012-06-11 04:13:39 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next)
|
|
|
|
|
ED_region_tag_redraw(ar);
|
2009-12-23 11:22:30 +00:00
|
|
|
}
|
2009-01-05 09:54:39 +00:00
|
|
|
|
|
|
|
|
/* region updates? */
|
2012-03-08 04:12:11 +00:00
|
|
|
// XXX re-sizing y-extents of tot should go here?
|
2009-01-04 17:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
static void action_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id)
|
|
|
|
|
{
|
|
|
|
|
SpaceAction *sact = (SpaceAction *)slink;
|
|
|
|
|
|
2017-09-20 20:24:54 +02:00
|
|
|
if ((ID *)sact->action == old_id) {
|
|
|
|
|
sact->action = (bAction *)new_id;
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((ID *)sact->ads.filter_grp == old_id) {
|
|
|
|
|
sact->ads.filter_grp = (Group *)new_id;
|
|
|
|
|
}
|
2017-09-20 20:24:54 +02:00
|
|
|
if ((ID *)sact->ads.source == old_id) {
|
|
|
|
|
sact->ads.source = new_id;
|
|
|
|
|
}
|
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
|
void ED_spacetype_action(void)
|
|
|
|
|
{
|
2012-05-08 16:02:13 +00:00
|
|
|
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action");
|
2008-12-14 14:43:08 +00:00
|
|
|
ARegionType *art;
|
|
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
st->spaceid = SPACE_ACTION;
|
2009-12-19 22:37:51 +00:00
|
|
|
strncpy(st->name, "Action", BKE_ST_MAXNAME);
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2012-05-08 16:02:13 +00:00
|
|
|
st->new = action_new;
|
|
|
|
|
st->free = action_free;
|
|
|
|
|
st->init = action_init;
|
|
|
|
|
st->duplicate = action_duplicate;
|
|
|
|
|
st->operatortypes = action_operatortypes;
|
|
|
|
|
st->keymap = action_keymap;
|
|
|
|
|
st->listener = action_listener;
|
|
|
|
|
st->refresh = action_refresh;
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
st->id_remap = action_id_remap;
|
|
|
|
|
|
2008-12-14 14:43:08 +00:00
|
|
|
/* regions: main window */
|
2012-05-08 16:02:13 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
|
2008-12-14 14:43:08 +00:00
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = action_main_region_init;
|
|
|
|
|
art->draw = action_main_region_draw;
|
|
|
|
|
art->listener = action_main_region_listener;
|
2018-04-19 16:31:19 +02:00
|
|
|
art->message_subscribe = saction_main_region_message_subscribe;
|
2012-05-08 16:02:13 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
|
|
/* regions: header */
|
2012-05-08 16:02:13 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
|
2008-12-14 14:43:08 +00:00
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
2012-05-08 16:02:13 +00:00
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = action_header_region_init;
|
|
|
|
|
art->draw = action_header_region_draw;
|
|
|
|
|
art->listener = action_header_region_listener;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
|
|
/* regions: channels */
|
2012-05-08 16:02:13 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
|
2008-12-14 14:43:08 +00:00
|
|
|
art->regionid = RGN_TYPE_CHANNELS;
|
2012-05-08 16:02:13 +00:00
|
|
|
art->prefsizex = 200;
|
2013-11-05 01:29:45 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = action_channel_region_init;
|
|
|
|
|
art->draw = action_channel_region_draw;
|
|
|
|
|
art->listener = action_channel_region_listener;
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
2016-05-08 14:38:30 +12:00
|
|
|
/* regions: UI buttons */
|
|
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype action region");
|
|
|
|
|
art->regionid = RGN_TYPE_UI;
|
|
|
|
|
art->prefsizex = 200;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI;
|
|
|
|
|
art->listener = action_region_listener;
|
|
|
|
|
art->init = action_buttons_area_init;
|
|
|
|
|
art->draw = action_buttons_area_draw;
|
|
|
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
|
|
action_buttons_register(art);
|
2008-12-14 14:43:08 +00:00
|
|
|
|
|
|
|
|
BKE_spacetype_register(st);
|
|
|
|
|
}
|
|
|
|
|
|