From 0b2a6e38e4ee2fe3e887b16952fd0528b4e61a3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 21 Jan 2008 23:06:23 +0000 Subject: [PATCH] Added view2d_getscale function for getting the opengl x/y scale for 2d windows. Display/Edit TimeOffset accounting for its added parent offset. removed Extension button by mistake. --- source/blender/include/BSE_drawipo.h | 1 + source/blender/src/buttons_object.c | 13 ++++++++++++- source/blender/src/buttons_scene.c | 2 ++ source/blender/src/drawipo.c | 4 ++++ source/blender/src/drawtime.c | 8 +++----- source/blender/src/editipo.c | 4 ++-- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/source/blender/include/BSE_drawipo.h b/source/blender/include/BSE_drawipo.h index 07f116d8d67..2053f41a178 100644 --- a/source/blender/include/BSE_drawipo.h +++ b/source/blender/include/BSE_drawipo.h @@ -55,6 +55,7 @@ void ipoco_to_areaco_noclip (struct View2D *v2d, float *vec, short *mval); void view2d_do_locks (struct ScrArea *cursa, int flag); void view2d_zoom (struct View2D *v2d, float factor, int winx, int winy); +void view2d_getscale (struct View2D *v2d, float *x, float *y); void test_view2d (struct View2D *v2d, int winx, int winy); void calc_scrollrcts (struct ScrArea *sa, struct View2D *v2d, int winx, int winy); diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 1da1ab3c749..54e81cc0667 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -2446,9 +2446,16 @@ static void object_panel_object(Object *ob) uiNewPanelHeight(block, 204 - (120-yco)); } +static void object_panel_anim_timeoffset_callback( void *data, void *timeoffset_ui) { + Object *ob = (Object *)data; + ob->sf = (*(float *)timeoffset_ui) - (give_timeoffset(ob) - ob->sf); +} + static void object_panel_anim(Object *ob) { uiBlock *block; + uiBut *but; + static float timeoffset_ui; char str[32]; block= uiNewBlock(&curarea->uiblocks, "object_panel_anim", UI_EMBOSS, UI_HELV, curarea->win); @@ -2500,7 +2507,11 @@ static void object_panel_anim(Object *ob) uiBlockEndAlign(block); uiBlockBeginAlign(block); - uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 24,35,115,20, &ob->sf, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Animation offset in frames for ipo's and dupligroup instances"); + + timeoffset_ui = give_timeoffset(ob); + but = uiDefButF(block, NUM, REDRAWALL, "TimeOffset:", 24,35,115,20, &timeoffset_ui, -MAXFRAMEF, MAXFRAMEF, 100, 0, "Animation offset in frames for ipo's and dupligroup instances"); + uiButSetFunc(but, object_panel_anim_timeoffset_callback, ob, &timeoffset_ui); + uiDefBut(block, BUT, B_AUTOTIMEOFS, "Auto", 139,35,34,20, 0, 0, 0, 0, 0, "Assign selected objects a timeoffset within a range, starting from the active object"); uiDefBut(block, BUT, B_OFSTIMEOFS, "Ofs", 173,35,34,20, 0, 0, 0, 0, 0, "Offset selected objects timeoffset"); uiDefBut(block, BUT, B_RANDTIMEOFS, "Rand", 207,35,34,20, 0, 0, 0, 0, 0, "Randomize selected objects timeoffset"); diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index b8ec72eff8c..0dc6c485db5 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -1873,6 +1873,8 @@ static void render_panel_output(void) uiDefButS(block, MENU, B_REDR, "Render Display %t|Render Window %x1|Image Editor %x0|Full Screen %x2", 72, 10, 120, 19, &G.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output display"); + uiDefButBitS(block, TOG, R_EXTENSION, B_NOP, "Extensions", 205, 10, 105, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds filetype extensions to the filename when rendering animations"); + /* Dither control */ uiDefButF(block, NUM,B_DIFF, "Dither:", 205,31,105,19, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)"); diff --git a/source/blender/src/drawipo.c b/source/blender/src/drawipo.c index 6a1744dccac..c94df84c7f7 100644 --- a/source/blender/src/drawipo.c +++ b/source/blender/src/drawipo.c @@ -521,6 +521,10 @@ void view2d_zoom(View2D *v2d, float factor, int winx, int winy) view2d_do_locks(curarea, V2D_LOCK_COPY); } +void view2d_getscale(View2D *v2d, float *x, float *y) { + if (x) *x = (G.v2d->mask.xmax-G.v2d->mask.xmin)/(G.v2d->cur.xmax-G.v2d->cur.xmin); + if (y) *y = (G.v2d->mask.ymax-G.v2d->mask.ymin)/(G.v2d->cur.ymax-G.v2d->cur.ymin); +} void test_view2d(View2D *v2d, int winx, int winy) { diff --git a/source/blender/src/drawtime.c b/source/blender/src/drawtime.c index 52aba50c9cd..ea1ea5a68b1 100644 --- a/source/blender/src/drawtime.c +++ b/source/blender/src/drawtime.c @@ -132,8 +132,7 @@ static void draw_cfra_time(SpaceTime *stime) glColor4ub(0, 0, 0, 0); BIF_ThemeColor(TH_TEXT); - xscale = (G.v2d->mask.xmax-G.v2d->mask.xmin)/(G.v2d->cur.xmax-G.v2d->cur.xmin); - yscale = (G.v2d->mask.ymax-G.v2d->mask.ymin)/(G.v2d->cur.ymax-G.v2d->cur.ymin); + view2d_getscale(G.v2d, &xscale, &yscale); /* because the frame number text is subject to the same scaling as the contents of the view */ glScalef( 1.0/xscale, 1.0/yscale, 1.0); @@ -157,9 +156,8 @@ static void draw_marker(TimeMarker *marker, int flag) /* no time correction for framelen! space is drawn with old values */ ypixels= G.v2d->mask.ymax-G.v2d->mask.ymin; - xscale = (G.v2d->mask.xmax-G.v2d->mask.xmin)/(G.v2d->cur.xmax-G.v2d->cur.xmin); - yscale = (G.v2d->mask.ymax-G.v2d->mask.ymin)/(G.v2d->cur.ymax-G.v2d->cur.ymin); - + view2d_getscale(G.v2d, &xscale, &yscale); + glScalef( 1.0/xscale, 1.0/yscale, 1.0); glEnable(GL_BLEND); diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index c8e1ae4a3cd..93ddb57ea66 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -1477,10 +1477,10 @@ void mouse_select_ipo(void) if(G.sipo->showkey) { float pixelwidth; - pixelwidth= (G.v2d->cur.xmax-G.v2d->cur.xmin)/(G.v2d->mask.xmax-G.v2d->mask.xmin); /* could make a generic function */ + + view2d_getscale(G.v2d, &pixelwidth, NULL); getmouseco_areawin(mval); - areamouseco_to_ipoco(G.v2d, mval, &x, &y); actik= 0; mindist= 1000.0;