Dopesheet-Timeline: Removal of Timeline Editor!

This commit removes all references to the old timeline editor.

Unfortuantely, the removal of the Timeline spacetype defining
functions has ended up breaking the version patching code I'd
been working on earlier (as now, the editor gets marked as
"unknown/info" before we get a chance to patch it!)
This commit is contained in:
Joshua Leung 2018-04-20 17:17:10 +02:00
parent b5b4802af6
commit 5374865523
Notes: blender-bot 2023-02-14 01:57:12 +01:00
Referenced by commit 8df339438a, Fix T72682: Regression when moving markers while holding ctrl
Referenced by issue #72682, Moving Animation Markers no longer allows snapping
28 changed files with 59 additions and 1335 deletions

View File

@ -21,24 +21,10 @@ import bpy
from bpy.types import Header, Menu
class TIME_HT_header(Header):
bl_space_type = 'TIMELINE'
def draw(self, context):
layout = self.layout
row = layout.row(align=True)
row.template_header()
TIME_MT_editor_menus.draw_collapsible(context, layout)
TIME_HT_editor_buttons.draw_header(context, layout)
# Header buttons for actual timeline editor header
# XXX: Temporary, until we have editor submodes in the actual editors menu
# Header buttons for timeline header (play, etc.)
class TIME_HT_editor_buttons(Header):
bl_idname = "TIME_HT_editor_buttons"
bl_space_type = 'TIMELINE' # XXX: Change this to 'DOPESHEET_EDITOR'
bl_space_type = 'DOPESHEET_EDITOR'
bl_label = ""
def draw(self, context):
@ -285,7 +271,6 @@ def marker_menu_generic(layout):
classes = (
TIME_HT_header,
TIME_HT_editor_buttons,
TIME_MT_editor_menus,
TIME_MT_marker,

View File

@ -171,7 +171,6 @@ struct SpaceFile *CTX_wm_space_file(const bContext *C);
struct SpaceSeq *CTX_wm_space_seq(const bContext *C);
struct SpaceOops *CTX_wm_space_outliner(const bContext *C);
struct SpaceNla *CTX_wm_space_nla(const bContext *C);
struct SpaceTime *CTX_wm_space_time(const bContext *C);
struct SpaceNode *CTX_wm_space_node(const bContext *C);
struct SpaceIpo *CTX_wm_space_graph(const bContext *C);
struct SpaceAction *CTX_wm_space_action(const bContext *C);

View File

@ -775,14 +775,6 @@ struct SpaceNla *CTX_wm_space_nla(const bContext *C)
return NULL;
}
struct SpaceTime *CTX_wm_space_time(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
if (sa && sa->spacetype == SPACE_TIME)
return sa->spacedata.first;
return NULL;
}
struct SpaceNode *CTX_wm_space_node(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);

View File

@ -285,19 +285,6 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
//ar->v2d.flag |= V2D_IS_INITIALISED;
}
break;
case SPACE_TIME:
{
SpaceTime *stime = (SpaceTime *)sl;
memcpy(&ar->v2d, &stime->v2d, sizeof(View2D));
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
ar->v2d.keepofs |= V2D_LOCKOFS_Y;
ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0;
ar->v2d.min[1] = ar->v2d.max[1] = 20.0;
}
break;
case SPACE_IPO:
{
SpaceIpo *sipo = (SpaceIpo *)sl;
@ -1613,14 +1600,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
}
}
}
else if (sl->spacetype == SPACE_TIME) {
SpaceTime *stime = (SpaceTime *) sl;
/* enable all cache display */
stime->cache_display |= TIME_CACHE_DISPLAY;
stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
}
}
}
}

View File

@ -637,7 +637,8 @@ void do_versions_after_linking_280(Main *main)
for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
/* Convert timelines to dopesheet editors with timelines */
if (sa->spacetype == SPACE_TIME) {
SpaceTime *stime = sa->spacedata.first;
//SpaceTime *stime = sa->spacedata.first;
SpaceLink *stime = sa->spacedata.first;
ARegion *main_region = NULL;
ARegion *ar = NULL;

View File

@ -2856,9 +2856,6 @@ static void write_area_regions(WriteData *wd, ScrArea *area)
writestruct(wd, DATA, bDopeSheet, 1, snla->ads);
}
}
else if (sl->spacetype == SPACE_TIME) {
writestruct(wd, DATA, SpaceTime, 1, sl);
}
else if (sl->spacetype == SPACE_NODE) {
SpaceNode *snode = (SpaceNode *)sl;
bNodeTreePath *path;

View File

@ -55,7 +55,6 @@ if(WITH_BLENDER)
add_subdirectory(space_script)
add_subdirectory(space_sequencer)
add_subdirectory(space_text)
add_subdirectory(space_time)
add_subdirectory(space_topbar)
add_subdirectory(space_userpref)
add_subdirectory(space_view3d)

View File

@ -583,12 +583,10 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wm
else
BKE_report(op->reports, RPT_ERROR, "Programming error: operator does not actually have code to do anything!");
/* return status modifications - for now, make this spacetype dependent as above */
if (sa->spacetype != SPACE_TIME) {
/* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */
if ((retval & (OPERATOR_FINISHED | OPERATOR_INTERFACE)) == 0) {
retval |= OPERATOR_PASS_THROUGH;
}
/* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */
if ((retval & (OPERATOR_FINISHED | OPERATOR_INTERFACE)) == 0) {
retval |= OPERATOR_PASS_THROUGH;
}
return retval;
@ -690,8 +688,7 @@ typedef struct MarkerMove {
static bool ed_marker_move_use_time(MarkerMove *mm)
{
if (((mm->slink->spacetype == SPACE_TIME) && !(((SpaceTime *)mm->slink)->flag & TIME_DRAWFRAMES)) ||
((mm->slink->spacetype == SPACE_SEQ) && !(((SpaceSeq *)mm->slink)->flag & SEQ_DRAWFRAMES)) ||
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_IPO) && !(((SpaceIpo *)mm->slink)->flag & SIPO_DRAWTIME)) ||
((mm->slink->spacetype == SPACE_NLA) && !(((SpaceNla *)mm->slink)->flag & SNLA_DRAWTIME)))
@ -935,10 +932,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even
mm->evtx = event->x;
fac = ((float)(event->x - mm->firstx) * dx);
if (mm->slink->spacetype == SPACE_TIME)
apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, FPS, 0.1 * FPS, 0);
else
apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, 1.0, 0.1, 0 /*was: U.flag & USER_AUTOGRABGRID*/);
apply_keyb_grid(event->shift, event->ctrl, &fac, 0.0, 1.0, 0.1, 0 /*was: U.flag & USER_AUTOGRABGRID*/);
RNA_int_set(op->ptr, "frames", (int)fac);
ed_marker_move_apply(C, op);

