UI: fix operator redo showing empty popovers
Many operators have no options, showing a popover button with no content isn't good.
This commit is contained in:
@@ -179,7 +179,7 @@ class TOPBAR_HT_lower_bar(Header):
|
|||||||
row.enabled = op is not None
|
row.enabled = op is not None
|
||||||
row.popover(
|
row.popover(
|
||||||
space_type='TOPBAR',
|
space_type='TOPBAR',
|
||||||
region_type='WINDOW',
|
region_type='HEADER',
|
||||||
panel_type="TOPBAR_PT_redo",
|
panel_type="TOPBAR_PT_redo",
|
||||||
text=op.name + " Settings" if op else "Command Settings",
|
text=op.name + " Settings" if op else "Command Settings",
|
||||||
)
|
)
|
||||||
@@ -232,16 +232,6 @@ class _draw_left_context_mode:
|
|||||||
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength")
|
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength")
|
||||||
|
|
||||||
|
|
||||||
class TOPBAR_PT_redo(Panel):
|
|
||||||
bl_label = "Redo"
|
|
||||||
bl_space_type = 'TOPBAR'
|
|
||||||
bl_region_type = 'WINDOW'
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
layout.column().template_operator_redo_props()
|
|
||||||
|
|
||||||
|
|
||||||
class INFO_MT_editor_menus(Menu):
|
class INFO_MT_editor_menus(Menu):
|
||||||
bl_idname = "INFO_MT_editor_menus"
|
bl_idname = "INFO_MT_editor_menus"
|
||||||
bl_label = ""
|
bl_label = ""
|
||||||
@@ -508,7 +498,6 @@ class INFO_MT_help(Menu):
|
|||||||
classes = (
|
classes = (
|
||||||
TOPBAR_HT_upper_bar,
|
TOPBAR_HT_upper_bar,
|
||||||
TOPBAR_HT_lower_bar,
|
TOPBAR_HT_lower_bar,
|
||||||
TOPBAR_PT_redo,
|
|
||||||
INFO_MT_editor_menus,
|
INFO_MT_editor_menus,
|
||||||
INFO_MT_file,
|
INFO_MT_file,
|
||||||
INFO_MT_file_import,
|
INFO_MT_file_import,
|
||||||
|
|||||||
@@ -1001,7 +1001,7 @@ void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char
|
|||||||
struct PointerRNA *root_ptr, const char *text);
|
struct PointerRNA *root_ptr, const char *text);
|
||||||
uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
|
uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr);
|
||||||
|
|
||||||
void uiTemplateOperatorRedoProperties(uiLayout *layout, struct bContext *C);
|
void uiTemplateOperatorRedoProperties(uiLayout *layout, const struct bContext *C);
|
||||||
|
|
||||||
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
|
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
|
||||||
void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
|
void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
|
||||||
|
|||||||
@@ -1561,7 +1561,7 @@ static void template_operator_redo_property_buts_draw(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTemplateOperatorRedoProperties(uiLayout *layout, bContext *C)
|
void uiTemplateOperatorRedoProperties(uiLayout *layout, const bContext *C)
|
||||||
{
|
{
|
||||||
wmOperator *op = WM_operator_last_redo(C);
|
wmOperator *op = WM_operator_last_redo(C);
|
||||||
uiBlock *block = uiLayoutGetBlock(layout);
|
uiBlock *block = uiLayoutGetBlock(layout);
|
||||||
|
|||||||
@@ -57,6 +57,8 @@
|
|||||||
#include "WM_message.h"
|
#include "WM_message.h"
|
||||||
|
|
||||||
|
|
||||||
|
void topbar_panels_register(ARegionType *art);
|
||||||
|
|
||||||
/* ******************** default callbacks for topbar space ***************** */
|
/* ******************** default callbacks for topbar space ***************** */
|
||||||
|
|
||||||
static SpaceLink *topbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
static SpaceLink *topbar_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
||||||
@@ -273,9 +275,58 @@ void ED_spacetype_topbar(void)
|
|||||||
art->layout = ED_region_header_layout;
|
art->layout = ED_region_header_layout;
|
||||||
art->draw = ED_region_header_draw;
|
art->draw = ED_region_header_draw;
|
||||||
|
|
||||||
|
/* For popovers. */
|
||||||
|
topbar_panels_register(art);
|
||||||
|
|
||||||
BLI_addhead(&st->regiontypes, art);
|
BLI_addhead(&st->regiontypes, art);
|
||||||
|
|
||||||
recent_files_menu_register();
|
recent_files_menu_register();
|
||||||
|
|
||||||
BKE_spacetype_register(st);
|
BKE_spacetype_register(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name Redo Panel
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
static int topbar_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt))
|
||||||
|
{
|
||||||
|
wmOperator *op = WM_operator_last_redo(C);
|
||||||
|
if (op == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (WM_operator_poll((bContext *)C, op->type) &&
|
||||||
|
WM_operator_check_ui_empty(op->type) == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void topbar_panel_operator_redo(const bContext *C, Panel *pa)
|
||||||
|
{
|
||||||
|
wmOperator *op = WM_operator_last_redo(C);
|
||||||
|
if (op == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!WM_operator_check_ui_enabled(C, op->type->name)) {
|
||||||
|
uiLayoutSetEnabled(pa->layout, false);
|
||||||
|
}
|
||||||
|
uiLayout *col = uiLayoutColumn(pa->layout, false);
|
||||||
|
uiTemplateOperatorRedoProperties(col, C);
|
||||||
|
}
|
||||||
|
|
||||||
|
void topbar_panels_register(ARegionType *art)
|
||||||
|
{
|
||||||
|
PanelType *pt;
|
||||||
|
|
||||||
|
pt = MEM_callocN(sizeof(PanelType), __func__);
|
||||||
|
strcpy(pt->idname, "TOPBAR_PT_redo");
|
||||||
|
strcpy(pt->label, N_("Redo"));
|
||||||
|
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||||
|
pt->draw = topbar_panel_operator_redo;
|
||||||
|
pt->poll = topbar_panel_operator_redo_poll;
|
||||||
|
pt->space_type = SPACE_TOPBAR;
|
||||||
|
pt->region_type = RGN_TYPE_HEADER;
|
||||||
|
BLI_addtail(&art->paneltypes, pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
|||||||
@@ -811,10 +811,6 @@ void RNA_api_ui_layout(StructRNA *srna)
|
|||||||
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
|
parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
|
||||||
RNA_def_function_return(func, parm);
|
RNA_def_function_return(func, parm);
|
||||||
|
|
||||||
func = RNA_def_function(srna, "template_operator_redo_props", "uiTemplateOperatorRedoProperties");
|
|
||||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
|
||||||
RNA_def_function_ui_description(func, "Adds properties of the last executed operator using redo");
|
|
||||||
|
|
||||||
func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
|
func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
|
||||||
RNA_def_function_ui_description(func, "Generates the UI layout for constraints");
|
RNA_def_function_ui_description(func, "Generates the UI layout for constraints");
|
||||||
parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
|
parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
|
||||||
|
|||||||
Reference in New Issue
Block a user