UI: Optional Complex Layout for Workspace Status #120595

Merged
Harley Acheson merged 51 commits from Harley/blender:WorkspaceStatus into main 2024-05-06 23:52:47 +02:00
4 changed files with 22 additions and 18 deletions
Showing only changes of commit 98dda8cc74 - Show all commits

View File

@ -640,10 +640,6 @@ bScreen *BKE_workspace_layout_screen_get(const WorkSpaceLayout *layout)
void BKE_workspace_status_clear(WorkSpace *workspace)
{
/* Clear simple status text. */
// MEM_SAFE_FREE(workspace->status_text);
/* Clear complex status list. */
LISTBASE_FOREACH_MUTABLE (WorkSpaceStatusItem *, item, &workspace->status) {
delete item;
}

View File

@ -448,19 +448,26 @@ bool ED_workspace_layout_delete(WorkSpace *workspace, WorkSpaceLayout *layout_ol
ATTR_NONNULL();
bool ED_workspace_layout_cycle(WorkSpace *workspace, short direction, bContext *C) ATTR_NONNULL();
/* Simple text output to status bar. */
void ED_workspace_status_text(bContext *C, const char *str, const int icon = 0);
/* Clears status bar text and allow the following actions. */
void ED_workspace_status_begin(bContext *C);
/* Adds a new item to the status bar. */
void ED_workspace_status_item(bContext *C,
const std::string text = {},
Harley marked this conversation as resolved Outdated

Not sure what the purpose of is of giving the text a default value, I would rather expected ED_workspace_status_space to be used for that case.

Not sure what the purpose of is of giving the text a default value, I would rather expected `ED_workspace_status_space` to be used for that case.

Indeed, looking at this it showed times when ED_workspace_status_icons should have been used.

Indeed, looking at this it showed times when `ED_workspace_status_icons` should have been used.
const int icon = 0,
const float space_factor = 0.0f);
/* Adds a horizontal space to the status bar. */
Harley marked this conversation as resolved Outdated

I'm not sure about overloading a function like this where one is a float and the other a boolean, it seems error prone. I would rather expect this to be a single function with 5 parameters, or two functions with different names.

I'm not sure about overloading a function like this where one is a float and the other a boolean, it seems error prone. I would rather expect this to be a single function with 5 parameters, or two functions with different names.

Yes, I think the larger error here is that the base function that creates a new WorkSpaceStatusItem should probably be a local static function. The others are more like formatted output instead. This overload confuses these.

Yes, I think the larger error here is that the base function that creates a new WorkSpaceStatusItem should probably be a local static function. The others are more like formatted output instead. This overload confuses these.
void ED_workspace_status_space(bContext *C, float space_factor = 1.0f);
/* Adds one ormore icons to the status bar. */
void ED_workspace_status_icons(bContext *C, const int icon);
void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2);
void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2, bool is_range = false);
void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2, const int icon3);
void ED_workspace_status_icons(
bContext *C, const int icon1, const int icon2, const int icon3, const int icon4);
Harley marked this conversation as resolved Outdated

Can this just be a single function?

void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2 = 0);
Can this just be a single function? ``` void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2 = 0); ```
/* Ends complex layout and requests a redraw of the status bar. */
void ED_workspace_status_end(bContext *C);
void ED_workspace_do_listen(bContext *C, const wmNotifier *note);

View File

@ -612,9 +612,7 @@ static void ui_popup_menu_create_from_menutype(bContext *C,
if (bool(mt->flag & MenuTypeFlag::SearchOnKeyPress)) {
ED_workspace_status_begin(C);
ED_workspace_status_icons(C, ICON_EVENT_A);
ED_workspace_status_item(C, "-");
ED_workspace_status_icons(C, ICON_EVENT_Z);
ED_workspace_status_icons(C, ICON_EVENT_A, ICON_EVENT_Z, true);
ED_workspace_status_space(C, 0.7f);
ED_workspace_status_item(C, IFACE_("Search"));
ED_workspace_status_end(C);

View File

@ -834,6 +834,15 @@ void ED_area_status_text(ScrArea *area, const char *str)
}
}
void ED_workspace_status_text(bContext *C, const char *str, const int icon)
{
ED_workspace_status_begin(C);
if (str) {
ED_workspace_status_item(C, str, icon);
}
ED_workspace_status_end(C);
}
void ED_workspace_status_begin(bContext *C)
{
WorkSpace *workspace = CTX_wm_workspace(C);
@ -870,9 +879,12 @@ void ED_workspace_status_icons(bContext *C, const int icon)
ED_workspace_status_item(C, {}, icon);
}
void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2)
void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2, bool is_range)
{
ED_workspace_status_item(C, {}, icon1);
if (is_range) {
ED_workspace_status_item(C, "");
}
ED_workspace_status_item(C, {}, icon2);
}
@ -897,15 +909,6 @@ void ED_workspace_status_end(bContext *C)
ED_area_tag_redraw(WM_window_status_area_find(CTX_wm_window(C), CTX_wm_screen(C)));
}
void ED_workspace_status_text(bContext *C, const char *str, const int icon)
{
ED_workspace_status_begin(C);
if (str) {
ED_workspace_status_item(C, str, icon);
}
ED_workspace_status_end(C);
}
/* ************************************************************ */
static void area_azone_init(wmWindow *win, const bScreen *screen, ScrArea *area)