View File

@ -75,7 +75,7 @@ static int change_frame_poll(bContext *C)
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
if (sa) {
if (ELEM(sa->spacetype, SPACE_TIME, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
return true;
}
else if (sa->spacetype == SPACE_IPO) {
@ -86,7 +86,7 @@ static int change_frame_poll(bContext *C)
}
}
CTX_wm_operator_poll_msg_set(C, "Expected an timeline/animation area to be active");
CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
return false;
}
@ -279,6 +279,26 @@ static void ANIM_OT_change_frame(wmOperatorType *ot)
/* ****************** Start/End Frame Operators *******************************/
static int anim_set_end_frames_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
if (G.is_rendering) return false;
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
*/
if (sa) {
if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) {
return true;
}
}
CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active");
return false;
}
static int anim_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
@ -316,7 +336,7 @@ static void ANIM_OT_start_frame_set(wmOperatorType *ot)
/* api callbacks */
ot->exec = anim_set_sfra_exec;
ot->poll = ED_operator_timeline_active;
ot->poll = anim_set_end_frames_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@ -360,7 +380,7 @@ static void ANIM_OT_end_frame_set(wmOperatorType *ot)
/* api callbacks */
ot->exec = anim_set_efra_exec;
ot->poll = ED_operator_timeline_active;
ot->poll = anim_set_end_frames_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

View File

@ -243,7 +243,6 @@ int ED_operator_objectmode(struct bContext *C);
int ED_operator_view3d_active(struct bContext *C);
int ED_operator_region_view3d_active(struct bContext *C);
int ED_operator_animview_active(struct bContext *C);
int ED_operator_timeline_active(struct bContext *C);
int ED_operator_outliner_active(struct bContext *C);
int ED_operator_outliner_active_no_editobject(struct bContext *C);
int ED_operator_file_active(struct bContext *C);

View File

@ -41,7 +41,6 @@ void ED_spacemacros_init(void);
/* calls for registering default spaces */
void ED_spacetype_outliner(void);
void ED_spacetype_time(void);
void ED_spacetype_view3d(void);
void ED_spacetype_ipo(void);
void ED_spacetype_image(void);

View File

@ -156,9 +156,6 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case SPACE_CONSOLE:
ts = &btheme->tconsole;
break;
case SPACE_TIME:
ts = &btheme->ttime;
break;
case SPACE_NODE:
ts = &btheme->tnode;
break;
@ -2144,8 +2141,6 @@ void init_userdef_do_versions(void)
strcpy(km->idname, "3D View Generic");
else if (STREQ(km->idname, "EditMesh"))
strcpy(km->idname, "Mesh");
else if (STREQ(km->idname, "TimeLine"))
strcpy(km->idname, "Timeline");
else if (STREQ(km->idname, "UVEdit"))
strcpy(km->idname, "UV Editor");
else if (STREQ(km->idname, "Animation_Channels"))
@ -2788,10 +2783,6 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tnode.gp_vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tnode.gp_vertex_select, 255, 133, 0, 255);
btheme->tnode.gp_vertex_size = 3;
/* Timeline Keyframe Indicators */
rgba_char_args_set(btheme->ttime.time_keyframe, 0xDD, 0xD7, 0x00, 0xFF);
rgba_char_args_set(btheme->ttime.time_gp_keyframe, 0xB5, 0xE6, 0x1D, 0xFF);
}
}

View File

@ -1481,19 +1481,15 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
/* time-markers */
wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0);
/* time space only has this keymap, the others get a boundbox restricted map */
if (sa->spacetype != SPACE_TIME) {
ARegion *ar;
/* same local check for all areas */
static rcti rect = {0, 10000, 0, -1};
rect.ymax = UI_MARKER_MARGIN_Y;
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
if (ar) {
WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
}
/* use a boundbox restricted map */
ARegion *ar;
/* same local check for all areas */
static rcti rect = {0, 10000, 0, -1};
rect.ymax = UI_MARKER_MARGIN_Y;
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
if (ar) {
WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct);
}
else
WM_event_add_keymap_handler(handlers, keymap);
}
if (flag & ED_KEYMAP_ANIMATION) {
/* frame changing and timeline operators (for time spaces) */

View File

@ -1608,7 +1608,7 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
if (sa)
spacetype = sa->spacetype;
sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_TIME));
sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA));
screen->animtimer->customdata = sad;

View File

