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
|
|
|
|
|
|
|
|
/* ******************** 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;
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2008-12-16 12:24:24 +01:00
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
|
2008-12-14 15:43:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sequencer_header_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
float col[3];
|
|
|
|
|
|
|
|
/* clear */
|
|
|
|
if(ED_screen_area_active(C))
|
|
|
|
UI_GetThemeColor3fv(TH_HEADER, col);
|
|
|
|
else
|
|
|
|
UI_GetThemeColor3fv(TH_HEADERDESEL, col);
|
|
|
|
|
|
|
|
glClearColor(col[0], col[1], col[2], 0.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
/* set view2d view matrix for scrolling (without scrollers) */
|
|
|
|
UI_view2d_view_ortho(C, &ar->v2d);
|
|
|
|
|
|
|
|
sequencer_header_buttons(C, ar);
|
|
|
|
|
|
|
|
/* restore view matrix? */
|
|
|
|
UI_view2d_view_restore(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
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);
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
|
|
|
|
BKE_spacetype_register(st);
|
|
|
|
}
|
|
|
|
|