From 747f24472d6e639ed7fde3b1bd04550ce859cae0 Mon Sep 17 00:00:00 2001 From: Remy Fayet Date: Tue, 14 Mar 2023 15:35:08 +0100 Subject: [PATCH 1/4] UI: Clicking the camera icon while rendering should open render window During rendering, clicking on the Camera icon of the jobs panel should focus or open a Render Window. Adds a `op_name` variable to store the operation. Fix #102210 --- .../editors/interface/interface_templates.cc | 61 ++++++++++++++----- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 618b04aa70a..b60b30493b2 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -6124,6 +6124,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) ScrArea *area = CTX_wm_area(C); void *owner = nullptr; int handle_event, icon = 0; + const char* op_name = NULL; uiBlock *block = uiLayoutGetBlock(layout); UI_block_layout_set_current(block, layout); @@ -6185,6 +6186,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) { handle_event = B_STOPRENDER; icon = ICON_SCENE; + op_name = "RENDER_OT_view_show"; break; } if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) { @@ -6243,21 +6245,50 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) /* job name and icon */ const int textwidth = UI_fontstyle_string_width(fstyle, name); - uiDefIconTextBut(block, - UI_BTYPE_LABEL, - 0, - icon, - name, - 0, - 0, - textwidth + UI_UNIT_X * 1.5f, - UI_UNIT_Y, - nullptr, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - ""); + if(op_name) { + uiDefIconButO(block, + UI_BTYPE_BUT, + op_name, + WM_OP_INVOKE_DEFAULT, + icon, + 0, + 0, + UI_UNIT_X, + UI_UNIT_Y, + TIP_("Show/ focus render window")); + uiDefIconTextBut(block, + UI_BTYPE_LABEL, + 0, + 0, + name, + 0, + 0, + textwidth + UI_UNIT_X * 1.5f, + UI_UNIT_Y, + nullptr, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + ""); + } + else { + uiDefIconTextBut(block, + UI_BTYPE_LABEL, + 0, + icon, + name, + 0, + 0, + textwidth + UI_UNIT_X * 1.5f, + UI_UNIT_Y, + nullptr, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + ""); + } /* stick progress bar and cancel button together */ row = uiLayoutRow(layout, true); -- 2.30.2 From 1f8dc7b7ae023ec520da7b5590fa92b5cc0270df Mon Sep 17 00:00:00 2001 From: Remy Fayet Date: Wed, 15 Mar 2023 12:50:41 +0100 Subject: [PATCH 2/4] Match cpp coding style and remove duplicates --- .../editors/interface/interface_templates.cc | 77 ++++++++----------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index b60b30493b2..5d1a6052bba 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -6124,7 +6124,8 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) ScrArea *area = CTX_wm_area(C); void *owner = nullptr; int handle_event, icon = 0; - const char* op_name = NULL; + const char *op_name = nullptr; + const char *op_desc = nullptr; uiBlock *block = uiLayoutGetBlock(layout); UI_block_layout_set_current(block, layout); @@ -6187,6 +6188,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) handle_event = B_STOPRENDER; icon = ICON_SCENE; op_name = "RENDER_OT_view_show"; + op_desc = "Show the render window"; break; } if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) { @@ -6243,53 +6245,38 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) const char *name = active ? WM_jobs_name(wm, owner) : "Canceling..."; - /* job name and icon */ - const int textwidth = UI_fontstyle_string_width(fstyle, name); - if(op_name) { + /* job icon as a button */ + if (op_name) { uiDefIconButO(block, - UI_BTYPE_BUT, - op_name, - WM_OP_INVOKE_DEFAULT, - icon, - 0, - 0, - UI_UNIT_X, - UI_UNIT_Y, - TIP_("Show/ focus render window")); - uiDefIconTextBut(block, - UI_BTYPE_LABEL, - 0, - 0, - name, - 0, - 0, - textwidth + UI_UNIT_X * 1.5f, - UI_UNIT_Y, - nullptr, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - ""); - } - else { - uiDefIconTextBut(block, - UI_BTYPE_LABEL, - 0, - icon, - name, - 0, - 0, - textwidth + UI_UNIT_X * 1.5f, - UI_UNIT_Y, - nullptr, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - ""); + UI_BTYPE_BUT, + op_name, + WM_OP_INVOKE_DEFAULT, + icon, + 0, + 0, + UI_UNIT_X, + UI_UNIT_Y, + TIP_(op_desc)); } + /* job name and icon if not previously set */ + const int textwidth = UI_fontstyle_string_width(fstyle, name); + uiDefIconTextBut(block, + UI_BTYPE_LABEL, + 0, + op_name ? 0 : icon, + name, + 0, + 0, + textwidth + UI_UNIT_X * 1.5f, + UI_UNIT_Y, + nullptr, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + ""); + /* stick progress bar and cancel button together */ row = uiLayoutRow(layout, true); uiLayoutSetActive(row, active); -- 2.30.2 From 441a043b71a6c4e3fd78e3efc3ea6d490ffe657a Mon Sep 17 00:00:00 2001 From: Remy Fayet Date: Sat, 18 Mar 2023 14:22:59 +0100 Subject: [PATCH 3/4] Remove abbreviation --- source/blender/editors/interface/interface_templates.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 5d1a6052bba..3688cb2cdaa 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -6125,7 +6125,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) void *owner = nullptr; int handle_event, icon = 0; const char *op_name = nullptr; - const char *op_desc = nullptr; + const char *op_description = nullptr; uiBlock *block = uiLayoutGetBlock(layout); UI_block_layout_set_current(block, layout); @@ -6188,7 +6188,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) handle_event = B_STOPRENDER; icon = ICON_SCENE; op_name = "RENDER_OT_view_show"; - op_desc = "Show the render window"; + op_description = "Show the render window"; break; } if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) { @@ -6256,7 +6256,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) 0, UI_UNIT_X, UI_UNIT_Y, - TIP_(op_desc)); + TIP_(op_description)); } /* job name and icon if not previously set */ -- 2.30.2 From a08ee75fd31666c4da5f24ee8d1c278b15209adb Mon Sep 17 00:00:00 2001 From: Remy Fayet Date: Mon, 20 Mar 2023 21:51:52 +0100 Subject: [PATCH 4/4] Exclude the `Keep User Interface` case --- source/blender/editors/interface/interface_templates.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 3688cb2cdaa..8744281e575 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -6187,8 +6187,10 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) { handle_event = B_STOPRENDER; icon = ICON_SCENE; - op_name = "RENDER_OT_view_show"; - op_description = "Show the render window"; + if (U.render_display_type != USER_RENDER_DISPLAY_NONE) { + op_name = "RENDER_OT_view_show"; + op_description = "Show the render window"; + } break; } if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) { -- 2.30.2