billiob pushed a commit to branch master.

http://git.enlightenment.org/apps/terminology.git/commit/?id=bb968b968e48813f750cc74711eb8572e5446800

commit bb968b968e48813f750cc74711eb8572e5446800
Author: Boris Faure <bill...@gmail.com>
Date:   Sat Nov 11 20:12:56 2017 +0100

    be able to configure shine level on the default theme
    
    Was asked about it too many times, so here it is :)
---
 ChangeLog.theme         |   8 +++-
 data/themes/default.edc | 102 +++++++++++++++++++++++++++++++++++++-----------
 src/bin/config.c        |  12 +++++-
 src/bin/config.h        |   1 +
 src/bin/options_theme.c |  50 +++++++++++++++++++++++-
 src/bin/win.c           |  76 +++++++++++++++++++++++++-----------
 src/bin/win.h           |   2 +
 7 files changed, 201 insertions(+), 50 deletions(-)

diff --git a/ChangeLog.theme b/ChangeLog.theme
index 1791a2f..49288df 100644
--- a/ChangeLog.theme
+++ b/ChangeLog.theme
@@ -1,7 +1,13 @@
 =================
-Terminology 0.9.1
+Terminology 1.2.0
 =================
 
+Changes since 1.1.1:
+--------------------
+
+  * In group "terminology/background", "message" with id 2 requires an INT to
+  specify the amount of shine
+
 Changes since 0.9.1:
 --------------------
 
