[Bf-blender-cvs] [e287122af6c] master: UI: improve label text colors in save and security popups

Yevgeny Makarov noreply at git.blender.org
Fri Feb 28 13:59:41 CET 2020


Commit: e287122af6ca2bb4b60ac938b5ac8a3f1354cad9
Author: Yevgeny Makarov
Date:   Fri Feb 28 13:51:40 2020 +0100
Branches: master
https://developer.blender.org/rBe287122af6ca2bb4b60ac938b5ac8a3f1354cad9

UI: improve label text colors in save and security popups

This adds a utility functions to draw a label highlighted or in red.

Differential Revision: https://developer.blender.org/D6934

===================================================================

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 74ecff22243..554a166b2ce 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2283,6 +2283,8 @@ void uiItemsFullEnumO_items(uiLayout *layout,
                             int totitem);
 
 void uiItemL(uiLayout *layout, const char *name, int icon); /* label */
+void uiItemL_ex(
+    uiLayout *layout, const char *name, int icon, const bool highlight, const bool redalert);
 uiLayout *uiItemL_respect_property_split(uiLayout *layout, const char *text, int icon);
 /* label icon for dragging */
 void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int icon);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 64c0e11976b..91b56177eac 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2957,6 +2957,21 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
   return but;
 }
 
+void uiItemL_ex(
+    uiLayout *layout, const char *name, int icon, const bool highlight, const bool redalert)
+{
+  uiBut *but = uiItemL_(layout, name, icon);
+
+  if (highlight) {
+    /* TODO: add another flag for this. */
+    UI_but_flag_enable(but, UI_SELECT_DRAW);
+  }
+
+  if (redalert) {
+    UI_but_flag_enable(but, UI_BUT_REDALERT);
+  }
+}
+
 void uiItemL(uiLayout *layout, const char *name, int icon)
 {
   uiItemL_(layout, name, icon);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 1775d9064d9..dae6f62319d 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2828,13 +2828,13 @@ static uiBlock *block_create_autorun_warning(struct bContext *C,
 
   /* Text and some vertical space */
   uiLayout *col = uiLayoutColumn(layout, true);
-  uiItemL(col,
-          TIP_("For security reasons, automatic execution of Python scripts in this file was "
-               "disabled:"),
-          ICON_ERROR);
-  uiLayout *sub = uiLayoutRow(col, true);
-  uiLayoutSetRedAlert(sub, true);
-  uiItemL(sub, G.autoexec_fail, ICON_BLANK1);
+  uiItemL_ex(col,
+             TIP_("For security reasons, automatic execution of Python scripts "
+                  "in this file was disabled:"),
+             ICON_ERROR,
+             true,
+             false);
+  uiItemL_ex(col, G.autoexec_fail, ICON_BLANK1, false, true);
   uiItemL(col, TIP_("This may lead to unexpected behavior"), ICON_BLANK1);
 
   uiItemS(layout);
@@ -3085,7 +3085,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi
                                      style);
 
   /* Title */
-  uiItemL(layout, title, ICON_ERROR);
+  uiItemL_ex(layout, title, ICON_ERROR, true, false);
 
   /* Image Saving */
   ReportList reports;
@@ -3093,9 +3093,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi
   uint modified_images_count = ED_image_save_all_modified_info(C, &reports);
 
   LISTBASE_FOREACH (Report *, report, &reports.list) {
-    uiLayout *row = uiLayoutRow(layout, false);
-    uiLayoutSetRedAlert(row, true);
-    uiItemL(row, report->message, ICON_CANCEL);
+    uiItemL_ex(layout, report->message, ICON_CANCEL, false, true);
   }
 
   if (modified_images_count > 0) {



More information about the Bf-blender-cvs mailing list