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-12-15 14:58:57 +0300
committerJoshua Leung <aligorith@gmail.com>2008-12-15 14:58:57 +0300
commit21ca5946258a6a79e309e8e2f7de3c9caa8d7a53 (patch)
tree59c445499af4ee3795ea613aee7fc81141bc834d /source/blender/editors
parentf7106acde8a2b4ac9e1ef94bb3f30c75eda2d432 (diff)
View2D: Simplification and documentation of settings
I've gone through and simplified some of the redundant options while documenting the various settings (in the code and also in the Wiki Doc), to make it clearer how to use each option. 'Preset' view-types have yet to be fully implemented, but started groundwork for this. Only some commonly used view configurations will be defined using this method. For all others, they still need to define all relavent view settings themselves (as there's too much variation in terms of the various editor's use of View2D). IPO Editor now draws with channels on the left, like all other anim editors. Now, how to make this wider...
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_view2d.h79
-rw-r--r--source/blender/editors/interface/view2d.c41
-rw-r--r--source/blender/editors/interface/view2d_ops.c2
-rw-r--r--source/blender/editors/space_action/space_action.c2
-rw-r--r--source/blender/editors/space_ipo/space_ipo.c6
-rw-r--r--source/blender/editors/space_nla/space_nla.c2
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c4
-rw-r--r--source/blender/editors/space_sound/space_sound.c2
-rw-r--r--source/blender/editors/space_time/space_time.c2
9 files changed, 80 insertions, 60 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 2705c5de4f6..0eb93580220 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -35,43 +35,70 @@
/* ------------------------------------------ */
/* Settings and Defines: */
+/* ---- General Defines ---- */
+
/* generic value to use when coordinate lies out of view when converting */
#define V2D_IS_CLIPPED 12000
-/* 'dummy' argument to pass when argument is irrelevant */
-#define V2D_ARG_DUMMY -1
+/* common View2D view types */
+enum {
+ /* custom view type (region has defined all necessary flags already) */
+ V2D_COMMONVIEW_CUSTOM = 0,
+ /* listview (i.e. Outliner) */
+ V2D_COMMONVIEW_LIST,
+ /* headers (this is basically the same as listview, but no y-panning) */
+ V2D_COMMONVIEW_HEADER,
+} eView2D_CommonViewTypes;
+/* ---- Defines for Scroller/Grid Arguments ----- */
-/* grid-units (for drawing time) */
-#define V2D_UNIT_SECONDS 0
-#define V2D_UNIT_FRAMES 1
+/* 'dummy' argument to pass when argument is irrelevant */
+#define V2D_ARG_DUMMY -1
-/* grid-units (for drawing values) */
-#define V2D_UNIT_VALUES 2
-#define V2D_UNIT_DEGREES 3
-#define V2D_UNIT_TIME 4
-#define V2D_UNIT_SECONDSSEQ 5
+/* Grid units */
+enum {
+ /* for drawing time */
+ V2D_UNIT_SECONDS = 0,
+ V2D_UNIT_FRAMES,
+
+ /* for drawing values */
+ V2D_UNIT_VALUES,
+ V2D_UNIT_DEGREES,
+ V2D_UNIT_TIME,
+ V2D_UNIT_SECONDSSEQ,
+} eView2D_Units;
/* clamping of grid values to whole numbers */
-#define V2D_GRID_NOCLAMP 0
-#define V2D_GRID_CLAMP 1
-
+enum {
+ V2D_GRID_NOCLAMP = 0,
+ V2D_GRID_CLAMP,
+} eView2D_Clamp;
/* flags for grid-lines to draw */
-#define V2D_HORIZONTAL_LINES (1<<0)
-#define V2D_VERTICAL_LINES (1<<1)
-#define V2D_HORIZONTAL_AXIS (1<<2)
-#define V2D_VERTICAL_AXIS (1<<3)
-#define V2D_HORIZONTAL_FINELINES (1<<4)
-
-#define V2D_GRIDLINES_MAJOR (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS|V2D_HORIZONTAL_LINES|V2D_HORIZONTAL_AXIS)
-#define V2D_GRIDLINES_ALL (V2D_GRIDLINES_MAJOR|V2D_HORIZONTAL_FINELINES)
-
+enum {
+ V2D_HORIZONTAL_LINES = (1<<0),
+ V2D_VERTICAL_LINES = (1<<1),
+ V2D_HORIZONTAL_AXIS = (1<<2),
+ V2D_VERTICAL_AXIS = (1<<3),
+ V2D_HORIZONTAL_FINELINES = (1<<4),
+
+ V2D_GRIDLINES_MAJOR = (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS|V2D_HORIZONTAL_LINES|V2D_HORIZONTAL_AXIS),
+ V2D_GRIDLINES_ALL = (V2D_GRIDLINES_MAJOR|V2D_HORIZONTAL_FINELINES),
+} eView2D_Gridlines;
+
+/* ------ Defines for Scrollers ----- */
+
+/* scroller thickness */
+#define V2D_SCROLL_HEIGHT 16
+#define V2D_SCROLL_WIDTH 16
+
+/* half the size (in pixels) of scroller 'handles' */
+#define V2D_SCROLLER_HANDLE_SIZE 5
/* ------------------------------------------ */
/* Macros: */
-/* test if mouse in a scrollbar */
+/* test if mouse in a scrollbar (assume that scroller availability has been tested) */
#define IN_2D_VERT_SCROLL(v2d, co) (BLI_in_rcti(&v2d->vert, co[0], co[1]))
#define IN_2D_HORIZ_SCROLL(v2d, co) (BLI_in_rcti(&v2d->hor, co[0], co[1]))
@@ -92,9 +119,14 @@ typedef struct View2DScrollers View2DScrollers;
/* Prototypes: */
/* refresh and validation (of view rects) */
+void UI_view2d_regiondata_init(struct View2D *v2d, short type, int winx, int winy);
+void UI_view2d_header_default(struct View2D *v2d);
+
void UI_view2d_size_update(struct View2D *v2d, int winx, int winy);
+
void UI_view2d_curRect_validate(struct View2D *v2d);
void UI_view2d_curRect_reset(struct View2D *v2d);
+
void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
/* view matrix operations */
@@ -121,7 +153,6 @@ void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *re
struct View2D *UI_view2d_fromcontext(const struct bContext *C);
struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C);
void UI_view2d_getscale(struct View2D *v2d, float *x, float *y);
-void UI_view2d_header_default(struct View2D *v2d);
/* operators */
void ui_view2d_operatortypes(void);
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 7177d62ef4e..d9d00702234 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -57,25 +57,24 @@
/* *********************************************************************** */
/* Refresh and Validation */
-#if 0 // experimental code - not ready to be used yet!
-/* common View2D view types */
-// XXX move this to header as part of API
-enum {
- /* 4 quadrants, centered at (0,0), zoomable and pannable, best for flexible sized data with precision needed */
- V2D_VIEWTYPE_CANVAS = 0,
- V2D_VIEWTYPE_LIST,
- V2D_VIEWTYPE_PANEL,
- /* same as canvas, except aspect ratio is important */
- // XXX is this more of the sort tweaks that region should do to its view2d data first?
- V2D_VIEWTYPE_IMAGE,
-} eView2D_CommonViewTypes;
-
/* Initialise all View2D data for a given region */
+// eView2D_CommonViewTypes <--- only check handle these types...
void UI_view2d_regiondata_init(View2D *v2d, short type, int winx, int winy)
{
}
-#endif
+
+
+/* allowing horizontal pan */
+// XXX this should become one of 'standard' setups...
+void UI_view2d_header_default(View2D *v2d)
+{
+ v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT);
+ v2d->keepofs = V2D_LOCKOFS_Y;
+ v2d->keeptot = 2; // this keeps the view in place when region size changes...
+ v2d->align = V2D_ALIGN_NO_NEG_X;
+
+}
/* Adjust mask size in response to view size changes
* - This should only be called in region init() callbacks, which are
@@ -614,16 +613,6 @@ void UI_view2d_view_restore(const bContext *C)
ED_region_pixelspace(C, C->region);
}
-/* allowing horizontal pan */
-void UI_view2d_header_default(View2D *v2d)
-{
- v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT);
- v2d->keepofs = V2D_LOCKOFS_Y;
- v2d->keeptot = 2; // this keeps the view in place when region size changes...
- v2d->align = V2D_ALIGN_NO_NEG_X;
-
-}
-
/* *********************************************************************** */
/* Gridlines */
@@ -915,7 +904,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
*/
/* horizontal scrollers */
- if (v2d->scroll & (V2D_SCROLL_HORIZONTAL|V2D_SCROLL_HORIZONTAL_O)) {
+ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
totsize= v2d->tot.xmax - v2d->tot.xmin;
scrollsize= hor.xmax - hor.xmin;
@@ -1086,7 +1075,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
hor= v2d->hor;
/* horizontal scrollbar */
- if (v2d->scroll & (V2D_SCROLL_HORIZONTAL|V2D_SCROLL_HORIZONTAL_O)) {
+ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller backdrop */
UI_ThemeColorShade(TH_SHADE1, light);
glRecti(hor.xmin, hor.ymin, hor.xmax, hor.ymax);
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index f1dde562c9d..d84932c82fe 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -72,7 +72,7 @@ static short mouse_in_v2d_scrollers (const bContext *C, View2D *v2d, int x, int
co[1]= y - ar->winrct.ymin;
/* check if within scrollbars */
- if (v2d->scroll & (V2D_SCROLL_HORIZONTAL|V2D_SCROLL_HORIZONTAL_O)) {
+ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) {
if (IN_2D_HORIZ_SCROLL(v2d, co)) return 'h';
}
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 5409fa07397..bf37f89e187 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -106,7 +106,7 @@ static SpaceLink *action_new(void)
ar->v2d.minzoom= 0.01f;
ar->v2d.maxzoom= 50;
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
saction->v2d.keepzoom= V2D_LOCKZOOM_Y;
diff --git a/source/blender/editors/space_ipo/space_ipo.c b/source/blender/editors/space_ipo/space_ipo.c
index 520a99d166b..4272f45ea6d 100644
--- a/source/blender/editors/space_ipo/space_ipo.c
+++ b/source/blender/editors/space_ipo/space_ipo.c
@@ -84,7 +84,7 @@ static SpaceLink *ipo_new(void)
BLI_addtail(&sipo->regionbase, ar);
ar->regiontype= RGN_TYPE_CHANNELS;
- ar->alignment= RGN_ALIGN_RIGHT;
+ ar->alignment= RGN_ALIGN_LEFT;
/* XXX view2d init for channels */
@@ -107,8 +107,8 @@ static SpaceLink *ipo_new(void)
ar->v2d.max[0]= MAXFRAMEF;
ar->v2d.max[1]= 10000.0f;
- ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
- ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_LEFT);
+ ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
ar->v2d.keeptot= 0;
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 2d05bc06c8b..71d837249fa 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -104,7 +104,7 @@ static SpaceLink *nla_new(void)
ar->v2d.minzoom= 0.1f;
ar->v2d.maxzoom= 50.0f;
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
ar->v2d.keepzoom= V2D_LOCKZOOM_Y;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index fc45b06e3c7..b2e2aa67c25 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -106,8 +106,8 @@ static SpaceLink *sequencer_new(void)
ar->v2d.minzoom= 0.01f;
ar->v2d.maxzoom= 100.0f;
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
- ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_SCALE_RIGHT);
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
+ ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
ar->v2d.keepzoom= 0;
ar->v2d.keeptot= 0;
diff --git a/source/blender/editors/space_sound/space_sound.c b/source/blender/editors/space_sound/space_sound.c
index 787d8663488..18e2c01a2e8 100644
--- a/source/blender/editors/space_sound/space_sound.c
+++ b/source/blender/editors/space_sound/space_sound.c
@@ -104,7 +104,7 @@ static SpaceLink *sound_new(void)
ar->v2d.minzoom= 0.1f;
ar->v2d.maxzoom= 10.0f;
- ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+ ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.scroll |= (V2D_SCROLL_LEFT);
ar->v2d.keepzoom= 0;
ar->v2d.keeptot= 0;
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index b74896782f3..182f0a02f6c 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -238,7 +238,7 @@ static SpaceLink *time_new(void)
ar->v2d.minzoom= 0.1f;
ar->v2d.maxzoom= 10.0;
- ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM);
+ ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
ar->v2d.align |= V2D_ALIGN_NO_NEG_Y;
ar->v2d.keepofs |= V2D_LOCKOFS_Y;
ar->v2d.keepzoom |= V2D_LOCKZOOM_Y;