[Bf-blender-cvs] [a4a1074f3d2] master: UI: Add theme option for time markers line

Michael Soluyanov noreply at git.blender.org
Tue Feb 25 15:19:34 CET 2020


Commit: a4a1074f3d2411a562c5cd4d5ebee6d92a1f0a27
Author: Michael Soluyanov
Date:   Tue Feb 25 15:09:30 2020 +0100
Branches: master
https://developer.blender.org/rBa4a1074f3d2411a562c5cd4d5ebee6d92a1f0a27

UI: Add theme option for time markers line

This patch adds the ability to set colors and alpha of dashed line of
Time Markers. That way themes can avoid contrast issues and communicate
selection better. See screenshots in D6877.

Bumps subversion.

Reviewed By: William Reynish, Julian Eisel

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

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

M	release/datafiles/userdef/userdef_default_theme.c
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/editors/animation/anim_markers.c
M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index f5f16183d92..3ad2da99b9f 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -435,6 +435,8 @@ const bTheme U_theme_default = {
     .vertex_select = RGBA(0xff8500ff),
     .cframe = RGBA(0x5680c2ff),
     .time_scrub_background = RGBA(0x292929e6),
+    .time_marker_line = RGBA(0x00000060),
+    .time_marker_line_selected = RGBA(0xffffff60),
     .lastsel_point = RGBA(0xffffffff),
     .handle_auto = RGBA(0x909000ff),
     .handle_vect = RGBA(0x409030ff),
@@ -526,6 +528,8 @@ const bTheme U_theme_default = {
     .strip_select = RGBA(0xff8c00cc),
     .cframe = RGBA(0x5680c2ff),
     .time_scrub_background = RGBA(0x292929e6),
+    .time_marker_line = RGBA(0x00000060),
+    .time_marker_line_selected = RGBA(0xffffff60),
     .ds_channel = RGBA(0x0f2c4d24),
     .ds_subchannel = RGBA(0x143e6624),
     .ds_ipoline = RGBA(0x94e575cc),
@@ -580,6 +584,8 @@ const bTheme U_theme_default = {
     .strip_select = RGBA(0xff8c00ff),
     .cframe = RGBA(0x5680c2ff),
     .time_scrub_background = RGBA(0x292929e6),
+    .time_marker_line = RGBA(0x00000060),
+    .time_marker_line_selected = RGBA(0xffffff60),
     .ds_channel = RGBA(0x5a85b2ff),
     .ds_subchannel = RGBA(0x7d98b3ff),
     .keyborder = RGBA(0x000000ff),
@@ -628,6 +634,8 @@ const bTheme U_theme_default = {
     .bone_pose = RGBA(0x50c8ff50),
     .cframe = RGBA(0x5680c2ff),
     .time_scrub_background = RGBA(0x292929e6),
+    .time_marker_line = RGBA(0x00000060),
+    .time_marker_line_selected = RGBA(0xffffff60),
     .vertex_size = 3,
     .outline_width = 1,
     .facedot_size = 4,
@@ -909,6 +917,8 @@ const bTheme U_theme_default = {
     .strip_select = RGBA(0xff8c00ff),
     .cframe = RGBA(0x5680c2ff),
     .time_scrub_background = RGBA(0x292929e6),
+    .time_marker_line = RGBA(0x00000060),
+    .time_marker_line_selected = RGBA(0xffffff60),
     .handle_auto = RGBA(0x909000ff),
     .handle_align = RGBA(0x803060ff),
     .handle_sel_auto = RGBA(0xf0ff40ff),
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 09aa4ca7a6b..3e7edb175d9 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 283
-#define BLENDER_SUBVERSION 4
+#define BLENDER_SUBVERSION 5
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index d0fad1aafab..627b38a58e8 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4466,18 +4466,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
-  /**
-   * Versioning code until next subversion bump goes here.
-   *
-   * \note Be sure to check when bumping the version:
-   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
-   * - "versioning_userdef.c", #do_versions_theme
-   *
-   * \note Keep this message at the bottom of the function.
-   */
-  {
-    /* Keep this block, even when empty. */
-
+  if (!MAIN_VERSION_ATLEAST(bmain, 283, 5)) {
     /* Alembic Transform Cache changed from world to local space. */
     LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
       LISTBASE_FOREACH (bConstraint *, con, &ob->constraints) {
@@ -4513,4 +4502,17 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
       }
     }
   }
+
+  /**
+   * Versioning code until next subversion bump goes here.
+   *
+   * \note Be sure to check when bumping the version:
+   * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
+   * - "versioning_userdef.c", #do_versions_theme
+   *
+   * \note Keep this message at the bottom of the function.
+   */
+  {
+    /* Keep this block, even when empty. */
+  }
 }
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 94ee8d46675..f70988c9277 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -175,6 +175,19 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
     FROM_DEFAULT_V4_UCHAR(space_info.info_operator_text);
   }
 
+  if (!USER_VERSION_ATLEAST(283, 5)) {
+    FROM_DEFAULT_V4_UCHAR(space_graph.time_marker_line);
+    FROM_DEFAULT_V4_UCHAR(space_action.time_marker_line);
+    FROM_DEFAULT_V4_UCHAR(space_nla.time_marker_line);
+    FROM_DEFAULT_V4_UCHAR(space_sequencer.time_marker_line);
+    FROM_DEFAULT_V4_UCHAR(space_clip.time_marker_line);
+    FROM_DEFAULT_V4_UCHAR(space_graph.time_marker_line_selected);
+    FROM_DEFAULT_V4_UCHAR(space_action.time_marker_line_selected);
+    FROM_DEFAULT_V4_UCHAR(space_nla.time_marker_line_selected);
+    FROM_DEFAULT_V4_UCHAR(space_sequencer.time_marker_line_selected);
+    FROM_DEFAULT_V4_UCHAR(space_clip.time_marker_line_selected);
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 8d3c932cbe6..4f1cab40463 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -416,41 +416,44 @@ void debug_markers_print_list(ListBase *markers)
 
 /* ************* Marker Drawing ************ */
 
-static void marker_color_get(TimeMarker *marker, unsigned char *color)
+static void marker_color_get(const TimeMarker *marker, uchar *r_text_color, uchar *r_line_color)
 {
   if (marker->flag & SELECT) {
-    UI_GetThemeColor4ubv(TH_TEXT_HI, color);
+    UI_GetThemeColor4ubv(TH_TEXT_HI, r_text_color);
+    UI_GetThemeColor4ubv(TH_TIME_MARKER_LINE_SELECTED, r_line_color);
   }
   else {
-    UI_GetThemeColor4ubv(TH_TEXT, color);
+    UI_GetThemeColor4ubv(TH_TEXT, r_text_color);
+    UI_GetThemeColor4ubv(TH_TIME_MARKER_LINE, r_line_color);
   }
 }
 
-static void draw_marker_name(const uiFontStyle *fstyle,
+static void draw_marker_name(const uchar *text_color,
+                             const uiFontStyle *fstyle,
                              TimeMarker *marker,
                              float marker_x,
                              float text_y)
 {
-  unsigned char text_color[4];
-  marker_color_get(marker, text_color);
-
   const char *name = marker->name;
+  uchar final_text_color[4];
+
+  copy_v4_v4_uchar(final_text_color, text_color);
 
 #ifdef DURIAN_CAMERA_SWITCH
   if (marker->camera) {
     Object *camera = marker->camera;
     name = camera->id.name + 2;
     if (camera->restrictflag & OB_RESTRICT_RENDER) {
-      text_color[3] = 100;
+      final_text_color[3] = 100;
     }
   }
 #endif
 
   int name_x = marker_x + UI_DPI_ICON_SIZE * 0.6;
-  UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, text_color);
+  UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, final_text_color);
 }
 
-static void draw_marker_line(const float color[4], int xpos, int ymin, int ymax)
+static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax)
 {
   GPUVertFormat *format = immVertexFormat();
   uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -461,7 +464,7 @@ static void draw_marker_line(const float color[4], int xpos, int ymin, int ymax)
   GPU_viewport_size_get_f(viewport_size);
   immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
-  immUniformColor4fv(color);
+  immUniformColor4ubv(color);
   immUniform1i("colors_len", 0); /* "simple" mode */
   immUniform1f("dash_width", 6.0f);
   immUniform1f("dash_factor", 0.5f);
@@ -493,19 +496,15 @@ static int marker_get_icon_id(TimeMarker *marker, int flag)
 static void draw_marker(
     const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height)
 {
+  uchar line_color[4], text_color[4];
+
+  marker_color_get(marker, text_color, line_color);
+
   GPU_blend(true);
   GPU_blend_set_func_separate(
       GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
-  float color[4];
-  if (marker->flag & SELECT) {
-    copy_v4_fl4(color, 1.0f, 1.0f, 1.0f, 0.38f);
-  }
-  else {
-    copy_v4_fl4(color, 0.0f, 0.0f, 0.0f, 0.38f);
-  }
-
-  draw_marker_line(color, xpos, UI_DPI_FAC * 20, region_height);
+  draw_marker_line(line_color, xpos, UI_DPI_FAC * 20, region_height);
 
   int icon_id = marker_get_icon_id(marker, flag);
   UI_icon_draw(xpos - 0.55f * UI_DPI_ICON_SIZE, UI_DPI_FAC * 18, icon_id);
@@ -518,7 +517,7 @@ static void draw_marker(
   if ((marker->flag & SELECT) || (cfra - 4 <= marker->frame && marker->frame <= cfra)) {
     name_y += UI_DPI_FAC * 10;
   }
-  draw_marker_name(fstyle, marker, xpos, name_y);
+  draw_marker_name(text_color, fstyle, marker, xpos, name_y);
 }
 
 static void draw_markers_background(rctf *rect)
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index e4b11977214..10ca89c8222 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -108,6 +108,8 @@ typedef enum ThemeColorID {
   TH_FACEDOT_SIZE,
   TH_CFRAME,
   TH_TIME_SCRUB_BACKGROUND,
+  TH_TIME_MARKER_LINE,
+  TH_TIME_MARKER_LINE_SELECTED,
   TH_TIME_KEYFRAME,
   TH_TIME_GP_KEYFRAME,
   TH_NURB_ULINE,
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 4a6ce59de9b..cdbd049346e 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -311,6 +311,12 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
         case TH_TIME_SCRUB_BACKGROUND:
           cp = ts->time_scrub_background;
           break;
+        case TH_TIME_MARKER_LINE:
+          cp = ts->time_marker_line;
+      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list