Compare commits
15 Commits
main
...
mb-0012-cu
Author | SHA1 | Date |
---|---|---|
Jaume Bellet | 280850ddf1 | |
Jaume Bellet | 750c5f2723 | |
Jaume Bellet | ea58d624cd | |
Jaume Bellet | dbaf864dde | |
Jaume Bellet | 63e9375ec8 | |
Jaume Bellet | cde3c2f0c4 | |
Jaume Bellet | 236564a441 | |
Jaume Bellet | e1dba50d08 | |
Jaume Bellet | aa234d9e15 | |
Jaume Bellet | 4ae40c1e3a | |
Jaume Bellet | 3b5da577f7 | |
Jaume Bellet | b7e97dc8bb | |
Jaume Bellet | 9414fe8f70 | |
Jaume Bellet | ed86f7be23 | |
Jaume Bellet | cca4693bdd |
|
@ -0,0 +1 @@
|
|||
/* Empty File */
|
|
@ -4065,6 +4065,7 @@ void wm_operatortypes_register()
|
|||
WM_operatortype_append(WM_OT_operator_defaults);
|
||||
WM_operatortype_append(WM_OT_splash);
|
||||
WM_operatortype_append(WM_OT_splash_about);
|
||||
WM_operatortype_append(WM_OT_splash_custom);
|
||||
WM_operatortype_append(WM_OT_search_menu);
|
||||
WM_operatortype_append(WM_OT_search_operator);
|
||||
WM_operatortype_append(WM_OT_search_single_menu);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
@ -45,6 +47,9 @@
|
|||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "RNA_define.hh"
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "wm.hh"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -369,4 +374,67 @@ void WM_OT_splash_about(wmOperatorType *ot)
|
|||
ot->poll = WM_operator_winactive;
|
||||
}
|
||||
|
||||
static uiBlock *wm_block_create_custom_splash(bContext *C, ARegion *region, void *arg) {
|
||||
|
||||
char *menutype_str = (char*) arg;
|
||||
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const int text_points_max = std::max(style->widget.points, style->widgetlabel.points);
|
||||
const int dialog_width = text_points_max * 42 * UI_SCALE_FAC;
|
||||
|
||||
uiBlock *block = UI_block_begin(C, region, "about", UI_EMBOSS);
|
||||
|
||||
UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP);
|
||||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
|
||||
uiLayout *layout = UI_block_layout(
|
||||
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, dialog_width, 0, 0, style);
|
||||
|
||||
uiLayout *col = uiLayoutColumn(layout, true);
|
||||
|
||||
MenuType *mt = WM_menutype_find(menutype_str, true);
|
||||
if (mt) {
|
||||
UI_menutype_draw(C, mt, col);
|
||||
} else {
|
||||
CLOG_ERROR(WM_LOG_OPERATORS, "cannot find WM menutype '%s'", menutype_str);
|
||||
}
|
||||
|
||||
UI_block_bounds_set_centered(block, 22 * UI_SCALE_FAC);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static int wm_about_custom_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
char *menutype_str = MEM_cnew_array<char>(100, __func__);
|
||||
*menutype_str = '\0';
|
||||
|
||||
if (RNA_struct_property_is_set(op->ptr, "menutype")) {
|
||||
RNA_string_get(op->ptr, "menutype", menutype_str);
|
||||
}
|
||||
|
||||
UI_popup_block_invoke(C, wm_block_create_custom_splash, menutype_str, MEM_freeN);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int wm_about_custom_invoke(bContext *C, wmOperator *op , const wmEvent * /*event*/) {
|
||||
return op->type->exec(C, op);
|
||||
}
|
||||
|
||||
void WM_OT_splash_custom(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_string(ot->srna, "menutype", "MT_", 100, "", "MenuType class name");
|
||||
|
||||
ot->name = "Custom Splash";
|
||||
ot->idname = "WM_OT_splash_custom";
|
||||
ot->description = "Open a splash window with some custom information";
|
||||
|
||||
ot->exec = wm_about_custom_exec;
|
||||
ot->invoke = wm_about_custom_invoke;
|
||||
ot->poll = WM_operator_winactive;
|
||||
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -98,6 +98,7 @@ void wm_autosave_delete();
|
|||
|
||||
void WM_OT_splash(wmOperatorType *ot);
|
||||
void WM_OT_splash_about(wmOperatorType *ot);
|
||||
void WM_OT_splash_custom(wmOperatorType *ot);
|
||||
|
||||
/* `wm_stereo.cc` */
|
||||
|
||||
|
|
Loading…
Reference in New Issue