diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-05-13 08:43:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-05-14 17:49:49 +0300 |
commit | 079f415debd85b44f9ceaca17edfb82517240448 (patch) | |
tree | fa7591fb909ac7a899c3b3024b1845fd6c21ad23 /source/blender/editors/screen/screen_intern.h | |
parent | 265d97556aa0f0f2a0e4dd7584e3b8573bbddd54 (diff) |
Cleanup: use enum types for screen direction variables
The term direction was used in 3 different ways in screen editing code,
making it hard to follow:
- 0-3 for as magic numbers mapped to [west,north,east,south].
- `h`, `v` characters for [horizontal,vertical] axes.
- Cycle direction SPACE_CONTEXT_CYCLE_PREV, SPACE_CONTEXT_CYCLE_NEXT
The following changes have been made:
- Add `eScreenDir` for [west,north,east,south], use variable name `dir`.
- Add `eScreenAxis` for [horizontal,vertical] values, use variable name
`dir_axis`.
- Add `eScreenCycle` for existing enum `SPACE_CONTEXT_CYCLE_{PREV/NEXT}`.
- Add macros `SCREEN_DIR_IS_VERTICAL(dir)`,
`SCREEN_DIR_IS_HORIZONTAL(dir)`.
Replacing `ELEM(dir, 1, 3)`, `ELEM(dir, 0, 2)`.
- Move `ED_screen_draw_join_highlight`, `ED_screen_draw_split_preview`
to `screen_intern.h`.
Reviewed By: Severin
Ref D11245
Diffstat (limited to 'source/blender/editors/screen/screen_intern.h')
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 9fc8913f583..683f2844371 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -29,6 +29,29 @@ struct bContextDataResult; /* internal exports only */ +typedef enum eScreenDir { + /** This can mean unset, unknown or invalid. */ + SCREEN_DIR_NONE = -1, + /** West/Left. */ + SCREEN_DIR_W = 0, + /** North/Up. */ + SCREEN_DIR_N = 1, + /** East/Right. */ + SCREEN_DIR_E = 2, + /** South/Down. */ + SCREEN_DIR_S = 3, +} eScreenDir; + +#define SCREEN_DIR_IS_VERTICAL(dir) (ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S)) +#define SCREEN_DIR_IS_HORIZONTAL(dir) (ELEM(dir, SCREEN_DIR_W, SCREEN_DIR_E)) + +typedef enum eScreenAxis { + /** Horizontal. */ + SCREEN_AXIS_H = 'h', + /** Vertical. */ + SCREEN_AXIS_V = 'v', +} eScreenAxis; + #define AZONESPOTW UI_HEADER_OFFSET /* width of corner #AZone - max */ #define AZONESPOTH (0.6f * U.widget_unit) /* height of corner #AZone */ #define AZONEFADEIN (5.0f * U.widget_unit) /* when #AZone is totally visible */ @@ -46,6 +69,10 @@ void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free) void ED_area_data_swap(ScrArea *area_dst, ScrArea *area_src); void region_toggle_hidden(struct bContext *C, ARegion *region, const bool do_fade); +/* screen_draw.c */ +void screen_draw_join_highlight(struct ScrArea *sa1, struct ScrArea *sa2); +void screen_draw_split_preview(struct ScrArea *area, const eScreenAxis dir_axis, const float fac); + /* screen_edit.c */ bScreen *screen_add(struct Main *bmain, const char *name, const rcti *rect); void screen_data_copy(bScreen *to, bScreen *from); @@ -59,12 +86,13 @@ void screen_change_prepare(bScreen *screen_old, ScrArea *area_split(const wmWindow *win, bScreen *screen, ScrArea *area, - char dir, + const eScreenAxis dir_axis, const float fac, const bool merge); int screen_area_join(struct bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2); -int area_getorientation(ScrArea *sa_a, ScrArea *sa_b); -void area_getoffsets(ScrArea *sa_a, ScrArea *sa_b, const int dir, int *r_offset1, int *r_offset2); +eScreenDir area_getorientation(ScrArea *sa_a, ScrArea *sa_b); +void area_getoffsets( + ScrArea *sa_a, ScrArea *sa_b, const eScreenDir dir, int *r_offset1, int *r_offset2); bool screen_area_close(struct bContext *C, bScreen *screen, ScrArea *area); struct AZone *ED_area_actionzone_find_xy(ScrArea *area, const int xy[2]); @@ -87,7 +115,7 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win, void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen); short screen_geom_find_area_split_point(const ScrArea *area, const rcti *window_rect, - char dir, + const eScreenAxis dir_axis, float fac); void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge); |