Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2008-11-30 09:15:33 +0300
committerJoshua Leung <aligorith@gmail.com>2008-11-30 09:15:33 +0300
commit43b26b72ab0df5ff8bbdb7e30c761099b95385a6 (patch)
tree07457dfbcfb633975e36c67482c5743b9836025a /source/blender/editors/space_time
parent970fa83fab52387aa3f9aa0f3e90d73b5af52bfd (diff)
View2D - Initial commit of Pan-View Operator
* Moved View2D data from space-data to ARegion (aka regions). This has been done because drawing occurs in regions not areas anymore. The View2D struct is currently stored in the ARegion struct (not as pointer), given that most of the regions in use will be 2D anyway (only the 3d-view's "window" region is the exception). Added version patch code for outliner and timeline only for now. Headers are also likely to need this. * Added separate keymap for View2D operators. All regions that use View2D will need this added. This includes headers too. * Pan view operator (ED_View2D_OT_view_pan), currently works for Outliner and Timeline. Use MMB-drag as before. - It currently doesn't exposed any parameters for redo (via RNA-ID-Props), but only uses some customdata. Suggestions on what these parameters could be are welcomed. - I've yet to implement the necessary axis-locking features for this panning (which is required in Timeline for example to prevent vertical panning, which moves the markers out of view).
Diffstat (limited to 'source/blender/editors/space_time')
-rw-r--r--source/blender/editors/space_time/space_time.c34
-rw-r--r--source/blender/editors/space_time/time_ops.c8
2 files changed, 23 insertions, 19 deletions
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index bc7c86c173e..e500477ba23 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -58,7 +58,7 @@
/* ************************ main time area region *********************** */
/* draws a current frame indicator for the TimeLine */
-static void time_draw_cfra_time(const bContext *C, SpaceTime *stime)
+static void time_draw_cfra_time(const bContext *C, SpaceTime *stime, ARegion *ar)
{
Scene *scene= C->scene;
float vec[2];
@@ -69,33 +69,33 @@ static void time_draw_cfra_time(const bContext *C, SpaceTime *stime)
glLineWidth(3.0);
glBegin(GL_LINES);
- vec[1]= stime->v2d.cur.ymin;
+ vec[1]= ar->v2d.cur.ymin;
glVertex2fv(vec);
- vec[1]= stime->v2d.cur.ymax;
+ vec[1]= ar->v2d.cur.ymax;
glVertex2fv(vec);
glEnd();
glLineWidth(1.0);
}
-static void time_draw_sfra_efra(const bContext *C, SpaceTime *stime)
+static void time_draw_sfra_efra(const bContext *C, SpaceTime *stime, ARegion *ar)
{
/* draw darkened area outside of active timeline
* frame range used is preview range or scene range */
UI_ThemeColorShade(TH_BACK, -25);
if (PSFRA < PEFRA) {
- glRectf(stime->v2d.cur.xmin, stime->v2d.cur.ymin, PSFRA, stime->v2d.cur.ymax);
- glRectf(PEFRA, stime->v2d.cur.ymin, stime->v2d.cur.xmax, stime->v2d.cur.ymax);
+ glRectf(ar->v2d.cur.xmin, ar->v2d.cur.ymin, PSFRA, ar->v2d.cur.ymax);
+ glRectf(PEFRA, ar->v2d.cur.ymin, ar->v2d.cur.xmax, ar->v2d.cur.ymax);
}
else {
- glRectf(stime->v2d.cur.xmin, stime->v2d.cur.ymin, stime->v2d.cur.xmax, stime->v2d.cur.ymax);
+ glRectf(ar->v2d.cur.xmin, ar->v2d.cur.ymin, ar->v2d.cur.xmax, ar->v2d.cur.ymax);
}
UI_ThemeColorShade(TH_BACK, -60);
/* thin lines where the actual frames are */
- fdrawline(PSFRA, stime->v2d.cur.ymin, PSFRA, stime->v2d.cur.ymax);
- fdrawline(PEFRA, stime->v2d.cur.ymin, PEFRA, stime->v2d.cur.ymax);
+ fdrawline(PSFRA, ar->v2d.cur.ymin, PSFRA, ar->v2d.cur.ymax);
+ fdrawline(PEFRA, ar->v2d.cur.ymin, PEFRA, ar->v2d.cur.ymax);
}
static void time_main_area_init(const bContext *C, ARegion *ar)
@@ -112,6 +112,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, windowsize changes should be handled here */
SpaceTime *stime= C->area->spacedata.first;
+ View2D *v2d= &ar->v2d;
View2DGrid *grid;
float col[3];
int unit, winx, winy;
@@ -119,26 +120,26 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
winx= ar->winrct.xmax-ar->winrct.xmin;
winy= ar->winrct.ymax-ar->winrct.ymin;
- UI_view2d_update_size(&stime->v2d, winx, winy);
+ UI_view2d_update_size(v2d, winx, winy);
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
- UI_view2d_ortho(C, &stime->v2d);
+ UI_view2d_ortho(C, v2d);
/* start and end frame */
- time_draw_sfra_efra(C, stime);
+ time_draw_sfra_efra(C, stime, ar);
/* grid */
unit= (stime->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS;
- grid= UI_view2d_calc_grid(C, &stime->v2d, unit, V2D_GRID_CLAMP, winx, winy);
- UI_view2d_draw_grid(C, &stime->v2d, grid, V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS);
+ grid= UI_view2d_calc_grid(C, v2d, unit, V2D_GRID_CLAMP, winx, winy);
+ UI_view2d_draw_grid(C, v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS));
UI_view2d_free_grid(grid);
/* current frame */
- time_draw_cfra_time(C, stime);
+ time_draw_cfra_time(C, stime, ar);
/* markers */
draw_markers_time(C, 0);
@@ -180,6 +181,7 @@ static SpaceLink *time_new(void)
stime->blockscale= 0.7;
stime->redraws= TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN;
+ // XXX move to region!
stime->v2d.tot.xmin= -4.0;
stime->v2d.tot.ymin= 0.0;
stime->v2d.tot.xmax= (float)EFRA + 4.0;
@@ -240,6 +242,7 @@ static void time_init(wmWindowManager *wm, ScrArea *sa)
* be looked at further */
WM_event_remove_keymap_handler(&ar->handlers, &wm->timekeymap);
WM_event_add_keymap_handler(&ar->handlers, &wm->timekeymap);
+ WM_event_add_keymap_handler(&ar->handlers, &wm->view2dkeymap); // XXX this should be added automatically!
}
else if(ar->regiontype == RGN_TYPE_HEADER) {
static ARegionType headerart={NULL, NULL, NULL, NULL, NULL};
@@ -249,6 +252,7 @@ static void time_init(wmWindowManager *wm, ScrArea *sa)
ar->type= &headerart;
WM_event_add_keymap_handler(&ar->handlers, &wm->uikeymap);
+ WM_event_add_keymap_handler(&ar->handlers, &wm->view2dkeymap); // XXX this should be added automatically!
}
else {
static ARegionType art={NULL, NULL, NULL, NULL, NULL};
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
index acf9d392ed4..bc30d07f878 100644
--- a/source/blender/editors/space_time/time_ops.c
+++ b/source/blender/editors/space_time/time_ops.c
@@ -111,10 +111,10 @@ static int frame_from_event(bContext *C, wmEvent *event)
ARegion *region= C->region;
int x, y;
float viewx;
-
+
x= event->x - region->winrct.xmin;
y= event->y - region->winrct.ymin;
- UI_view2d_region_to_view(&stime->v2d, x, y, &viewx, NULL);
+ UI_view2d_region_to_view(&region->v2d, x, y, &viewx, NULL);
return (int)(viewx+0.5f);
}
@@ -126,7 +126,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event)
change_frame_apply(C, op);
/* add temp handler */
- WM_event_add_modal_handler(&C->region->handlers, op);
+ WM_event_add_modal_handler(&C->region->handlers, op); // XXX should be for window, but we crash otherwise
return OPERATOR_RUNNING_MODAL;
}
@@ -149,7 +149,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event)
case LEFTMOUSE:
if(event->val==0) {
change_frame_exit(C, op);
- WM_event_remove_modal_handler(&C->region->handlers, op);
+ WM_event_remove_modal_handler(&C->region->handlers, op); // XXX should be for window, but we crash otherwise
return OPERATOR_FINISHED;
}
break;