diff --git a/data/themes/default.edc b/data/themes/default.edc
index 113ecda..c794f28 100644
--- a/data/themes/default.edc
+++ b/data/themes/default.edc
@@ -142,16 +142,18 @@ collections {
    group { name: "terminology/core";
       script {
          public message(Msg_Type:type, id, ...) {
-            new r, g, b, a, v;
-
-            if ((type != MSG_INT) || (id != 1)) return;
 
-            v = (getarg(2) * 255) / 100;
+            if (type != MSG_INT)
+                return;
+            if (id == 1) { // fade
+                new r, g, b, a, v;
+                v = (getarg(2) * 255) / 100;
 
-            custom_state(PART:"fade", "default", 0.0);
-            get_state_val(PART:"fade", STATE_COLOR, r, g, b, a);
-            set_state_val(PART:"fade", STATE_COLOR, r, g, b, v);
-            set_state(PART:"fade", "custom", 0.0);
+                custom_state(PART:"fade", "default", 0.0);
+                get_state_val(PART:"fade", STATE_COLOR, r, g, b, a);
+                set_state_val(PART:"fade", STATE_COLOR, r, g, b, v);
+                set_state(PART:"fade", "custom", 0.0);
+            }
          }
       }
       parts {
@@ -279,19 +281,33 @@ collections {
          public message(Msg_Type:type, id, ...) {
             new r, g, b, a, v;
 
-            if ((type != MSG_INT) || (id != 1)) return;
+            if (type != MSG_INT)
+              return;
+            if (id == 1) {
+                v = (getarg(2) * 255) / 100;
 
-            v = (getarg(2) * 255) / 100;
+                custom_state(PART:"shadow", "default", 0.0);
+                get_state_val(PART:"shadow", STATE_COLOR, r, g, b, a);
+                set_state_val(PART:"shadow", STATE_COLOR, r, g, b, v);
+                set_state(PART:"shadow", "custom", 0.0);
 
-            custom_state(PART:"shadow", "default", 0.0);
-            get_state_val(PART:"shadow", STATE_COLOR, r, g, b, a);
-            set_state_val(PART:"shadow", STATE_COLOR, r, g, b, v);
-            set_state(PART:"shadow", "custom", 0.0);
+                custom_state(PART:"base", "default", 0.0);
+                get_state_val(PART:"base", STATE_COLOR, r, g, b, a);
+                set_state_val(PART:"base", STATE_COLOR, r, g, b, v);
+                set_state(PART:"base", "custom", 0.0);
+            } else if (id == 2) {
+                v = getarg(2);
+
+                custom_state(PART:"shine_focused", "focused", 0.0);
+                get_state_val(PART:"shine_focused", STATE_COLOR, r, g, b, a);
+                set_state_val(PART:"shine_focused", STATE_COLOR, r, g, b, v);
+                set_state(PART:"shine_focused", "custom", 0.0);
 
-            custom_state(PART:"base", "default", 0.0);
-            get_state_val(PART:"base", STATE_COLOR, r, g, b, a);
-            set_state_val(PART:"base", STATE_COLOR, r, g, b, v);
-            set_state(PART:"base", "custom", 0.0);
+                custom_state(PART:"shine_unfocused", "default", 0.0);
+                get_state_val(PART:"shine_unfocused", STATE_COLOR, r, g, b, a);
+                set_state_val(PART:"shine_unfocused", STATE_COLOR, r, g, b, 
v/8);
+                set_state(PART:"shine_unfocused", "custom", 0.0);
+            }
          }
       }
       parts {
@@ -697,7 +713,7 @@ collections {
                visible: 0;
             }
          }
-         part { name: "shine";
+         part { name: "shine_focused";
             mouse_events: 0;
             description { state: "default" 0.0;
                rel1.offset: 0 0;
@@ -707,13 +723,30 @@ collections {
                align: 0.5 0.0;
                aspect: (256/120) (256/120);
                aspect_preference: HORIZONTAL;
-               color: 255 255 255 64;
+               color: 255 255 255 0;
             }
             description { state: "focused" 0.0;
                inherit: "default" 0.0;
                color: 255 255 255 255;
             }
          }
+         part { name: "shine_unfocused";
+            mouse_events: 0;
+            description { state: "default" 0.0;
+               rel1.offset: 0 0;
+               rel2.offset: -1 -1;
+               image.normal: "bg_shine";
+               fill.smooth: 0;
+               align: 0.5 0.0;
+               aspect: (256/120) (256/120);
+               aspect_preference: HORIZONTAL;
+               color: 255 255 255 64;
+            }
+            description { state: "focused" 0.0;
+               inherit: "default" 0.0;
+               color: 255 255 255 0;
+            }
+         }
          part { name: "glintclip"; type: RECT;
             description { state: "default" 0.0;
             }
@@ -1005,19 +1038,31 @@ collections {
             action: STATE_SET "focused" 0.0;
             target: "glint";
             target: "glow";
-            target: "shine";
+            target: "shine_unfocused";
+            target: "shine_focused";
             after: "focus_in2";
+#if (EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 9)
+            sequence {
+               action: STATE_SET "custom" 0.0;
+               target: "shine_focused";
+            }
+#endif
          }
          program {
             signal: "focused,set"; source: "terminology";
             action: STATE_SET "focused" 0.0;
             target: "glint";
-            target: "shine";
+            target: "shine_focused";
+            target: "shine_unfocused";
 #if (EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 9)
             sequence {
                action: STATE_SET "focused2" 0.0;
                target: "glow";
             }
+            sequence {
+               action: STATE_SET "custom" 0.0;
+               target: "shine_focused";
+            }
 #endif
          }
          program { name: "focus_in2";
@@ -1030,7 +1075,18 @@ collections {
             action: STATE_SET "default" 0.0;
             target: "glint";
             target: "glow";
-            target: "shine";
+            target: "shine_focused";
+            target: "shine_unfocused";
+#if (EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 9)
+            sequence {
+               action: STATE_SET "focused2" 0.0;
+               target: "glow";
+            }
+            sequence {
+               action: STATE_SET "custom" 0.0;
+               target: "shine_unfocused";
+            }
+#endif
          }
 
          ////////////////////////////////////////////////////////////////////
diff --git a/src/bin/config.c b/src/bin/config.c
index 56a34b2..9138066 100644
--- a/src/bin/config.c
+++ b/src/bin/config.c
@@ -7,7 +7,7 @@
 #include "col.h"
 #include "utils.h"
 
-#define CONF_VER 16
+#define CONF_VER 17
 
 #define LIM(v, min, max) {if (v >= max) v = max; else if (v <= min) v = min;}
 
@@ -172,6 +172,8 @@ config_init(void)
      (edd_base, Config, "ty_escapes", ty_escapes, EET_T_UCHAR);
    EET_DATA_DESCRIPTOR_ADD_BASIC
      (edd_base, Config, "changedir_to_current", changedir_to_current, 
EET_T_UCHAR);
+   EET_DATA_DESCRIPTOR_ADD_BASIC
+     (edd_base, Config, "shine", shine, EET_T_INT);
 }
 
 void
@@ -275,6 +277,7 @@ config_sync(const Config *config_src, Config *config)
    config->mv_always_show = config_src->mv_always_show;
    config->ty_escapes = config_src->ty_escapes;
    config->changedir_to_current = config_src->changedir_to_current;
+   config->shine = config_src->shine;
 }
 
 static void
@@ -541,6 +544,7 @@ config_new(void)
                }
           }
         _add_default_keys(config);
+        config->shine = 255;
      }
    return config;
 }
@@ -648,7 +652,10 @@ config_load(const char *key)
                   _add_key(config, "Right", 0, 1, 0, 0, "term_right");
                   EINA_FALLTHROUGH;
                   /*pass through*/
-                case CONF_VER: /* 16 */
+                case 16:
+                  config->shine = 255;
+                  /*pass through*/
+                case CONF_VER: /* 17 */
                   config->version = CONF_VER;
                   break;
                 default:
@@ -747,6 +754,7 @@ config_fork(const Config *config)
    CPY(mv_always_show);
    CPY(ty_escapes);
    CPY(changedir_to_current);
+   CPY(shine);
 
    EINA_LIST_FOREACH(config->keys, l, key)
      {
diff --git a/src/bin/config.h b/src/bin/config.h
index cef03fc..21e1bd7 100644
--- a/src/bin/config.h
+++ b/src/bin/config.h
@@ -52,6 +52,7 @@ struct _Config
    double            tab_zoom;
    int               vidmod;
    int               opacity;
+   int               shine;
    int               cg_width;
    int               cg_height;
    Eina_Bool         jump_on_keypress;
diff --git a/src/bin/options_theme.c b/src/bin/options_theme.c
index 19ab60d..f3838c1 100644
--- a/src/bin/options_theme.c
+++ b/src/bin/options_theme.c
@@ -21,6 +21,29 @@ struct _Theme
 static Evas_Object *op_themelist;
 static Eina_List *themes = NULL;
 static Ecore_Timer *seltimer = NULL;
+static Evas_Object *op_shine_slider = NULL;
+
+static void
+_cb_op_shine_sel(void *data,
+                 Evas_Object *obj,
+                 void *_event EINA_UNUSED)
+{
+   Evas_Object *termio_obj = data;
+   Config *config = termio_config_get(termio_obj);
+   Term *term = termio_term_get(termio_obj);
+   Win *wn = term_win_get(term);
+   int shine = elm_slider_value_get(obj);
+   Eina_List *l, *wn_list;
+
+   if (config->shine == shine)
+       return;
+
+   wn_list = win_terms_get(wn);
+   EINA_LIST_FOREACH(wn_list, l, term)
+     {
+        term_apply_shine(term, shine);
+     }
+}
 
 static char *
 _cb_op_theme_text_get(void *data,
@@ -121,10 +144,35 @@ options_theme(Evas_Object *opbox, Evas_Object *term)
    box = o = elm_box_add(opbox);
    evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   elm_box_horizontal_set(o, EINA_TRUE);
+   elm_box_horizontal_set(o, EINA_FALSE);
    elm_object_content_set(fr, o);
    evas_object_show(o);
 
+   o = elm_label_add(opbox);
+   evas_object_size_hint_weight_set(o, 0.0, 0.0);
+   evas_object_size_hint_align_set(o, 0.0, 0.5);
+   elm_object_text_set(o, _("Shine:"));
+   elm_box_pack_end(box, o);
+   evas_object_show(o);
+
+   op_shine_slider = o = elm_slider_add(opbox);
+   evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
+   elm_slider_span_size_set(o, 40);
+   elm_slider_unit_format_set(o, "%1.0f");
+   elm_slider_indicator_format_set(o, "%1.0f");
+   elm_slider_min_max_set(o, 0, 255);
+#if (ECORE_VERSION_MAJOR > 1) || (ECORE_VERSION_MINOR >= 8)
+   elm_slider_step_set(o, 1);
+#endif
+   elm_slider_value_set(o, config->shine);
+   elm_box_pack_end(box, o);
+   evas_object_show(o);
+
+   evas_object_smart_callback_add(o, "delay,changed",
+                                  _cb_op_shine_sel, term);
+
+
    it_class = elm_gengrid_item_class_new();
    it_class->item_style = "thumb";
    it_class->func.text_get = _cb_op_theme_text_get;
diff --git a/src/bin/win.c b/src/bin/win.c
index 1b8315a..6c0cb50 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -181,6 +181,8 @@ static void _tab_new_cb(void *data, Evas_Object *_obj 
EINA_UNUSED, void *_event_
 static Tab_Item* tab_item_new(Tabs *tabs, Term_Container *child);
 static void _tabs_refresh(Tabs *tabs);
 static void _term_tabregion_free(Term *term);
+static void _set_trans(Config *config, Evas_Object *bg, Evas_Object *base);
+static void _set_shine(Config *config, Evas_Object *bg);
 
 
 /* {{{ Solo */
@@ -2104,7 +2106,6 @@ _cb_tab_selector_show(Tabs *tabs, Tab_Item *to_item)
    Eina_List *l;
    int count;
    double z;
-   Edje_Message_Int msg;
    Win *wn = tc->wn;
    Tab_Item *tab_item;
    Evas_Object *o;
@@ -2122,12 +2123,8 @@ _cb_tab_selector_show(Tabs *tabs, Tab_Item *to_item)
    evas_object_geometry_set(tabs->selector_bg, x, y, w, h);
    evas_object_hide(o);
 
-   if (wn->config->translucent)
-     msg.val = wn->config->opacity;
-   else
-     msg.val = 100;
-
-   edje_object_message_send(tabs->selector_bg, EDJE_MESSAGE_INT, 1, &msg);
+    _set_trans(wn->config, tabs->selector_bg, NULL);
+    _set_shine(wn->config, tabs->selector_bg);
    edje_object_signal_emit(tabs->selector_bg, "begin", "terminology");
 
    tab_item = tabs->current;
@@ -3009,6 +3006,50 @@ _tabs_new(Term_Container *child, Term_Container *parent)
 /* {{{ Term */
 
 static void
+_set_shine(Config *config, Evas_Object *bg)
+{
+   Edje_Message_Int msg;
+
+   if (config)
+     msg.val = config->shine;
+   else
+     msg.val = 255;
+
+   if (bg)
+       edje_object_message_send(bg, EDJE_MESSAGE_INT, 2, &msg);
+}
+
+void
+term_apply_shine(Term *term, int shine)
+{
+   Config *config = term->config;
+
+   if (config->shine != shine)
+     {
+        config->shine = shine;
+        _set_shine(config, term->bg);
+        config_save(config, NULL);
+     }
+}
+
+
+static void
+_set_trans(Config *config, Evas_Object *bg, Evas_Object *base)
+{
+   Edje_Message_Int msg;
+
+   if (config && config->translucent)
+     msg.val = config->opacity;
+   else
+     msg.val = 100;
+
+   if (bg)
+       edje_object_message_send(bg, EDJE_MESSAGE_INT, 1, &msg);
+   if (base)
+       edje_object_message_send(base, EDJE_MESSAGE_INT, 1, &msg);
+}
+
+static void
 _term_config_set(Term *term, Config *config)
 {
    Config *old_config = term->config;
@@ -4244,18 +4285,12 @@ _cb_tabcount_next(void *data,
    _cb_next(data, NULL, NULL);
 }
 
+
 static void
 _term_bg_config(Term *term)
 {
-   Edje_Message_Int msg;
-
-   if (term->config->translucent)
-     msg.val = term->config->opacity;
-   else
-     msg.val = 100;
-
-   edje_object_message_send(term->bg, EDJE_MESSAGE_INT, 1, &msg);
-   edje_object_message_send(term->base, EDJE_MESSAGE_INT, 1, &msg);
+    _set_trans(term->config, term->bg, term->base);
+    _set_shine(term->config, term->bg);
 
    termio_theme_set(term->termio, term->bg);
    edje_object_signal_callback_add(term->bg, "popmedia,done", "terminology",
@@ -4490,7 +4525,6 @@ term_new(Win *wn, Config *config, const char *cmd,
    Term *term;
    Evas_Object *o;
    Evas *canvas = evas_object_evas_get(wn->win);
-   Edje_Message_Int msg;
 
    term = calloc(1, sizeof(Term));
    if (!term) return NULL;
@@ -4541,16 +4575,12 @@ term_new(Win *wn, Config *config, const char *cmd,
 
    _term_tabregion_setup(term);
 
-   if (term->config->translucent)
-     msg.val = term->config->opacity;
-   else
-     msg.val = 100;
 
    if (term->config->mv_always_show)
      term->miniview_shown = EINA_TRUE;
 
-   edje_object_message_send(term->bg, EDJE_MESSAGE_INT, 1, &msg);
-   edje_object_message_send(term->base, EDJE_MESSAGE_INT, 1, &msg);
+    _set_trans(term->config, term->bg, term->base);
+    _set_shine(term->config, term->bg);
 
    term->termio = o = termio_add(wn->win, config, cmd, login_shell, cd,
                                  size_w, size_h, term, title);
diff --git a/src/bin/win.h b/src/bin/win.h
index ef9f311..c646f90 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -74,5 +74,7 @@ typedef Eina_Bool (*For_Each_Term)(Term *term, void *data);
 Eina_Bool
 for_each_term_do(Win *wn, For_Each_Term cb, void *data);
 
+void
+term_apply_shine(Term *term, int shine);
 
 #endif

-- 


Reply via email to