@ -197,7 +197,7 @@ int ED_operator_animview_active(bContext *C)
{
if (ED_operator_areaactive(C)) {
SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C);
if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO, SPACE_TIME)))
if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO)))
return true;
}
@ -205,11 +205,6 @@ int ED_operator_animview_active(bContext *C)
return 0;
}
int ED_operator_timeline_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_TIME);
}
int ED_operator_outliner_active(bContext *C)
{
return ed_spacetype_test(C, SPACE_OUTLINER);
@ -2280,7 +2275,7 @@ static void areas_do_frame_follow(bContext *C, bool middle)
/* do follow here if editor type supports it */
if ((scr->redraws_flag & TIME_FOLLOW)) {
if ((ar->regiontype == RGN_TYPE_WINDOW &&
ELEM(sa->spacetype, SPACE_SEQ, SPACE_TIME, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
ELEM(sa->spacetype, SPACE_SEQ, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
(sa->spacetype == SPACE_CLIP && ar->regiontype == RGN_TYPE_PREVIEW))
{
float w = BLI_rctf_size_x(&ar->v2d.cur);
@ -3570,13 +3565,14 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws,
return 1;
break;
case SPACE_IPO:
case SPACE_ACTION:
case SPACE_NLA:
if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit)
return 1;
break;
case SPACE_TIME:
/* if only 1 window or 3d windows, we do timeline too */
case SPACE_ACTION:
/* if only 1 window or 3d windows, we do timeline too
* NOTE: Now we do do action editor in all these cases, since timeline is here
*/
if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit)
return 1;
break;
@ -3627,7 +3623,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws,
return 1;
}
else if (regiontype == RGN_TYPE_HEADER) {
if (spacetype == SPACE_TIME)
if (spacetype == SPACE_ACTION)
return 1;
}
else if (regiontype == RGN_TYPE_PREVIEW) {
@ -3789,7 +3785,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
/* do follow here if editor type supports it */
if ((sad->redraws & TIME_FOLLOW)) {
if ((ar->regiontype == RGN_TYPE_WINDOW &&
ELEM(sa->spacetype, SPACE_SEQ, SPACE_TIME, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
ELEM(sa->spacetype, SPACE_SEQ, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) ||
(sa->spacetype == SPACE_CLIP && ar->regiontype == RGN_TYPE_PREVIEW))
{
float w = BLI_rctf_size_x(&ar->v2d.cur);
@ -3892,7 +3888,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
else {
int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */
int refresh = SPACE_ACTION; /* these settings are currently only available from a menu in the TimeLine */
if (mode == 1) /* XXX only play audio forwards!? */
BKE_sound_play_scene(scene);

View File

@ -82,7 +82,6 @@ void ED_spacetypes_init(void)
/* create space types */
ED_spacetype_outliner();
ED_spacetype_time();
ED_spacetype_view3d();
ED_spacetype_ipo();
ED_spacetype_image();

View File

@ -1,46 +0,0 @@
# ***** 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,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Contributor(s): Jacques Beaurain.
#
# ***** END GPL LICENSE BLOCK *****
set(INC
../include
../../blenkernel
../../blenlib
../../gpu
../../makesdna
../../makesrna
../../windowmanager
../../../../intern/guardedalloc
../../../../intern/glew-mx
)
set(INC_SYS
${GLEW_INCLUDE_PATH}
)
set(SRC
space_time.c
time_ops.c
time_intern.h
)
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_editor_space_time "${SRC}" "${INC}" "${INC_SYS}")

View File

@ -1,858 +0,0 @@
/*
* ***** 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,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/editors/space_time/space_time.c
* \ingroup sptime
*/
#include <string.h>
#include <stdio.h>
#include "DNA_cachefile_types.h"
#include "DNA_constraint_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_dlrbTree.h"
#include "BLI_utildefines.h"
#include "BKE_constraint.h"
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "BKE_pointcache.h"
#include "ED_anim_api.h"
#include "ED_keyframes_draw.h"
#include "ED_screen.h"
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
#include "RNA_access.h"
#include "BIF_gl.h"
#include "UI_resources.h"
#include "UI_view2d.h"
#include "UI_interface.h"
#include "ED_space_api.h"
#include "ED_markers.h"
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "time_intern.h"
/* ************************ main time area region *********************** */
static void time_draw_sfra_efra(Scene *scene, View2D *v2d)
{
/* draw darkened area outside of active timeline
* frame range used is preview range or scene range
*/
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(0.0f, 0.0f, 0.0f, 0.4f);
if (PSFRA < PEFRA) {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax);
immRectf(pos, (float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
else {
immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
}
glDisable(GL_BLEND);
/* thin lines where the actual frames are */
immUniformThemeColorShade(TH_BACK, -60);
immBegin(GWN_PRIM_LINES, 4);
immVertex2f(pos, (float)PSFRA, v2d->cur.ymin);
immVertex2f(pos, (float)PSFRA, v2d->cur.ymax);
immVertex2f(pos, (float)PEFRA, v2d->cur.ymin);
immVertex2f(pos, (float)PEFRA, v2d->cur.ymax);
immEnd();
immUnbindProgram();
}
static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
{
PTCacheID *pid;
ListBase pidlist;
const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
float yoffs = 0.f;
if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob))
return;
BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
/* iterate over pointcaches on the active object, drawing */
for (pid = pidlist.first; pid; pid = pid->next) {
float col[4];
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue;
break;
case PTCACHE_TYPE_PARTICLES:
if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue;
break;
case PTCACHE_TYPE_CLOTH:
if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue;
break;
case PTCACHE_TYPE_SMOKE_DOMAIN:
case PTCACHE_TYPE_SMOKE_HIGHRES:
if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue;
break;
case PTCACHE_TYPE_DYNAMICPAINT:
if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue;
break;
case PTCACHE_TYPE_RIGIDBODY:
if (!(stime->cache_display & TIME_CACHE_RIGIDBODY)) continue;
break;
}
if (pid->cache->cached_frames == NULL)
continue;
gpuPushMatrix();
gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs);
gpuScale2f(1.0, cache_draw_height);
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
col[3] = 0.1;
break;
case PTCACHE_TYPE_PARTICLES:
col[0] = 1.0; col[1] = 0.1; col[2] = 0.02;
col[3] = 0.1;
break;
case PTCACHE_TYPE_CLOTH:
col[0] = 0.1; col[1] = 0.1; col[2] = 0.75;
col[3] = 0.1;
break;
case PTCACHE_TYPE_SMOKE_DOMAIN:
case PTCACHE_TYPE_SMOKE_HIGHRES:
col[0] = 0.2; col[1] = 0.2; col[2] = 0.2;
col[3] = 0.1;
break;
case PTCACHE_TYPE_DYNAMICPAINT:
col[0] = 1.0; col[1] = 0.1; col[2] = 0.75;
col[3] = 0.1;
break;
case PTCACHE_TYPE_RIGIDBODY:
col[0] = 1.0; col[1] = 0.6; col[2] = 0.0;
col[3] = 0.1;
break;
default:
col[0] = 1.0; col[1] = 0.0; col[2] = 1.0;
col[3] = 0.1;
BLI_assert(0);
break;
}
const int sta = pid->cache->startframe, end = pid->cache->endframe;
const int len = (end - sta + 1) * 6;
glEnable(GL_BLEND);
immUniformColor4fv(col);
immRectf(pos, (float)sta, 0.0, (float)end, 1.0);
col[3] = 0.4f;
if (pid->cache->flag & PTCACHE_BAKED) {
col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f;
}
else if (pid->cache->flag & PTCACHE_OUTDATED) {
col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f;
}
immUniformColor4fv(col);
if (len > 0) {
immBeginAtMost(GWN_PRIM_TRIS, len);
/* draw a quad for each cached frame */
for (int i = sta; i <= end; i++) {
if (pid->cache->cached_frames[i - sta]) {
immVertex2f(pos, (float)i - 0.5f, 0.0f);
immVertex2f(pos, (float)i - 0.5f, 1.0f);
immVertex2f(pos, (float)i + 0.5f, 1.0f);
immVertex2f(pos, (float)i - 0.5f, 0.0f);
immVertex2f(pos, (float)i + 0.5f, 1.0f);
immVertex2f(pos, (float)i + 0.5f, 0.0f);
}
}
immEnd();
}
glDisable(GL_BLEND);
gpuPopMatrix();
yoffs += cache_draw_height;
}
immUnbindProgram();
BLI_freelistN(&pidlist);
}
/* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */
static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe)
{
ActKeyColumn *akn = NULL;
/* sanity checks */
if (ak == NULL)
return NULL;
/* check if this is a match, or whether it is in some subtree */
if (cframe < ak->cfra)
akn = time_cfra_find_ak(ak->left, cframe);
else if (cframe > ak->cfra)
akn = time_cfra_find_ak(ak->right, cframe);
/* if no match found (or found match), just use the current one */
if (akn == NULL)
return ak;
else
return akn;
}
/* helper for time_draw_keyframes() */
static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel, const unsigned char color[3])
{
bDopeSheet ads = {NULL};
DLRBT_Tree keys;
ActKeyColumn *ak;
float fac1 = (GS(id->name) == ID_GD) ? 0.8f : 0.6f; /* draw GPencil keys taller, to help distinguish them */
float fac2 = 1.0f - fac1;
float ymin = v2d->tot.ymin;
float ymax = v2d->tot.ymax * fac1 + ymin * fac2;
/* init binarytree-list for getting keyframes */
BLI_dlrbTree_init(&keys);
/* init dopesheet settings */
if (onlysel)
ads.filterflag |= ADS_FILTER_ONLYSEL;
/* populate tree with keyframe nodes */
switch (GS(id->name)) {
case ID_SCE:
scene_to_keylist(&ads, (Scene *)id, &keys, NULL);
break;
case ID_OB:
ob_to_keylist(&ads, (Object *)id, &keys, NULL);
break;
case ID_GD:
gpencil_to_keylist(&ads, (bGPdata *)id, &keys);
break;
case ID_CF:
cachefile_to_keylist(&ads, (CacheFile *)id, &keys, NULL);
break;
default:
break;
}
/* build linked-list for searching */
BLI_dlrbTree_linkedlist_sync(&keys);
/* start drawing keyframes
* - we use the binary-search capabilities of the tree to only start from
* the first visible keyframe (last one can then be easily checked)
* - draw within a single GL block to be faster
*/
ActKeyColumn *link;
int max_len = 0;
ak = time_cfra_find_ak(keys.root, v2d->cur.xmin);
for (link = ak; link; link = link->next) {
max_len++;
}
if (max_len > 0) {
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubv(color);
immBeginAtMost(GWN_PRIM_LINES, max_len * 2);
for (; (ak) && (ak->cfra <= v2d->cur.xmax); ak = ak->next) {
immVertex2f(pos, ak->cfra, ymin);
immVertex2f(pos, ak->cfra, ymax);
}
immEnd();
immUnbindProgram();
}
/* free temp stuff */
BLI_dlrbTree_free(&keys);
}
static void time_draw_caches_keyframes(Main *bmain, ViewLayer *view_layer, View2D *v2d, bool onlysel, const unsigned char color[3])
{
CacheFile *cache_file;
for (cache_file = bmain->cachefiles.first;
cache_file;
cache_file = cache_file->id.next)
{
cache_file->draw_flag &= ~CACHEFILE_KEYFRAME_DRAWN;
}
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
Object *ob = base->object;
ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
if (md) {
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
cache_file = mcmd->cache_file;
if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
continue;
}
cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;
time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel, color);
}
for (bConstraint *con = ob->constraints.first; con; con = con->next) {
if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
continue;
}
bTransformCacheConstraint *data = con->data;
cache_file = data->cache_file;
if (!cache_file || (cache_file->draw_flag & CACHEFILE_KEYFRAME_DRAWN) != 0) {
continue;
}
cache_file->draw_flag |= CACHEFILE_KEYFRAME_DRAWN;
time_draw_idblock_keyframes(v2d, (ID *)cache_file, onlysel, color);
}
}
}
/* draw keyframe lines for timeline */
static void time_draw_keyframes(const bContext *C, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = CTX_data_active_object(C);
View2D *v2d = &ar->v2d;
bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0);
unsigned char color[3];
/* set this for all keyframe lines once and for all */
glLineWidth(1.0);
/* draw cache files keyframes (if available) */
UI_GetThemeColor3ubv(TH_TIME_KEYFRAME, color);
time_draw_caches_keyframes(CTX_data_main(C), view_layer, v2d, onlysel, color);
/* draw grease pencil keyframes (if available) */
UI_GetThemeColor3ubv(TH_TIME_GP_KEYFRAME, color);
if (scene->gpd) {
time_draw_idblock_keyframes(v2d, (ID *)scene->gpd, onlysel, color);
}
if (ob && ob->gpd) {
time_draw_idblock_keyframes(v2d, (ID *)ob->gpd, onlysel, color);
}
/* draw scene keyframes first
* - don't try to do this when only drawing active/selected data keyframes,
* since this can become quite slow
*/
if (onlysel == 0) {
/* set draw color */
UI_GetThemeColorShade3ubv(TH_TIME_KEYFRAME, -50, color);
time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel, color);
}
/* draw keyframes from selected objects
* - only do the active object if in posemode (i.e. showing only keyframes for the bones)
* OR the onlysel flag was set, which means that only active object's keyframes should
* be considered
*/
UI_GetThemeColor3ubv(TH_TIME_KEYFRAME, color);
if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) {
/* draw keyframes for active object only */
time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel, color);
}
else {
bool active_done = false;
/* draw keyframes from all selected objects */
CTX_DATA_BEGIN (C, Object *, obsel, selected_objects)
{
/* last arg is 0, since onlysel doesn't apply here... */
time_draw_idblock_keyframes(v2d, (ID *)obsel, 0, color);
/* if this object is the active one, set flag so that we don't draw again */
if (obsel == ob)
active_done = true;
}
CTX_DATA_END;
/* if active object hasn't been done yet, draw it... */
if (ob && (active_done == 0))
time_draw_idblock_keyframes(v2d, (ID *)ob, 0, color);
}
}
/* ---------------- */
/* editor level listener */
static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *UNUSED(scene),
WorkSpace *UNUSED(workspace))
{
/* mainly for updating cache display */
switch (wmn->category) {
case NC_OBJECT:
{
switch (wmn->data) {
case ND_BONE_SELECT:
case ND_BONE_ACTIVE:
case ND_POINTCACHE:
case ND_MODIFIER:
case ND_PARTICLE:
case ND_KEYS:
ED_area_tag_refresh(sa);
ED_area_tag_redraw(sa);
break;
}
break;
}
case NC_SCENE:
{
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;
}
}
break;
}
case NC_SPACE:
{
switch (wmn->data) {
case ND_SPACE_CHANGED:
ED_area_tag_refresh(sa);
break;
}
break;
}
case NC_WM:
{
switch (wmn->data) {
case ND_FILEREAD:
ED_area_tag_refresh(sa);
break;
}
break;
}
}
}
/* ---------------- */
/* add handlers, stuff you only do once or on area/region changes */
static void time_main_region_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
/* own keymap */
keymap = WM_keymap_find(wm->defaultconf, "Timeline", SPACE_TIME, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void time_main_region_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
Scene *scene = CTX_data_scene(C);
SpaceTime *stime = CTX_wm_space_time(C);
Object *obact = CTX_data_active_object(C);
View2D *v2d = &ar->v2d;
View2DGrid *grid;
View2DScrollers *scrollers;
int unit, flag = 0;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(v2d);
/* grid */
unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy);
UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS));
UI_view2d_grid_free(grid);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
/* start and end frame */
time_draw_sfra_efra(scene, v2d);
/* current frame */
flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */
if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS;
if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX;
ANIM_draw_cfra(C, v2d, flag);
UI_view2d_view_ortho(v2d);
/* keyframes */
time_draw_keyframes(C, ar);
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ED_markers_draw(C, 0);
/* caches */
time_draw_cache(stime, obact, scene);
/* callback */
UI_view2d_view_ortho(v2d);
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
/* reset view matrix */
UI_view2d_view_restore(C);
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
static void time_main_region_listener(
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
switch (wmn->category) {
case NC_SPACE:
if (wmn->data == ND_SPACE_TIME)
ED_region_tag_redraw(ar);
break;
case NC_ANIMATION:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
switch (wmn->data) {
case ND_OB_SELECT:
case ND_OB_ACTIVE:
case ND_FRAME:
case ND_FRAME_RANGE:
case ND_KEYINGSET:
case ND_RENDER_OPTIONS:
ED_region_tag_redraw(ar);
break;
}
break;
case NC_GPENCIL:
if (wmn->data == ND_DATA)
ED_region_tag_redraw(ar);
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
ED_region_tag_redraw(ar);
}
break;
}
}
static void time_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;
RNA_pointer_create(&screen->id, &RNA_SpaceTimeline, sa->spacedata.first, &ptr);
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__);
}
}
}
/* ************************ header time area region *********************** */
/* add handlers, stuff you only do once or on area/region changes */
static void time_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
{
ED_region_header_init(ar);
}
static void time_header_region_draw(const bContext *C, ARegion *ar)
{
ED_region_header(C, ar);
}
static void time_header_region_listener(
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
{
/* context changes */
switch (wmn->category) {
case NC_SCREEN:
{
if (wmn->data == ND_ANIMPLAY)
ED_region_tag_redraw(ar);
break;
}
case NC_SCENE:
{
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;
}
break;
}
case NC_SPACE:
{
if (wmn->data == ND_SPACE_TIME)
ED_region_tag_redraw(ar);
break;
}
}
}
/* ******************** default callbacks for time space ***************** */
static SpaceLink *time_new(const bContext *C)
{
Scene *scene = CTX_data_scene(C);
ARegion *ar;
SpaceTime *stime;
stime = MEM_callocN(sizeof(SpaceTime), "inittime");
stime->spacetype = SPACE_TIME;
stime->flag |= TIME_DRAWFRAMES;
/* enable all cache display */
stime->cache_display |= TIME_CACHE_DISPLAY;
stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES);
stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT);
stime->cache_display |= TIME_CACHE_RIGIDBODY;
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for time");
BLI_addtail(&stime->regionbase, ar);
ar->regiontype = RGN_TYPE_HEADER;
ar->alignment = RGN_ALIGN_BOTTOM;
/* main region */
ar = MEM_callocN(sizeof(ARegion), "main region for time");
BLI_addtail(&stime->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
ar->v2d.tot.xmin = (float)(SFRA - 4);
ar->v2d.tot.ymin = 0.0f;
ar->v2d.tot.xmax = (float)(EFRA + 4);
ar->v2d.tot.ymax = 50.0f;
ar->v2d.cur = ar->v2d.tot;
ar->v2d.min[0] = 1.0f;
ar->v2d.min[1] = 50.0f;
ar->v2d.max[0] = MAXFRAMEF;
ar->v2d.max[1] = 50.0;
ar->v2d.minzoom = 0.1f;
ar->v2d.maxzoom = 10.0;
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
ar->v2d.keepofs |= V2D_LOCKOFS_Y;
ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;
return (SpaceLink *)stime;
}
/* spacetype; init callback in ED_area_initialize() */
/* init is called to (re)initialize an existing editor (file read, screen changes) */
/* validate spacedata, add own area level handlers */
static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
{
//SpaceTime *stime = (SpaceTime *)sa->spacedata.first;
}
static SpaceLink *time_duplicate(SpaceLink *sl)
{
SpaceTime *stime = (SpaceTime *)sl;
SpaceTime *stimen = MEM_dupallocN(stime);
return (SpaceLink *)stimen;
}
/* only called once, from space_api/spacetypes.c */
/* it defines all callbacks to maintain spaces */
void ED_spacetype_time(void)
{
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time");
ARegionType *art;
st->spaceid = SPACE_TIME;
strncpy(st->name, "Timeline", BKE_ST_MAXNAME);
st->new = time_new;
st->init = time_init;
st->duplicate = time_duplicate;
st->operatortypes = time_operatortypes;
st->keymap = NULL;
st->listener = time_listener;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
art->regionid = RGN_TYPE_WINDOW;
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
art->init = time_main_region_init;
art->draw = time_main_region_draw;
art->listener = time_main_region_listener;
art->message_subscribe = time_main_region_message_subscribe;
art->keymap = time_keymap;
art->lock = 1; /* Due to pointcache, see T4960. */
BLI_addhead(&st->regiontypes, art);
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype time region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->init = time_header_region_init;
art->draw = time_header_region_draw;
art->listener = time_header_region_listener;
BLI_addhead(&st->regiontypes, art);
BKE_spacetype_register(st);
}

