Cleanup: Add internal header for View2D files
Code was exposing apparently internal functions to the public header, so it could reuse it in other View2D files. Worse even, a struct was defined twice in different source files and they would have to be kept in sync, just because there is no shared header file. Such internal header files are useful and don't really cause any harm.
This commit is contained in:
@@ -122,8 +122,6 @@ struct wmKeyConfig;
|
||||
struct wmOperator;
|
||||
struct wmOperatorType;
|
||||
|
||||
typedef struct View2DScrollers View2DScrollers;
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -167,10 +165,6 @@ void UI_view2d_sync(struct bScreen *screen, struct ScrArea *area, struct View2D
|
||||
void UI_view2d_curRect_changed(const struct bContext *C, struct View2D *v2d);
|
||||
|
||||
void UI_view2d_totRect_set(struct View2D *v2d, int width, int height);
|
||||
/**
|
||||
* Change the size of the maximum viewable area (i.e. 'tot' rect).
|
||||
*/
|
||||
void UI_view2d_totRect_set_resize(struct View2D *v2d, int width, int height, bool resize);
|
||||
|
||||
void UI_view2d_mask_from_win(const struct View2D *v2d, struct rcti *r_mask);
|
||||
|
||||
@@ -271,13 +265,6 @@ void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *region,
|
||||
/** \name Scroll-bar Drawing
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* Calculate relevant scroller properties.
|
||||
*/
|
||||
void UI_view2d_scrollers_calc(struct View2D *v2d,
|
||||
const struct rcti *mask_custom,
|
||||
struct View2DScrollers *r_scrollers);
|
||||
|
||||
/**
|
||||
* Draw scroll-bars in the given 2D-region.
|
||||
*/
|
||||
@@ -560,8 +547,6 @@ typedef struct View2DEdgePanData {
|
||||
double edge_pan_start_time_x, edge_pan_start_time_y;
|
||||
} View2DEdgePanData;
|
||||
|
||||
bool UI_view2d_edge_pan_poll(struct bContext *C);
|
||||
|
||||
void UI_view2d_edge_pan_init(struct bContext *C,
|
||||
struct View2DEdgePanData *vpd,
|
||||
float inside_pad,
|
||||
|
||||
@@ -89,6 +89,7 @@ set(SRC
|
||||
eyedroppers/eyedropper_intern.hh
|
||||
interface_intern.hh
|
||||
interface_regions_intern.hh
|
||||
view2d_intern.hh
|
||||
)
|
||||
|
||||
set(LIB
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "interface_intern.hh"
|
||||
#include "view2d_intern.hh"
|
||||
|
||||
static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize);
|
||||
|
||||
@@ -368,7 +369,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
|
||||
/* set 'tot' rect before setting cur? */
|
||||
/* XXX confusing stuff here still */
|
||||
if (tot_changed) {
|
||||
UI_view2d_totRect_set_resize(v2d, winx, winy, !do_init);
|
||||
view2d_totRect_set_resize(v2d, winx, winy, !do_init);
|
||||
}
|
||||
else {
|
||||
ui_view2d_curRect_validate_resize(v2d, !do_init);
|
||||
@@ -960,7 +961,7 @@ void UI_view2d_curRect_reset(View2D *v2d)
|
||||
|
||||
/* ------------------ */
|
||||
|
||||
void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
|
||||
void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
|
||||
{
|
||||
/* don't do anything if either value is 0 */
|
||||
width = abs(width);
|
||||
@@ -1021,7 +1022,7 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resiz
|
||||
|
||||
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
|
||||
{
|
||||
UI_view2d_totRect_set_resize(v2d, width, height, false);
|
||||
view2d_totRect_set_resize(v2d, width, height, false);
|
||||
}
|
||||
|
||||
void UI_view2d_zoom_cache_reset(void)
|
||||
@@ -1367,28 +1368,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d,
|
||||
/** \name Scrollers
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* View2DScrollers is typedef'd in UI_view2d.h
|
||||
*
|
||||
* \warning The start of this struct must not change, as view2d_ops.c uses this too.
|
||||
* For now, we don't need to have a separate (internal) header for structs like this...
|
||||
*/
|
||||
struct View2DScrollers {
|
||||
/* focus bubbles */
|
||||
/* focus bubbles */
|
||||
/* focus bubbles */
|
||||
int vert_min, vert_max; /* vertical scroll-bar */
|
||||
int hor_min, hor_max; /* horizontal scroll-bar */
|
||||
|
||||
/** Exact size of slider backdrop. */
|
||||
rcti hor, vert;
|
||||
/* set if sliders are full, we don't draw them */
|
||||
/* int horfull, vertfull; */ /* UNUSED */
|
||||
};
|
||||
|
||||
void UI_view2d_scrollers_calc(View2D *v2d,
|
||||
const rcti *mask_custom,
|
||||
struct View2DScrollers *r_scrollers)
|
||||
void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers)
|
||||
{
|
||||
rcti vert, hor;
|
||||
float fac1, fac2, totsize, scrollsize;
|
||||
@@ -1515,7 +1495,7 @@ void UI_view2d_scrollers_calc(View2D *v2d,
|
||||
void UI_view2d_scrollers_draw_ex(View2D *v2d, const rcti *mask_custom, bool use_full_hide)
|
||||
{
|
||||
View2DScrollers scrollers;
|
||||
UI_view2d_scrollers_calc(v2d, mask_custom, &scrollers);
|
||||
view2d_scrollers_calc(v2d, mask_custom, &scrollers);
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
rcti vert, hor;
|
||||
const int scroll = view2d_scroll_mapped(v2d->scroll);
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "view2d_intern.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Edge Pan Operator Utilities
|
||||
* \{ */
|
||||
|
||||
bool UI_view2d_edge_pan_poll(bContext *C)
|
||||
bool view2d_edge_pan_poll(bContext *C)
|
||||
{
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
@@ -58,7 +60,7 @@ void UI_view2d_edge_pan_init(bContext *C,
|
||||
float delay,
|
||||
float zoom_influence)
|
||||
{
|
||||
if (!UI_view2d_edge_pan_poll(C)) {
|
||||
if (!view2d_edge_pan_poll(C)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
35
source/blender/editors/interface/view2d_intern.hh
Normal file
35
source/blender/editors/interface/view2d_intern.hh
Normal file
@@ -0,0 +1,35 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup edinterface
|
||||
*
|
||||
* Share between view2d_*.cc files.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
struct bContext;
|
||||
struct View2D;
|
||||
|
||||
struct View2DScrollers {
|
||||
/* focus bubbles */
|
||||
int vert_min, vert_max; /* vertical scroll-bar */
|
||||
int hor_min, hor_max; /* horizontal scroll-bar */
|
||||
|
||||
/** Exact size of slider backdrop. */
|
||||
rcti hor, vert;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate relevant scroller properties.
|
||||
*/
|
||||
void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers);
|
||||
|
||||
/**
|
||||
* Change the size of the maximum viewable area (i.e. 'tot' rect).
|
||||
*/
|
||||
void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize);
|
||||
|
||||
bool view2d_edge_pan_poll(bContext *C);
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include "PIL_time.h" /* USER_ZOOM_CONTINUE */
|
||||
|
||||
#include "view2d_intern.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Utilities
|
||||
* \{ */
|
||||
@@ -388,7 +390,7 @@ static void VIEW2D_OT_edge_pan(wmOperatorType *ot)
|
||||
ot->invoke = view_edge_pan_invoke;
|
||||
ot->modal = view_edge_pan_modal;
|
||||
ot->cancel = view_edge_pan_cancel;
|
||||
ot->poll = UI_view2d_edge_pan_poll;
|
||||
ot->poll = view2d_edge_pan_poll;
|
||||
|
||||
/* operator is modal */
|
||||
ot->flag = OPTYPE_INTERNAL;
|
||||
@@ -1752,23 +1754,6 @@ struct v2dScrollerMove {
|
||||
int lastx, lasty;
|
||||
};
|
||||
|
||||
/**
|
||||
* #View2DScrollers is typedef'd in UI_view2d.h
|
||||
* This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c,
|
||||
* as we only need focus bubble info.
|
||||
*
|
||||
* \warning The start of this struct must not change,
|
||||
* so that it stays in sync with the 'real' version.
|
||||
* For now, we don't need to have a separate (internal) header for structs like this...
|
||||
*/
|
||||
struct View2DScrollers {
|
||||
int vert_min, vert_max; /* vertical scrollbar */
|
||||
int hor_min, hor_max; /* horizontal scrollbar */
|
||||
|
||||
/* These values are written into, even if we don't use them. */
|
||||
rcti _hor, _vert;
|
||||
};
|
||||
|
||||
/* quick enum for vsm->zone (scroller handles) */
|
||||
enum {
|
||||
SCROLLHANDLE_MIN = -1,
|
||||
@@ -1874,7 +1859,7 @@ static void scroller_activate_init(bContext *C,
|
||||
* - zooming must be allowed on this axis, otherwise, default to pan
|
||||
*/
|
||||
View2DScrollers scrollers;
|
||||
UI_view2d_scrollers_calc(v2d, nullptr, &scrollers);
|
||||
view2d_scrollers_calc(v2d, nullptr, &scrollers);
|
||||
|
||||
/* Use a union of 'cur' & 'tot' in case the current view is far outside 'tot'. In this cases
|
||||
* moving the scroll bars has far too little effect and the view can get stuck #31476. */
|
||||
|
||||
Reference in New Issue
Block a user