UI: About Blender Dialog
Adds an 'About Blender' dialog to the 'App' menu to display information like branch and hash. Differential Revision: https://developer.blender.org/D7146 Reviewed by Campbell Barton
This commit is contained in:
parent
613715a994
commit
5b86fe6f33
|
@ -2557,6 +2557,36 @@ class WM_MT_splash(Menu):
|
|||
layout.separator()
|
||||
|
||||
|
||||
class WM_MT_splash_about(Menu):
|
||||
bl_label = "About"
|
||||
|
||||
def draw(self, context):
|
||||
|
||||
layout = self.layout
|
||||
layout.operator_context = 'EXEC_DEFAULT'
|
||||
|
||||
layout.label(text="Blender is free software")
|
||||
layout.label(text="Licensed under the GNU General Public License")
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
|
||||
split = layout.split()
|
||||
split.emboss = 'PULLDOWN_MENU'
|
||||
split.scale_y = 1.3
|
||||
|
||||
col1 = split.column()
|
||||
|
||||
col1.operator("wm.url_open_preset", text="Release Notes", icon='URL').type = 'RELEASE_NOTES'
|
||||
col1.operator("wm.url_open_preset", text="Credits", icon='URL').type = 'CREDITS'
|
||||
col1.operator("wm.url_open", text="License", icon='URL').url = "https://www.blender.org/about/license/"
|
||||
|
||||
col2 = split.column()
|
||||
|
||||
col2.operator("wm.url_open_preset", text="Blender Website", icon='URL').type = 'BLENDER'
|
||||
col2.operator("wm.url_open", text="Blender Store", icon='URL').url = "https://store.blender.org"
|
||||
col2.operator("wm.url_open_preset", text="Development Fund", icon='FUND').type = 'FUND'
|
||||
|
||||
|
||||
class WM_OT_drop_blend_file(Operator):
|
||||
bl_idname = "wm.drop_blend_file"
|
||||
bl_label = "Handle dropped .blend file"
|
||||
|
@ -2626,4 +2656,5 @@ classes = (
|
|||
BatchRenameAction,
|
||||
WM_OT_batch_rename,
|
||||
WM_MT_splash,
|
||||
WM_MT_splash_about,
|
||||
)
|
||||
|
|
|
@ -229,14 +229,7 @@ class TOPBAR_MT_app(Menu):
|
|||
layout = self.layout
|
||||
|
||||
layout.operator("wm.splash")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("TOPBAR_MT_app_support")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("TOPBAR_MT_app_about")
|
||||
layout.operator("wm.splash_about")
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
@ -407,45 +400,6 @@ class TOPBAR_MT_file_defaults(Menu):
|
|||
props.app_template = app_template
|
||||
|
||||
|
||||
class TOPBAR_MT_app_about(Menu):
|
||||
bl_label = "About"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("wm.url_open_preset", text="Release Notes",
|
||||
icon='URL').type = 'RELEASE_NOTES'
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("wm.url_open_preset",
|
||||
text="Blender Website", icon='URL').type = 'BLENDER'
|
||||
layout.operator("wm.url_open_preset", text="Credits",
|
||||
icon='URL').type = 'CREDITS'
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator(
|
||||
"wm.url_open", text="License", icon='URL',
|
||||
).url = "https://www.blender.org/about/license/"
|
||||
|
||||
|
||||
class TOPBAR_MT_app_support(Menu):
|
||||
bl_label = "Support Blender"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator("wm.url_open_preset",
|
||||
text="Development Fund", icon='FUND').type = 'FUND'
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.operator(
|
||||
"wm.url_open", text="Blender Store", icon='URL',
|
||||
).url = "https://store.blender.org"
|
||||
|
||||
|
||||
# Include technical operators here which would otherwise have no way for users to access.
|
||||
class TOPBAR_MT_app_system(Menu):
|
||||
bl_label = "System"
|
||||
|
@ -854,9 +808,7 @@ classes = (
|
|||
TOPBAR_MT_workspace_menu,
|
||||
TOPBAR_MT_editor_menus,
|
||||
TOPBAR_MT_app,
|
||||
TOPBAR_MT_app_about,
|
||||
TOPBAR_MT_app_system,
|
||||
TOPBAR_MT_app_support,
|
||||
TOPBAR_MT_file,
|
||||
TOPBAR_MT_file_new,
|
||||
TOPBAR_MT_file_recover,
|
||||
|
|
|
@ -3797,6 +3797,7 @@ void wm_operatortypes_register(void)
|
|||
WM_operatortype_append(WM_OT_debug_menu);
|
||||
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_search_menu);
|
||||
WM_operatortype_append(WM_OT_search_operator);
|
||||
WM_operatortype_append(WM_OT_call_menu);
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
#include "BKE_context.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BLF_api.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
|
@ -56,6 +58,7 @@
|
|||
#include "ED_screen.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_interface_icons.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
|
@ -63,21 +66,19 @@
|
|||
|
||||
#include "wm.h"
|
||||
|
||||
static void wm_block_splash_close(bContext *C, void *arg_block, void *UNUSED(arg))
|
||||
static void wm_block_close(bContext *C, void *arg_block, void *UNUSED(arg))
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
UI_popup_block_close(C, win, arg_block);
|
||||
}
|
||||
|
||||
static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *arg_unused);
|
||||
|
||||
static void wm_block_splash_refreshmenu(bContext *C, void *UNUSED(arg_block), void *UNUSED(arg))
|
||||
{
|
||||
ARegion *region_menu = CTX_wm_menu(C);
|
||||
ED_region_tag_refresh_ui(region_menu);
|
||||
}
|
||||
|
||||
static void wm_block_splash_add_label(uiBlock *block, const char *label, int x, int *y)
|
||||
static void wm_block_splash_add_label(uiBlock *block, const char *label, int x, int y)
|
||||
{
|
||||
if (!(label && label[0])) {
|
||||
return;
|
||||
|
@ -86,21 +87,19 @@ static void wm_block_splash_add_label(uiBlock *block, const char *label, int x,
|
|||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
|
||||
uiBut *but = uiDefBut(
|
||||
block, UI_BTYPE_LABEL, 0, label, 0, *y, x, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
||||
block, UI_BTYPE_LABEL, 0, label, 0, y, x, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
||||
UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
|
||||
UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT);
|
||||
|
||||
/* 1 = UI_SELECT, internal flag to draw in white. */
|
||||
UI_but_flag_enable(but, 1);
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
*y -= 12 * U.dpi_fac;
|
||||
}
|
||||
|
||||
static void wm_block_splash_add_labels(uiBlock *block, int x, int y)
|
||||
static void get_version_string(char *ver, const int max_length)
|
||||
{
|
||||
/* Version number. */
|
||||
const char *version_cycle = NULL;
|
||||
bool show_build_info = true;
|
||||
|
||||
if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) {
|
||||
version_cycle = " Alpha";
|
||||
|
@ -110,11 +109,9 @@ static void wm_block_splash_add_labels(uiBlock *block, int x, int y)
|
|||
}
|
||||
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) {
|
||||
version_cycle = " Release Candidate";
|
||||
show_build_info = false;
|
||||
}
|
||||
else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) {
|
||||
version_cycle = STRINGIFY(BLENDER_VERSION_CHAR);
|
||||
show_build_info = false;
|
||||
}
|
||||
|
||||
const char *version_cycle_number = "";
|
||||
|
@ -122,46 +119,14 @@ static void wm_block_splash_add_labels(uiBlock *block, int x, int y)
|
|||
version_cycle_number = " " STRINGIFY(BLENDER_VERSION_CYCLE_NUMBER);
|
||||
}
|
||||
|
||||
char version_buf[256] = "\0";
|
||||
BLI_snprintf(version_buf,
|
||||
sizeof(version_buf),
|
||||
"v %d.%d%s%s",
|
||||
BLI_snprintf(ver,
|
||||
max_length,
|
||||
"%d.%d.%d%s%s",
|
||||
BLENDER_VERSION / 100,
|
||||
BLENDER_VERSION % 100,
|
||||
BLENDER_SUBVERSION,
|
||||
version_cycle,
|
||||
version_cycle_number);
|
||||
|
||||
wm_block_splash_add_label(block, version_buf, x, &y);
|
||||
|
||||
#ifdef WITH_BUILDINFO
|
||||
if (show_build_info) {
|
||||
extern unsigned long build_commit_timestamp;
|
||||
extern char build_hash[], build_commit_date[], build_commit_time[], build_branch[];
|
||||
|
||||
/* Date, hidden for builds made from tag. */
|
||||
if (build_commit_timestamp != 0) {
|
||||
char date_buf[256] = "\0";
|
||||
BLI_snprintf(
|
||||
date_buf, sizeof(date_buf), "Date: %s %s", build_commit_date, build_commit_time);
|
||||
wm_block_splash_add_label(block, date_buf, x, &y);
|
||||
}
|
||||
|
||||
/* Hash. */
|
||||
char hash_buf[256] = "\0";
|
||||
BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash);
|
||||
wm_block_splash_add_label(block, hash_buf, x, &y);
|
||||
|
||||
/* Branch. */
|
||||
if (!STREQ(build_branch, "master")) {
|
||||
char branch_buf[256] = "\0";
|
||||
BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch);
|
||||
|
||||
wm_block_splash_add_label(block, branch_buf, x, &y);
|
||||
}
|
||||
}
|
||||
#else
|
||||
UNUSED_VARS(show_build_info);
|
||||
#endif /* WITH_BUILDINFO */
|
||||
}
|
||||
|
||||
static void wm_block_splash_image_roundcorners_add(ImBuf *ibuf)
|
||||
|
@ -281,10 +246,12 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
|
|||
|
||||
but = uiDefButImage(block, ibuf, 0, 0.5f * U.widget_unit, splash_width, splash_height, NULL);
|
||||
|
||||
UI_but_func_set(but, wm_block_splash_close, block, NULL);
|
||||
UI_but_func_set(but, wm_block_close, block, NULL);
|
||||
UI_block_func_set(block, wm_block_splash_refreshmenu, block, NULL);
|
||||
|
||||
wm_block_splash_add_labels(block, splash_width, splash_height - 13 * U.dpi_fac);
|
||||
char version_buf[256] = "\0";
|
||||
get_version_string(version_buf, sizeof(version_buf));
|
||||
wm_block_splash_add_label(block, version_buf, splash_width, splash_height - 13.0 * U.dpi_fac);
|
||||
|
||||
const int layout_margin_x = U.dpi_fac * 26;
|
||||
uiLayout *layout = UI_block_layout(block,
|
||||
|
@ -323,3 +290,93 @@ void WM_OT_splash(wmOperatorType *ot)
|
|||
ot->invoke = wm_splash_invoke;
|
||||
ot->poll = WM_operator_winactive;
|
||||
}
|
||||
|
||||
static uiBlock *wm_block_create_about(bContext *C, ARegion *region, void *UNUSED(arg))
|
||||
{
|
||||
uiBlock *block;
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const int dialog_width = U.widget_unit * 24;
|
||||
const short logo_size = 128 * U.dpi_fac;
|
||||
|
||||
/* Calculate icon column factor. */
|
||||
const float split_factor = (float)logo_size / (float)(dialog_width - style->columnspace);
|
||||
|
||||
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_NUMSELECT);
|
||||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
||||
uiLayout *block_layout = UI_block_layout(
|
||||
block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, dialog_width, 0, 0, style);
|
||||
|
||||
/* Split layout to put Blender logo on left side. */
|
||||
uiLayout *split_block = uiLayoutSplit(block_layout, split_factor, false);
|
||||
|
||||
/* Blender Logo. */
|
||||
uiLayout *layout = uiLayoutColumn(split_block, false);
|
||||
uiDefButAlert(block, ALERT_ICON_BLENDER, 0, 0, 0, logo_size);
|
||||
|
||||
/* The rest of the content on the right. */
|
||||
layout = uiLayoutColumn(split_block, false);
|
||||
|
||||
uiLayoutSetScaleY(layout, 0.7f);
|
||||
|
||||
uiItemS_ex(layout, 1.0f);
|
||||
|
||||
/* Title. */
|
||||
uiItemL_ex(layout, "Blender", ICON_NONE, true, false);
|
||||
|
||||
/* Version. */
|
||||
char str_buf[256] = "\0";
|
||||
get_version_string(str_buf, sizeof(str_buf));
|
||||
uiItemL(layout, str_buf, ICON_NONE);
|
||||
|
||||
uiItemS_ex(layout, 3.0f);
|
||||
|
||||
#ifdef WITH_BUILDINFO
|
||||
|
||||
extern char build_hash[], build_commit_date[], build_commit_time[], build_branch[];
|
||||
|
||||
BLI_snprintf(str_buf, sizeof(str_buf), "Date: %s %s", build_commit_date, build_commit_time);
|
||||
uiItemL(layout, str_buf, ICON_NONE);
|
||||
|
||||
BLI_snprintf(str_buf, sizeof(str_buf), "Hash: %s", build_hash);
|
||||
uiItemL(layout, str_buf, ICON_NONE);
|
||||
|
||||
BLI_snprintf(str_buf, sizeof(str_buf), "Branch: %s", build_branch);
|
||||
uiItemL(layout, str_buf, ICON_NONE);
|
||||
|
||||
#endif /* WITH_BUILDINFO */
|
||||
|
||||
uiItemS_ex(layout, 1.5f);
|
||||
|
||||
MenuType *mt = WM_menutype_find("WM_MT_splash_about", true);
|
||||
if (mt) {
|
||||
UI_menutype_draw(C, mt, layout);
|
||||
}
|
||||
|
||||
uiItemS_ex(layout, 2.0f);
|
||||
|
||||
UI_block_bounds_set_centered(block, 14 * U.dpi_fac);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
static int wm_about_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
|
||||
{
|
||||
UI_popup_block_invoke(C, wm_block_create_about, NULL, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void WM_OT_splash_about(wmOperatorType *ot)
|
||||
{
|
||||
ot->name = "About Blender";
|
||||
ot->idname = "WM_OT_splash_about";
|
||||
ot->description = "Open a window with information about Blender";
|
||||
|
||||
ot->invoke = wm_about_invoke;
|
||||
ot->poll = WM_operator_winactive;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ void wm_autosave_location(char *filepath);
|
|||
|
||||
/* wm_splash_screen.c */
|
||||
void WM_OT_splash(wmOperatorType *ot);
|
||||
void WM_OT_splash_about(wmOperatorType *ot);
|
||||
|
||||
/* wm_stereo.c */
|
||||
void wm_stereo3d_draw_sidebyside(wmWindow *win, int view);
|
||||
|
@ -96,4 +97,4 @@ void wm_stereo3d_set_cancel(bContext *C, wmOperator *op);
|
|||
void wm_open_init_load_ui(wmOperator *op, bool use_prefs);
|
||||
void wm_open_init_use_scripts(wmOperator *op, bool use_prefs);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue