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:
authorJulian Eisel <eiseljulian@gmail.com>2018-04-20 18:14:03 +0300
committerJulian Eisel <eiseljulian@gmail.com>2018-04-20 18:14:52 +0300
commit5f6c45498c92b91a710a1317f6d41f73fbe83477 (patch)
tree93b136fb49c656c2c2a5463c91e8a6a38d518354 /source/blender/editors
parent4bfb6d21df96688187f6f1a5d95dd62bcbf85116 (diff)
UI: New Global Top-Bar (WIP)
== Main Features/Changes for Users * Add horizontal bar at top of all non-temp windows, consisting out of two horizontal sub-bars. * Upper sub-bar contains global menus (File, Render, etc.), tabs for workspaces and scene selector. * Lower sub-bar contains object mode selector, screen-layout and render-layer selector. Later operator and/or tool settings will be placed here. * Individual sections of the topbar are individually scrollable. * Workspace tabs can be double- or ctrl-clicked for renaming and contain 'x' icon for deleting. * Top-bar should scale nicely with DPI. * The lower half of the top-bar can be hided by dragging the lower top-bar edge up. Better hiding options are planned (e.g. hide in fullscreen modes). * Info editors at the top of the window and using the full window width with be replaced by the top-bar. * In fullscreen modes, no more info editor is added on top, the top-bar replaces it. == Technical Features/Changes * Adds initial support for global areas A global area is part of the window, not part of the regular screen-layout. I've added a macro iterator to iterate over both, global and screen-layout level areas. When iterating over areas, from now on developers should always consider if they have to include global areas. * Adds a TOPBAR editor type The editor type is hidden in the UI editor type menu. * Adds a variation of the ID template to display IDs as tab buttons (template_ID_tabs in BPY) * Does various changes to RNA button creation code to improve their appearance in the horizontal top-bar. * Adds support for dynamically sized regions. That is, regions that scale automatically to the layout bounds. The code for this is currently a big hack (it's based on drawing the UI multiple times). This should definitely be improved. * Adds a template for displaying operator properties optimized for the top-bar. This will probably change a lot still and is in fact disabled in code. Since the final top-bar design depends a lot on other 2.8 designs (mainly tool-system and workspaces), we decided to not show the operator or tool settings in the top-bar for now. That means most of the lower sub-bar is empty for the time being. NOTE: Top-bar or global area data is not written to files or SDNA. They are simply added to the window when opening Blender or reading a file. This allows us doing changes to the top-bar without having to care for compatibility. == ToDo's It's a bit hard to predict all the ToDo's here are the known main ones: * Add options for the new active-tool system and for operator redo to the topbar. * Automatically hide the top-bar in fullscreen modes. * General visual polish. * Top-bar drag & drop support (WIP in temp-tab_drag_drop). * Improve dynamic regions (should also fix some layout glitches). * Make internal terminology consistent. * Enable topbar file writing once design is more advanced. * Address TODO's and XXX's in code :) Thanks @brecht for the review! And @sergey for the complaining ;) Differential Revision: D2758
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/CMakeLists.txt1
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c2
-rw-r--r--source/blender/editors/include/ED_screen.h23
-rw-r--r--source/blender/editors/include/ED_space_api.h1
-rw-r--r--source/blender/editors/include/ED_undo.h12
-rw-r--r--source/blender/editors/include/ED_util.h5
-rw-r--r--source/blender/editors/include/UI_interface.h51
-rw-r--r--source/blender/editors/include/UI_resources.h4
-rw-r--r--source/blender/editors/interface/interface.c82
-rw-r--r--source/blender/editors/interface/interface_align.c45
-rw-r--r--source/blender/editors/interface/interface_handlers.c82
-rw-r--r--source/blender/editors/interface/interface_intern.h7
-rw-r--r--source/blender/editors/interface/interface_layout.c95
-rw-r--r--source/blender/editors/interface/interface_templates.c295
-rw-r--r--source/blender/editors/interface/interface_utils.c76
-rw-r--r--source/blender/editors/interface/interface_widgets.c23
-rw-r--r--source/blender/editors/interface/resources.c22
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c2
-rw-r--r--source/blender/editors/object/object_data_transfer.c2
-rw-r--r--source/blender/editors/object/object_relations.c2
-rw-r--r--source/blender/editors/screen/area.c150
-rw-r--r--source/blender/editors/screen/screen_edit.c344
-rw-r--r--source/blender/editors/screen/screen_intern.h13
-rw-r--r--source/blender/editors/screen/screen_ops.c205
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/screen/workspace_edit.c4
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c6
-rw-r--r--source/blender/editors/sound/sound_ops.c2
-rw-r--r--source/blender/editors/space_api/spacetypes.c1
-rw-r--r--source/blender/editors/space_clip/clip_toolbar.c23
-rw-r--r--source/blender/editors/space_clip/space_clip.c21
-rw-r--r--source/blender/editors/space_file/file_panels.c3
-rw-r--r--source/blender/editors/space_image/image_ops.c4
-rw-r--r--source/blender/editors/space_sequencer/sequencer_add.c2
-rw-r--r--source/blender/editors/space_topbar/CMakeLists.txt45
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c265
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c45
-rw-r--r--source/blender/editors/space_view3d/view3d_toolbar.c9
-rw-r--r--source/blender/editors/undo/ed_undo.c43
39 files changed, 1585 insertions, 434 deletions
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index 619b031e27a..f6ceda9bc5a 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -56,6 +56,7 @@ if(WITH_BLENDER)
add_subdirectory(space_sequencer)
add_subdirectory(space_text)
add_subdirectory(space_time)
+ add_subdirectory(space_topbar)
add_subdirectory(space_userpref)
add_subdirectory(space_view3d)
add_subdirectory(transform)
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 2c3c9f4f9b9..19663b66f92 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -1450,7 +1450,7 @@ static void gp_convert_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call */
- uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
void GPENCIL_OT_convert(wmOperatorType *ot)
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 0a1ddabb294..8d7b6c86aa1 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -111,6 +111,11 @@ int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *bl
void ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
void ED_area_exit(struct bContext *C, struct ScrArea *sa);
int ED_screen_area_active(const struct bContext *C);
+void ED_screen_global_topbar_area_create(
+ struct wmWindow *win,
+ const struct bScreen *screen);
+void ED_screen_global_areas_create(
+ struct wmWindow *win);
void ED_area_do_listen(struct bScreen *sc, ScrArea *sa, struct wmNotifier *note, Scene *scene,
struct WorkSpace *workspace);
void ED_area_tag_redraw(ScrArea *sa);
@@ -123,6 +128,23 @@ void ED_area_newspace(struct bContext *C, ScrArea *sa, int type, const bool s
void ED_area_prevspace(struct bContext *C, ScrArea *sa);
void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
int ED_area_headersize(void);
+int ED_area_global_size_y(const ScrArea *area);
+bool ED_area_is_global(const ScrArea *area);
+int ED_region_global_size_y(void);
+
+/** Iterate over all areas visible in the screen (screen as in everything visible in the window, not just bScreen) */
+#define ED_screen_areas_iter(win, screen, area_name) \
+ for (ScrArea *area_name = (win)->global_areas.areabase.first ? \
+ (win)->global_areas.areabase.first : \
+ screen->areabase.first; \
+ area_name != NULL; \
+ area_name = (area_name == (win)->global_areas.areabase.last) ? (screen)->areabase.first : area_name->next)
+#define ED_screen_verts_iter(win, screen, vert_name) \
+ for (ScrVert *vert_name = (win)->global_areas.vertbase.first ? \
+ (win)->global_areas.vertbase.first : \
+ screen->vertbase.first; \
+ vert_name != NULL; \
+ vert_name = (vert_name == (win)->global_areas.vertbase.last) ? (screen)->vertbase.first : vert_name->next)
/* screens */
void ED_screens_initialize(struct wmWindowManager *wm);
@@ -130,6 +152,7 @@ void ED_screen_draw_edges(struct wmWindow *win);
void ED_screen_draw_join_shape(struct ScrArea *sa1, struct ScrArea *sa2);
void ED_screen_draw_split_preview(struct ScrArea *sa, const int dir, const float fac);
void ED_screen_refresh(struct wmWindowManager *wm, struct wmWindow *win);
+void ED_screen_ensure_updated(struct wmWindowManager *wm, struct wmWindow *win, struct bScreen *screen);
void ED_screen_do_listen(struct bContext *C, struct wmNotifier *note);
bool ED_screen_change(struct bContext *C, struct bScreen *sc);
void ED_screen_update_after_scene_change(
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index d268c578cf2..873ab8371fc 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -58,6 +58,7 @@ void ED_spacetype_logic(void);
void ED_spacetype_console(void);
void ED_spacetype_userpref(void);
void ED_spacetype_clip(void);
+void ED_spacetype_topbar(void);
/* calls for instancing and freeing spacetype static data
* called in WM_init_exit */
diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h
index 43ffb091666..da8cd95555c 100644
--- a/source/blender/editors/include/ED_undo.h
+++ b/source/blender/editors/include/ED_undo.h
@@ -25,6 +25,8 @@
#ifndef __ED_UNDO_H__
#define __ED_UNDO_H__
+#include "BLI_compiler_attrs.h"
+
struct bContext;
struct CLG_LogRef;
struct wmOperator;
@@ -50,6 +52,16 @@ int ED_undo_operator_repeat(struct bContext *C, struct wmOperator *op);
void ED_undo_operator_repeat_cb(struct bContext *C, void *arg_op, void *arg_unused);
void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg_unused);
+#ifdef WITH_REDO_REGION_REMOVAL
+/* Context sanity helpers for operator repeat. */
+typedef struct OperatorRepeatContextHandle OperatorRepeatContextHandle;
+
+const OperatorRepeatContextHandle *ED_operator_repeat_prepare_context(
+ struct bContext *C, struct wmOperator *op) ATTR_WARN_UNUSED_RESULT;
+void ED_operator_repeat_reset_context(
+ struct bContext *C, const OperatorRepeatContextHandle *context_info);
+#endif
+
bool ED_undo_is_valid(const struct bContext *C, const char *undoname);
struct UndoStack *ED_undo_stack_get(void);
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 2653585dacc..69e80f60d0a 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -31,11 +31,10 @@
#ifndef __ED_UTIL_H__
#define __ED_UTIL_H__
+#include "BLI_compiler_attrs.h"
+
struct bContext;
struct wmOperatorType;
-struct ScrArea;
-struct SpaceLink;
-struct PackedFile;
/* ed_util.c */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d85c77d55fb..402be964436 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -699,8 +699,30 @@ uiBut *uiDefSearchButO_ptr(uiBlock *block, struct wmOperatorType *ot, struct IDP
void *arg, int retval, int icon, int maxlen, int x, int y,
short width, short height, float a1, float a2, const char *tip);
+
+/* For uiDefAutoButsRNA */
+typedef enum {
+ /* Keep current layout for aligning label with property button. */
+ UI_BUT_LABEL_ALIGN_NONE,
+ /* Align label and property button vertically. */
+ UI_BUT_LABEL_ALIGN_COLUMN,
+ /* Split layout into a column for the label and one for property button. */
+ UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+} eButLabelAlign;
+
+/* Return info for uiDefAutoButsRNA */
+typedef enum {
+ /* Returns when no buttons were added */
+ UI_PROP_BUTS_NONE_ADDED = (1 << 0),
+ /* Returned when any property failed the custom check callback (check_prop) */
+ UI_PROP_BUTS_ANY_FAILED_CHECK = (1 << 1),
+} eAutoPropButsReturn;
+
uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2);
-int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align);
+eAutoPropButsReturn uiDefAutoButsRNA(
+ uiLayout *layout, struct PointerRNA *ptr,
+ bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
+ eButLabelAlign label_align, const bool compact);
/* use inside searchfunc to add items */
bool UI_search_item_add(uiSearchItems *items, const char *name, void *poin, int iconid);
@@ -836,6 +858,7 @@ void UI_exit(void);
#define UI_LAYOUT_ALIGN_CENTER 2
#define UI_LAYOUT_ALIGN_RIGHT 3
+#define UI_ITEM_O_RETURN_PROPS (1 << 0)
#define UI_ITEM_R_EXPAND (1 << 1)
#define UI_ITEM_R_SLIDER (1 << 2)
#define UI_ITEM_R_TOGGLE (1 << 3)
@@ -845,10 +868,15 @@ void UI_exit(void);
#define UI_ITEM_R_NO_BG (1 << 7)
#define UI_ITEM_R_IMMEDIATE (1 << 8)
#define UI_ITEM_O_DEPRESS (1 << 9)
+#define UI_ITEM_R_COMPACT (1 << 10)
-/* uiTemplateOperatorPropertyButs flags */
-#define UI_TEMPLATE_OP_PROPS_SHOW_TITLE 1
-#define UI_TEMPLATE_OP_PROPS_SHOW_EMPTY 2
+
+/* uiLayoutOperatorButs flags */
+enum {
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE = (1 << 0),
+ UI_TEMPLATE_OP_PROPS_SHOW_EMPTY = (1 << 1),
+ UI_TEMPLATE_OP_PROPS_COMPACT = (1 << 2),
+};
/* used for transp checkers */
#define UI_ALPHA_CHECKER_DARK 100
@@ -931,6 +959,11 @@ void uiTemplateIDBrowse(
void uiTemplateIDPreview(
uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname,
const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter);
+void uiTemplateIDTabs(
+ uiLayout *layout, struct bContext *C,
+ PointerRNA *ptr, const char *propname,
+ const char *newop, const char *openop, const char *unlinkop,
+ int filter);
void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
const char *proptypename, const char *text);
void uiTemplateSearch(
@@ -947,6 +980,9 @@ void uiTemplateSearchPreview(
void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
struct PointerRNA *root_ptr, const char *text);
uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
+#ifdef WITH_REDO_REGION_REMOVAL
+void uiTemplateOperatorRedoProperties(uiLayout *layout, struct bContext *C);
+#endif
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
struct MTex *slot, const char *preview_id);
@@ -971,9 +1007,10 @@ void uiTemplateImageInfo(uiLayout *layout, struct bContext *C, struct Image *ima
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
void UI_but_func_operator_search(uiBut *but);
void uiTemplateOperatorSearch(uiLayout *layout);
-void uiTemplateOperatorPropertyButs(const struct bContext *C, uiLayout *layout, struct wmOperator *op,
- bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
- const char label_align, const short flag);
+eAutoPropButsReturn uiTemplateOperatorPropertyButs(
+ const struct bContext *C, uiLayout *layout, struct wmOperator *op,
+ bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
+ const eButLabelAlign label_align, const short flag);
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C);
void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 7d2837ffe4e..49c9cffdd54 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -51,7 +51,7 @@ typedef enum {
/* use to denote intentionally unset theme color */
#define TH_UNDEFINED -1
-enum {
+typedef enum ThemeColorID {
TH_REDALERT,
TH_THEMEUI,
@@ -308,7 +308,7 @@ enum {
TH_EDGE_BEVEL,
TH_VERTEX_BEVEL
-};
+} ThemeColorID;
/* specific defines per space should have higher define values */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 20eb0ce50e5..a9fdd1678e2 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1193,7 +1193,7 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
if (block->layouts.first) {
UI_block_layout_resolve(block, NULL, NULL);
}
- ui_block_align_calc(block);
+ ui_block_align_calc(block, CTX_wm_region(C));
if ((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) {
ui_menu_block_set_keyaccels(block); /* could use a different flag to check */
}
@@ -1420,7 +1420,6 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
break;
case UI_BTYPE_ROW:
case UI_BTYPE_LISTROW:
- case UI_BTYPE_TAB:
UI_GET_BUT_VALUE_INIT(but, *value);
/* support for rna enum buts */
if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) {
@@ -1430,6 +1429,18 @@ int ui_but_is_pushed_ex(uiBut *but, double *value)
if (*value == (double)but->hardmax) is_push = true;
}
break;
+ case UI_BTYPE_TAB:
+ if (but->rnaprop && but->custom_data) {
+ /* uiBut.custom_data points to data this tab represents (e.g. workspace).
+ * uiBut.rnapoin/prop store an active value (e.g. active workspace). */
+ if (RNA_property_type(but->rnaprop) == PROP_POINTER) {
+ PointerRNA active_ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
+ if (active_ptr.data == but->custom_data) {
+ is_push = true;
+ }
+ }
+ }
+ break;
default:
is_push = -1;
break;
@@ -1915,7 +1926,7 @@ static bool ui_but_icon_extra_is_visible_text_clear(const uiBut *but)
static bool ui_but_icon_extra_is_visible_search_unlink(const uiBut *but)
{
- BLI_assert(but->type == UI_BTYPE_SEARCH_MENU);
+ BLI_assert(ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB));
return ((but->editstr == NULL) &&
(but->drawstr[0] != '\0') &&
(but->flag & UI_BUT_VALUE_CLEAR));
@@ -1958,6 +1969,11 @@ uiButExtraIconType ui_but_icon_extra_get(uiBut *but)
return UI_BUT_ICONEXTRA_EYEDROPPER;
}
break;
+ case UI_BTYPE_TAB:
+ if (ui_but_icon_extra_is_visible_search_unlink(but)) {
+ return UI_BUT_ICONEXTRA_CLEAR;
+ }
+ break;
default:
break;
}
@@ -2071,14 +2087,23 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
*r_use_exp_float = false;
}
- if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
+ if (but->rnaprop && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU, UI_BTYPE_TAB)) {
PropertyType type;
const char *buf = NULL;
int buf_len;
type = RNA_property_type(but->rnaprop);
- if (type == PROP_STRING) {
+ if ((but->type == UI_BTYPE_TAB) && (but->custom_data)) {
+ StructRNA *ptr_type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
+ PointerRNA ptr;
+
+ /* uiBut.custom_data points to data this tab represents (e.g. workspace).
+ * uiBut.rnapoin/prop store an active value (e.g. active workspace). */
+ RNA_pointer_create(but->rnapoin.id.data, ptr_type, but->custom_data, &ptr);
+ buf = RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
+ }
+ else if (type == PROP_STRING) {
/* RNA string */
buf = RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
}
@@ -2114,12 +2139,7 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
MEM_freeN((void *)buf);
}
}
- else if (but->type == UI_BTYPE_TEXT) {
- /* string */
- BLI_strncpy(str, but->poin, maxlen);
- return;
- }
- else if (but->type == UI_BTYPE_SEARCH_MENU) {
+ else if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
/* string */
BLI_strncpy(str, but->poin, maxlen);
return;
@@ -2329,18 +2349,16 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
return true;
}
else if (type == PROP_POINTER) {
- /* RNA pointer */
- PointerRNA ptr, rptr;
- PropertyRNA *prop;
-
if (str[0] == '\0') {
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL);
return true;
}
else {
- ptr = but->rnasearchpoin;
- prop = but->rnasearchprop;
-
+ /* RNA pointer */
+ PointerRNA rptr;
+ PointerRNA ptr = but->rnasearchpoin;
+ PropertyRNA *prop = but->rnasearchprop;
+
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr))
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
@@ -2362,6 +2380,21 @@ bool ui_but_string_set(bContext *C, uiBut *but, const char *str)
}
}
}
+ else if (but->type == UI_BTYPE_TAB) {
+ if (but->rnaprop && but->custom_data) {
+ StructRNA *ptr_type = RNA_property_pointer_type(&but->rnapoin, but->rnaprop);
+ PointerRNA ptr;
+ PropertyRNA *prop;
+
+ /* uiBut.custom_data points to data this tab represents (e.g. workspace).
+ * uiBut.rnapoin/prop store an active value (e.g. active workspace). */
+ RNA_pointer_create(but->rnapoin.id.data, ptr_type, but->custom_data, &ptr);
+ prop = RNA_struct_name_property(ptr_type);
+ if (RNA_property_editable(&ptr, prop)) {
+ RNA_property_string_set(&ptr, prop, str);
+ }
+ }
+ }
else if (but->type == UI_BTYPE_TEXT) {
/* string */
if (!but->poin || (str[0] == '\0')) {
@@ -2907,6 +2940,7 @@ void ui_but_update_ex(uiBut *but, const bool validate)
case UI_BTYPE_TEXT:
case UI_BTYPE_SEARCH_MENU:
+ case UI_BTYPE_TAB:
if (!but->editstr) {
char str[UI_MAX_DRAW_STR];
@@ -3030,6 +3064,16 @@ void ui_block_cm_to_display_space_range(uiBlock *block, float *min, float *max)
*max = max_fff(UNPACK3(pixel));
}
+static uiBut *ui_but_alloc(const eButType type)
+{
+ switch (type) {
+ case UI_BTYPE_TAB:
+ return MEM_callocN(sizeof(uiButTab), "uiButTab");
+ default:
+ return MEM_callocN(sizeof(uiBut), "uiBut");
+ }
+}
+
/**
* \brief ui_def_but is the function that draws many button types
*
@@ -3063,7 +3107,7 @@ static uiBut *ui_def_but(
}
}
- but = MEM_callocN(sizeof(uiBut), "uiBut");
+ but = ui_but_alloc(type & BUTTYPE);
but->type = type & BUTTYPE;
but->pointype = type & UI_BUT_POIN_TYPES;
diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c
index 9aeb685a907..1fc38a27303 100644
--- a/source/blender/editors/interface/interface_align.c
+++ b/source/blender/editors/interface/interface_align.c
@@ -320,13 +320,43 @@ static int ui_block_align_butal_cmp(const void *a, const void *b)
return 0;
}
+static void ui_block_align_but_to_region(uiBut *but, const ARegion *region)
+{
+ rctf *rect = &but->rect;
+ const float but_width = BLI_rctf_size_x(rect);
+ const float but_height = BLI_rctf_size_y(rect);
+ const float px = U.pixelsize;
+
+ switch (but->drawflag & UI_BUT_ALIGN) {
+ case UI_BUT_ALIGN_TOP:
+ rect->ymax = region->winy + px;
+ rect->ymin = but->rect.ymax - but_height;
+ break;
+ case UI_BUT_ALIGN_DOWN:
+ rect->ymin = -px;
+ rect->ymax = rect->ymin + but_height;
+ break;
+ case UI_BUT_ALIGN_LEFT:
+ rect->xmin = -px;
+ rect->xmax = rect->xmin + but_width;
+ break;
+ case UI_BUT_ALIGN_RIGHT:
+ rect->xmax = region->winx + px;
+ rect->xmin = rect->xmax - but_width;
+ break;
+ default:
+ BLI_assert(0);
+ break;
+ }
+}
+
/**
* Compute the alignment of all 'align groups' of buttons in given block.
*
* This is using an order-independent algorithm, i.e. alignment of buttons should be OK regardless of order in which
* they are added to the block.
*/
-void ui_block_align_calc(uiBlock *block)
+void ui_block_align_calc(uiBlock *block, const ARegion *region)
{
uiBut *but;
int num_buttons = 0;
@@ -338,10 +368,17 @@ void ui_block_align_calc(uiBlock *block)
int side;
int i, j;
- /* First loop: we count number of buttons belonging to an align group, and clear their align flag. */
+ /* First loop: we count number of buttons belonging to an align group, and clear their align flag.
+ * Tabs get some special treatment here, they get aligned to region border. */
for (but = block->buttons.first; but; but = but->next) {
- /* Clear old align flags. */
- but->drawflag &= ~UI_BUT_ALIGN_ALL;
+ /* special case: tabs need to be aligned to a region border, drawflag tells which one */
+ if (but->type == UI_BTYPE_TAB) {
+ ui_block_align_but_to_region(but, region);
+ }
+ else {
+ /* Clear old align flags. */
+ but->drawflag &= ~UI_BUT_ALIGN_ALL;
+ }
if (but->alignnr != 0) {
num_buttons++;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 63fe440b36c..9e88c3cbb7f 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -931,6 +931,20 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
data->applied = true;
}
+static void ui_apply_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data)
+{
+ if (data->str) {
+ ui_but_string_set(C, but, data->str);
+ ui_but_update_edited(but);
+ }
+ else {
+ ui_apply_but_func(C, but);
+ }
+
+ data->retval = but->retval;
+ data->applied = true;
+}
+
static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
{
if (data->str) {
@@ -1892,9 +1906,11 @@ static void ui_apply_but(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
break;
case UI_BTYPE_ROW:
case UI_BTYPE_LISTROW:
- case UI_BTYPE_TAB:
ui_apply_but_ROW(C, block, but, data);
break;
+ case UI_BTYPE_TAB:
+ ui_apply_but_TAB(C, but, data);
+ break;
case UI_BTYPE_SCROLL:
case UI_BTYPE_GRIP:
case UI_BTYPE_NUM:
@@ -3649,18 +3665,6 @@ static int ui_do_but_KEYEVT(
return WM_UI_HANDLER_CONTINUE;
}
-static int ui_do_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
-{
- if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
- button_activate_state(C, but, BUTTON_STATE_EXIT);
- return WM_UI_HANDLER_CONTINUE;
- }
- }
-
- return WM_UI_HANDLER_CONTINUE;
-}
-
static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, const int mouse_xy[2])
{
int x = mouse_xy[0], y = mouse_xy[1];
@@ -3676,6 +3680,43 @@ static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, c
return BLI_rcti_isect_pt(&icon_rect, x, y);
}
+static int ui_do_but_TAB(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
+{
+ if (data->state == BUTTON_STATE_HIGHLIGHT) {
+ if ((event->type == LEFTMOUSE) &&
+ ((event->val == KM_DBL_CLICK) || event->ctrl))
+ {
+ button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ return WM_UI_HANDLER_BREAK;
+ }
+ else if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && (event->val == KM_CLICK)) {
+ const bool has_icon_extra = ui_but_icon_extra_get(but) == UI_BUT_ICONEXTRA_CLEAR;
+
+ if (has_icon_extra && ui_but_is_mouse_over_icon_extra(data->region, but, &event->x)) {
+ uiButTab *tab = (uiButTab *)but;
+ wmOperatorType *ot_backup = but->optype;
+
+ but->optype = tab->unlink_ot;
+ /* Force calling unlink/delete operator. */
+ ui_apply_but(C, block, but, data, true);
+ but->optype = ot_backup;
+ }
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ return WM_UI_HANDLER_BREAK;
+ }
+ }
+ else if (data->state == BUTTON_STATE_TEXT_EDITING) {
+ ui_do_but_textedit(C, block, but, data, event);
+ return WM_UI_HANDLER_BREAK;
+ }
+ else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
+ ui_do_but_textedit_select(C, block, but, data, event);
+ return WM_UI_HANDLER_BREAK;
+ }
+
+ return WM_UI_HANDLER_CONTINUE;
+}
+
static int ui_do_but_TEX(
bContext *C, uiBlock *block, uiBut *but,
uiHandleButtonData *data, const wmEvent *event)
@@ -6946,7 +6987,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
retval = ui_do_but_HOTKEYEVT(C, but, data, event);
break;
case UI_BTYPE_TAB:
- retval = ui_do_but_TAB(C, but, data, event);
+ retval = ui_do_but_TAB(C, block, but, data, event);
break;
case UI_BTYPE_BUT_TOGGLE:
case UI_BTYPE_TOGGLE:
@@ -7216,15 +7257,14 @@ bool ui_but_is_active(ARegion *ar)
/* is called by notifier */
void UI_screen_free_active_but(const bContext *C, bScreen *screen)
{
- ScrArea *sa = screen->areabase.first;
-
- for (; sa; sa = sa->next) {
- ARegion *ar = sa->regionbase.first;
- for (; ar; ar = ar->next) {
- uiBut *but = ui_but_find_active_in_region(ar);
+ wmWindow *win = CTX_wm_window(C);
+
+ ED_screen_areas_iter(win, screen, area) {
+ for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ uiBut *but = ui_but_find_active_in_region(region);
if (but) {
uiHandleButtonData *data = but->active;
-
+
if (data->menu == NULL && data->searchbox == NULL)
if (data->state == BUTTON_STATE_HIGHLIGHT)
ui_but_active_free(C, but);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 17ea50d5465..e71f36018e3 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -330,6 +330,11 @@ struct uiBut {
uiBlock *block;
};
+typedef struct uiButTab {
+ uiBut but;
+ struct wmOperatorType *unlink_ot;
+} uiButTab;
+
typedef struct ColorPicker {
struct ColorPicker *next, *prev;
float color_data[3]; /* colr data may be HSV or HSL for now */
@@ -773,7 +778,7 @@ void ui_layout_list_set_labels_active(uiLayout *layout);
/* interface_align.c */
bool ui_but_can_align(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
-void ui_block_align_calc(uiBlock *block);
+void ui_block_align_calc(uiBlock *block, const ARegion *region);
/* interface_anim.c */
void ui_but_anim_flag(uiBut *but, float cfra);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 969367f485c..7193ad64359 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -392,7 +392,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
static void ui_item_array(
uiLayout *layout, uiBlock *block, const char *name, int icon,
PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h),
- bool expand, bool slider, bool toggle, bool icon_only)
+ bool expand, bool slider, bool toggle, bool icon_only, bool compact)
{
uiStyle *style = layout->root->style;
uiBut *but;
@@ -541,9 +541,18 @@ static void ui_item_array(
}
for (a = 0; a < len; a++) {
- if (!icon_only) str[0] = RNA_property_array_item_char(prop, a);
- if (boolarr) icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
- but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y);
+ int width_item;
+
+ if (!icon_only) {
+ str[0] = RNA_property_array_item_char(prop, a);
+ }
+ if (boolarr) {
+ icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
+ }
+ width_item = (compact && type == PROP_BOOLEAN) ?
+ min_ii(w, ui_text_icon_width(layout, str, icon, false)) : w;
+
+ but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, width_item, UI_UNIT_Y);
if (slider && but->type == UI_BTYPE_NUM)
but->type = UI_BTYPE_NUM_SLIDER;
if (toggle && but->type == UI_BTYPE_CHECKBOX)
@@ -669,27 +678,38 @@ static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_
RNA_boolean_set(&but->rnapoin, "oskey", (but->modifier_key & KM_OSKEY) != 0);
}
-/* create label + button for RNA property */
-static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int flag)
+/**
+ * Create label + button for RNA property
+ *
+ * \param w_hint: For varying width layout, this becomes the label width.
+ * Otherwise it's used to fit both items into it.
+ **/
+static uiBut *ui_item_with_label(
+ uiLayout *layout, uiBlock *block, const char *name, int icon,
+ PointerRNA *ptr, PropertyRNA *prop, int index,
+ int x, int y, int w_hint, int h, int flag)
{
uiLayout *sub;
uiBut *but = NULL;
PropertyType type;
PropertySubType subtype;
- int labelw;
+ int prop_but_width = w_hint;
sub = uiLayoutRow(layout, layout->align);
UI_block_layout_set_current(block, sub);
if (name[0]) {
- /* XXX UI_fontstyle_string_width is not accurate */
-#if 0
- labelw = UI_fontstyle_string_width(fstyle, name);
- CLAMP(labelw, w / 4, 3 * w / 4);
-#endif
- labelw = w / 3;
- uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, labelw, h, NULL, 0.0, 0.0, 0, 0, "");
- w = w - labelw;
+ int w_label;
+
+ if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
+ /* w_hint is width for label in this case. Use a default width for property button(s) */
+ prop_but_width = UI_UNIT_X * 5;
+ w_label = w_hint;
+ }
+ else {
+ w_label = w_hint / 3;
+ }
+ uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, w_label, h, NULL, 0.0, 0.0, 0, 0, "");
}
type = RNA_property_type(prop);
@@ -697,14 +717,14 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
UI_block_layout_set_current(block, uiLayoutRow(sub, true));
- but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h);
+ but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h);
/* BUTTONS_OT_file_browse calls UI_context_active_but_prop_get_filebrowser */
uiDefIconButO(block, UI_BTYPE_BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse",
WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
}
else if (flag & UI_ITEM_R_EVENT) {
- but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL);
+ but = uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, prop_but_width, h, ptr, prop, index, 0, 0, -1, -1, NULL);
}
else if (flag & UI_ITEM_R_FULL_EVENT) {
if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
@@ -712,14 +732,17 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
WM_keymap_item_to_string(ptr->data, false, buf, sizeof(buf));
- but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
+ but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, prop_but_width, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
if (flag & UI_ITEM_R_IMMEDIATE)
UI_but_flag_enable(but, UI_BUT_IMMEDIATE);
}
}
- else
- but = uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "", icon, x, y, w, h);
+ else {
+ const char *str = (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "";
+ but = uiDefAutoButR(block, ptr, prop, index, str, icon,
+ x, y, prop_but_width, h);
+ }
UI_block_layout_set_current(block, layout);
return but;
@@ -1302,8 +1325,10 @@ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
/* RNA property items */
static void ui_item_rna_size(
- uiLayout *layout, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop,
- int index, bool icon_only, int *r_w, int *r_h)
+ uiLayout *layout, const char *name, int icon,
+ PointerRNA *ptr, PropertyRNA *prop,
+ int index, bool icon_only, bool compact,
+ int *r_w, int *r_h)
{
PropertyType type;
PropertySubType subtype;
@@ -1329,7 +1354,7 @@ static void ui_item_rna_size(
RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
for (item = item_array; item->identifier; item++) {
if (item->identifier[0]) {
- w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, 0));
+ w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, compact));
}
}
if (free) {
@@ -1340,12 +1365,13 @@ static void ui_item_rna_size(
if (!w) {
if (type == PROP_ENUM && icon_only) {
- w = ui_text_icon_width(layout, "", ICON_BLANK1, 0);
+ w = ui_text_icon_width(layout, "", ICON_BLANK1, compact);
if (index != RNA_ENUM_VALUE)
w += 0.6f * UI_UNIT_X;
}
else {
- w = ui_text_icon_width(layout, name, icon, 0);
+ /* not compact for float/int buttons, looks too squashed */
+ w = ui_text_icon_width(layout, name, icon, ELEM(type, PROP_FLOAT, PROP_INT) ? false : compact);
}
}
h = UI_UNIT_Y;
@@ -1382,7 +1408,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
PropertyType type;
char namestr[UI_MAX_NAME_STR];
int len, w, h;
- bool slider, toggle, expand, icon_only, no_bg;
+ bool slider, toggle, expand, icon_only, no_bg, compact;
bool is_array;
UI_block_layout_set_current(block, layout);
@@ -1415,7 +1441,12 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
name = ui_item_name_add_colon(name, namestr);
}
else if (type == PROP_ENUM && index != RNA_ENUM_VALUE) {
- name = ui_item_name_add_colon(name, namestr);
+ if (flag & UI_ITEM_R_COMPACT) {
+ name = "";
+ }
+ else {
+ name = ui_item_name_add_colon(name, namestr);
+ }
}
/* menus and pie-menus don't show checkbox without this */
@@ -1443,16 +1474,19 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
expand = (flag & UI_ITEM_R_EXPAND) != 0;
icon_only = (flag & UI_ITEM_R_ICON_ONLY) != 0;
no_bg = (flag & UI_ITEM_R_NO_BG) != 0;
+ compact = (flag & UI_ITEM_R_COMPACT) != 0;
/* get size */
- ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h);
+ ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, compact, &w, &h);
if (no_bg)
UI_block_emboss_set(block, UI_EMBOSS_NONE);
/* array property */
if (index == RNA_NO_INDEX && is_array)
- ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only);
+ ui_item_array(
+ layout, block, name, icon, ptr, prop, len, 0, 0, w, h,
+ expand, slider, toggle, icon_only, compact);
/* enum item */
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
if (icon && name[0] && !icon_only)
@@ -1641,6 +1675,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
/* Pointer RNA button with search */
+
static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA **prop)
{
StructRNA *srna;
@@ -1771,7 +1806,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
/* create button */
block = uiLayoutGetBlock(layout);
- ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, &w, &h);
+ ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, false, &w, &h);
w += UI_UNIT_X; /* X icon needs more space */
but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ae2b8c8060c..4af63f2bbcb 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -120,7 +120,9 @@ static void template_add_button_search_menu(
if (use_previews) {
ARegion *region = CTX_wm_region(C);
- const bool use_big_size = (region->regiontype != RGN_TYPE_HEADER); /* silly check, could be more generic */
+ ScrArea *area = CTX_wm_area(C);
+ /* XXX ugly top-bar exception */
+ const bool use_big_size = (region->regiontype != RGN_TYPE_HEADER) && (area->spacetype != SPACE_TOPBAR); /* silly check, could be more generic */
/* Ugly exception for screens here, drawing their preview in icon size looks ugly/useless */
const bool use_preview_icon = use_big_size || (id && (GS(id->name) != ID_SCR));
const short width = UI_UNIT_X * (use_big_size ? 6 : 1.6f);
@@ -238,7 +240,7 @@ typedef struct TemplateID {
} TemplateID;
/* Search browse menu, assign */
-static void id_search_call_cb(bContext *C, void *arg_template, void *item)
+static void template_ID_set_property_cb(bContext *C, void *arg_template, void *item)
{
TemplateID *template_ui = (TemplateID *)arg_template;
@@ -379,7 +381,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
}
return template_common_search_menu(
- C, ar, id_search_cb_p, &template_ui, id_search_call_cb, active_item_ptr.data,
+ C, ar, id_search_cb_p, &template_ui, template_ID_set_property_cb, active_item_ptr.data,
template_ui.prv_rows, template_ui.prv_cols);
}
@@ -570,6 +572,67 @@ static const char *template_id_context(StructRNA *type)
}
#endif
+static uiBut *template_id_def_new_but(
+ uiBlock *block, const ID *id, const TemplateID *template_ui, StructRNA *type,
+ const char * const newop, const bool editable, const bool id_open, const bool use_tab_but)
+{
+ ID *idfrom = template_ui->ptr.id.data;
+ uiBut *but;
+ const int w = id ? UI_UNIT_X : id_open ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
+ const int but_type = use_tab_but ? UI_BTYPE_TAB : UI_BTYPE_BUT;
+
+ /* i18n markup, does nothing! */
+ BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT,
+ BLT_I18NCONTEXT_ID_SCENE,
+ BLT_I18NCONTEXT_ID_OBJECT,
+ BLT_I18NCONTEXT_ID_MESH,
+ BLT_I18NCONTEXT_ID_CURVE,
+ BLT_I18NCONTEXT_ID_METABALL,
+ BLT_I18NCONTEXT_ID_MATERIAL,
+ BLT_I18NCONTEXT_ID_TEXTURE,
+ BLT_I18NCONTEXT_ID_IMAGE,
+ BLT_I18NCONTEXT_ID_LATTICE,
+ BLT_I18NCONTEXT_ID_LAMP,
+ BLT_I18NCONTEXT_ID_CAMERA,
+ BLT_I18NCONTEXT_ID_WORLD,
+ BLT_I18NCONTEXT_ID_SCREEN,
+ BLT_I18NCONTEXT_ID_TEXT,
+ );
+ BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_ID_SPEAKER,
+ BLT_I18NCONTEXT_ID_SOUND,
+ BLT_I18NCONTEXT_ID_ARMATURE,
+ BLT_I18NCONTEXT_ID_ACTION,
+ BLT_I18NCONTEXT_ID_NODETREE,
+ BLT_I18NCONTEXT_ID_BRUSH,
+ BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
+ BLT_I18NCONTEXT_ID_GPENCIL,
+ BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
+ BLT_I18NCONTEXT_ID_WORKSPACE,
+ BLT_I18NCONTEXT_ID_LIGHTPROBE,
+ );
+
+ if (newop) {
+ but = uiDefIconTextButO(block, but_type, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
+ (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
+ UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
+ }
+ else {
+ but = uiDefIconTextBut(block, but_type, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
+ 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
+ }
+
+ if ((idfrom && idfrom->lib) || !editable) {
+ UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
+
+#ifndef WITH_INTERNATIONAL
+ UNUSED_VARS(type);
+#endif
+
+ return but;
+}
+
static void template_ID(
bContext *C, uiLayout *layout, TemplateID *template_ui, StructRNA *type, int flag,
const char *newop, const char *openop, const char *unlinkop)
@@ -672,51 +735,7 @@ static void template_ID(
}
if (flag & UI_ID_ADD_NEW) {
- int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
-
- /* i18n markup, does nothing! */
- BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_DEFAULT,
- BLT_I18NCONTEXT_ID_SCENE,
- BLT_I18NCONTEXT_ID_OBJECT,
- BLT_I18NCONTEXT_ID_MESH,
- BLT_I18NCONTEXT_ID_CURVE,
- BLT_I18NCONTEXT_ID_METABALL,
- BLT_I18NCONTEXT_ID_MATERIAL,
- BLT_I18NCONTEXT_ID_TEXTURE,
- BLT_I18NCONTEXT_ID_IMAGE,
- BLT_I18NCONTEXT_ID_LATTICE,
- BLT_I18NCONTEXT_ID_LAMP,
- BLT_I18NCONTEXT_ID_CAMERA,
- BLT_I18NCONTEXT_ID_WORLD,
- BLT_I18NCONTEXT_ID_SCREEN,
- BLT_I18NCONTEXT_ID_TEXT,
- );
- BLT_I18N_MSGID_MULTI_CTXT("New", BLT_I18NCONTEXT_ID_SPEAKER,
- BLT_I18NCONTEXT_ID_SOUND,
- BLT_I18NCONTEXT_ID_ARMATURE,
- BLT_I18NCONTEXT_ID_ACTION,
- BLT_I18NCONTEXT_ID_NODETREE,
- BLT_I18NCONTEXT_ID_BRUSH,
- BLT_I18NCONTEXT_ID_PARTICLESETTINGS,
- BLT_I18NCONTEXT_ID_GPENCIL,
- BLT_I18NCONTEXT_ID_FREESTYLELINESTYLE,
- BLT_I18NCONTEXT_ID_WORKSPACE,
- BLT_I18NCONTEXT_ID_LIGHTPROBE,
- );
-
- if (newop) {
- but = uiDefIconTextButO(block, UI_BTYPE_BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN,
- (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL);
- UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
- }
- else {
- but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"),
- 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
- UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
- }
-
- if ((idfrom && idfrom->lib) || !editable)
- UI_but_flag_enable(but, UI_BUT_DISABLED);
+ template_id_def_new_but(block, id, template_ui, type, newop, editable, flag & UI_ID_OPEN, false);
}
/* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack.
@@ -785,9 +804,57 @@ static void template_ID(
UI_block_align_end(block);
}
+static void template_ID_tabs(
+ bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag,
+ const char *newop, const char *UNUSED(openop), const char *unlinkop)
+{
+ const ARegion *region = CTX_wm_region(C);
+ const PointerRNA active_ptr = RNA_property_pointer_get(&template->ptr, template->prop);
+ const int but_align = (region->alignment == RGN_ALIGN_TOP) ? UI_BUT_ALIGN_DOWN : UI_BUT_ALIGN_TOP;
+
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiStyle *style = UI_style_get_dpi();
+
+
+ for (ID *id = template->idlb->first; id; id = id->next) {
+ wmOperatorType *unlink_ot = WM_operatortype_find(unlinkop, false);
+ const bool is_active = active_ptr.data == id;
+ const unsigned int but_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2) + UI_UNIT_X +
+ (is_active ? ICON_DEFAULT_WIDTH_SCALE : 0);
+ uiButTab *tab;
+
+ tab = (uiButTab *)uiDefButR_prop(
+ block, UI_BTYPE_TAB, 0, "", 0, 0, but_width, UI_UNIT_Y,
+ &template->ptr, template->prop, 0, 0.0f,
+ sizeof(id->name) - 2, 0.0f, 0.0f, "");
+ UI_but_funcN_set(&tab->but, template_ID_set_property_cb, MEM_dupallocN(template), id);
+ tab->but.custom_data = (void *)id;
+ tab->unlink_ot = unlink_ot;
+
+ if (is_active) {
+ UI_but_flag_enable(&tab->but, UI_BUT_VALUE_CLEAR);
+ }
+ UI_but_drawflag_enable(&tab->but, but_align);
+ }
+
+ if (flag & UI_ID_ADD_NEW) {
+ const bool editable = RNA_property_editable(&template->ptr, template->prop);
+ uiBut *but;
+
+ if (active_ptr.type) {
+ type = active_ptr.type;
+ }
+
+ but = template_id_def_new_but(block, active_ptr.data, template, type, newop, editable, flag & UI_ID_OPEN, true);
+ UI_but_drawflag_enable(but, but_align);
+ }
+}
+
static void ui_template_id(
- uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
- const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols, int filter)
+ uiLayout *layout, bContext *C,
+ PointerRNA *ptr, const char *propname,
+ const char *newop, const char *openop, const char *unlinkop,
+ int flag, int prv_rows, int prv_cols, int filter, bool use_tabs)
{
TemplateID *template_ui;
PropertyRNA *prop;
@@ -828,8 +895,14 @@ static void ui_template_id(
* - template_ID makes a copy of the template data and assigns it to the relevant buttons
*/
if (template_ui->idlb) {
- uiLayoutRow(layout, true);
- template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop);
+ if (use_tabs) {
+ uiLayoutRow(layout, false);
+ template_ID_tabs(C, layout, template_ui, type, flag, newop, openop, unlinkop);
+ }
+ else {
+ uiLayoutRow(layout, true);
+ template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop);
+ }
}
MEM_freeN(template_ui);
@@ -839,23 +912,49 @@ void uiTemplateID(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
const char *openop, const char *unlinkop, int filter)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
- UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0, filter);
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
+ 0, 0, filter, false);
}
void uiTemplateIDBrowse(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
const char *openop, const char *unlinkop, int filter)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME, 0, 0, filter);
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME,
+ 0, 0, filter, false);
}
void uiTemplateIDPreview(
uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop,
const char *openop, const char *unlinkop, int rows, int cols, int filter)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop,
- UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols, filter);
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS,
+ rows, cols, filter, false);
+}
+
+/**
+ * Version of #uiTemplateID using tabs.
+ */
+void uiTemplateIDTabs(
+ uiLayout *layout, bContext *C,
+ PointerRNA *ptr, const char *propname,
+ const char *newop, const char *openop, const char *unlinkop,
+ int filter)
+{
+ ui_template_id(
+ layout, C, ptr, propname,
+ newop, openop, unlinkop,
+ UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE,
+ 0, 0, filter, true);
}
/************************ ID Chooser Template ***************************/
@@ -1429,6 +1528,63 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
return NULL;
}
+
+/************************ Redo Buttons Template *************************/
+
+#ifdef WITH_REDO_REGION_REMOVAL
+static bool template_operator_redo_property_buts_poll(PointerRNA *UNUSED(ptr), PropertyRNA *prop)
+{
+ return (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED) == 0;
+}
+
+static void template_operator_redo_property_buts_draw(
+ const bContext *C, wmOperator *op,
+ uiLayout *layout, int layout_flags,
+ bool *r_has_advanced)
+{
+ if (op->type->flag & OPTYPE_MACRO) {
+ for (wmOperator *macro_op = op->macro.first; macro_op; macro_op = macro_op->next) {
+ template_operator_redo_property_buts_draw(C, macro_op, layout, layout_flags, r_has_advanced);
+ }
+ }
+ else {
+ /* Might want to make label_align adjustable somehow. */
+ eAutoPropButsReturn return_info = uiTemplateOperatorPropertyButs(
+ C, layout, op, template_operator_redo_property_buts_poll,
+ UI_BUT_LABEL_ALIGN_NONE, layout_flags);
+ if (return_info & UI_PROP_BUTS_ANY_FAILED_CHECK) {
+ *r_has_advanced = true;
+ }
+ }
+}
+
+void uiTemplateOperatorRedoProperties(uiLayout *layout, bContext *C)
+{
+ wmOperator *op = WM_operator_last_redo(C);
+ uiBlock *block = uiLayoutGetBlock(layout);
+
+ if (op == NULL) {
+ return;
+ }
+
+ /* Repeat button with operator name as text. */
+ uiItemFullO(layout, "SCREEN_OT_repeat_last", RNA_struct_ui_name(op->type->srna),
+ ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, NULL);
+
+ if (WM_operator_repeat_check(C, op)) {
+ bool has_advanced = false;
+
+ UI_block_func_set(block, ED_undo_operator_repeat_cb, op, NULL);
+ template_operator_redo_property_buts_draw(C, op, layout, UI_TEMPLATE_OP_PROPS_COMPACT, &has_advanced);
+ UI_block_func_set(block, NULL, NULL, NULL); /* may want to reset to old state instead of NULLing all */
+
+ if (has_advanced) {
+ uiItemO(layout, IFACE_("More..."), ICON_NONE, "SCREEN_OT_redo_last");
+ }
+ }
+}
+#endif
+
/************************ Constraint Template *************************/
#include "DNA_constraint_types.h"
@@ -3716,11 +3872,14 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt,
* Draw Operator property buttons for redoing execution with different settings.
* This function does not initialize the layout, functions can be called on the layout before and after.
*/
-void uiTemplateOperatorPropertyButs(
+eAutoPropButsReturn uiTemplateOperatorPropertyButs(
const bContext *C, uiLayout *layout, wmOperator *op,
bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *),
- const char label_align, const short flag)
+ const eButLabelAlign label_align, const short flag)
{
+ uiBlock *block = uiLayoutGetBlock(layout);
+ eAutoPropButsReturn return_info = 0;
+
if (!op->properties) {
IDPropertyTemplate val = {0};
op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
@@ -3733,14 +3892,14 @@ void uiTemplateOperatorPropertyButs(
/* poll() on this operator may still fail, at the moment there is no nice feedback when this happens
* just fails silently */
if (!WM_operator_repeat_check(C, op)) {
- UI_block_lock_set(uiLayoutGetBlock(layout), true, "Operator can't' redo");
+ UI_block_lock_set(block, true, "Operator can't' redo");
/* XXX, could give some nicer feedback or not show redo panel at all? */
uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE);
}
else {
/* useful for macros where only one of the steps can't be re-done */
- UI_block_lock_clear(uiLayoutGetBlock(layout));
+ UI_block_lock_clear(block);
}
/* menu */
@@ -3749,7 +3908,7 @@ void uiTemplateOperatorPropertyButs(
PointerRNA op_ptr;
uiLayout *row;
- uiLayoutGetBlock(layout)->ui_operator = op;
+ block->ui_operator = op;
row = uiLayoutRow(layout, true);
uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE);
@@ -3768,19 +3927,19 @@ void uiTemplateOperatorPropertyButs(
op->type->ui((bContext *)C, op);
op->layout = NULL;
- /* UI_LAYOUT_OP_SHOW_EMPTY ignored */
+ /* UI_LAYOUT_OP_SHOW_EMPTY ignored. return_info is ignored too. We could
+ * allow ot.ui callback to return this, but not needed right now. */
}
else {
wmWindowManager *wm = CTX_wm_manager(C);
PointerRNA ptr;
- int empty;
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* main draw call */
- empty = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
+ return_info = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align, (flag & UI_TEMPLATE_OP_PROPS_COMPACT));
- if (empty && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) {
+ if ((return_info & UI_PROP_BUTS_NONE_ADDED) && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) {
uiItemL(layout, IFACE_("No Properties"), ICON_NONE);
}
}
@@ -3790,7 +3949,6 @@ void uiTemplateOperatorPropertyButs(
* but this is not so important if this button is drawn in those cases
* (which isn't all that likely anyway) - campbell */
if (op->properties->len) {
- uiBlock *block;
uiBut *but;
uiLayout *col; /* needed to avoid alignment errors with previous buttons */
@@ -3804,7 +3962,6 @@ void uiTemplateOperatorPropertyButs(
/* set various special settings for buttons */
{
- uiBlock *block = uiLayoutGetBlock(layout);
const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0;
uiBut *but;
@@ -3824,6 +3981,8 @@ void uiTemplateOperatorPropertyButs(
}
}
}
+
+ return return_info;
}
/************************* Running Jobs Template **************************/
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index f0317087ddc..f28da5a666b 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -157,62 +157,72 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
* \a check_prop callback filters functions to avoid drawing certain properties,
* in cases where PROP_HIDDEN flag can't be used for a property.
*/
-int uiDefAutoButsRNA(
+eAutoPropButsReturn uiDefAutoButsRNA(
uiLayout *layout, PointerRNA *ptr,
bool (*check_prop)(PointerRNA *, PropertyRNA *),
- const char label_align)
+ const eButLabelAlign label_align, const bool compact)
{
+ eAutoPropButsReturn return_info = UI_PROP_BUTS_NONE_ADDED;
uiLayout *split, *col;
int flag;
const char *name;
- int tot = 0;
-
- assert(ELEM(label_align, '\0', 'H', 'V'));
RNA_STRUCT_BEGIN (ptr, prop)
{
flag = RNA_property_flag(prop);
- if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop) == 0))
+
+ if (flag & PROP_HIDDEN) {
+ continue;
+ }
+ if (check_prop && check_prop(ptr, prop) == 0) {
+ return_info |= UI_PROP_BUTS_ANY_FAILED_CHECK;
continue;
+ }
- if (label_align != '\0') {
- PropertyType type = RNA_property_type(prop);
- const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
+ switch (label_align) {
+ case UI_BUT_LABEL_ALIGN_COLUMN:
+ case UI_BUT_LABEL_ALIGN_SPLIT_COLUMN:
+ {
+ PropertyType type = RNA_property_type(prop);
+ const bool is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
- name = RNA_property_ui_name(prop);
+ name = RNA_property_ui_name(prop);
- if (label_align == 'V') {
- col = uiLayoutColumn(layout, true);
+ if (label_align == UI_BUT_LABEL_ALIGN_COLUMN) {
+ col = uiLayoutColumn(layout, true);
- if (!is_boolean)
- uiItemL(col, name, ICON_NONE);
- }
- else { /* (label_align == 'H') */
- BLI_assert(label_align == 'H');
- split = uiLayoutSplit(layout, 0.5f, false);
+ if (!is_boolean)
+ uiItemL(col, name, ICON_NONE);
+ }
+ else {
+ BLI_assert(label_align == UI_BUT_LABEL_ALIGN_SPLIT_COLUMN);
+ split = uiLayoutSplit(layout, 0.5f, false);
- col = uiLayoutColumn(split, false);
- uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
- col = uiLayoutColumn(split, false);
- }
+ col = uiLayoutColumn(split, false);
+ uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
+ col = uiLayoutColumn(split, false);
+ }
- /* may meed to add more cases here.
- * don't override enum flag names */
+ /* may meed to add more cases here.
+ * don't override enum flag names */
- /* name is shown above, empty name for button below */
- name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
- }
- else {
- col = layout;
- name = NULL; /* no smart label alignment, show default name with button */
+ /* name is shown above, empty name for button below */
+ name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
+
+ break;
+ }
+ case UI_BUT_LABEL_ALIGN_NONE:
+ col = layout;
+ name = NULL; /* no smart label alignment, show default name with button */
+ break;
}
- uiItemFullR(col, ptr, prop, -1, 0, 0, name, ICON_NONE);
- tot++;
+ uiItemFullR(col, ptr, prop, -1, 0, compact ? UI_ITEM_R_COMPACT : 0, name, ICON_NONE);
+ return_info &= ~UI_PROP_BUTS_NONE_ADDED;
}
RNA_STRUCT_END;
- return tot;
+ return return_info;
}
/* *** RNA collection search menu *** */
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 7714d065363..e5e89260ed5 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2289,7 +2289,7 @@ static struct uiWidgetColors wcol_list_item = {
};
struct uiWidgetColors wcol_tab = {
- {255, 255, 255, 255},
+ {60, 60, 60, 255},
{83, 83, 83, 255},
{114, 114, 114, 255},
{90, 90, 90, 255},
@@ -3832,16 +3832,20 @@ static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, in
widgetbase_draw(&wtb, wcol);
}
-static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
+static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
const uiStyle *style = UI_style_get();
- const float rad = 0.15f * U.widget_unit;
+ const float rad = 0.25f * U.widget_unit;
const int fontid = style->widget.uifont_id;
- const bool is_active = (but->flag & UI_SELECT);
+ const bool is_active = (state & UI_SELECT);
+
+/* Draw shaded outline - Disabled for now, seems incorrect and also looks nicer without it imho ;) */
+//#define USE_TAB_SHADED_HIGHLIGHT
uiWidgetBase wtb;
unsigned char theme_col_tab_highlight[3];
+#ifdef USE_TAB_SHADED_HIGHLIGHT
/* create outline highlight colors */
if (is_active) {
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner_sel,
@@ -3851,6 +3855,7 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner,
(unsigned char *)wcol->outline, 0.12f);
}
+#endif
widget_init(&wtb);
@@ -3858,7 +3863,9 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
round_box_edges(&wtb, roundboxalign, rect, rad);
/* draw inner */
+#ifdef USE_TAB_SHADED_HIGHLIGHT
wtb.draw_outline = 0;
+#endif
widgetbase_draw(&wtb, wcol);
/* We are drawing on top of widget bases. Flush cache. */
@@ -3866,13 +3873,19 @@ static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
UI_widgetbase_draw_cache_flush();
glDisable(GL_BLEND);
+#ifdef USE_TAB_SHADED_HIGHLIGHT
/* draw outline (3d look) */
ui_draw_but_TAB_outline(rect, rad, theme_col_tab_highlight, (unsigned char *)wcol->inner);
+#endif
/* text shadow */
BLF_enable(fontid, BLF_SHADOW);
BLF_shadow(fontid, 3, (const float[4]){1.0f, 1.0f, 1.0f, 0.25f});
BLF_shadow_offset(fontid, 0, -1);
+
+#ifndef USE_TAB_SHADED_HIGHLIGHT
+ UNUSED_VARS(is_active, theme_col_tab_highlight);
+#endif
}
static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
@@ -3963,8 +3976,8 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
case UI_WTYPE_TAB:
- wt.custom = widget_tab;
wt.wcol_theme = &btheme->tui.wcol_tab;
+ wt.draw = widget_tab;
break;
case UI_WTYPE_TOOLTIP:
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index d13b7e8ea74..b40ab09036f 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -165,6 +165,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
case SPACE_CLIP:
ts = &btheme->tclip;
break;
+ case SPACE_TOPBAR:
+ ts = &btheme->ttopbar;
+ break;
default:
ts = &btheme->tv3d;
break;
@@ -1225,6 +1228,14 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tclip.strip_select, 0xff, 0x8c, 0x00, 0xff);
btheme->tclip.handle_vertex_size = 5;
ui_theme_space_init_handles_color(&btheme->tclip);
+
+ /* space topbar */
+ char tmp[4];
+ btheme->ttopbar = btheme->tv3d;
+ /* swap colors */
+ copy_v4_v4_char(tmp, btheme->ttopbar.header);
+ copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive);
+ copy_v4_v4_char(btheme->ttopbar.back, tmp);
}
void ui_style_init_default(void)
@@ -2914,10 +2925,10 @@ void init_userdef_do_versions(void)
U.uiflag |= USER_LOCK_CURSOR_ADJUST;
}
- if (!USER_VERSION_ATLEAST(280, 1)) {
+ if (!USER_VERSION_ATLEAST(280, 9)) {
/* interface_widgets.c */
struct uiWidgetColors wcol_tab = {
- {255, 255, 255, 255},
+ {60, 60, 60, 255},
{83, 83, 83, 255},
{114, 114, 114, 255},
{90, 90, 90, 255},
@@ -2930,7 +2941,14 @@ void init_userdef_do_versions(void)
};
for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) {
+ char tmp[4];
+
btheme->tui.wcol_tab = wcol_tab;
+ btheme->ttopbar = btheme->tv3d;
+ /* swap colors */
+ copy_v4_v4_char(tmp, btheme->ttopbar.header);
+ copy_v4_v4_char(btheme->ttopbar.header, btheme->ttopbar.tab_inactive);
+ copy_v4_v4_char(btheme->ttopbar.back, tmp);
}
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 5c2df386ef8..371f42e17b3 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -5584,7 +5584,7 @@ static void edbm_sort_elements_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call. */
- uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
void MESH_OT_sort_elements(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 603f5b1c77f..d4e8955b38e 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -528,7 +528,7 @@ static void data_transfer_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call */
- uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, data_transfer_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
/* transfers weight from active to selected */
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index d2ac0f77c78..272478e46ff 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -972,7 +972,7 @@ static void parent_set_ui(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* Main auto-draw call. */
- uiDefAutoButsRNA(layout, &ptr, parent_set_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, parent_set_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
void OBJECT_OT_parent_set(wmOperatorType *ot)
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 105fff38f62..b6e2d2c57d4 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1168,7 +1168,7 @@ static bool region_is_overlap(wmWindow *win, ScrArea *sa, ARegion *ar)
return 0;
}
-static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad)
+static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti *remainder, int quad, bool add_azones)
{
rcti *remainder_prev = remainder;
int prefsizex, prefsizey;
@@ -1195,13 +1195,17 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
/* user errors */
if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT)
alignment = RGN_ALIGN_NONE;
-
+
/* prefsize, for header we stick to exception (prevent dpi rounding error) */
- prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex);
-
+ const float sizex_dpi_fac = (ar->flag & RGN_SIZEX_DPI_APPLIED) ? 1.0f : UI_DPI_FAC;
+ prefsizex = sizex_dpi_fac * ((ar->sizex > 1) ? ar->sizex + 0.5f : ar->type->prefsizex);
+
if (ar->regiontype == RGN_TYPE_HEADER) {
prefsizey = ED_area_headersize();
}
+ else if (ED_area_is_global(sa)) {
+ prefsizey = ED_region_global_size_y();
+ }
else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
}
@@ -1397,7 +1401,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
* but accounts for small common rounding problems when scaling the UI,
* must be minimum '4' */
}
- else {
+ else if (add_azones) {
const bScreen *screen = WM_window_get_active_screen(win);
if (ELEM(screen->state, SCREENNORMAL, SCREENMAXIMIZED)) {
@@ -1409,23 +1413,36 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
}
}
- region_rect_recursive(win, sa, ar->next, remainder, quad);
+ region_rect_recursive(win, sa, ar->next, remainder, quad, add_azones);
}
-static void area_calc_totrct(ScrArea *sa, int sizex, int sizey)
+static void area_calc_totrct(ScrArea *sa, int window_size_x, int window_size_y)
{
- short rt = (short) U.pixelsize;
+ short px = (short)U.pixelsize;
+
+ sa->totrct.xmin = sa->v1->vec.x;
+ sa->totrct.xmax = sa->v4->vec.x;
+ sa->totrct.ymin = sa->v1->vec.y;
+ sa->totrct.ymax = sa->v2->vec.y;
+
+ /* scale down totrct by 1 pixel on all sides not matching window borders */
+ if (sa->totrct.xmin > 0) {
+ sa->totrct.xmin += px;
+ }
+ if (sa->totrct.xmax < (window_size_x - 1)) {
+ sa->totrct.xmax -= px;
+ }
+ if (sa->totrct.ymin > 0) {
+ sa->totrct.ymin += px;
+ }
+ if (sa->totrct.ymax < (window_size_y - 1)) {
+ sa->totrct.ymax -= px;
+ }
+ BLI_assert(sa->totrct.xmin >= 0);
+ BLI_assert(sa->totrct.xmax >= 0);
+ BLI_assert(sa->totrct.ymin >= 0);
+ BLI_assert(sa->totrct.ymax >= 0);
- if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + rt;
- else sa->totrct.xmin = sa->v1->vec.x;
- if (sa->v4->vec.x < sizex - 1) sa->totrct.xmax = sa->v4->vec.x - rt;
- else sa->totrct.xmax = sa->v4->vec.x;
-
- if (sa->v1->vec.y > 0) sa->totrct.ymin = sa->v1->vec.y + rt;
- else sa->totrct.ymin = sa->v1->vec.y;
- if (sa->v2->vec.y < sizey - 1) sa->totrct.ymax = sa->v2->vec.y - rt;
- else sa->totrct.ymax = sa->v2->vec.y;
-
/* for speedup */
sa->winx = BLI_rcti_size_x(&sa->totrct) + 1;
sa->winy = BLI_rcti_size_y(&sa->totrct) + 1;
@@ -1510,11 +1527,36 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand
}
}
+void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area)
+{
+ const int size_x = WM_window_pixels_x(win);
+ const int size_y = WM_window_pixels_y(win);
+ rcti rect;
+
+ area_calc_totrct(area, size_x, size_y);
+
+ /* region rect sizes */
+ rect = area->totrct;
+ region_rect_recursive(win, area, area->regionbase.first, &rect, 0, false);
+
+ for (ARegion *ar = area->regionbase.first; ar; ar = ar->next) {
+ region_subwindow(ar);
+
+ /* region size may have changed, init does necessary adjustments */
+ if (ar->type->init) {
+ ar->type->init(wm, ar);
+ }
+ }
+
+ area->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
+}
/* called in screen_refresh, or screens_init, also area size changes */
void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
{
const bScreen *screen = WM_window_get_active_screen(win);
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
ARegion *ar;
rcti rect;
@@ -1528,16 +1570,17 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
for (ar = sa->regionbase.first; ar; ar = ar->next)
ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype);
-
+
/* area sizes */
- area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win));
-
+ area_calc_totrct(sa, window_size_x, window_size_y);
+
/* clear all azones, add the area triange widgets */
area_azone_initialize(win, screen, sa);
/* region rect sizes */
rect = sa->totrct;
- region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0);
+ region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0, true);
+ sa->flag &= ~AREA_FLAG_REGION_SIZE_UPDATE;
/* default area handlers */
ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag);
@@ -1832,6 +1875,18 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco)
/************************ standard UI regions ************************/
+static ThemeColorID region_background_color_id(const bContext *C, const ARegion *region)
+{
+ switch (region->regiontype) {
+ case RGN_TYPE_HEADER:
+ return ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL;
+ case RGN_TYPE_PREVIEW:
+ return TH_PREVIEW_BACK;
+ default:
+ return TH_BACK;
+ }
+}
+
void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int contextnr, const bool vertical)
{
const WorkSpace *workspace = CTX_wm_workspace(C);
@@ -2117,17 +2172,25 @@ void ED_region_header(const bContext *C, ARegion *ar)
Header header = {NULL};
int maxco, xco, yco;
int headery = ED_area_headersize();
+ const int start_ofs = 0.4f * UI_UNIT_X;
+ bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE;
/* clear */
- UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL);
+ UI_ThemeClearColor(region_background_color_id(C, ar));
glClear(GL_COLOR_BUFFER_BIT);
/* set view2d view matrix for scrolling (without scrollers) */
UI_view2d_view_ortho(&ar->v2d);
- xco = maxco = 0.4f * UI_UNIT_X;
+ xco = maxco = start_ofs;
yco = headery - floor(0.2f * UI_UNIT_Y);
+ /* XXX workaround for 1 px alignment issue. Not sure what causes it... Would prefer a proper fix - Julian */
+ if (CTX_wm_area(C)->spacetype == SPACE_TOPBAR) {
+ xco += 1;
+ yco += 1;
+ }
+
/* draw all headers types */
for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS);
@@ -2149,13 +2212,23 @@ void ED_region_header(const bContext *C, ARegion *ar)
/* for view2d */
if (xco > maxco)
maxco = xco;
-
+
+ if (region_layout_based && (ar->sizex != (maxco + start_ofs))) {
+ /* region size is layout based and needs to be updated */
+ ScrArea *sa = CTX_wm_area(C);
+
+ ar->sizex = maxco + start_ofs;
+ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->sizex, ar->winy);
+
+ sa->flag |= AREA_FLAG_REGION_SIZE_UPDATE;
+ ar->flag |= RGN_SIZEX_DPI_APPLIED;
+ }
UI_block_end(C, block);
UI_block_draw(C, block);
}
/* always as last */
- UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery);
+ UI_view2d_totRect_set(&ar->v2d, maxco + (region_layout_based ? 0 : UI_UNIT_X + 80), headery);
/* restore view matrix? */
UI_view2d_view_restore(C);
@@ -2172,6 +2245,31 @@ int ED_area_headersize(void)
return (int)(HEADERY * UI_DPI_FAC);
}
+/**
+ * \return the final height of a global \a area, accounting for DPI.
+ */
+int ED_area_global_size_y(const ScrArea *area)
+{
+ BLI_assert(ED_area_is_global(area));
+ return round_fl_to_int(area->global->cur_fixed_height * UI_DPI_FAC);
+}
+
+bool ED_area_is_global(const ScrArea *area)
+{
+ return area->global != NULL;
+}
+
+/**
+ * For now we just assume all global areas are made up out of horizontal bars
+ * with the same size. A fixed size could be stored in ARegion instead if needed.
+ *
+ * \return the DPI aware height of a single bar/region in global areas.
+ */
+int ED_region_global_size_y(void)
+{
+ return ED_area_headersize(); /* same size as header */
+}
+
void ED_region_info_draw_multiline(ARegion *ar, const char *text_array[], float fill_color[4], const bool full_redraw)
{
const int header_height = UI_UNIT_Y;
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index e961a7f5d64..82093b4326a 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -76,17 +76,21 @@
/* ******************* screen vert, edge, area managing *********************** */
-static ScrVert *screen_addvert(bScreen *sc, short x, short y)
+static ScrVert *screen_addvert_ex(ScrAreaMap *area_map, short x, short y)
{
ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert");
sv->vec.x = x;
sv->vec.y = y;
- BLI_addtail(&sc->vertbase, sv);
+ BLI_addtail(&area_map->vertbase, sv);
return sv;
}
+static ScrVert *screen_addvert(bScreen *sc, short x, short y)
+{
+ return screen_addvert_ex(AREAMAP_FROM_SCREEN(sc), x, y);
+}
-static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
+static ScrEdge *screen_addedge_ex(ScrAreaMap *area_map, ScrVert *v1, ScrVert *v2)
{
ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge");
@@ -94,10 +98,13 @@ static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
se->v1 = v1;
se->v2 = v2;
- BLI_addtail(&sc->edgebase, se);
+ BLI_addtail(&area_map->edgebase, se);
return se;
}
-
+static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2)
+{
+ return screen_addedge_ex(AREAMAP_FROM_SCREEN(sc), v1, v2);
+}
bool scredge_is_horizontal(ScrEdge *se)
{
@@ -105,16 +112,16 @@ bool scredge_is_horizontal(ScrEdge *se)
}
/* need win size to make sure not to include edges along screen edge */
-ScrEdge *screen_find_active_scredge(const bScreen *sc,
- const int winsize_x, const int winsize_y,
- const int mx, const int my)
+ScrEdge *screen_area_map_find_active_scredge(
+ const ScrAreaMap *area_map,
+ const int winsize_x, const int winsize_y,
+ const int mx, const int my)
{
- ScrEdge *se;
int safety = U.widget_unit / 10;
-
- if (safety < 2) safety = 2;
-
- for (se = sc->edgebase.first; se; se = se->next) {
+
+ CLAMP_MIN(safety, 2);
+
+ for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
if (scredge_is_horizontal(se)) {
if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) {
short min, max;
@@ -136,27 +143,56 @@ ScrEdge *screen_find_active_scredge(const bScreen *sc,
}
}
}
-
+
return NULL;
}
+/* need win size to make sure not to include edges along screen edge */
+ScrEdge *screen_find_active_scredge(
+ const wmWindow *win, const bScreen *screen,
+ const int mx, const int my)
+{
+ /* Use layout size (screen excluding global areas) for screen-layout area edges */
+ const int screen_x = WM_window_screen_pixels_x(win), screen_y = WM_window_screen_pixels_y(win);
+ ScrEdge *se = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(screen), screen_x, screen_y, mx, my);
+
+ if (!se) {
+ /* Use entire window size (screen including global areas) for global area edges */
+ const int win_x = WM_window_pixels_x(win), win_y = WM_window_pixels_y(win);
+ se = screen_area_map_find_active_scredge(&win->global_areas, win_x, win_y, mx, my);
+ }
+ return se;
+}
+
/* adds no space data */
-static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype)
+static ScrArea *screen_addarea_ex(
+ ScrAreaMap *area_map,
+ ScrVert *bottom_left, ScrVert *top_left, ScrVert *top_right, ScrVert *bottom_right,
+ short headertype, short spacetype)
{
ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea");
- sa->v1 = v1;
- sa->v2 = v2;
- sa->v3 = v3;
- sa->v4 = v4;
+
+ sa->v1 = bottom_left;
+ sa->v2 = top_left;
+ sa->v3 = top_right;
+ sa->v4 = bottom_right;
sa->headertype = headertype;
sa->spacetype = sa->butspacetype = spacetype;
-
- BLI_addtail(&sc->areabase, sa);
-
+
+ BLI_addtail(&area_map->areabase, sa);
+
return sa;
}
+static ScrArea *screen_addarea(
+ bScreen *sc,
+ ScrVert *left_bottom, ScrVert *left_top, ScrVert *right_top, ScrVert *right_bottom,
+ short headertype, short spacetype)
+{
+ return screen_addarea_ex(AREAMAP_FROM_SCREEN(sc), left_bottom, left_top, right_top, right_bottom,
+ headertype, spacetype);
+}
static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
{
@@ -462,10 +498,10 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
return 1;
}
-void select_connected_scredge(bScreen *sc, ScrEdge *edge)
+void select_connected_scredge(const wmWindow *win, ScrEdge *edge)
{
+ bScreen *sc = WM_window_get_active_screen(win);
ScrEdge *se;
- ScrVert *sv;
int oneselected;
char dir;
@@ -475,12 +511,10 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v';
else dir = 'h';
- sv = sc->vertbase.first;
- while (sv) {
+ ED_screen_verts_iter(win, sc, sv) {
sv->flag = 0;
- sv = sv->next;
}
-
+
edge->v1->flag = 1;
edge->v2->flag = 1;
@@ -508,8 +542,13 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge)
}
}
-/* test if screen vertices should be scaled */
-static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
+/**
+ * Test if screen vertices should be scaled and do if needed.
+ */
+static void screen_vertices_scale(
+ const wmWindow *win, bScreen *sc,
+ int window_size_x, int window_size_y,
+ int screen_size_x, int screen_size_y)
{
/* clamp Y size of header sized areas when expanding windows
* avoids annoying empty space around file menu */
@@ -518,7 +557,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
const int headery_init = ED_area_headersize();
ScrVert *sv = NULL;
ScrArea *sa;
- int winsize_x_prev, winsize_y_prev;
+ int screen_size_x_prev, screen_size_y_prev;
float facx, facy, tempf, min[2], max[2];
/* calculate size */
@@ -536,8 +575,8 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
sv->vec.y -= min[1];
}
- winsize_x_prev = (max[0] - min[0]) + 1;
- winsize_y_prev = (max[1] - min[1]) + 1;
+ screen_size_x_prev = (max[0] - min[0]) + 1;
+ screen_size_y_prev = (max[1] - min[1]) + 1;
#ifdef USE_HEADER_SIZE_CLAMP
@@ -545,14 +584,14 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
#define TEMP_TOP 2
/* if the window's Y axis grows, clamp header sized areas */
- if (winsize_y_prev < winsize_y) { /* growing? */
+ if (screen_size_y_prev < screen_size_y) { /* growing? */
const int headery_margin_max = headery_init + 4;
for (sa = sc->areabase.first; sa; sa = sa->next) {
ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
sa->temp = 0;
if (ar && !(ar->flag & RGN_FLAG_HIDDEN)) {
- if (sa->v2->vec.y == winsize_y_prev - 1) {
+ if (sa->v2->vec.y == screen_size_y_prev) {
if ((sa->v2->vec.y - sa->v1->vec.y) < headery_margin_max) {
sa->temp = TEMP_TOP;
}
@@ -568,9 +607,9 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
#endif
- if (winsize_x_prev != winsize_x || winsize_y_prev != winsize_y) {
- facx = ((float)winsize_x - 1) / ((float)winsize_x_prev - 1);
- facy = ((float)winsize_y - 1) / ((float)winsize_y_prev - 1);
+ if (screen_size_x_prev != screen_size_x || screen_size_y_prev != screen_size_y) {
+ facx = ((float)screen_size_x - 1) / ((float)screen_size_x_prev - 1);
+ facy = ((float)screen_size_y) / ((float)screen_size_y_prev);
/* make sure it fits! */
for (sv = sc->vertbase.first; sv; sv = sv->next) {
@@ -581,20 +620,20 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
//sv->vec.x += AREAGRID - 1;
//sv->vec.x -= (sv->vec.x % AREAGRID);
- CLAMP(sv->vec.x, 0, winsize_x - 1);
+ CLAMP(sv->vec.x, 0, screen_size_x - 1);
tempf = ((float)sv->vec.y) * facy;
sv->vec.y = (short)(tempf + 0.5f);
//sv->vec.y += AREAGRID - 1;
//sv->vec.y -= (sv->vec.y % AREAGRID);
- CLAMP(sv->vec.y, 0, winsize_y - 1);
+ CLAMP(sv->vec.y, 0, screen_size_y);
}
}
#ifdef USE_HEADER_SIZE_CLAMP
- if (winsize_y_prev < winsize_y) { /* growing? */
+ if (screen_size_y_prev < screen_size_y) { /* growing? */
for (sa = sc->areabase.first; sa; sa = sa->next) {
ScrEdge *se = NULL;
@@ -610,7 +649,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
const int yval = sa->v2->vec.y - headery_init;
se = BKE_screen_find_edge(sc, sa->v4, sa->v1);
if (se != NULL) {
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
}
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v2 && sv != sa->v3) {
@@ -625,7 +664,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
const int yval = sa->v1->vec.y + headery_init;
se = BKE_screen_find_edge(sc, sa->v2, sa->v3);
if (se != NULL) {
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
}
for (sv = sc->vertbase.first; sv; sv = sv->next) {
if (sv != sa->v1 && sv != sa->v4) {
@@ -654,7 +693,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
/* adjust headery if verts are along the edge of window */
if (sa->v1->vec.y > 0)
headery += U.pixelsize;
- if (sa->v2->vec.y < winsize_y - 1)
+ if (sa->v2->vec.y < screen_size_y)
headery += U.pixelsize;
if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) {
@@ -663,7 +702,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
if (se && sa->v1 != sa->v2) {
int yval;
- select_connected_scredge(sc, se);
+ select_connected_scredge(win, se);
/* all selected vertices get the right offset */
yval = sa->v2->vec.y - headery + 1;
@@ -678,7 +717,17 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y)
}
}
}
-
+
+ /* Global areas have a fixed size that only changes with the DPI. Here we ensure that exactly this size is set.
+ * TODO Assumes global area to be top-aligned. Should be made more generic */
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ /* width */
+ area->v1->vec.x = area->v2->vec.x = 0;
+ area->v3->vec.x = area->v4->vec.x = window_size_x - 1;
+ /* height */
+ area->v2->vec.y = area->v3->vec.y = window_size_y - 1;
+ area->v1->vec.y = area->v4->vec.y = area->v2->vec.y - ED_area_global_size_y(area);
+ }
}
@@ -689,7 +738,7 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
{
bScreen *screen = WM_window_get_active_screen(win);
- for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, screen, sa) {
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar == screen->active_region) {
if (swin_changed || (ar->type && ar->type->event_cursor)) {
@@ -751,20 +800,21 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
/* exception for bg mode, we only need the screen context */
if (!G.background) {
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
- ScrArea *sa;
-
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
+
/* header size depends on DPI, let's verify */
WM_window_set_dpi(win);
screen_refresh_headersizes();
-
- screen_test_scale(screen, winsize_x, winsize_y);
-
- for (sa = screen->areabase.first; sa; sa = sa->next) {
+
+ screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
+
+ ED_screen_areas_iter(win, screen, area) {
/* set spacetype and region callbacks, calls init() */
/* sets subwindows for regions, adds handlers */
- ED_area_initialize(wm, win, sa);
+ ED_area_initialize(wm, win, area);
}
/* wake up animtimer */
@@ -782,6 +832,36 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
screen->context = ed_screen_context;
}
+static bool screen_regions_need_size_refresh(
+ const wmWindow *win, const bScreen *screen)
+{
+ ED_screen_areas_iter(win, screen, area) {
+ if (area->flag & AREA_FLAG_REGION_SIZE_UPDATE) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static void screen_refresh_region_sizes_only(
+ wmWindowManager *wm, wmWindow *win,
+ bScreen *screen)
+{
+ const int window_size_x = WM_window_pixels_x(win);
+ const int window_size_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
+
+ screen_vertices_scale(win, screen, window_size_x, window_size_y, screen_size_x, screen_size_y);
+
+ ED_screen_areas_iter(win, screen, area) {
+ screen_area_update_region_sizes(wm, win, area);
+ /* XXX hack to force drawing */
+ ED_area_tag_redraw(area);
+ }
+}
+
/* file read, set all screens, ... */
void ED_screens_initialize(wmWindowManager *wm)
{
@@ -792,8 +872,21 @@ void ED_screens_initialize(wmWindowManager *wm)
WM_window_set_active_workspace(win, G.main->workspaces.first);
}
+ if (BLI_listbase_is_empty(&win->global_areas.areabase)) {
+ ED_screen_global_areas_create(win);
+ }
+ ED_screen_refresh(wm, win);
+ }
+}
+
+void ED_screen_ensure_updated(wmWindowManager *wm, wmWindow *win, bScreen *screen)
+{
+ if (screen->do_refresh) {
ED_screen_refresh(wm, win);
}
+ else if (screen_regions_need_size_refresh(win, screen)) {
+ screen_refresh_region_sizes_only(wm, win, screen);
+ }
}
@@ -872,6 +965,9 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
for (sa = screen->areabase.first; sa; sa = sa->next) {
ED_area_exit(C, sa);
}
+ for (sa = window->global_areas.areabase.first; sa; sa = sa->next) {
+ ED_area_exit(C, sa);
+ }
/* mark it available for use for other windows */
screen->winid = 0;
@@ -893,9 +989,6 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
static void screen_cursor_set(wmWindow *win, const wmEvent *event)
{
const bScreen *screen = WM_window_get_active_screen(win);
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
-
AZone *az = NULL;
ScrArea *sa;
@@ -914,8 +1007,8 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event)
}
}
else {
- ScrEdge *actedge = screen_find_active_scredge(screen, winsize_x, winsize_y, event->x, event->y);
-
+ ScrEdge *actedge = screen_find_active_scredge(win, screen, event->x, event->y);
+
if (actedge) {
if (scredge_is_horizontal(actedge))
WM_cursor_set(win, CURSOR_Y_MOVE);
@@ -936,15 +1029,19 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
bScreen *scr = WM_window_get_active_screen(win);
if (scr) {
- ScrArea *sa;
+ ScrArea *sa = NULL;
ARegion *ar;
ARegion *old_ar = scr->active_region;
- for (sa = scr->areabase.first; sa; sa = sa->next) {
- if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax)
- if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax)
- if (NULL == is_in_area_actionzone(sa, &event->x))
+ ED_screen_areas_iter(win, scr, area_iter) {
+ if (event->x > area_iter->totrct.xmin && event->x < area_iter->totrct.xmax) {
+ if (event->y > area_iter->totrct.ymin && event->y < area_iter->totrct.ymax) {
+ if (is_in_area_actionzone(area_iter, &event->x) == NULL) {
+ sa = area_iter;
break;
+ }
+ }
+ }
}
if (sa) {
/* make overlap active when mouse over */
@@ -961,17 +1058,21 @@ void ED_screen_set_active_region(bContext *C, const wmEvent *event)
/* check for redraw headers */
if (old_ar != scr->active_region) {
- for (sa = scr->areabase.first; sa; sa = sa->next) {
+ ED_screen_areas_iter(win, scr, area_iter) {
bool do_draw = false;
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar == old_ar || ar == scr->active_region)
+ for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
+ if (ar == old_ar || ar == scr->active_region) {
do_draw = true;
+ }
+ }
if (do_draw) {
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar->regiontype == RGN_TYPE_HEADER)
+ for (ar = area_iter->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_HEADER) {
ED_region_tag_redraw(ar);
+ }
+ }
}
}
}
@@ -1016,6 +1117,47 @@ int ED_screen_area_active(const bContext *C)
return 0;
}
+void ED_screen_global_topbar_area_create(wmWindow *win, const bScreen *screen)
+{
+ if (screen->temp == 0) {
+ SpaceType *st = BKE_spacetype_from_id(SPACE_TOPBAR);
+ SpaceLink *sl = st->new(NULL);
+ ScrArea *sa;
+ const short size_y = 2 * HEADERY;
+ const int minx = 0, maxx = WM_window_pixels_x(win) - 1;
+ const int maxy = WM_window_pixels_y(win) - 1, miny = maxy - size_y;
+
+ ScrVert *bottom_left = screen_addvert_ex(&win->global_areas, minx, miny);
+ ScrVert *top_left = screen_addvert_ex(&win->global_areas, minx, maxy);
+ ScrVert *top_right = screen_addvert_ex(&win->global_areas, maxx, maxy);
+ ScrVert *bottom_right = screen_addvert_ex(&win->global_areas, maxx, miny);
+ screen_addedge_ex(&win->global_areas, bottom_left, top_left);
+ screen_addedge_ex(&win->global_areas, top_left, top_right);
+ screen_addedge_ex(&win->global_areas, top_right, bottom_right);
+ screen_addedge_ex(&win->global_areas, bottom_right, bottom_left);
+
+ sa = screen_addarea_ex(&win->global_areas, bottom_left, top_left, top_right, bottom_right,
+ HEADERTOP, SPACE_TOPBAR);
+ sa->regionbase = sl->regionbase;
+
+ /* Data specific to global areas. */
+ sa->global = MEM_callocN(sizeof(*sa->global), __func__);
+ sa->global->cur_fixed_height = size_y;
+ sa->global->size_max = size_y;
+ sa->global->size_min = HEADERY;
+
+ BLI_addhead(&sa->spacedata, sl);
+ BLI_listbase_clear(&sl->regionbase);
+ }
+ /* Do not create more area types here! Function is called on file load (wm_window_ghostwindows_ensure). TODO */
+}
+
+void ED_screen_global_areas_create(wmWindow *win)
+{
+ const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
+ ED_screen_global_topbar_area_create(win, screen);
+}
+
/* -------------------------------------------------------------------- */
/* Screen changing */
@@ -1168,7 +1310,6 @@ void ED_screen_update_after_scene_change(const bScreen *screen, Scene *scene_new
ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
{
wmWindow *win = CTX_wm_window(C);
- bScreen *screen = CTX_wm_screen(C);
ScrArea *newsa = NULL;
if (!sa || sa->full == NULL) {
@@ -1176,18 +1317,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
}
if (!newsa) {
- if (sa->full && (screen->state == SCREENMAXIMIZED)) {
- /* if this has been called from the temporary info header generated in
- * temp fullscreen layouts, find the correct fullscreen area to change
- * to create a new space inside */
- for (newsa = screen->areabase.first; newsa; newsa = newsa->next) {
- if (!(sa->flag & AREA_TEMP_INFO))
- break;
- }
- }
- else {
- newsa = sa;
- }
+ newsa = sa;
}
BLI_assert(newsa);
@@ -1308,10 +1438,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
/* clear full screen state */
old->full = NULL;
- old->flag &= ~AREA_TEMP_INFO;
}
- sa->flag &= ~AREA_TEMP_INFO;
sa->full = NULL;
if (fullsa == NULL) {
@@ -1349,6 +1477,8 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
ScrArea *newa;
char newname[MAX_ID_NAME - 2];
+ BLI_assert(ELEM(state, SCREENMAXIMIZED, SCREENFULL));
+
oldscreen = WM_window_get_active_screen(win);
oldscreen->state = state;
@@ -1367,50 +1497,30 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
/* use random area when we have no active one, e.g. when the
* mouse is outside of the window and we open a file browser */
- if (!sa)
+ if (!sa) {
sa = oldscreen->areabase.first;
-
- if (state == SCREENMAXIMIZED) {
- /* returns the top small area */
- newa = area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1);
- ED_area_newspace(C, newa, SPACE_INFO, false);
-
- /* copy area */
- newa = newa->prev;
- ED_area_data_swap(newa, sa);
- sa->flag |= AREA_TEMP_INFO;
-
- sa->full = oldscreen;
- newa->full = oldscreen;
- newa->next->full = oldscreen; // XXX
}
- else if (state == SCREENFULL) {
- newa = (ScrArea *)sc->areabase.first;
- /* copy area */
- ED_area_data_swap(newa, sa);
- newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
+ newa = (ScrArea *)sc->areabase.first;
+
+ /* copy area */
+ ED_area_data_swap(newa, sa);
+ newa->flag = sa->flag; /* mostly for AREA_FLAG_WASFULLSCREEN */
+ if (state == SCREENFULL) {
/* temporarily hide the side panels/header */
for (ar = newa->regionbase.first; ar; ar = ar->next) {
ar->flagfullscreen = ar->flag;
- if (ELEM(ar->regiontype,
- RGN_TYPE_UI,
- RGN_TYPE_HEADER,
- RGN_TYPE_TOOLS))
- {
+ if (ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_HEADER, RGN_TYPE_TOOLS)){
ar->flag |= RGN_FLAG_HIDDEN;
}
}
-
- sa->full = oldscreen;
- newa->full = oldscreen;
- }
- else {
- BLI_assert(false);
}
+ sa->full = oldscreen;
+ newa->full = oldscreen;
+
ED_screen_change(C, sc);
}
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 606838ae890..045e5ee6b48 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -44,6 +44,7 @@ struct Main;
/* area.c */
void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free);
void ED_area_data_swap(ScrArea *sa1, ScrArea *sa2);
+void screen_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *area);
void region_toggle_hidden(struct bContext *C, ARegion *ar, const bool do_fade);
/* screen_edit.c */
@@ -55,12 +56,16 @@ bScreen *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, stru
ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
int screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2);
int area_getorientation(ScrArea *sa, ScrArea *sb);
-void select_connected_scredge(bScreen *sc, ScrEdge *edge);
+void select_connected_scredge(const wmWindow *win, ScrEdge *edge);
bool scredge_is_horizontal(ScrEdge *se);
-ScrEdge *screen_find_active_scredge(const bScreen *sc,
- const int winsize_x, const int winsize_y,
- const int mx, const int my);
+ScrEdge *screen_area_map_find_active_scredge(
+ const struct ScrAreaMap *area_map,
+ const int winsize_x, const int winsize_y,
+ const int mx, const int my);
+ScrEdge *screen_find_active_scredge(
+ const wmWindow *win, const bScreen *screen,
+ const int mx, const int my);
struct AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 25d5fbbdc4c..8b889c61deb 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -791,8 +791,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sActionzoneData *sad = op->customdata;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
switch (event->type) {
case MOUSEMOVE:
@@ -816,7 +816,8 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* once we drag outside the actionzone, register a gesture
* check we're not on an edge so join finds the other area */
is_gesture = ((is_in_area_actionzone(sad->sa1, &event->x) != sad->az) &&
- (screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y) == NULL));
+ (screen_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y) == NULL));
}
else {
const int delta_min = 1;
@@ -1049,6 +1050,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
layout_new = ED_workspace_layout_add(workspace, newwin, BKE_workspace_layout_name_get(layout_old));
newsc = BKE_workspace_layout_screen_get(layout_new);
WM_window_set_active_layout(newwin, workspace, layout_new);
+ ED_screen_global_areas_create(newwin);
/* copy area to new screen */
ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);
@@ -1116,25 +1118,73 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot)
*/
typedef struct sAreaMoveData {
- int bigger, smaller, origval;
+ int bigger, smaller, origval, step;
char dir;
- bool do_snap;
+ enum AreaMoveSnapType {
+ /* Snapping disabled */
+ SNAP_NONE = 0,
+ /* Snap to mid-point and adjacent edges. */
+ SNAP_MIDPOINT_AND_ADJACENT,
+ /* Snap to either bigger or smaller, nothing in-between (used for
+ * global areas). This has priority over other snap types, if it is
+ * used, toggling SNAP_MIDPOINT_AND_ADJACENT doesn't work. */
+ SNAP_BIGGER_SMALLER_ONLY,
+ } snap_type;
} sAreaMoveData;
/* helper call to move area-edge, sets limits
* need window size in order to get correct limits */
-static void area_move_set_limits(bScreen *sc, int dir,
- const int winsize_x, const int winsize_y,
- int *bigger, int *smaller)
+static void area_move_set_limits(
+ wmWindow *win, bScreen *sc, int dir,
+ const int winsize_x, const int winsize_y,
+ int *bigger, int *smaller,
+ bool *use_bigger_smaller_snap)
{
- ScrArea *sa;
int areaminy = ED_area_headersize();
int areamin;
-
+
/* we check all areas and test for free space with MINSIZE */
*bigger = *smaller = 100000;
-
- for (sa = sc->areabase.first; sa; sa = sa->next) {
+
+ if (use_bigger_smaller_snap != NULL) {
+ *use_bigger_smaller_snap = false;
+ for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ const int size_min = round_fl_to_int(area->global->size_min * UI_DPI_FAC);
+ const int size_max = round_fl_to_int(area->global->size_max * UI_DPI_FAC);
+
+ /* logic here is only tested for lower edge :) */
+ /* left edge */
+ if ((area->v1->editflag && area->v2->editflag)) {
+ *smaller = area->v4->vec.x - size_max;
+ *bigger = area->v4->vec.x - size_min;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* top edge */
+ else if ((area->v2->editflag && area->v3->editflag)) {
+ *smaller = area->v1->vec.y + size_min;
+ *bigger = area->v1->vec.y + size_max;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* right edge */
+ else if ((area->v3->editflag && area->v4->editflag)) {
+ *smaller = area->v1->vec.x + size_min;
+ *bigger = area->v1->vec.x + size_max;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ /* lower edge */
+ else if ((area->v4->editflag && area->v1->editflag)) {
+ *smaller = area->v2->vec.y - size_max;
+ *bigger = area->v2->vec.y - size_min;
+ *use_bigger_smaller_snap = true;
+ return;
+ }
+ }
+ }
+
+ for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
if (dir == 'h') {
int y1;
areamin = areaminy;
@@ -1180,9 +1230,8 @@ static int area_move_init(bContext *C, wmOperator *op)
wmWindow *win = CTX_wm_window(C);
ScrEdge *actedge;
sAreaMoveData *md;
- ScrVert *v1;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
int x, y;
/* required properties */
@@ -1190,7 +1239,7 @@ static int area_move_init(bContext *C, wmOperator *op)
y = RNA_int_get(op->ptr, "y");
/* setup */
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
+ actedge = screen_find_active_scredge(win, sc, x, y);
if (actedge == NULL) return 0;
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
@@ -1200,23 +1249,33 @@ static int area_move_init(bContext *C, wmOperator *op)
if (md->dir == 'h') md->origval = actedge->v1->vec.y;
else md->origval = actedge->v1->vec.x;
- select_connected_scredge(sc, actedge);
- /* now all vertices with 'flag==1' are the ones that can be moved. Move this to editflag */
- for (v1 = sc->vertbase.first; v1; v1 = v1->next)
+ select_connected_scredge(win, actedge);
+ /* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
+ ED_screen_verts_iter(win, sc, v1) {
v1->editflag = v1->flag;
-
- area_move_set_limits(sc, md->dir, winsize_x, winsize_y, &md->bigger, &md->smaller);
-
+ }
+
+ bool use_bigger_smaller_snap = false;
+ area_move_set_limits(win, sc, md->dir, screen_size_x, screen_size_y,
+ &md->bigger, &md->smaller,
+ &use_bigger_smaller_snap);
+
+ md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_NONE;
+
return 1;
}
static int area_snap_calc_location(
- const bScreen *sc, const int delta,
- const int origval, const int dir,
+ const bScreen *sc, const enum AreaMoveSnapType snap_type,
+ const int delta, const int origval, const int dir,
const int bigger, const int smaller)
{
- int final_loc = -1;
+ BLI_assert(snap_type != SNAP_NONE);
+ if (snap_type == SNAP_BIGGER_SMALLER_ONLY) {
+ return ((origval + delta) >= bigger) ? bigger : smaller;
+ }
+ int final_loc = -1;
const int m_loc = origval + delta;
const int axis = (dir == 'v') ? 0 : 1;
int snap_dist;
@@ -1260,29 +1319,29 @@ static void area_move_apply_do(
const bContext *C, int delta,
const int origval, const int dir,
const int bigger, const int smaller,
- const bool do_snap)
+ const enum AreaMoveSnapType snap_type)
{
+ wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
- ScrVert *v1;
bool doredraw = false;
CLAMP(delta, -smaller, bigger);
short final_loc = -1;
- if (do_snap) {
- final_loc = area_snap_calc_location(sc, delta, origval, dir, bigger, smaller);
- }
- else {
+ if (snap_type == SNAP_NONE) {
final_loc = origval + delta;
if (delta != bigger && delta != -smaller) {
final_loc -= (final_loc % AREAGRID);
}
}
+ else {
+ final_loc = area_snap_calc_location(sc, snap_type, delta, origval, dir, bigger, smaller);
+ }
BLI_assert(final_loc != -1);
short axis = (dir == 'v') ? 0 : 1;
- for (v1 = sc->vertbase.first; v1; v1 = v1->next) {
+ ED_screen_verts_iter(win, sc, v1) {
if (v1->editflag) {
short oldval = (&v1->vec.x)[axis];
(&v1->vec.x)[axis] = final_loc;
@@ -1297,11 +1356,23 @@ static void area_move_apply_do(
/* only redraw if we actually moved a screen vert, for AREAGRID */
if (doredraw) {
- for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) {
+ bool redraw_all = false;
+ ED_screen_areas_iter(win, sc, sa) {
if (sa->v1->editflag || sa->v2->editflag || sa->v3->editflag || sa->v4->editflag) {
+ if (ED_area_is_global(sa)) {
+ sa->global->cur_fixed_height = round_fl_to_int((sa->v2->vec.y - sa->v1->vec.y) / UI_DPI_FAC);
+ sc->do_refresh = true;
+ redraw_all = true;
+ }
ED_area_tag_redraw(sa);
}
}
+ if (redraw_all) {
+ ED_screen_areas_iter(win, sc, sa) {
+ ED_area_tag_redraw(sa);
+ }
+ }
+
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
/* Update preview thumbnail */
BKE_icon_changed(sc->id.icon_id);
@@ -1313,7 +1384,7 @@ static void area_move_apply(bContext *C, wmOperator *op)
sAreaMoveData *md = op->customdata;
int delta = RNA_int_get(op->ptr, "delta");
- area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->do_snap);
+ area_move_apply_do(C, delta, md->origval, md->dir, md->bigger, md->smaller, md->snap_type);
}
static void area_move_exit(bContext *C, wmOperator *op)
@@ -1392,10 +1463,14 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
case KM_MODAL_SNAP_ON:
- md->do_snap = true;
+ if (md->snap_type == SNAP_NONE) {
+ md->snap_type = SNAP_MIDPOINT_AND_ADJACENT;
+ }
break;
case KM_MODAL_SNAP_OFF:
- md->do_snap = false;
+ if (md->snap_type == SNAP_MIDPOINT_AND_ADJACENT) {
+ md->snap_type = SNAP_NONE;
+ }
break;
}
break;
@@ -1644,8 +1719,8 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
wmWindow *win = CTX_wm_window(C);
bScreen *sc = CTX_wm_screen(C);
sAreaSplitData *sd;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
int dir;
/* no full window splitting allowed */
@@ -1698,7 +1773,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
else
y = event->x;
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y);
+ actedge = screen_area_map_find_active_scredge(AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, x, y);
if (actedge == NULL)
return OPERATOR_CANCELLED;
@@ -1718,7 +1793,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* do the split */
if (area_split_apply(C, op)) {
- area_move_set_limits(sc, dir, winsize_x, winsize_y, &sd->bigger, &sd->smaller);
+ area_move_set_limits(win, sc, dir, screen_size_x, screen_size_y, &sd->bigger, &sd->smaller, NULL);
/* add temp handler for edge move or cancel */
WM_event_add_modal_handler(C, op);
@@ -1836,10 +1911,11 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (sd->previewmode == 0) {
if (sd->do_snap) {
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->bigger, sd->smaller);
+ CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ sd->bigger, sd->smaller);
sd->delta = snap_loc - sd->origval;
}
- area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, false);
+ area_move_apply_do(C, sd->delta, sd->origval, dir, sd->bigger, sd->smaller, SNAP_NONE);
}
else {
if (sd->sarea) {
@@ -1863,7 +1939,8 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event)
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 1;
const int snap_loc = area_snap_calc_location(
- CTX_wm_screen(C), sd->delta, sd->origval, dir, sd->origmin + sd->origsize, -sd->origmin);
+ CTX_wm_screen(C), SNAP_MIDPOINT_AND_ADJACENT, sd->delta, sd->origval, dir,
+ sd->origmin + sd->origsize, -sd->origmin);
sa->v1->editflag = sa->v2->editflag = sa->v3->editflag = sa->v4->editflag = 0;
sd->delta = snap_loc - sd->origval;
@@ -2579,6 +2656,14 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int screen_maximize_area_poll(bContext *C)
+{
+ const bScreen *screen = CTX_wm_screen(C);
+ const ScrArea *area = CTX_wm_area(C);
+ return ED_operator_areaactive(C) &&
+ ((screen->state != SCREENNORMAL) || (area->spacetype != SPACE_TOPBAR));
+}
+
static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -2588,7 +2673,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot)
ot->idname = "SCREEN_OT_screen_full_area";
ot->exec = screen_maximize_area_exec;
- ot->poll = ED_operator_areaactive;
+ ot->poll = screen_maximize_area_poll;
ot->flag = 0;
prop = RNA_def_boolean(ot->srna, "use_hide_panels", false, "Hide Panels", "Hide all the panels");
@@ -2898,10 +2983,11 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
uiLayout *layout;
PointerRNA ptr;
ScrEdge *actedge;
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
- actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y);
+ actedge = screen_area_map_find_active_scredge(
+ AREAMAP_FROM_SCREEN(sc), screen_size_x, screen_size_y, event->x, event->y);
if (actedge == NULL) return OPERATOR_CANCELLED;
@@ -3305,6 +3391,18 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
+static int region_flip_poll(bContext *C)
+{
+ ScrArea *area = CTX_wm_area(C);
+
+ /* don't flip anything around in topbar */
+ if (area->spacetype == SPACE_TOPBAR) {
+ CTX_wm_operator_poll_msg_set(C, "Flipping regions in the Top-bar is not allowed");
+ return 0;
+ }
+
+ return ED_operator_areaactive(C);
+}
static void SCREEN_OT_region_flip(wmOperatorType *ot)
{
@@ -3315,7 +3413,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot)
/* api callbacks */
ot->exec = region_flip_exec;
- ot->poll = ED_operator_areaactive;
+ ot->poll = region_flip_poll;
ot->flag = 0;
}
@@ -3408,12 +3506,11 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN
uiItemS(layout);
- /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */
- if (sa->spacetype != SPACE_FILE) {
- if (sa->full)
- uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
- else
- uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area");
+ /* file browser should be fullscreen all the time, topbar should
+ * never be. But other regions can be maximized/restored... */
+ if (!ELEM(sa->spacetype, SPACE_FILE, SPACE_TOPBAR)) {
+ const char *but_str = sa->full ? IFACE_("Tile Area") : IFACE_("Maximize Area");
+ uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area");
}
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 69891a727d4..2c1cbc3d21d 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -275,7 +275,7 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, screenshot_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
static int screenshot_poll(bContext *C)
diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c
index b40eef8a38f..c8aa4560dc4 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -313,11 +313,9 @@ static void WORKSPACE_OT_workspace_duplicate(wmOperatorType *ot)
static int workspace_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain = CTX_data_main(C);
- wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
- ED_workspace_delete(WM_window_get_active_workspace(win), bmain, C, wm);
+ WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_DELETE, WM_window_get_active_workspace(win));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index d84df160125..a6f991d4bbe 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -50,10 +50,10 @@ WorkSpaceLayout *ED_workspace_layout_add(
wmWindow *win,
const char *name)
{
- const int winsize_x = WM_window_pixels_x(win);
- const int winsize_y = WM_window_pixels_y(win);
+ const int screen_size_x = WM_window_screen_pixels_x(win);
+ const int screen_size_y = WM_window_screen_pixels_y(win);
- bScreen *screen = screen_add(name, winsize_x, winsize_y);
+ bScreen *screen = screen_add(name, screen_size_x, screen_size_y);
WorkSpaceLayout *layout = BKE_workspace_layout_add(workspace, screen, name);
return layout;
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index a01b4aa1b18..eaf101b1083 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -635,7 +635,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* main draw call */
- uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, sound_mixdown_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
}
#endif // WITH_AUDASPACE
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index fbdf543e5c4..ca9b87a5858 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -98,6 +98,7 @@ void ED_spacetypes_init(void)
ED_spacetype_console();
ED_spacetype_userpref();
ED_spacetype_clip();
+ ED_spacetype_topbar();
// ...
/* register operator types for screen and all spaces */
diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c
index d2a7244eded..3b1f423b5ef 100644
--- a/source/blender/editors/space_clip/clip_toolbar.c
+++ b/source/blender/editors/space_clip/clip_toolbar.c
@@ -32,6 +32,7 @@
#include <string.h>
#include "DNA_windowmanager_types.h"
+#include "DNA_workspace_types.h"
#include "MEM_guardedalloc.h"
@@ -118,19 +119,30 @@ void CLIP_OT_properties(wmOperatorType *ot)
static ARegion *clip_has_tools_region(ScrArea *sa)
{
- ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
+ ARegion *ar, *artool = NULL, *arhead;
+#ifndef WITH_REDO_REGION_REMOVAL
+ ARegion *arprops = NULL;
+#endif
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_TOOLS)
artool = ar;
+#ifndef WITH_REDO_REGION_REMOVAL
if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
arprops = ar;
+#endif
}
/* tool region hide/unhide also hides props */
- if (arprops && artool)
+ if (artool
+#ifndef WITH_REDO_REGION_REMOVAL
+ && arprops
+#endif
+ )
+ {
return artool;
+ }
if (artool == NULL) {
/* add subdiv level; after header */
@@ -149,6 +161,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa)
artool->flag = RGN_FLAG_HIDDEN;
}
+#ifndef WITH_REDO_REGION_REMOVAL
if (arprops == NULL) {
/* add extra subdivided region for tool properties */
arprops = MEM_callocN(sizeof(ARegion), "tool props for clip");
@@ -157,6 +170,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa)
arprops->regiontype = RGN_TYPE_TOOL_PROPS;
arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
}
+#endif
return artool;
}
@@ -189,11 +203,13 @@ void CLIP_OT_tools(wmOperatorType *ot)
ot->poll = tools_poll;
}
+#ifndef WITH_REDO_REGION_REMOVAL
+
/************************** redo panel ******************************/
static void clip_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op)
{
- uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, 'V', 0);
+ uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
}
static void clip_panel_operator_redo_header(const bContext *C, Panel *pa)
@@ -263,3 +279,4 @@ void ED_clip_tool_props_register(ARegionType *art)
pt->draw = clip_panel_operator_redo;
BLI_addtail(&art->paneltypes, pt);
}
+#endif
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 478254fb165..ba9684411b3 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -256,12 +256,14 @@ static SpaceLink *clip_new(const bContext *C)
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
- /* tool properties */
+#ifndef WITH_REDO_REGION_REMOVAL
+ /* tools view */
ar = MEM_callocN(sizeof(ARegion), "tool properties for clip");
BLI_addtail(&sc->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOL_PROPS;
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+#endif
/* properties view */
ar = MEM_callocN(sizeof(ARegion), "properties for clip");
@@ -889,20 +891,25 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
- ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
ARegion *ar_preview = ED_clip_has_preview_region(C, sa);
ARegion *ar_properties = ED_clip_has_properties_region(sa);
ARegion *ar_channels = ED_clip_has_channels_region(sa);
bool main_visible = false, preview_visible = false, tools_visible = false;
- bool tool_props_visible = false, properties_visible = false, channels_visible = false;
+ bool properties_visible = false, channels_visible = false;
bool view_changed = false;
+#ifndef WITH_REDO_REGION_REMOVAL
+ ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
+ bool tool_props_visible = false;
+#endif
switch (sc->view) {
case SC_VIEW_CLIP:
main_visible = true;
preview_visible = false;
tools_visible = true;
+#ifndef WITH_REDO_REGION_REMOVAL
tool_props_visible = true;
+#endif
properties_visible = true;
channels_visible = false;
break;
@@ -910,7 +917,9 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
main_visible = false;
preview_visible = true;
tools_visible = false;
+#ifndef WITH_REDO_REGION_REMOVAL
tool_props_visible = false;
+#endif
properties_visible = false;
channels_visible = false;
@@ -920,7 +929,9 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
main_visible = false;
preview_visible = true;
tools_visible = false;
+#ifndef WITH_REDO_REGION_REMOVAL
tool_props_visible = false;
+#endif
properties_visible = false;
channels_visible = true;
@@ -1001,6 +1012,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
}
}
+#ifndef WITH_REDO_REGION_REMOVAL
if (tool_props_visible) {
if (ar_tool_props && (ar_tool_props->flag & RGN_FLAG_HIDDEN)) {
ar_tool_props->flag &= ~RGN_FLAG_HIDDEN;
@@ -1024,6 +1036,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
view_changed = true;
}
}
+#endif
if (preview_visible) {
if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
@@ -1607,6 +1620,7 @@ void ED_spacetype_clip(void)
BLI_addhead(&st->regiontypes, art);
+#ifndef WITH_REDO_REGION_REMOVAL
/* tool properties */
art = MEM_callocN(sizeof(ARegionType), "spacetype clip tool properties region");
art->regionid = RGN_TYPE_TOOL_PROPS;
@@ -1619,6 +1633,7 @@ void ED_spacetype_clip(void)
ED_clip_tool_props_register(art);
BLI_addhead(&st->regiontypes, art);
+#endif
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype clip region");
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 1839e861518..363e9666399 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -88,7 +88,8 @@ static void file_panel_operator(const bContext *C, Panel *pa)
UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);
- uiTemplateOperatorPropertyButs(C, pa->layout, op, file_panel_check_prop, '\0', UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
+ uiTemplateOperatorPropertyButs(C, pa->layout, op, file_panel_check_prop, UI_BUT_LABEL_ALIGN_NONE,
+ UI_TEMPLATE_OP_PROPS_SHOW_EMPTY);
UI_block_func_set(uiLayoutGetBlock(pa->layout), NULL, NULL, NULL);
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index a905e61dd88..a2afb5cb5c5 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1431,7 +1431,7 @@ static void image_open_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
@@ -2147,7 +2147,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
/* multiview template */
if (is_multiview)
diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c
index 0b6bacfbe68..caa3ba593fb 100644
--- a/source/blender/editors/space_sequencer/sequencer_add.c
+++ b/source/blender/editors/space_sequencer/sequencer_add.c
@@ -690,7 +690,7 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op)
/* main draw call */
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
- uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, '\0');
+ uiDefAutoButsRNA(layout, &ptr, sequencer_add_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false);
/* image template */
RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr);
diff --git a/source/blender/editors/space_topbar/CMakeLists.txt b/source/blender/editors/space_topbar/CMakeLists.txt
new file mode 100644
index 00000000000..9559c28de0a
--- /dev/null
+++ b/source/blender/editors/space_topbar/CMakeLists.txt
@@ -0,0 +1,45 @@
+# ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../blenloader
+ ../../blentranslation
+ ../../gpu
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+ ../../../../intern/guardedalloc
+ ../../../../intern/glew-mx
+)
+
+set(INC_SYS
+ ${GLEW_INCLUDE_PATH}
+)
+
+set(SRC
+ space_topbar.c
+)
+
+add_definitions(${GL_DEFINITIONS})
+
+blender_add_lib(bf_editor_space_topbar "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
new file mode 100644
index 00000000000..35858a927fe
--- /dev/null
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -0,0 +1,265 @@
+/*
+ * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2017 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_topbar/space_topbar.c
+ * \ingroup sptopbar
+ */
+
+
+#include <string.h>
+#include <stdio.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+
+#include "BLO_readfile.h"
+#include "BLT_translation.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_screen.h"
+
+#include "ED_screen.h"
+#include "ED_space_api.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+
+/* ******************** default callbacks for topbar space ***************** */
+
+static SpaceLink *topbar_new(const bContext *UNUSED(C))
+{
+ ARegion *ar;
+ SpaceTopBar *stopbar;
+
+ stopbar = MEM_callocN(sizeof(*stopbar), "init topbar");
+ stopbar->spacetype = SPACE_TOPBAR;
+
+ /* header */
+ ar = MEM_callocN(sizeof(ARegion), "left aligned header for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_TOP;
+ ar = MEM_callocN(sizeof(ARegion), "right aligned header for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_HEADER;
+ ar->alignment = RGN_ALIGN_RIGHT | RGN_SPLIT_PREV;
+
+ /* main regions */
+ ar = MEM_callocN(sizeof(ARegion), "left aligned main region for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
+ ar->alignment = RGN_ALIGN_LEFT;
+ ar = MEM_callocN(sizeof(ARegion), "right aligned main region for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
+ ar->alignment = RGN_ALIGN_RIGHT;
+ ar = MEM_callocN(sizeof(ARegion), "center main region for topbar");
+ BLI_addtail(&stopbar->regionbase, ar);
+ ar->regiontype = RGN_TYPE_WINDOW;
+
+ return (SpaceLink *)stopbar;
+}
+
+/* not spacelink itself */
+static void topbar_free(SpaceLink *UNUSED(sl))
+{
+
+}
+
+
+/* spacetype; init callback */
+static void topbar_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
+{
+
+}
+
+static SpaceLink *topbar_duplicate(SpaceLink *sl)
+{
+ SpaceTopBar *stopbarn = MEM_dupallocN(sl);
+
+ /* clear or remove stuff from old */
+
+ return (SpaceLink *)stopbarn;
+}
+
+
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void topbar_main_region_init(wmWindowManager *wm, ARegion *region)
+{
+ wmKeyMap *keymap;
+
+ /* force delayed UI_view2d_region_reinit call */
+ if (ELEM(region->alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) {
+ region->flag |= RGN_FLAG_DYNAMIC_SIZE;
+ }
+ UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_HEADER, region->winx, region->winy);
+
+ keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0);
+ WM_event_add_keymap_handler(&region->handlers, keymap);
+}
+
+static void topbar_main_region_draw(const bContext *C, ARegion *region)
+{
+ ED_region_header(C, region);
+}
+
+static void topbar_operatortypes(void)
+{
+
+}
+
+static void topbar_keymap(struct wmKeyConfig *UNUSED(keyconf))
+{
+
+}
+
+/* add handlers, stuff you only do once or on area/region changes */
+static void topbar_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
+{
+ if ((ar->alignment & ~RGN_SPLIT_PREV) == RGN_ALIGN_RIGHT) {
+ ar->flag |= RGN_FLAG_DYNAMIC_SIZE;
+ }
+ ED_region_header_init(ar);
+}
+
+static void topbar_header_region_draw(const bContext *C, ARegion *ar)
+{
+ ED_region_header(C, ar);
+}
+
+static void topbar_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
+ wmNotifier *wmn, const Scene *UNUSED(scene))
+{
+ /* context changes */
+ switch (wmn->category) {
+ case NC_WM:
+ if (wmn->data == ND_HISTORY)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SCENE:
+ if (wmn->data == ND_MODE)
+ ED_region_tag_redraw(ar);
+ break;
+ case NC_SPACE:
+ if (wmn->data == ND_SPACE_VIEW3D)
+ ED_region_tag_redraw(ar);
+ break;
+ }
+}
+
+static void topbar_header_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar),
+ wmNotifier *UNUSED(wmn), const Scene *UNUSED(scene))
+{
+ /* context changes */
+#if 0
+ switch (wmn->category) {
+ default:
+ break;
+ }
+#endif
+}
+
+static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
+{
+ struct RecentFile *recent;
+ uiLayout *layout = menu->layout;
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
+ if (!BLI_listbase_is_empty(&G.recent_files)) {
+ for (recent = G.recent_files.first; (recent); recent = recent->next) {
+ const char *file = BLI_path_basename(recent->filepath);
+ const int icon = BLO_has_bfile_extension(file) ? ICON_FILE_BLEND : ICON_FILE_BACKUP;
+ uiItemStringO(layout, file, icon, "WM_OT_open_mainfile", "filepath", recent->filepath);
+ }
+ }
+ else {
+ uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE);
+ }
+}
+
+static void recent_files_menu_register(void)
+{
+ MenuType *mt;
+
+ mt = MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
+ strcpy(mt->idname, "TOPBAR_MT_file_open_recent");
+ strcpy(mt->label, N_("Open Recent..."));
+ strcpy(mt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
+ mt->draw = recent_files_menu_draw;
+ WM_menutype_add(mt);
+}
+
+
+/* only called once, from space/spacetypes.c */
+void ED_spacetype_topbar(void)
+{
+ SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype topbar");
+ ARegionType *art;
+
+ st->spaceid = SPACE_TOPBAR;
+ strncpy(st->name, "Top Bar", BKE_ST_MAXNAME);
+
+ st->new = topbar_new;
+ st->free = topbar_free;
+ st->init = topbar_init;
+ st->duplicate = topbar_duplicate;
+ st->operatortypes = topbar_operatortypes;
+ st->keymap = topbar_keymap;
+
+ /* regions: main window */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype topbar main region");
+ art->regionid = RGN_TYPE_WINDOW;
+ art->init = topbar_main_region_init;
+ art->draw = topbar_main_region_draw;
+ art->listener = topbar_main_region_listener;
+ art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: header */
+ art = MEM_callocN(sizeof(ARegionType), "spacetype topbar header region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->prefsizey = HEADERY;
+ art->prefsizex = UI_UNIT_X * 5; /* Mainly to avoid glitches */
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+ art->listener = topbar_header_listener;
+ art->init = topbar_header_region_init;
+ art->draw = topbar_header_region_draw;
+
+ BLI_addhead(&st->regiontypes, art);
+
+ recent_files_menu_register();
+
+ BKE_spacetype_register(st);
+}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index a87154ea049..8ee3f185c49 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -113,18 +113,30 @@ ARegion *view3d_has_buttons_region(ScrArea *sa)
ARegion *view3d_has_tools_region(ScrArea *sa)
{
- ARegion *ar, *artool = NULL, *arprops = NULL, *arhead;
-
+ ARegion *ar, *artool = NULL, *arhead;
+#ifndef WITH_REDO_REGION_REMOVAL
+ ARegion *arprops = NULL;
+#endif
+
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_TOOLS)
artool = ar;
+#ifndef WITH_REDO_REGION_REMOVAL
if (ar->regiontype == RGN_TYPE_TOOL_PROPS)
arprops = ar;
+#endif
}
-
+
/* tool region hide/unhide also hides props */
- if (arprops && artool) return artool;
-
+ if (artool
+#ifndef WITH_REDO_REGION_REMOVAL
+ && arprops
+#endif
+ )
+ {
+ return artool;
+ }
+
if (artool == NULL) {
/* add subdiv level; after header */
for (arhead = sa->regionbase.first; arhead; arhead = arhead->next)
@@ -142,15 +154,17 @@ ARegion *view3d_has_tools_region(ScrArea *sa)
artool->flag = RGN_FLAG_HIDDEN;
}
+#ifndef WITH_REDO_REGION_REMOVAL
if (arprops == NULL) {
/* add extra subdivided region for tool properties */
arprops = MEM_callocN(sizeof(ARegion), "tool props for view3d");
-
+
BLI_insertlinkafter(&sa->regionbase, artool, arprops);
arprops->regiontype = RGN_TYPE_TOOL_PROPS;
arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
}
-
+#endif
+
return artool;
}
@@ -369,15 +383,17 @@ static SpaceLink *view3d_new(const bContext *C)
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
ar->flag = RGN_FLAG_HIDDEN;
-
+
+#ifndef WITH_REDO_REGION_REMOVAL
/* tool properties */
ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d");
-
+
BLI_addtail(&v3d->regionbase, ar);
ar->regiontype = RGN_TYPE_TOOL_PROPS;
ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
ar->flag = RGN_FLAG_HIDDEN;
-
+#endif
+
/* buttons/list view */
ar = MEM_callocN(sizeof(ARegion), "buttons for view3d");
@@ -1312,6 +1328,7 @@ static void view3d_tools_region_draw(const bContext *C, ARegion *ar)
ED_region_panels(C, ar, CTX_data_mode_string(C), -1, true);
}
+#ifndef WITH_REDO_REGION_REMOVAL
static void view3d_props_region_listener(
bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar,
wmNotifier *wmn, const Scene *UNUSED(scene))
@@ -1332,6 +1349,7 @@ static void view3d_props_region_listener(
break;
}
}
+#endif
/* area (not region) level listener */
static void space_view3d_listener(
@@ -1523,6 +1541,7 @@ void ED_spacetype_view3d(void)
view3d_toolshelf_register(art);
#endif
+#ifndef WITH_REDO_REGION_REMOVAL
/* regions: tool properties */
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tool properties region");
art->regionid = RGN_TYPE_TOOL_PROPS;
@@ -1533,10 +1552,10 @@ void ED_spacetype_view3d(void)
art->init = view3d_tools_region_init;
art->draw = view3d_tools_region_draw;
BLI_addhead(&st->regiontypes, art);
-
+
view3d_tool_props_register(art);
-
-
+#endif
+
/* regions: header */
art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region");
art->regionid = RGN_TYPE_HEADER;
diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c
index dfa64bd2015..8c77cf36c91 100644
--- a/source/blender/editors/space_view3d/view3d_toolbar.c
+++ b/source/blender/editors/space_view3d/view3d_toolbar.c
@@ -63,11 +63,12 @@
#include "view3d_intern.h" /* own include */
+#ifndef WITH_REDO_REGION_REMOVAL
/* ******************* view3d space & buttons ************** */
static void view3d_panel_operator_redo_buts(const bContext *C, Panel *pa, wmOperator *op)
{
- uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, 'V', 0);
+ uiTemplateOperatorPropertyButs(C, pa->layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
}
static void view3d_panel_operator_redo_header(const bContext *C, Panel *pa)
@@ -126,6 +127,8 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa)
CTX_wm_region_set((bContext *)C, ar);
}
+#endif
+
/* ******************* */
typedef struct CustomTool {
@@ -239,10 +242,11 @@ void view3d_toolshelf_register(ARegionType *art)
BLI_addtail(&art->paneltypes, pt);
}
+#ifndef WITH_REDO_REGION_REMOVAL
void view3d_tool_props_register(ARegionType *art)
{
PanelType *pt;
-
+
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator");
strcpy(pt->idname, "VIEW3D_PT_last_operator");
strcpy(pt->label, N_("Operator"));
@@ -251,6 +255,7 @@ void view3d_tool_props_register(ARegionType *art)
pt->draw = view3d_panel_operator_redo;
BLI_addtail(&art->paneltypes, pt);
}
+#endif
/* ********** operator to open/close toolshelf region */
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 18366f87b59..03dd1ad26e7 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -304,12 +304,44 @@ void ED_OT_undo_redo(wmOperatorType *ot)
/** \} */
+#ifdef WITH_REDO_REGION_REMOVAL
+struct OperatorRepeatContextHandle {
+ ScrArea *restore_area;
+ ARegion *restore_region;
+};
+
+/**
+ * Resets the context to the state \a op was executed in (or at least, was in when registering).
+ * #ED_operator_repeat_reset_context should be called when done repeating!
+ */
+const OperatorRepeatContextHandle *ED_operator_repeat_prepare_context(bContext *C, wmOperator *op)
+{
+ static OperatorRepeatContextHandle context_info;
+
+ context_info.restore_area = CTX_wm_area(C);
+ context_info.restore_region = CTX_wm_region(C);
+
+ CTX_wm_area_set(C, op->execution_area);
+ CTX_wm_region_set(C, op->execution_region);
+
+ return &context_info;
+}
+/**
+ * Resets context to the old state from before #ED_operator_repeat_prepare_context was called.
+ */
+void ED_operator_repeat_reset_context(bContext *C, const OperatorRepeatContextHandle *context_info)
+{
+ CTX_wm_area_set(C, context_info->restore_area);
+ CTX_wm_region_set(C, context_info->restore_region);
+}
+#endif
+
/* -------------------------------------------------------------------- */
/** \name Operator Repeat
* \{ */
/* ui callbacks should call this rather than calling WM_operator_repeat() themselves */
-int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
+int ED_undo_operator_repeat(bContext *C, wmOperator *op)
{
int ret = 0;
@@ -318,12 +350,17 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
wmWindowManager *wm = CTX_wm_manager(C);
struct Scene *scene = CTX_data_scene(C);
+#ifdef WITH_REDO_REGION_REMOVAL
+ const OperatorRepeatContextHandle *context_info;
+ context_info = ED_operator_repeat_prepare_context(C, op);
+#else
/* keep in sync with logic in view3d_panel_operator_redo() */
ARegion *ar = CTX_wm_region(C);
ARegion *ar1 = BKE_area_find_region_active_win(CTX_wm_area(C));
if (ar1)
CTX_wm_region_set(C, ar1);
+#endif
if ((WM_operator_repeat_check(C, op)) &&
(WM_operator_poll(C, op->type)) &&
@@ -369,8 +406,12 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op)
}
}
+#ifdef WITH_REDO_REGION_REMOVAL
+ ED_operator_repeat_reset_context(C, context_info);
+#else
/* set region back */
CTX_wm_region_set(C, ar);
+#endif
}
else {
CLOG_WARN(&LOG, "called with NULL 'op'");