2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup DNA
|
2011-02-17 21:48:12 +01:00
|
|
|
*/
|
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2011-12-30 08:25:49 +01:00
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
#include "DNA_vec_types.h"
|
|
|
|
|
2008-11-28 05:01:35 +01:00
|
|
|
/* ---------------------------------- */
|
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/** View 2D data - stored per region. */
|
2002-10-12 13:37:38 +02:00
|
|
|
typedef struct View2D {
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Tot - area that data can be drawn in; cur - region of tot that is visible in viewport. */
|
|
|
|
rctf tot, cur;
|
2022-09-19 06:47:27 +02:00
|
|
|
/** Vert - vertical scroll-bar region; hor - horizontal scroll-bar region. */
|
2019-01-07 12:19:13 +01:00
|
|
|
rcti vert, hor;
|
2022-09-19 06:47:27 +02:00
|
|
|
/** Mask - region (in screen-space) within which 'cur' can be viewed. */
|
2019-01-07 12:19:13 +01:00
|
|
|
rcti mask;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Min/max sizes of 'cur' rect (only when keepzoom not set). */
|
|
|
|
float min[2], max[2];
|
|
|
|
/** Allowable zoom factor range (only when (keepzoom & V2D_LIMITZOOM)) is set. */
|
|
|
|
float minzoom, maxzoom;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-09-19 06:47:27 +02:00
|
|
|
/** Scroll - scroll-bars to display (bit-flag). */
|
2019-01-07 12:19:13 +01:00
|
|
|
short scroll;
|
|
|
|
/** Scroll_ui - temp settings used for UI drawing of scrollers. */
|
|
|
|
short scroll_ui;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-23 08:56:00 +02:00
|
|
|
/** Keeptot - 'cur' rect cannot move outside the 'tot' rect? */
|
2019-01-07 12:19:13 +01:00
|
|
|
short keeptot;
|
|
|
|
/** Keepzoom - axes that zooming cannot occur on, and also clamp within zoom-limits. */
|
|
|
|
short keepzoom;
|
|
|
|
/** Keepofs - axes that translation is not allowed to occur on. */
|
|
|
|
short keepofs;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Settings. */
|
|
|
|
short flag;
|
|
|
|
/** Alignment of content in totrect. */
|
|
|
|
short align;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Storage of current winx/winy values, set in UI_view2d_size_update. */
|
|
|
|
short winx, winy;
|
2023-05-24 03:21:18 +02:00
|
|
|
/**
|
|
|
|
* Storage of previous winx/winy values encountered by #UI_view2d_curRect_validate(),
|
|
|
|
* for keep-aspect.
|
|
|
|
*/
|
2019-01-07 12:19:13 +01:00
|
|
|
short oldwinx, oldwiny;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-07 12:19:13 +01:00
|
|
|
/** Pivot point for transforms (rotate and scale). */
|
|
|
|
short around;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-07 01:31:18 +02:00
|
|
|
/* Usually set externally (as in, not in view2d files). */
|
2022-09-19 06:47:27 +02:00
|
|
|
/** Alpha of vertical and horizontal scroll-bars (range is [0, 255]). */
|
2019-01-07 12:19:13 +01:00
|
|
|
char alpha_vert, alpha_hor;
|
2023-07-03 15:15:18 +02:00
|
|
|
|
|
|
|
char _pad[2];
|
|
|
|
/** When set (not 0), determines how many pixels to scroll when scrolling an entire page.
|
|
|
|
* Otherwise the height of #View2D.mask is used. */
|
|
|
|
float page_size_y;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-08-12 03:07:31 +02:00
|
|
|
/* animated smooth view */
|
|
|
|
struct SmoothView2DStore *sms;
|
|
|
|
struct wmTimer *smooth_timer;
|
2002-10-12 13:37:38 +02:00
|
|
|
} View2D;
|
|
|
|
|
2008-11-28 05:01:35 +01:00
|
|
|
/* ---------------------------------- */
|
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/** View zooming restrictions, per axis (#View2D.keepzoom) */
|
2018-04-26 14:03:08 +02:00
|
|
|
enum {
|
2008-12-15 12:58:57 +01:00
|
|
|
/* zoom is clamped to lie within limits set by minzoom and maxzoom */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_LIMITZOOM = (1 << 0),
|
2008-12-15 12:58:57 +01:00
|
|
|
/* aspect ratio is maintained on view resize */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_KEEPASPECT = (1 << 1),
|
2009-07-30 00:57:53 +02:00
|
|
|
/* zoom is kept when the window resizes */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_KEEPZOOM = (1 << 2),
|
2008-12-15 12:58:57 +01:00
|
|
|
/* zooming on x-axis is not allowed */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_LOCKZOOM_X = (1 << 8),
|
2008-12-15 12:58:57 +01:00
|
|
|
/* zooming on y-axis is not allowed */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_LOCKZOOM_Y = (1 << 9),
|
|
|
|
};
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/** View panning restrictions, per axis (#View2D.keepofs). */
|
2018-04-26 14:03:08 +02:00
|
|
|
enum {
|
2008-12-15 12:58:57 +01:00
|
|
|
/* panning on x-axis is not allowed */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_LOCKOFS_X = (1 << 1),
|
2008-12-15 12:58:57 +01:00
|
|
|
/* panning on y-axis is not allowed */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_LOCKOFS_Y = (1 << 2),
|
2009-07-30 00:57:53 +02:00
|
|
|
/* on resize, keep the x offset */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_KEEPOFS_X = (1 << 3),
|
2009-07-30 00:57:53 +02:00
|
|
|
/* on resize, keep the y offset */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_KEEPOFS_Y = (1 << 4),
|
|
|
|
};
|
2008-11-30 07:15:33 +01:00
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/** View extent restrictions (#View2D.keeptot). */
|
2018-04-26 14:03:08 +02:00
|
|
|
enum {
|
2019-01-15 13:14:35 +01:00
|
|
|
/** 'cur' view can be out of extents of 'tot' */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_KEEPTOT_FREE = 0,
|
2019-01-15 13:14:35 +01:00
|
|
|
/** 'cur' rect is adjusted so that it satisfies the extents of 'tot', with some compromises */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_KEEPTOT_BOUNDS = 1,
|
2019-01-15 13:14:35 +01:00
|
|
|
/** 'cur' rect is moved so that the 'minimum' bounds of the 'tot' rect are always respected
|
|
|
|
* (particularly in x-axis) */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_KEEPTOT_STRICT = 2,
|
|
|
|
};
|
2008-12-15 12:58:57 +01:00
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/** General refresh settings (#View2D.flag). */
|
2018-04-26 14:03:08 +02:00
|
|
|
enum {
|
2008-12-05 03:03:37 +01:00
|
|
|
/* global view2d horizontal locking (for showing same time interval) */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_VIEWSYNC_SCREEN_TIME = (1 << 0),
|
2008-12-21 12:56:42 +01:00
|
|
|
/* within area (i.e. between regions) view2d vertical locking */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_VIEWSYNC_AREA_VERTICAL = (1 << 1),
|
2008-12-21 12:56:42 +01:00
|
|
|
/* apply pixel offsets on x-axis when setting view matrices */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_PIXELOFS_X = (1 << 2),
|
2008-12-21 12:56:42 +01:00
|
|
|
/* apply pixel offsets on y-axis when setting view matrices */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_PIXELOFS_Y = (1 << 3),
|
2021-09-21 10:38:15 +02:00
|
|
|
/* zoom, pan or similar action is in progress */
|
|
|
|
V2D_IS_NAVIGATING = (1 << 9),
|
2008-12-15 12:58:57 +01:00
|
|
|
/* view settings need to be set still... */
|
2020-08-01 05:02:21 +02:00
|
|
|
V2D_IS_INIT = (1 << 10),
|
2023-07-03 15:15:18 +02:00
|
|
|
/* Ensure scrolling always snaps to multiples of #View2D.page_size_y or the #View2D.mask height
|
|
|
|
* if this is 0. Zooming doesn't respect this. */
|
|
|
|
V2D_SNAP_TO_PAGESIZE_Y = (1 << 11),
|
2018-04-26 14:03:08 +02:00
|
|
|
};
|
2008-12-07 13:15:04 +01:00
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/** Scroller flags for View2D (#View2D.scroll). */
|
2018-04-26 14:03:08 +02:00
|
|
|
enum {
|
2022-09-19 06:47:27 +02:00
|
|
|
/* Left scroll-bar. */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_SCROLL_LEFT = (1 << 0),
|
|
|
|
V2D_SCROLL_RIGHT = (1 << 1),
|
|
|
|
V2D_SCROLL_VERTICAL = (V2D_SCROLL_LEFT | V2D_SCROLL_RIGHT),
|
2022-09-19 06:47:27 +02:00
|
|
|
/* Horizontal scroll-bar. */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_SCROLL_TOP = (1 << 2),
|
|
|
|
V2D_SCROLL_BOTTOM = (1 << 3),
|
|
|
|
/* UNUSED = (1 << 4), */
|
|
|
|
V2D_SCROLL_HORIZONTAL = (V2D_SCROLL_TOP | V2D_SCROLL_BOTTOM),
|
2019-05-08 15:09:02 +02:00
|
|
|
/* display vertical scale handles */
|
|
|
|
V2D_SCROLL_VERTICAL_HANDLES = (1 << 5),
|
|
|
|
/* display horizontal scale handles */
|
|
|
|
V2D_SCROLL_HORIZONTAL_HANDLES = (1 << 6),
|
2022-09-19 06:47:27 +02:00
|
|
|
/* Induce hiding of scroll-bar - set by region drawing in response to size of region. */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_SCROLL_VERTICAL_HIDE = (1 << 7),
|
|
|
|
V2D_SCROLL_HORIZONTAL_HIDE = (1 << 8),
|
2022-09-19 06:47:27 +02:00
|
|
|
/* Scroll-bar extends beyond its available window -
|
|
|
|
* set when calculating scroll-bar for drawing */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_SCROLL_VERTICAL_FULLR = (1 << 9),
|
|
|
|
V2D_SCROLL_HORIZONTAL_FULLR = (1 << 10),
|
|
|
|
};
|
2008-12-01 12:37:05 +01:00
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/** scroll_ui, activate flag for drawing. */
|
2018-04-26 14:03:08 +02:00
|
|
|
enum {
|
|
|
|
V2D_SCROLL_H_ACTIVE = (1 << 0),
|
|
|
|
V2D_SCROLL_V_ACTIVE = (1 << 1),
|
|
|
|
};
|
2009-07-02 20:12:46 +02:00
|
|
|
|
2021-12-20 08:58:37 +01:00
|
|
|
/**
|
|
|
|
* Alignment flags for `totrect`, flags use 'shading-out' convention (#View2D.align).
|
|
|
|
*/
|
2018-04-26 14:03:08 +02:00
|
|
|
enum {
|
2008-12-05 03:03:37 +01:00
|
|
|
/* all quadrants free */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_ALIGN_FREE = 0,
|
2008-12-05 03:03:37 +01:00
|
|
|
/* horizontal restrictions */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_ALIGN_NO_POS_X = (1 << 0),
|
|
|
|
V2D_ALIGN_NO_NEG_X = (1 << 1),
|
2008-12-05 03:03:37 +01:00
|
|
|
/* vertical restrictions */
|
2018-04-26 14:03:08 +02:00
|
|
|
V2D_ALIGN_NO_POS_Y = (1 << 2),
|
|
|
|
V2D_ALIGN_NO_NEG_Y = (1 << 3),
|
|
|
|
};
|