Some drawing tweaks for animsys:

- added notifier ND_KEYS type, to send proper notes around.
  now insert-key redraws fcurve/action view
- made slider-draggers disappear when view is total or bigger.

Also experimented with making sliders go away entirely, but
this conflicts too much with current code for channel lists.

Ali: I think you have to make call that calculates the 'tot'
for channels, and run this in region listener, including the
totRect update for view2d.

The 'minsize' for channels also fails when there's a slider,
it always doesn't fit then :)
This commit is contained in:
2009-01-28 18:26:47 +00:00
parent f29a20043c
commit 4e232753c0
11 changed files with 145 additions and 75 deletions

View File

@@ -2117,9 +2117,9 @@ static int insert_key_exec (bContext *C, wmOperator *op)
ED_undo_push(C, "Insert Keyframe");
if (mode == 3) // material color requires different notifiers
WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, NULL);
WM_event_add_notifier(C, NC_MATERIAL|ND_KEYS, NULL);
else
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
return OPERATOR_FINISHED;
}
@@ -2184,7 +2184,7 @@ static int delete_key_exec (bContext *C, wmOperator *op)
ED_undo_push(C, "Delete Keyframe");
// XXX what if it was a material keyframe?
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
return OPERATOR_FINISHED;
}

View File

@@ -57,6 +57,91 @@
#include "interface_intern.h"
/* *********************************************************************** */
/* helper to allow scrollbars to dynamically hide */
static int view2d_scroll_mapped(int scroll)
{
if(scroll & V2D_SCROLL_HORIZONTAL_HIDE)
scroll &= ~(V2D_SCROLL_HORIZONTAL);
if(scroll & V2D_SCROLL_VERTICAL_HIDE)
scroll &= ~(V2D_SCROLL_VERTICAL);
return scroll;
}
/* called each time cur changes, to dynamically update masks */
static void view2_masks(View2D *v2d)
{
int scroll;
/* mask - view frame */
v2d->mask.xmin= v2d->mask.ymin= 0;
v2d->mask.xmax= v2d->winx - 1; /* -1 yes! masks are pixels */
v2d->mask.ymax= v2d->winy - 1;
#if 0
v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_VERTICAL_HIDE);
/* check size if: */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL)
if(!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL))
if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin)
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
if (v2d->scroll & V2D_SCROLL_VERTICAL)
if(!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL))
if (v2d->tot.ymax-v2d->tot.ymin <= v2d->cur.ymax-v2d->cur.ymin)
v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE;
#endif
scroll= view2d_scroll_mapped(v2d->scroll);
/* scrollers shrink mask area, but should be based off regionsize
* - they can only be on one to two edges of the region they define
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
*/
if (scroll) {
/* vertical scroller */
if (scroll & V2D_SCROLL_LEFT) {
/* on left-hand edge of region */
v2d->vert= v2d->mask;
v2d->vert.xmax= V2D_SCROLL_WIDTH;
v2d->mask.xmin= v2d->vert.xmax + 1;
}
else if (scroll & V2D_SCROLL_RIGHT) {
/* on right-hand edge of region */
v2d->vert= v2d->mask;
v2d->vert.xmax++; /* one pixel extra... was having leaving a minor gap... */
v2d->vert.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
v2d->mask.xmax= v2d->vert.xmin - 1;
}
/* horizontal scroller */
if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
v2d->hor= v2d->mask;
v2d->hor.ymax= V2D_SCROLL_HEIGHT;
v2d->mask.ymin= v2d->hor.ymax + 1;
}
else if (scroll & V2D_SCROLL_TOP) {
/* on upper edge of region */
v2d->hor= v2d->mask;
v2d->hor.ymin= v2d->hor.ymax - V2D_SCROLL_HEIGHT;
v2d->mask.ymax= v2d->hor.ymin - 1;
}
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
if (scroll & V2D_SCROLL_VERTICAL) {
/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
v2d->vert.ymin= v2d->mask.ymin;
}
else if (scroll & V2D_SCROLL_TOP) {
/* on upper edge of region */
v2d->vert.ymax= v2d->mask.ymax;
}
}
}
}
/* Refresh and Validation */
/* Initialise all relevant View2D data (including view rects if first time) and/or refresh mask sizes after view resize
@@ -153,69 +238,19 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
}
}
/* store view size */
v2d->winx= winx;
v2d->winy= winy;
/* mask - view frame */
v2d->mask.xmin= v2d->mask.ymin= 0;
v2d->mask.xmax= winx - 1; /* -1 yes! masks are pixels */
v2d->mask.ymax= winy - 1;
/* scrollers shrink mask area, but should be based off regionsize
* - they can only be on one to two edges of the region they define
* - if they overlap, they must not occupy the corners (which are reserved for other widgets)
*/
if (v2d->scroll) {
/* vertical scroller */
if (v2d->scroll & V2D_SCROLL_LEFT) {
/* on left-hand edge of region */
v2d->vert= v2d->mask;
v2d->vert.xmax= V2D_SCROLL_WIDTH;
v2d->mask.xmin= v2d->vert.xmax + 1;
}
else if (v2d->scroll & V2D_SCROLL_RIGHT) {
/* on right-hand edge of region */
v2d->vert= v2d->mask;
v2d->vert.xmax++; /* one pixel extra... was having leaving a minor gap... */
v2d->vert.xmin= v2d->vert.xmax - V2D_SCROLL_WIDTH;
v2d->mask.xmax= v2d->vert.xmin - 1;
}
/* horizontal scroller */
if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
v2d->hor= v2d->mask;
v2d->hor.ymax= V2D_SCROLL_HEIGHT;
v2d->mask.ymin= v2d->hor.ymax + 1;
}
else if (v2d->scroll & V2D_SCROLL_TOP) {
/* on upper edge of region */
v2d->hor= v2d->mask;
v2d->hor.ymin= v2d->hor.ymax - V2D_SCROLL_HEIGHT;
v2d->mask.ymax= v2d->hor.ymin - 1;
}
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
v2d->vert.ymin= v2d->mask.ymin;
}
else if (v2d->scroll & V2D_SCROLL_TOP) {
/* on upper edge of region */
v2d->vert.ymax= v2d->mask.ymax;
}
}
}
/* set masks */
view2_masks(v2d);
/* set 'tot' rect before setting cur? */
if (tot_changed)
UI_view2d_totRect_set(v2d, winx, winy);
else
UI_view2d_curRect_validate(v2d);
}
/* Ensure View2D rects remain in a viable configuration
@@ -549,6 +584,9 @@ void UI_view2d_curRect_validate(View2D *v2d)
}
}
}
/* set masks */
view2_masks(v2d);
}
/* ------------------ */
@@ -731,7 +769,7 @@ static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
{
*curmasked= v2d->cur;
if ((v2d->scroll)) {
if (view2d_scroll_mapped(v2d->scroll)) {
float dx= (v2d->cur.xmax-v2d->cur.xmin)/((float)(v2d->mask.xmax-v2d->mask.xmin+1));
float dy= (v2d->cur.ymax-v2d->cur.ymin)/((float)(v2d->mask.ymax-v2d->mask.ymin+1));
@@ -1116,6 +1154,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
View2DScrollers *scrollers;
rcti vert, hor;
float fac, totsize, scrollsize;
int scroll= view2d_scroll_mapped(v2d->scroll);
vert= v2d->vert;
hor= v2d->hor;
@@ -1129,7 +1168,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
*/
/* horizontal scrollers */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
totsize= v2d->tot.xmax - v2d->tot.xmin;
scrollsize= (float)(hor.xmax - hor.xmin);
@@ -1145,7 +1184,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
}
/* vertical scrollers */
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
totsize= v2d->tot.ymax - v2d->tot.ymin;
scrollsize= (float)(vert.ymax - vert.ymin);
@@ -1161,7 +1200,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
}
/* grid markings on scrollbars */
if (v2d->scroll & (V2D_SCROLL_SCALE_HORIZONTAL|V2D_SCROLL_SCALE_VERTICAL)) {
if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL|V2D_SCROLL_SCALE_VERTICAL)) {
/* store clamping */
scrollers->xclamp= xclamp;
scrollers->xunits= xunits;
@@ -1292,13 +1331,14 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
Scene *scene= CTX_data_scene(C);
const short darker= -50, dark= -10, light= 20, lighter= 50;
rcti vert, hor, corner;
int scroll= view2d_scroll_mapped(v2d->scroll);
/* make copies of rects for less typing */
vert= v2d->vert;
hor= v2d->hor;
/* horizontal scrollbar */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller backdrop */
UI_ThemeColorShade(TH_SHADE1, light);
glRecti(hor.xmin, hor.ymin, hor.xmax, hor.ymax);
@@ -1306,8 +1346,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* scroller 'button'
* - if view is zoomable in x, draw handles too
* - handles are drawn darker
* - no slider when view is > total
*/
if (v2d->keepzoom & V2D_LOCKZOOM_X) {
if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin);
else if (v2d->keepzoom & V2D_LOCKZOOM_X) {
/* draw base bar as rounded shape */
UI_ThemeColorShade(TH_SHADE1, dark);
uiSetRoundBox(15);
@@ -1362,7 +1404,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* scale indicators */
// XXX will need to update the font drawing when the new stuff comes in
if ((v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
if ((scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
View2DGrid *grid= vs->grid;
float fac, dfac, fac2, val;
@@ -1426,14 +1468,14 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* decoration outer bevel line */
UI_ThemeColorShade(TH_SHADE1, lighter);
if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
sdrawline(hor.xmin, hor.ymax, hor.xmax, hor.ymax);
else if (v2d->scroll & V2D_SCROLL_TOP)
else if (scroll & V2D_SCROLL_TOP)
sdrawline(hor.xmin, hor.ymin, hor.xmax, hor.ymin);
}
/* vertical scrollbar */
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller backdrop */
UI_ThemeColorShade(TH_SHADE1, light);
glRecti(vert.xmin, vert.ymin, vert.xmax, vert.ymax);
@@ -1442,7 +1484,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - if view is zoomable in y, draw handles too
* - handles are drawn darker
*/
if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
if (v2d->tot.ymax-v2d->tot.ymin <= v2d->cur.ymax-v2d->cur.ymin);
else if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
/* draw base bar as rounded shape */
UI_ThemeColorShade(TH_SHADE1, dark);
uiSetRoundBox(15);
@@ -1497,7 +1540,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* scale indiators */
// XXX will need to update the font drawing when the new stuff comes in
if ((v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
View2DGrid *grid= vs->grid;
float fac, dfac, val;
@@ -1532,14 +1575,14 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* decoration outer bevel line */
UI_ThemeColorShade(TH_SHADE1, lighter);
if (v2d->scroll & V2D_SCROLL_RIGHT)
if (scroll & V2D_SCROLL_RIGHT)
sdrawline(vert.xmin, vert.ymin, vert.xmin, vert.ymax);
else if (v2d->scroll & V2D_SCROLL_LEFT)
else if (scroll & V2D_SCROLL_LEFT)
sdrawline(vert.xmax, vert.ymin, vert.xmax, vert.ymax);
}
/* draw a 'sunken square' to cover up any overlapping corners resulting from intersection of overflowing scroller data */
if ((v2d->scroll & V2D_SCROLL_VERTICAL) && (v2d->scroll & V2D_SCROLL_HORIZONTAL)) {
if ((scroll & V2D_SCROLL_VERTICAL) && (scroll & V2D_SCROLL_HORIZONTAL)) {
/* set bounds (these should be right) */
corner.xmin= vert.xmin;
corner.xmax= vert.xmax;
@@ -1811,16 +1854,17 @@ short UI_view2d_mouse_in_scrollers (const bContext *C, View2D *v2d, int x, int y
{
ARegion *ar= CTX_wm_region(C);
int co[2];
int scroll= view2d_scroll_mapped(v2d->scroll);
/* clamp x,y to region-coordinates first */
co[0]= x - ar->winrct.xmin;
co[1]= y - ar->winrct.ymin;
/* check if within scrollbars */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
if (scroll & V2D_SCROLL_HORIZONTAL) {
if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h';
}
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
if (scroll & V2D_SCROLL_VERTICAL) {
if (IN_2D_VERT_SCROLL(v2d, co)) return 'v';
}

View File

@@ -1760,6 +1760,10 @@ void ED_keymap_screen(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
/* files */
WM_keymap_add_item(keymap, "ED_FILE_OT_load", RETKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ED_FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
/* undo */
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0);

View File

@@ -298,10 +298,14 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn)
switch(wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
ED_region_tag_redraw(ar);
break;
}
break;
default:
if(wmn->data==ND_KEYS)
ED_region_tag_redraw(ar);
}
}
@@ -322,10 +326,14 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn)
switch(wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
ED_region_tag_redraw(ar);
break;
}
break;
default:
if(wmn->data==ND_KEYS)
ED_region_tag_redraw(ar);
}
}

View File

@@ -269,7 +269,6 @@ void file_keymap(struct wmWindowManager *wm)
WM_keymap_add_item(keymap, "ED_FILE_OT_select_all", AKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ED_FILE_OT_border_select", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ED_FILE_OT_highlight", MOUSEMOVE, KM_ANY, 0, 0);
WM_keymap_add_item(keymap, "ED_FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ED_FILE_OT_loadimages", TIMER1, KM_ANY, KM_ANY, 0);

View File

@@ -67,6 +67,7 @@
#include "BKE_global.h"
#include "BKE_key.h"
#include "BKE_object.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
@@ -667,6 +668,7 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
* start of list offset, and the second is as a correction for the scrollers.
*/
height= ((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2));
if (height > (v2d->mask.ymax - v2d->mask.ymin)) {
/* don't use totrect set, as the width stays the same
* (NOTE: this is ok here, the configuration is pretty straightforward)
@@ -674,6 +676,9 @@ void graph_draw_channel_names(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
v2d->tot.ymin= (float)(-height);
}
/* XXX I would call the below line! (ton) */
/* UI_view2d_totRect_set(v2d, ar->type->minsizex, height); */
/* loop through channels, and set up drawing depending on their type */
y= (float)ACHANNEL_FIRST;

View File

@@ -296,10 +296,15 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
switch(wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
ED_region_tag_redraw(ar);
break;
}
break;
default:
if(wmn->data==ND_KEYS)
ED_region_tag_redraw(ar);
}
}

View File

@@ -290,6 +290,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn)
case ND_GEOM_SELECT:
case ND_DRAW:
case ND_MODIFIER:
case ND_KEYS:
ED_region_tag_redraw(ar);
break;
}

View File

@@ -114,6 +114,9 @@ typedef struct View2D {
#define V2D_SCROLL_SCALE_VERTICAL (1<<5)
/* scale markings - horizontal */
#define V2D_SCROLL_SCALE_HORIZONTAL (1<<6)
/* disable draw temporary */
#define V2D_SCROLL_VERTICAL_HIDE (1<<7)
#define V2D_SCROLL_HORIZONTAL_HIDE (1<<8)
/* alignment flags for totrect, flags use 'shading-out' convention (v2d->align) */
/* all quadrants free */

View File

@@ -177,6 +177,7 @@ typedef struct wmNotifier {
#define ND_GEOM_SELECT (21<<16)
#define ND_DRAW (22<<16)
#define ND_MODIFIER (23<<16)
#define ND_KEYS (24<<16)
/* Material */
#define ND_SHADING (30<<16)

View File

@@ -1171,6 +1171,6 @@ void wm_window_keymap(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "WM_OT_save_as_mainfile", F2KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "WM_OT_window_fullscreen_toggle", F11KEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ED_FILE_OT_load", RETKEY, KM_PRESS, 0, 0);
}