View File

@ -1,43 +0,0 @@
/*
* ***** 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,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/editors/space_time/time_intern.h
* \ingroup sptime
*/
#ifndef __TIME_INTERN_H__
#define __TIME_INTERN_H__
/* internal exports only */
/* time_ops.c */
void time_operatortypes(void);
void time_keymap(struct wmKeyConfig *keyconf);
#endif /* __TIME_INTERN_H__ */

View File

@ -1,138 +0,0 @@
/*
* ***** 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,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/editors/space_time/time_ops.c
* \ingroup sptime
*/
#include <stdlib.h>
#include <math.h>
#include "DNA_scene_types.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
#include "ED_anim_api.h"
#include "ED_screen.h"
#include "WM_api.h"
#include "WM_types.h"
#include "time_intern.h"
/* ************************ View All Operator *******************************/
static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
if (ELEM(NULL, scene, ar))
return OPERATOR_CANCELLED;
View2D *v2d = &ar->v2d;
/* set extents of view to start/end frames (Preview Range too) */
v2d->cur.xmin = (float)PSFRA;
v2d->cur.xmax = (float)PEFRA;
/* we need an extra "buffer" factor on either side so that the endpoints are visible */
const float extra = 0.01f * BLI_rctf_size_x(&v2d->cur);
v2d->cur.xmin -= extra;
v2d->cur.xmax += extra;
/* this only affects this TimeLine instance, so just force redraw of this region */
ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
}
static void TIME_OT_view_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "View All";
ot->idname = "TIME_OT_view_all";
ot->description = "Show the entire playable frame range";
/* api callbacks */
ot->exec = time_view_all_exec;
ot->poll = ED_operator_timeline_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ************************ View Frame Operator *******************************/
static int time_view_frame_exec(bContext *C, wmOperator *op)
{
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
ANIM_center_frame(C, smooth_viewtx);
return OPERATOR_FINISHED;
}
static void TIME_OT_view_frame(wmOperatorType *ot)
{
/* identifiers */
ot->name = "View Frame";
ot->idname = "TIME_OT_view_frame";
ot->description = "Reset viewable area to show range around current frame";
/* api callbacks */
ot->exec = time_view_frame_exec;
ot->poll = ED_operator_timeline_active;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ************************** registration **********************************/
void time_operatortypes(void)
{
WM_operatortype_append(TIME_OT_view_all);
WM_operatortype_append(TIME_OT_view_frame);
}
void time_keymap(wmKeyConfig *keyconf)
{
wmKeyMap *keymap = WM_keymap_find(keyconf, "Timeline", SPACE_TIME, 0);
WM_keymap_add_item(keymap, "ANIM_OT_start_frame_set", SKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ANIM_OT_end_frame_set", EKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "TIME_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
#ifdef WITH_INPUT_NDOF
WM_keymap_add_item(keymap, "TIME_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
#endif
WM_keymap_add_item(keymap, "TIME_OT_view_frame", PAD0, KM_PRESS, 0, 0);
}

View File

@ -474,30 +474,6 @@ typedef enum eSpaceNla_Flag {
/* Timeline =============================================== */
/* Timeline View */
typedef struct SpaceTime {
SpaceLink *next, *prev;
ListBase regionbase; /* storage of regions for inactive spaces */
int spacetype;
float blockscale DNA_DEPRECATED;
View2D v2d DNA_DEPRECATED; /* deprecated, copied to region */
int cache_display;
int flag;
} SpaceTime;
/* time->flag */
typedef enum eTimeline_Flag {
/* show timing in frames instead of in seconds */
TIME_DRAWFRAMES = (1 << 0),
/* show time indicator box beside the frame number */
TIME_CFRA_NUM = (1 << 1),
/* only keyframes from active/selected channels get shown */
TIME_ONLYACTSEL = (1 << 2),
} eTimeline_Flag;
/* time->redraws (now screen->redraws_flag) */
typedef enum eScreen_Redraws_Flag {
TIME_REGION = (1 << 0),
@ -514,8 +490,6 @@ typedef enum eScreen_Redraws_Flag {
TIME_FOLLOW = (1 << 15),
} eScreen_Redraws_Flag;
/* Sequence Editor ======================================= */
/* Sequencer */
@ -1406,7 +1380,7 @@ typedef enum eSpace_Type {
SPACE_NLA = 13,
/* TODO: fully deprecate */
SPACE_SCRIPT = 14, /* Deprecated */
SPACE_TIME = 15,
SPACE_TIME = 15, /* Deprecated */
SPACE_NODE = 16,
SPACE_LOGIC = 17, /* deprecated */
SPACE_CONSOLE = 18,

View File

@ -577,7 +577,6 @@ extern StructRNA RNA_SpaceOutliner;
extern StructRNA RNA_SpaceProperties;
extern StructRNA RNA_SpaceSequenceEditor;
extern StructRNA RNA_SpaceTextEditor;
extern StructRNA RNA_SpaceTimeline;
extern StructRNA RNA_SpaceUVEditor;
extern StructRNA RNA_SpaceUserPreferences;
extern StructRNA RNA_SpaceView3D;
@ -651,7 +650,6 @@ extern StructRNA RNA_ThemeSpaceGradient;
extern StructRNA RNA_ThemeSpaceListGeneric;
extern StructRNA RNA_ThemeStyle;
extern StructRNA RNA_ThemeTextEditor;
extern StructRNA RNA_ThemeTimeline;
extern StructRNA RNA_ThemeUserInterface;
extern StructRNA RNA_ThemeUserPreferences;
extern StructRNA RNA_ThemeView3D;

View File

@ -72,8 +72,10 @@ static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
{
bScreen *screen = (bScreen *)ptr->data;
/* the settings for this are currently only available from a menu in the TimeLine, hence refresh=SPACE_TIME */
ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_TIME);
/* the settings for this are currently only available from a menu in the TimeLine,
* hence refresh=SPACE_ACTION, as timeline is now in there
*/
ED_screen_animation_timer_update(screen, screen->redraws_flag, SPACE_ACTION);
}
static int rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))

View File

@ -75,7 +75,7 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
/* Animation */
{0, "", ICON_NONE, "Animation", ""},
{SPACE_TIME, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls"},
//{SPACE_ACTION, "TIMELINE", ICON_TIME, "Timeline", "Timeline and playback controls (NOTE: Switch to 'Timeline' mode)"}, /* XXX */
{SPACE_IPO, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", "Edit drivers and keyframe interpolation"},
{SPACE_ACTION, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", "Adjust timing of keyframes"},
{SPACE_NLA, "NLA_EDITOR", ICON_NLA, "NLA Editor", "Combine and layer Actions"},
@ -310,8 +310,6 @@ static StructRNA *rna_Space_refine(struct PointerRNA *ptr)
return &RNA_SpaceDopeSheetEditor;
case SPACE_NLA:
return &RNA_SpaceNLA;
case SPACE_TIME:
return &RNA_SpaceTimeline;
case SPACE_NODE:
return &RNA_SpaceNodeEditor;
case SPACE_CONSOLE:
@ -3529,63 +3527,6 @@ static void rna_def_space_nla(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NLA, NULL);
}
static void rna_def_space_time(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "SpaceTimeline", "Space");
RNA_def_struct_sdna(srna, "SpaceTime");
RNA_def_struct_ui_text(srna, "Space Timeline Editor", "Timeline editor space data");
/* view settings */
prop = RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_CFRA_NUM);
RNA_def_property_ui_text(prop, "Show Frame Number Indicator",
"Show frame number beside the current frame indicator line");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TIME_DRAWFRAMES);
RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
/* displaying cache status */
prop = RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY);
RNA_def_property_ui_text(prop, "Show Cache", "Show the status of cached frames in the timeline");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_softbody", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SOFTBODY);
RNA_def_property_ui_text(prop, "Softbody", "Show the active object's softbody point cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_particles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_PARTICLES);
RNA_def_property_ui_text(prop, "Particles", "Show the active object's particle point cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_cloth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_CLOTH);
RNA_def_property_ui_text(prop, "Cloth", "Show the active object's cloth point cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_smoke", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_SMOKE);
RNA_def_property_ui_text(prop, "Smoke", "Show the active object's smoke cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_dynamicpaint", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DYNAMICPAINT);
RNA_def_property_ui_text(prop, "Dynamic Paint", "Show the active object's Dynamic Paint cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
prop = RNA_def_property(srna, "cache_rigidbody", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_RIGIDBODY);
RNA_def_property_ui_text(prop, "Rigid Body", "Show the active object's Rigid Body cache");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, NULL);
}
static void rna_def_console_line(BlenderRNA *brna)
{
@ -4561,7 +4502,6 @@ void RNA_def_space(BlenderRNA *brna)
rna_def_space_dopesheet(brna);
rna_def_space_graph(brna);
rna_def_space_nla(brna);
rna_def_space_time(brna);
rna_def_space_console(brna);
rna_def_console_line(brna);
rna_def_space_info(brna);

View File

@ -2296,44 +2296,6 @@ static void rna_def_userdef_theme_space_buts(BlenderRNA *brna)
}
static void rna_def_userdef_theme_space_time(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/* space_time */
srna = RNA_def_struct(brna, "ThemeTimeline", NULL);
RNA_def_struct_sdna(srna, "ThemeSpace");
RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
RNA_def_struct_ui_text(srna, "Theme Timeline", "Theme settings for the Timeline");
rna_def_userdef_theme_spaces_main(srna);
prop = RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Grid", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "frame_current", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "cframe");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Current Frame", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "time_keyframe", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "time_keyframe");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Keyframe", "Base color for keyframe indicator lines");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop = RNA_def_property(srna, "time_grease_pencil", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "time_gp_keyframe");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Grease Pencil", "Color of Grease Pencil keyframes");
RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_space_image(BlenderRNA *brna)
{
StructRNA *srna;
@ -2989,7 +2951,6 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
{19, "STYLE", ICON_FONTPREVIEW, "Text Style", ""},
{18, "BONE_COLOR_SETS", ICON_COLOR, "Bone Color Sets", ""},
{1, "VIEW_3D", ICON_VIEW3D, "3D View", ""},
{2, "TIMELINE", ICON_TIME, "Timeline", ""},
{3, "GRAPH_EDITOR", ICON_IPO, "Graph Editor", ""},
{4, "DOPESHEET_EDITOR", ICON_ACTION, "Dope Sheet", ""},
{5, "NLA_EDITOR", ICON_NLA, "NLA Editor", ""},
@ -3085,12 +3046,6 @@ static void rna_def_userdef_themes(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "ThemeTextEditor");
RNA_def_property_ui_text(prop, "Text Editor", "");
prop = RNA_def_property(srna, "timeline", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "ttime");
RNA_def_property_struct_type(prop, "ThemeTimeline");
RNA_def_property_ui_text(prop, "Timeline", "");
prop = RNA_def_property(srna, "node_editor", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_pointer_sdna(prop, NULL, "tnode");
@ -3221,7 +3176,6 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna)
rna_def_userdef_theme_space_seq(brna);
rna_def_userdef_theme_space_buts(brna);
rna_def_userdef_theme_space_text(brna);
rna_def_userdef_theme_space_time(brna);
rna_def_userdef_theme_space_node(brna);
rna_def_userdef_theme_space_outliner(brna);
rna_def_userdef_theme_space_info(brna);

View File

@ -168,7 +168,6 @@ static eSpace_Type rna_Space_refine_reverse(StructRNA *srna)
if (srna == &RNA_SpaceTextEditor) return SPACE_TEXT;
if (srna == &RNA_SpaceDopeSheetEditor) return SPACE_ACTION;
if (srna == &RNA_SpaceNLA) return SPACE_NLA;
if (srna == &RNA_SpaceTimeline) return SPACE_TIME;
if (srna == &RNA_SpaceNodeEditor) return SPACE_NODE;
if (srna == &RNA_SpaceConsole) return SPACE_CONSOLE;
if (srna == &RNA_SpaceUserPreferences) return SPACE_USERPREF;

View File

@ -34,7 +34,7 @@ defs = """
SPACE_ACTION,
SPACE_NLA,
SPACE_SCRIPT, #Deprecated
SPACE_TIME,
SPACE_TIME, #Deprecated
SPACE_NODE,
SPACEICONMAX
"""

View File

@ -1817,10 +1817,6 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
break;
}
}
/* Timeline */
else if (STRPREFIX(opname, "TIME_OT")) {
km = WM_keymap_find_all(C, "Timeline", sl->spacetype, 0);
}
/* Image Editor */
else if (STRPREFIX(opname, "IMAGE_OT")) {
km = WM_keymap_find_all(C, "Image", sl->spacetype, 0);