2008-12-14 15:43:08 +01:00
|
|
|
/**
|
|
|
|
* $Id:
|
|
|
|
*
|
|
|
|
* ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
#include "BLI_rand.h"
|
|
|
|
|
|
|
|
#include "BKE_colortools.h"
|
2008-12-18 03:56:48 +01:00
|
|
|
#include "BKE_context.h"
|
2008-12-14 15:43:08 +01:00
|
|
|
#include "BKE_screen.h"
|
2009-01-12 20:02:08 +01:00
|
|
|
#include "BKE_sequence.h"
|
2008-12-14 15:43:08 +01:00
|
|
|
|
|
|
|
#include "ED_space_api.h"
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "ED_markers.h"
|
|
|
|
|
|
|
|
#include "sequencer_intern.h" // own include
|
|
|
|
|
2009-06-08 12:38:28 +02:00
|
|
|
/* ******************** manage regions ********************* */
|
|
|
|
|
|
|
|
ARegion *sequencer_has_buttons_region(ScrArea *sa)
|
|
|
|
{
|
|
|
|
ARegion *ar, *arnew;
|
|
|
|
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
|
|
|
if(ar->regiontype==RGN_TYPE_UI)
|
|
|
|
return ar;
|
|
|
|
|
|
|
|
/* add subdiv level; after header */
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
|
|
|
if(ar->regiontype==RGN_TYPE_HEADER)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* is error! */
|
|
|
|
if(ar==NULL) return NULL;
|
|
|
|
|
|
|
|
arnew= MEM_callocN(sizeof(ARegion), "buttons for sequencer");
|
|
|
|
|
|
|
|
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 15:43:08 +01:00
|
|
|
/* ******************** default callbacks for sequencer space ***************** */
|
|
|
|
|
2008-12-22 11:09:56 +01:00
|
|
|
static SpaceLink *sequencer_new(const bContext *C)
|
2008-12-14 15:43:08 +01:00
|
|
|
{
|
2008-12-22 11:09:56 +01:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
2008-12-14 15:43:08 +01:00
|
|
|
ARegion *ar;
|
|
|
|
SpaceSeq *sseq;
|
|
|
|
|
|
|
|
sseq= MEM_callocN(sizeof(SpaceSeq), "initsequencer");
|
|
|
|
sseq->spacetype= SPACE_SEQ;
|
|
|
|
sseq->zoom= 4;
|
|
|
|
sseq->chanshown = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* header */
|
|
|
|
ar= MEM_callocN(sizeof(ARegion), "header for sequencer");
|
|
|
|
|
|
|
|
BLI_addtail(&sseq->regionbase, ar);
|
|
|
|
ar->regiontype= RGN_TYPE_HEADER;
|
|
|
|
ar->alignment= RGN_ALIGN_BOTTOM;
|
|
|
|
|
2009-06-08 12:38:28 +02:00
|
|
|
/* buttons/list view */
|
|
|
|
ar= MEM_callocN(sizeof(ARegion), "buttons for sequencer");
|
|
|
|
|
|
|
|
BLI_addtail(&sseq->regionbase, ar);
|
|
|
|
ar->regiontype= RGN_TYPE_UI;
|
|
|
|
ar->alignment= RGN_ALIGN_RIGHT;
|
|
|
|
ar->flag = RGN_FLAG_HIDDEN;
|
|
|
|
|
2008-12-14 15:43:08 +01:00
|
|
|
/* main area */
|
|
|
|
ar= MEM_callocN(sizeof(ARegion), "main area for sequencer");
|
|
|
|
|
|
|
|
BLI_addtail(&sseq->regionbase, ar);
|
|
|
|
ar->regiontype= RGN_TYPE_WINDOW;
|
|
|
|
|
|
|
|
|
2008-12-22 11:09:56 +01:00
|
|
|
/* seq space goes from (0,8) to (0, efra) */
|
2008-12-14 15:43:08 +01:00
|
|
|
|
|
|
|
ar->v2d.tot.xmin= 0.0f;
|
|
|
|
ar->v2d.tot.ymin= 0.0f;
|
2008-12-22 11:09:56 +01:00
|
|
|
ar->v2d.tot.xmax= scene->r.efra;
|
2008-12-14 15:43:08 +01:00
|
|
|
ar->v2d.tot.ymax= 8.0f;
|
|
|
|
|
|
|
|
ar->v2d.cur= ar->v2d.tot;
|
|
|
|
|
|
|
|
ar->v2d.min[0]= 10.0f;
|
|
|
|
ar->v2d.min[1]= 4.0f;
|
|
|
|
|
|
|
|
ar->v2d.max[0]= MAXFRAMEF;
|
|
|
|
ar->v2d.max[1]= MAXSEQ;
|
|
|
|
|
|
|
|
ar->v2d.minzoom= 0.01f;
|
|
|
|
ar->v2d.maxzoom= 100.0f;
|
|
|
|
|
2008-12-15 12:58:57 +01:00
|
|
|
ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
|
|
|
ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
|
2008-12-14 15:43:08 +01:00
|
|
|
ar->v2d.keepzoom= 0;
|
|
|
|
ar->v2d.keeptot= 0;
|
2009-01-12 23:54:30 +01:00
|
|
|
ar->v2d.align= V2D_ALIGN_NO_NEG_Y;
|
2008-12-14 15:43:08 +01:00
|
|
|
|
|
|
|
return (SpaceLink *)sseq;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not spacelink itself */
|
|
|
|
static void sequencer_free(SpaceLink *sl)
|
|
|
|
{
|
|
|
|
// SpaceSeq *sseq= (SpaceSequencer*) sl;
|
|
|
|
|
|
|
|
// XXX if(sseq->gpd) free_gpencil_data(sseq->gpd);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* spacetype; init callback */
|
|
|
|
static void sequencer_init(struct wmWindowManager *wm, ScrArea *sa)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static SpaceLink *sequencer_duplicate(SpaceLink *sl)
|
|
|
|
{
|
|
|
|
SpaceSeq *sseqn= MEM_dupallocN(sl);
|
|
|
|
|
|
|
|
/* clear or remove stuff from old */
|
|
|
|
// XXX sseq->gpd= gpencil_data_duplicate(sseq->gpd);
|
|
|
|
|
|
|
|
return (SpaceLink *)sseqn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
|
|
|
ListBase *keymap;
|
|
|
|
|
2008-12-17 11:25:02 +01:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
|
2008-12-14 15:43:08 +01:00
|
|
|
|
|
|
|
/* own keymap */
|
|
|
|
keymap= WM_keymap_listbase(wm, "Sequencer", SPACE_SEQ, 0); /* XXX weak? */
|
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void sequencer_header_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
2009-06-08 18:48:12 +02:00
|
|
|
ED_region_header_init(ar);
|
2008-12-14 15:43:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sequencer_header_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
2009-06-08 18:48:12 +02:00
|
|
|
ED_region_header(C, ar);
|
2008-12-14 15:43:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
|
|
|
{
|
Added back some functionality to the sequencer
- removed static vars _last_seq, last_imagename and last_sounddir, replacing them with with vars in the "Editing" struct. didnt manage to get the active sequence to load so currently thats lost when loading.
- removed flag SEQ_ACTIVE
- Added operators cut, mute, unmute, deselect_all, select_invert, select, select_more, select_less, select_pick_linked, select_linked and borderselect.
2009-01-19 22:42:18 +01:00
|
|
|
/* context changes */
|
|
|
|
switch(wmn->category) {
|
|
|
|
case NC_SCENE:
|
|
|
|
switch(wmn->data) {
|
|
|
|
case ND_FRAME:
|
|
|
|
case ND_MARKERS:
|
2009-01-21 08:01:20 +01:00
|
|
|
case ND_SEQUENCER:
|
Added back some functionality to the sequencer
- removed static vars _last_seq, last_imagename and last_sounddir, replacing them with with vars in the "Editing" struct. didnt manage to get the active sequence to load so currently thats lost when loading.
- removed flag SEQ_ACTIVE
- Added operators cut, mute, unmute, deselect_all, select_invert, select, select_more, select_less, select_pick_linked, select_linked and borderselect.
2009-01-19 22:42:18 +01:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
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 22:51:09 +02:00
|
|
|
case NC_SPACE:
|
|
|
|
if(wmn->data == ND_SPACE_SEQUENCER)
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
Added back some functionality to the sequencer
- removed static vars _last_seq, last_imagename and last_sounddir, replacing them with with vars in the "Editing" struct. didnt manage to get the active sequence to load so currently thats lost when loading.
- removed flag SEQ_ACTIVE
- Added operators cut, mute, unmute, deselect_all, select_invert, select, select_more, select_less, select_pick_linked, select_linked and borderselect.
2009-01-19 22:42:18 +01:00
|
|
|
}
|
2008-12-14 15:43:08 +01:00
|
|
|
}
|
|
|
|
|
2009-06-08 12:38:28 +02:00
|
|
|
/* *********************** buttons region ************************ */
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void sequencer_buttons_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
|
|
|
|
|
|
|
ED_region_panels_init(wm, ar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sequencer_buttons_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
2009-07-30 00:57:53 +02:00
|
|
|
ED_region_panels(C, ar, 1, NULL, -1);
|
2009-06-08 12:38:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
|
|
|
|
{
|
|
|
|
/* context changes */
|
|
|
|
switch(wmn->category) {
|
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 22:51:09 +02:00
|
|
|
case NC_SPACE:
|
|
|
|
if(wmn->data == ND_SPACE_SEQUENCER)
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
2009-06-08 12:38:28 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* ************************************* */
|
|
|
|
|
2008-12-14 15:43:08 +01:00
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
void ED_spacetype_sequencer(void)
|
|
|
|
{
|
|
|
|
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype sequencer");
|
|
|
|
ARegionType *art;
|
|
|
|
|
|
|
|
st->spaceid= SPACE_SEQ;
|
|
|
|
|
|
|
|
st->new= sequencer_new;
|
|
|
|
st->free= sequencer_free;
|
|
|
|
st->init= sequencer_init;
|
|
|
|
st->duplicate= sequencer_duplicate;
|
|
|
|
st->operatortypes= sequencer_operatortypes;
|
|
|
|
st->keymap= sequencer_keymap;
|
|
|
|
|
|
|
|
/* regions: main window */
|
|
|
|
art= MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
|
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
|
|
|
art->init= sequencer_main_area_init;
|
2009-01-12 20:02:08 +01:00
|
|
|
art->draw= drawseqspace;
|
2008-12-14 15:43:08 +01:00
|
|
|
art->listener= sequencer_main_area_listener;
|
2009-01-23 15:43:25 +01:00
|
|
|
art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
|
2008-12-14 15:43:08 +01:00
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
2009-06-08 12:38:28 +02:00
|
|
|
/* regions: listview/buttons */
|
|
|
|
art= MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
|
|
|
|
art->regionid = RGN_TYPE_UI;
|
|
|
|
art->minsizex= 220; // XXX
|
|
|
|
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
|
|
|
|
art->listener= sequencer_buttons_area_listener;
|
|
|
|
art->init= sequencer_buttons_area_init;
|
|
|
|
art->draw= sequencer_buttons_area_draw;
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
2009-06-08 18:48:12 +02:00
|
|
|
/* Keep as python only for now
|
2009-06-08 12:38:28 +02:00
|
|
|
sequencer_buttons_register(art);
|
2009-06-08 18:48:12 +02:00
|
|
|
*/
|
2009-06-08 12:38:28 +02:00
|
|
|
|
2008-12-14 15:43:08 +01:00
|
|
|
/* regions: header */
|
|
|
|
art= MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
|
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
|
|
|
art->minsizey= HEADERY;
|
2009-01-23 15:43:25 +01:00
|
|
|
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
|
2008-12-14 15:43:08 +01:00
|
|
|
|
|
|
|
art->init= sequencer_header_area_init;
|
|
|
|
art->draw= sequencer_header_area_draw;
|
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 22:51:09 +02:00
|
|
|
art->listener= sequencer_main_area_listener;
|
2008-12-14 15:43:08 +01:00
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
BKE_spacetype_register(st);
|
|
|
|
}
|
|
|
|
|