UI: Improved Window Titles #111495

Open
Harley Acheson wants to merge 7 commits from Harley/blender:WindowTitles into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
11 changed files with 145 additions and 99 deletions

View File

@ -343,15 +343,13 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, short
* Wrapper to open a temporary space either as full-screen space, or as separate window,
* as defined by \a display_type.
*
* \param title: Title to set for the window, if a window is spawned.
* \param rect_unscaled: Position & size of the window, if a window is spawned.
*/
ScrArea *ED_screen_temp_space_open(bContext *C,
const char *title,
const rcti *rect_unscaled,
eSpace_Type space_type,
int display_type,
bool dialog) ATTR_NONNULL(1, 2, 3);
bool dialog) ATTR_NONNULL(1, 2);
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *arg);
void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *arg);
void ED_screens_region_flip_menu_create(bContext *C, uiLayout *layout, void *arg);

View File

@ -164,7 +164,6 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Render"),
&window_rect,
SPACE_IMAGE,
true,

View File

@ -685,6 +685,8 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
if (screen->animtimer) {
WM_event_timer_sleep(wm, win, screen->animtimer, false);
}
WM_window_title(wm, win);
}
if (G.debug & G_DEBUG_EVENTS) {
@ -1634,19 +1636,14 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
return static_cast<ScrArea *>(screen->areabase.first);
}
ScrArea *ED_screen_temp_space_open(bContext *C,
const char *title,
const rcti *rect_unscaled,
eSpace_Type space_type,
int display_type,
bool dialog)
ScrArea *ED_screen_temp_space_open(
bContext *C, const rcti *rect_unscaled, eSpace_Type space_type, int display_type, bool dialog)
{
ScrArea *area = nullptr;
switch (display_type) {
case USER_TEMP_SPACE_DISPLAY_WINDOW:
if (WM_window_open(C,
title,
rect_unscaled,
int(space_type),
false,

View File

@ -1462,7 +1462,6 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* Create new window. No need to set space_type since it will be copied over. */
wmWindow *newwin = WM_window_open(C,
"Blender",
&window_rect,
SPACE_EMPTY,
false,
@ -1474,6 +1473,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
(void *)area);
if (newwin) {
WM_window_title(CTX_wm_manager(C), newwin);
/* screen, areas init */
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr);
}
@ -1934,6 +1934,7 @@ static void area_move_apply_do(const bContext *C,
ED_screen_global_areas_sync(win);
WM_window_title(CTX_wm_manager(C), CTX_wm_window(C));
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, nullptr); /* redraw everything */
/* Update preview thumbnail */
BKE_icon_changed(screen->id.icon_id);
@ -3535,6 +3536,11 @@ static bool area_join_apply(bContext *C, wmOperator *op)
CTX_wm_region_set(C, nullptr);
}
if (BLI_listbase_is_single(&CTX_wm_screen(C)->areabase)) {
/* Areas reduced to just one, so update the window title. */
WM_window_title(CTX_wm_manager(C), CTX_wm_window(C));
}
return true;
}
@ -5205,7 +5211,6 @@ static int userpref_show_exec(bContext *C, wmOperator *op)
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Preferences"),
&window_rect,
SPACE_USERPREF,
false,
@ -5284,7 +5289,6 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Drivers Editor"),
&window_rect,
SPACE_GRAPH,
false,
@ -5367,7 +5371,6 @@ static int info_log_show_exec(bContext *C, wmOperator *op)
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Info Log"),
&window_rect,
SPACE_INFO,
false,

View File

@ -34,6 +34,7 @@ DEF_ENUM(rna_enum_mesh_select_mode_items)
DEF_ENUM(rna_enum_mesh_select_mode_uv_items)
DEF_ENUM(rna_enum_mesh_delimit_mode_items)
DEF_ENUM(rna_enum_space_graph_mode_items)
DEF_ENUM(rna_enum_space_outliner_display_mode_items)
DEF_ENUM(rna_enum_space_file_browse_mode_items)
DEF_ENUM(rna_enum_space_sequencer_view_type_items)
DEF_ENUM(rna_enum_space_type_items)

View File

@ -262,6 +262,11 @@ static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr)
ScrArea *area = static_cast<ScrArea *>(ptr->data);
SpaceType *st = BKE_spacetype_from_id(area->butspacetype);
if (BLI_listbase_is_single(&CTX_wm_screen(C)->areabase)) {
/* Update the window title if we only have a single area. */
WM_window_title(CTX_wm_manager(C), CTX_wm_window(C));
}
rna_Area_type_update(C, ptr);
if ((area->type == st) && (st->space_subtype_item_extend != nullptr)) {

View File

@ -210,6 +210,45 @@ const EnumPropertyItem rna_enum_space_file_browse_mode_items[] = {
{0, nullptr, 0, nullptr, nullptr},
};
const EnumPropertyItem rna_enum_space_outliner_display_mode_items[] = {
{SO_SCENES,
"SCENES",
ICON_SCENE_DATA,
"Scenes",
"Display scenes and their view layers, collections and objects"},
{SO_VIEW_LAYER,
"VIEW_LAYER",
ICON_RENDER_RESULT,
"View Layer",
"Display collections and objects in the view layer"},
{SO_SEQUENCE,
"SEQUENCE",
ICON_SEQUENCE,
"Video Sequencer",
"Display data belonging to the Video Sequencer"},
{SO_LIBRARIES,
"LIBRARIES",
ICON_FILE_BLEND,
"Blender File",
"Display data of current file and linked libraries"},
{SO_DATA_API,
"DATA_API",
ICON_RNA,
"Data API",
"Display low level Blender data and its properties"},
{SO_OVERRIDES_LIBRARY,
"LIBRARY_OVERRIDES",
ICON_LIBRARY_DATA_OVERRIDE,
"Library Overrides",
"Display data-blocks with library overrides and list their overridden properties"},
{SO_ID_ORPHANS,
"ORPHAN_DATA",
ICON_ORPHAN_DATA,
"Orphan Data",
"Display data-blocks which are unused and/or will be lost when the file is reloaded"},
{0, nullptr, 0, nullptr, nullptr},
};
#define SACT_ITEM_DOPESHEET \
{ \
SACTCONT_DOPESHEET, "DOPESHEET", ICON_ACTION, "Dope Sheet", "Edit all keyframes in scene" \
@ -3365,6 +3404,16 @@ static void rna_FileAssetSelectParams_catalog_id_set(PointerRNA *ptr, const char
params->asset_catalog_visibility = FILE_SHOW_ASSETS_FROM_CATALOG;
}
static void rna_SpaceOutliner_display_mode_update(Main *bmain,
Scene * /*scene*/,
PointerRNA *ptr)
{
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
bScreen *screen = (bScreen *)ptr->owner_id;
wmWindow *win = ED_screen_window_find(screen, wm);
WM_window_title(wm, win);
}
#else
static const EnumPropertyItem dt_uv_items[] = {
@ -3700,45 +3749,6 @@ static void rna_def_space_outliner(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static const EnumPropertyItem display_mode_items[] = {
{SO_SCENES,
"SCENES",
ICON_SCENE_DATA,
"Scenes",
"Display scenes and their view layers, collections and objects"},
{SO_VIEW_LAYER,
"VIEW_LAYER",
ICON_RENDER_RESULT,
"View Layer",
"Display collections and objects in the view layer"},
{SO_SEQUENCE,
"SEQUENCE",
ICON_SEQUENCE,
"Video Sequencer",
"Display data belonging to the Video Sequencer"},
{SO_LIBRARIES,
"LIBRARIES",
ICON_FILE_BLEND,
"Blender File",
"Display data of current file and linked libraries"},
{SO_DATA_API,
"DATA_API",
ICON_RNA,
"Data API",
"Display low level Blender data and its properties"},
{SO_OVERRIDES_LIBRARY,
"LIBRARY_OVERRIDES",
ICON_LIBRARY_DATA_OVERRIDE,
"Library Overrides",
"Display data-blocks with library overrides and list their overridden properties"},
{SO_ID_ORPHANS,
"ORPHAN_DATA",
ICON_ORPHAN_DATA,
"Orphan Data",
"Display data-blocks which are unused and/or will be lost when the file is reloaded"},
{0, nullptr, 0, nullptr, nullptr},
};
static const EnumPropertyItem lib_override_view_mode[] = {
{SO_LIB_OVERRIDE_VIEW_PROPERTIES,
"PROPERTIES",
@ -3769,9 +3779,9 @@ static void rna_def_space_outliner(BlenderRNA *brna)
prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "outlinevis");
RNA_def_property_enum_items(prop, display_mode_items);
RNA_def_property_enum_items(prop, rna_enum_space_outliner_display_mode_items);
RNA_def_property_ui_text(prop, "Display Mode", "Type of information to display");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, nullptr);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, "rna_SpaceOutliner_display_mode_update");
prop = RNA_def_property(srna, "lib_override_view_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, lib_override_view_mode);

View File

@ -337,7 +337,6 @@ enum eWindowAlignment {
* \return the window or NULL in case of failure.
*/
wmWindow *WM_window_open(bContext *C,
const char *title,
const rcti *rect_unscaled,
int space_type,
bool toplevel,
@ -345,10 +344,12 @@ wmWindow *WM_window_open(bContext *C,
bool temp,
eWindowAlignment alignment,
void (*area_setup_fn)(bScreen *screen, ScrArea *area, void *user_data),
void *area_setup_user_data) ATTR_NONNULL(1, 2, 3);
void *area_setup_user_data) ATTR_NONNULL(1, 2);
void WM_window_set_dpi(const wmWindow *win);
void WM_window_title(wmWindowManager *wm, wmWindow *win);
bool WM_stereo3d_enabled(wmWindow *win, bool only_fullscreen_test);
/* wm_files.cc */

View File

@ -538,10 +538,10 @@ void wm_event_do_notifiers(bContext *C)
if (note->category == NC_WM) {
if (ELEM(note->data, ND_FILEREAD, ND_FILESAVE)) {
wm->file_saved = 1;
wm_window_title(wm, win);
WM_window_title(wm, win);
}
else if (note->data == ND_DATACHANGED) {
wm_window_title(wm, win);
WM_window_title(wm, win);
}
else if (note->data == ND_UNDO) {
ED_preview_restart_queue_work(C);
@ -2654,12 +2654,8 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C,
/*ymax*/ window_center[1] + int(U.file_space_data.temp_win_sizey * UI_SCALE_FAC),
};
if (ScrArea *area = ED_screen_temp_space_open(C,
IFACE_("Blender File View"),
&window_rect,
SPACE_FILE,
U.filebrowser_display_type,
true))
if (ScrArea *area = ED_screen_temp_space_open(
C, &window_rect, SPACE_FILE, U.filebrowser_display_type, true))
{
ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER);

View File

@ -43,6 +43,7 @@
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_enum_types.hh"
#include "RNA_prototypes.h"
#include "WM_api.hh"
#include "WM_types.hh"
@ -475,14 +476,27 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
}
}
void wm_window_title(wmWindowManager *wm, wmWindow *win)
void WM_window_title(wmWindowManager *wm, wmWindow *win)
{
if (WM_window_is_temp_screen(win)) {
/* Nothing to do for 'temp' windows,
* because #WM_window_open always sets window title. */
if (!win || !win->ghostwin) {
return;
}
else if (win->ghostwin) {
char str[sizeof(Main::filepath) + 24];
char str[sizeof(Main::filepath) + 24] = "Blender";
bScreen *screen = WM_window_get_active_screen(win);
ScrArea *area = (screen) ? static_cast<ScrArea *>(screen->areabase.first) : nullptr;
const bool is_single = screen && BLI_listbase_is_single(&screen->areabase);
bool is_main_window = false;
LISTBASE_FOREACH (ScrArea *, area_iter, &win->global_areas.areabase) {
if (area_iter->spacetype == SPACE_TOPBAR) {
is_main_window = true;
break;
}
}
if (is_main_window) {
const char *filepath = BKE_main_blendfile_path_from_global();
const char *filename = BLI_path_basename(filepath);
const bool has_filepath = filepath[0] != '\0';
@ -497,14 +511,42 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
has_directory ? filepath : "",
has_directory ? "]" : "",
BKE_blender_version_string_compact());
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), str);
/* Informs GHOST of unsaved changes, to set window modified visual indicator (macOS)
* and to give hint of unsaved changes for a user warning mechanism in case of OS application
* terminate request (e.g. OS Shortcut Alt+F4, Command+Q, (...), or session end). */
GHOST_SetWindowModifiedState(static_cast<GHOST_WindowHandle>(win->ghostwin),
bool(!wm->file_saved));
}
else if (is_single) {
PointerRNA ptr = RNA_pointer_create(&(screen->id), &RNA_Area, area);
PropertyRNA *prop_ui_type = RNA_struct_find_property(&ptr, "ui_type");
const int space_type_ui = RNA_property_enum_get(&ptr, prop_ui_type);
int space_type = space_type_ui >> 16;
const char *area_name = "";
bContext *C = CTX_create();
CTX_data_main_set(C, G_MAIN);
CTX_data_scene_set(C, WM_window_get_active_scene(win));
CTX_wm_manager_set(C, wm);
CTX_wm_window_set(C, win);
CTX_wm_screen_set(C, screen);
CTX_wm_area_set(C, area);
RNA_property_enum_name_gettexted(
C, &ptr, prop_ui_type, RNA_property_enum_get(&ptr, prop_ui_type), &area_name);
CTX_free(C);
STRNCPY(str, IFACE_(area_name));
if (space_type == SPACE_OUTLINER) {
SpaceOutliner *space_outliner = static_cast<SpaceOutliner *>(area->spacedata.first);
const char *subtitle = "";
RNA_enum_name(
rna_enum_space_outliner_display_mode_items, space_outliner->outlinevis, &subtitle);
BLI_snprintf(str, sizeof(str), "%s %s", str, IFACE_(subtitle));
}
}
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), str);
/* Informs GHOST of unsaved changes, to set window modified visual indicator (macOS)
* and to give hint of unsaved changes for a user warning mechanism in case of OS application
* terminate request (e.g. OS Shortcut Alt+F4, Command+Q, (...), or session end). */
GHOST_SetWindowModifiedState(static_cast<GHOST_WindowHandle>(win->ghostwin), (bool)!wm->file_saved);
}
void WM_window_set_dpi(const wmWindow *win)
@ -815,7 +857,7 @@ static void wm_window_ghostwindow_ensure(wmWindowManager *wm, wmWindow *win, boo
ListBase *lb = WM_dropboxmap_find("Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
WM_event_add_dropbox_handler(&win->handlers, lb);
}
wm_window_title(wm, win);
WM_window_title(wm, win);
/* Add top-bar. */
ED_screen_global_areas_refresh(win);
@ -883,7 +925,6 @@ static bool wm_window_update_size_position(wmWindow *win)
}
wmWindow *WM_window_open(bContext *C,
const char *title,
const rcti *rect_unscaled,
int space_type,
bool toplevel,
@ -1014,6 +1055,7 @@ wmWindow *WM_window_open(bContext *C,
ScrArea *area = static_cast<ScrArea *>(screen->areabase.first);
CTX_wm_area_set(C, area);
ED_area_newspace(C, area, space_type, false);
WM_window_title(wm, win);
}
ED_screen_change(C, screen);
@ -1030,7 +1072,6 @@ wmWindow *WM_window_open(bContext *C,
if (win->ghostwin) {
wm_window_raise(win);
GHOST_SetTitle(static_cast<GHOST_WindowHandle>(win->ghostwin), title);
return win;
}
@ -1055,7 +1096,7 @@ int wm_window_close_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
int wm_window_new_exec(bContext *C, wmOperator *op)
int wm_window_new_exec(bContext *C, wmOperator * /*op*/)
{
wmWindow *win_src = CTX_wm_window(C);
ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0);
@ -1066,22 +1107,18 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
/*ymax*/ int(win_src->sizey * 0.9f),
};
bool ok = (WM_window_open(C,
IFACE_("Blender"),
&window_rect,
area->spacetype,
false,
false,
false,
WIN_ALIGN_PARENT_CENTER,
nullptr,
nullptr) != nullptr);
wmWindow *win = WM_window_open(C,
&window_rect,
area->spacetype,
false,
false,
false,
WIN_ALIGN_PARENT_CENTER,
nullptr,
nullptr);
if (!ok) {
BKE_report(op->reports, RPT_ERROR, "Failed to create window");
return OPERATOR_CANCELLED;
}
return OPERATOR_FINISHED;
WM_window_title(CTX_wm_manager(C), win);
return (win != NULL) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
int wm_window_new_main_exec(bContext *C, wmOperator *op)

View File

@ -63,7 +63,6 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win);
*/
void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win);
void wm_window_title(wmWindowManager *wm, wmWindow *win);
/**
* Initialize #wmWindow without `ghostwin`, open these and clear.
*