Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/windowmanager/intern/wm_operators.c')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c272
1 files changed, 124 insertions, 148 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 63ca46e05c6..367a5a81098 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1151,38 +1151,27 @@ typedef struct wmOpPopUp {
/* Only invoked by OK button in popups created with wm_block_dialog_create() */
static void dialog_exec_cb(bContext *C, void *arg1, void *arg2)
{
- wmOpPopUp *data = arg1;
- uiBlock *block = arg2;
+ wmOperator *op;
+ {
+ /* Execute will free the operator.
+ * In this case, wm_operator_ui_popup_cancel wont run. */
+ wmOpPopUp *data = arg1;
+ op = data->op;
+ MEM_freeN(data);
+ }
+ uiBlock *block = arg2;
/* Explicitly set UI_RETURN_OK flag, otherwise the menu might be canceled
* in case WM_operator_call_ex exits/reloads the current file (T49199). */
- UI_popup_menu_retval_set(block, UI_RETURN_OK, true);
-
- WM_operator_call_ex(C, data->op, true);
- /* let execute handle freeing it */
- // data->free_op = false;
- // data->op = NULL;
-
- /* in this case, wm_operator_ui_popup_cancel wont run */
- MEM_freeN(data);
+ UI_popup_menu_retval_set(block, UI_RETURN_OK, true);
/* Get context data *after* WM_operator_call_ex
* which might have closed the current file and changed context. */
- wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
+ UI_popup_block_close(C, win, block);
- /* check window before 'block->handle' incase the
- * popup execution closed the window and freed the block. see T44688.
- */
- /* Post 2.78 TODO: Check if this fix and others related to T44688 are still
- * needed or can be improved now that requesting context data has been corrected
- * (see above). We're close to release so not a good time for experiments.
- * -- Julian
- */
- if (BLI_findindex(&wm->windows, win) != -1) {
- UI_popup_block_close(C, win, block);
- }
+ WM_operator_call_ex(C, op, true);
}
/* Dialogs are popups that require user verification (click OK) before exec */
@@ -1478,43 +1467,113 @@ static void wm_block_splash_refreshmenu(bContext *C, void *UNUSED(arg_block), vo
ED_region_tag_refresh_ui(ar_menu);
}
-static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg))
+static void wm_block_splash_add_label(uiBlock *block, const char *label, int x, int *y)
{
- uiBlock *block;
- uiBut *but;
+ if (!(label && label[0])) {
+ return;
+ }
+
uiStyle *style = UI_style_get();
-#ifndef WITH_HEADLESS
- extern char datatoc_splash_png[];
- extern int datatoc_splash_png_size;
+ BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi);
+ int label_width = BLF_width(style->widgetlabel.uifont_id, label, strlen(label));
+ label_width = label_width + U.widget_unit;
- extern char datatoc_splash_2x_png[];
- extern int datatoc_splash_2x_png_size;
- ImBuf *ibuf;
-#else
- ImBuf *ibuf = NULL;
-#endif
+ UI_block_emboss_set(block, UI_EMBOSS_NONE);
+
+ uiBut *but = uiDefBut(block,
+ UI_BTYPE_LABEL,
+ 0,
+ label,
+ x - label_width,
+ *y,
+ label_width,
+ UI_UNIT_Y,
+ NULL,
+ 0,
+ 0,
+ 0,
+ 0,
+ NULL);
+
+ /* 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)
+{
+ /* Version number. */
+ const char *version_suffix = NULL;
+ bool show_build_info = true;
+
+ if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) {
+ version_suffix = " Alpha";
+ }
+ else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "beta")) {
+ version_suffix = " Beta";
+ }
+ else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) {
+ version_suffix = " Release Candidate";
+ show_build_info = false;
+ }
+ else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) {
+ version_suffix = STRINGIFY(BLENDER_VERSION_CHAR);
+ show_build_info = false;
+ }
+
+ char version_buf[256] = "\0";
+ BLI_snprintf(version_buf,
+ sizeof(version_buf),
+ "v %d.%d%s",
+ BLENDER_VERSION / 100,
+ BLENDER_VERSION % 100,
+ version_suffix);
+
+ wm_block_splash_add_label(block, version_buf, x, &y);
#ifdef WITH_BUILDINFO
- int label_delta = 0;
- int hash_width, date_width;
- char date_buf[128] = "\0";
- char hash_buf[128] = "\0";
- extern unsigned long build_commit_timestamp;
- extern char build_hash[], build_commit_date[], build_commit_time[], build_branch[];
+ 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);
+ }
- /* Builds made from tag only shows tag sha */
- BLI_snprintf(hash_buf, sizeof(hash_buf), "Hash: %s", build_hash);
- BLI_snprintf(date_buf, sizeof(date_buf), "Date: %s %s", build_commit_date, build_commit_time);
+ /* 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);
- BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.pixelsize * U.dpi);
- hash_width = (int)BLF_width(style->widgetlabel.uifont_id, hash_buf, sizeof(hash_buf)) +
- U.widget_unit;
- date_width = (int)BLF_width(style->widgetlabel.uifont_id, date_buf, sizeof(date_buf)) +
- U.widget_unit;
+ /* 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 ImBuf *wm_block_splash_image(void)
+{
#ifndef WITH_HEADLESS
+ extern char datatoc_splash_png[];
+ extern int datatoc_splash_png_size;
+ extern char datatoc_splash_2x_png[];
+ extern int datatoc_splash_2x_png_size;
+
+ ImBuf *ibuf = NULL;
+
if (U.dpi_fac > 1.0) {
ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_splash_2x_png,
datatoc_splash_2x_png_size,
@@ -1541,7 +1600,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
BLI_join_dirfile(splash_filepath,
sizeof(splash_filepath),
template_directory,
- (U.pixelsize == 2) ? "splash_2x.png" : "splash.png");
+ (U.dpi_fac > 1.0) ? "splash_2x.png" : "splash.png");
ibuf_template = IMB_loadiffname(splash_filepath, IB_rect, NULL);
if (ibuf_template) {
const int x_expect = ibuf->x;
@@ -1565,7 +1624,17 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
}
}
}
+ return ibuf;
+#else
+ return NULL;
#endif
+}
+
+static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg))
+{
+ uiBlock *block;
+ uiBut *but;
+ uiStyle *style = UI_style_get();
block = UI_block_begin(C, ar, "splash", UI_EMBOSS);
@@ -1575,6 +1644,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
+ ImBuf *ibuf = wm_block_splash_image();
but = uiDefBut(block,
UI_BTYPE_IMAGE,
0,
@@ -1592,109 +1662,15 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
UI_but_func_set(but, wm_block_splash_close, block, NULL);
UI_block_func_set(block, wm_block_splash_refreshmenu, block, NULL);
- /* label for 'a' bugfix releases, or 'Release Candidate 1'...
- * avoids recreating splash for version updates */
- const char *version_suffix = NULL;
-
- if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "alpha")) {
- version_suffix = " Alpha";
- }
- else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "beta")) {
- version_suffix = " Beta";
- }
- else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "rc")) {
- version_suffix = " Release Candidate";
- }
- else if (STREQ(STRINGIFY(BLENDER_VERSION_CYCLE), "release")) {
- version_suffix = STRINGIFY(BLENDER_VERSION_CHAR);
- }
-
- char *version = BLI_sprintfN(
- "Version %d.%d%s", BLENDER_VERSION / 100, BLENDER_VERSION % 100, version_suffix);
-
- if (version != NULL && version[0]) {
- /* placed after the version number in the image,
- * placing y is tricky to match baseline */
- /* hack to have text draw 'text_sel' */
- UI_block_emboss_set(block, UI_EMBOSS_NONE);
- int x = 202 * U.dpi_fac;
- int y = 130 * U.dpi_fac;
- int w = 240 * U.dpi_fac;
+ int x = U.dpi_fac * 502;
+ int y = U.dpi_fac * 237;
- but = uiDefBut(block, UI_BTYPE_LABEL, 0, version, x, y, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
- /* XXX, set internal flag - UI_SELECT */
- UI_but_flag_enable(but, 1);
- UI_block_emboss_set(block, UI_EMBOSS);
- }
-
- MEM_freeN(version);
-
-#ifdef WITH_BUILDINFO
- if (build_commit_timestamp != 0) {
- but = uiDefBut(block,
- UI_BTYPE_LABEL,
- 0,
- date_buf,
- U.dpi_fac * 502 - date_width,
- U.dpi_fac * 237,
- date_width,
- UI_UNIT_Y,
- NULL,
- 0,
- 0,
- 0,
- 0,
- NULL);
- /* XXX, set internal flag - UI_SELECT */
- UI_but_flag_enable(but, 0);
- label_delta = 12;
- }
- but = uiDefBut(block,
- UI_BTYPE_LABEL,
- 0,
- hash_buf,
- U.dpi_fac * 502 - hash_width,
- U.dpi_fac * (237 - label_delta),
- hash_width,
- UI_UNIT_Y,
- NULL,
- 0,
- 0,
- 0,
- 0,
- NULL);
- /* XXX, set internal flag - UI_SELECT */
- UI_but_flag_enable(but, 0);
-
- if (!STREQ(build_branch, "master")) {
- char branch_buf[128] = "\0";
- int branch_width;
- BLI_snprintf(branch_buf, sizeof(branch_buf), "Branch: %s", build_branch);
- branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf, sizeof(branch_buf)) +
- U.widget_unit;
- but = uiDefBut(block,
- UI_BTYPE_LABEL,
- 0,
- branch_buf,
- U.dpi_fac * 502 - branch_width,
- U.dpi_fac * (225 - label_delta),
- branch_width,
- UI_UNIT_Y,
- NULL,
- 0,
- 0,
- 0,
- 0,
- NULL);
- /* XXX, set internal flag - UI_SELECT */
- UI_but_flag_enable(but, 0);
- }
-#endif /* WITH_BUILDINFO */
+ wm_block_splash_add_labels(block, x, y);
uiLayout *layout = UI_block_layout(block,
UI_LAYOUT_VERTICAL,
UI_LAYOUT_PANEL,
- U.dpi_fac * 40,
+ U.dpi_fac * 26,
0,
U.dpi_fac * 450,
U.dpi_fac * 110,