*** Proof of concept! **** 3D window Panels back, in own designated region for now. Activate or hide it with Nkey. Note that Background Image doesn't work yet, Transform Orientations probably need tests by Martin, Sculpt options have to be recoded there by Nicholas. The UI design sessions will of course review all of this! We'll have to solve a lot of related topics; - navigation (where) and context (what) - non-overlapping layouts vs floating panels/bars - properties vs tools (toolbars) - drop panels and make nice (semi-automated) list views? I've also done experiments with making the main 3d view stay 'behind' the buttons region. That makes popping buttons in and out less distracting, but also makes it obscuring the view... it's not in this commit, it didn't work proper :) To get that work it has to be handled by the internal compositor, then it even can have fancy transparency in back. Anyhoo, time enough to play with this a while. Especially for Image window (paint) it can work well too.
190 lines
6.5 KiB
C
190 lines
6.5 KiB
C
/**
|
|
* $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, Joshua Leung
|
|
*
|
|
*
|
|
* Generic 2d view with should allow drawing grids,
|
|
* panning, zooming, scrolling, ..
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
*/
|
|
|
|
#ifndef UI_VIEW2D_H
|
|
#define UI_VIEW2D_H
|
|
|
|
/* ------------------------------------------ */
|
|
/* Settings and Defines: */
|
|
|
|
/* ---- General Defines ---- */
|
|
|
|
/* generic value to use when coordinate lies out of view when converting */
|
|
#define V2D_IS_CLIPPED 12000
|
|
|
|
/* Common View2D view types
|
|
* NOTE: only define a type here if it completely sets all (+/- a few) of the relevant flags
|
|
* and settings for a View2D region, and that set of settings is used in more
|
|
* than one specific place
|
|
*/
|
|
enum {
|
|
/* custom view type (region has defined all necessary flags already) */
|
|
V2D_COMMONVIEW_CUSTOM = -1,
|
|
/* standard (only use this when setting up a new view, as a sensible base for most settings) */
|
|
V2D_COMMONVIEW_STANDARD,
|
|
/* listview (i.e. Outliner) */
|
|
V2D_COMMONVIEW_LIST,
|
|
/* headers (this is basically the same as listview, but no y-panning) */
|
|
V2D_COMMONVIEW_HEADER,
|
|
/* ui listviews, tries to wrap tot inside region width */
|
|
V2D_COMMONVIEW_LIST_UI,
|
|
} eView2D_CommonViewTypes;
|
|
|
|
/* ---- Defines for Scroller/Grid Arguments ----- */
|
|
|
|
/* 'dummy' argument to pass when argument is irrelevant */
|
|
#define V2D_ARG_DUMMY -1
|
|
|
|
/* 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 */
|
|
enum {
|
|
V2D_GRID_NOCLAMP = 0,
|
|
V2D_GRID_CLAMP,
|
|
} eView2D_Clamp;
|
|
|
|
/* flags for grid-lines to draw */
|
|
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
|
|
|
|
/* ------ Define for UI_view2d_sync ----- */
|
|
|
|
/* means copy it from another v2d */
|
|
#define V2D_LOCK_SET 0
|
|
/* means copy it to the other v2ds */
|
|
#define V2D_LOCK_COPY 1
|
|
|
|
|
|
/* ------------------------------------------ */
|
|
/* Macros: */
|
|
|
|
/* 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]))
|
|
|
|
/* ------------------------------------------ */
|
|
/* Type definitions: */
|
|
|
|
struct View2D;
|
|
struct View2DGrid;
|
|
struct View2DScrollers;
|
|
|
|
struct wmWindowManager;
|
|
struct bScreen;
|
|
struct ScrArea;
|
|
struct bContext;
|
|
struct rctf;
|
|
|
|
typedef struct View2DGrid View2DGrid;
|
|
typedef struct View2DScrollers View2DScrollers;
|
|
|
|
/* ----------------------------------------- */
|
|
/* Prototypes: */
|
|
|
|
/* refresh and validation (of view rects) */
|
|
void UI_view2d_region_reinit(struct View2D *v2d, short type, int winx, int winy);
|
|
|
|
void UI_view2d_curRect_validate(struct View2D *v2d);
|
|
void UI_view2d_curRect_reset(struct View2D *v2d);
|
|
void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v2dcur, int flag);
|
|
|
|
void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
|
|
|
|
/* view matrix operations */
|
|
void UI_view2d_view_ortho(const struct bContext *C, struct View2D *v2d);
|
|
void UI_view2d_view_orthoSpecial(const struct bContext *C, struct View2D *v2d, short xaxis);
|
|
void UI_view2d_view_restore(const struct bContext *C);
|
|
|
|
/* grid drawing */
|
|
View2DGrid *UI_view2d_grid_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy);
|
|
void UI_view2d_grid_draw(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
|
|
void UI_view2d_constant_grid_draw(const struct bContext *C, struct View2D *v2d);
|
|
void UI_view2d_grid_free(View2DGrid *grid);
|
|
|
|
/* scrollbar drawing */
|
|
View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp);
|
|
void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers);
|
|
void UI_view2d_scrollers_free(View2DScrollers *scrollers);
|
|
|
|
/* list view tools */
|
|
void UI_view2d_listview_cell_to_view(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int column, int row, struct rctf *rect);
|
|
void UI_view2d_listview_view_to_cell(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, float viewx, float viewy, int *column, int *row);
|
|
void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, short rowheight, float startx, float starty, int *column_min, int *column_max, int *row_min, int *row_max);
|
|
|
|
/* coordinate conversion */
|
|
void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
|
|
void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *regiony);
|
|
void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, int *regionx, int *region_y);
|
|
|
|
/* utilities */
|
|
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);
|
|
|
|
short UI_view2d_mouse_in_scrollers(const struct bContext *C, struct View2D *v2d, int x, int y);
|
|
|
|
|
|
/* operators */
|
|
void ui_view2d_operatortypes(void);
|
|
void UI_view2d_keymap(struct wmWindowManager *wm);
|
|
|
|
#endif /* UI_VIEW2D_H */
|
|
|