[chronojump] Logos transparent or not depending on background



commit 10aa73e4ee0ca3ba708b4fcbd9e9d2b61981bd6b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Apr 14 12:21:37 2020 +0200

    Logos transparent or not depending on background

 glade/app1.glade           | 61 +++++++++++++++++++++++++++++++++++++++++-----
 src/gui/app1/chronojump.cs |  4 +++
 src/gui/app1/icons.cs      | 14 +++++++++--
 src/gui/app1/menu.cs       | 23 ++++++++++++++++-
 src/gui/app1/menu_tiny.cs  | 12 ++++++++-
 src/utilGtk.cs             | 18 ++++++++++++++
 6 files changed, 122 insertions(+), 10 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 26a3ad39..4039c6cc 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1150,8 +1150,7 @@
                                       </packing>
                                     </child>
                                     <child>
-                                      <widget class="GtkFrame" id="frame17">
-                                        <property name="visible">True</property>
+                                      <widget class="GtkFrame" id="frame_image_logo_icon">
                                         <property name="can_focus">False</property>
                                         <property name="label_xalign">0</property>
                                         <property name="label_yalign">1</property>
@@ -1186,6 +1185,21 @@
                                         <property name="position">5</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <widget class="GtkImage" id="image_logo_icon_transp">
+                                        <property name="width_request">48</property>
+                                        <property name="height_request">48</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="stock">gtk-missing-image</property>
+                                        <property name="icon-size">2</property>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="pack_type">end</property>
+                                        <property name="position">6</property>
+                                      </packing>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -1221,7 +1235,7 @@
                                                 <property name="left_padding">3</property>
                                                 <property name="right_padding">2</property>
                                                 <child>
-                                                  <widget class="GtkHBox" id="hbox367">
+                                                  <widget class="GtkHBox" 
id="hbox_radio_show_menu_and_persons">
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
                                                     <property name="spacing">4</property>
@@ -6822,8 +6836,7 @@ EncoderInertialCapture</property>
                                                   </packing>
                                                 </child>
                                                 <child>
-                                                  <widget class="GtkFrame" id="frame18">
-                                                    <property name="visible">True</property>
+                                                  <widget class="GtkFrame" id="frame_logo_contacts">
                                                     <property name="can_focus">False</property>
                                                     <property name="label_xalign">0</property>
                                                     <property name="label_yalign">1</property>
@@ -6833,11 +6846,23 @@ EncoderInertialCapture</property>
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
                                                         <child>
-                                                          <widget class="GtkImage" id="image_logo_contacts">
+                                                          <widget class="GtkHBox" id="hbox403">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="border_width">2</property>
+                                                            <child>
+                                                            <widget class="GtkImage" 
id="image_logo_contacts">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
                                                             <property 
name="stock">gtk-missing-image</property>
                                                             <property name="icon-size">2</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">True</property>
+                                                            <property name="fill">True</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
                                                           </widget>
                                                         </child>
                                                       </widget>
@@ -6856,6 +6881,18 @@ EncoderInertialCapture</property>
                                                     <property name="position">3</property>
                                                   </packing>
                                                 </child>
+                                                <child>
+                                                  <widget class="GtkImage" id="image_logo_contacts_transp">
+                                                    <property name="can_focus">False</property>
+                                                    <property name="stock">gtk-missing-image</property>
+                                                  </widget>
+                                                  <packing>
+                                                    <property name="expand">False</property>
+                                                    <property name="fill">False</property>
+                                                    <property name="pack_type">end</property>
+                                                    <property name="position">4</property>
+                                                  </packing>
+                                                </child>
                                               </widget>
                                               <packing>
                                                 <property name="expand">False</property>
@@ -24866,6 +24903,12 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -34940,6 +34983,12 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 88513431..f67207d1 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -2528,6 +2528,10 @@ public partial class ChronoJumpWindow
 
                if( ! configChronojump.PersonWinHide) {
                        alignment_buttons_menu_and_persons.Visible = true;
+                       radio_show_menu_and_persons_adjust_height(
+                               UtilGtk.ColorIsOkWithLogoTransparent(UtilGtk.ColorParse(
+                                               preferences.colorBackgroundString)));
+
                        //on_radio_show_persons_clicked (new object (), new EventArgs ());
                        radio_show_persons.Active = true;
                }
diff --git a/src/gui/app1/icons.cs b/src/gui/app1/icons.cs
index c79447b8..d5b0f79e 100644
--- a/src/gui/app1/icons.cs
+++ b/src/gui/app1/icons.cs
@@ -27,7 +27,9 @@ using Glade;
 public partial class ChronoJumpWindow 
 {
        [Widget] Gtk.Image image_mode_main_menu;
+       [Widget] Gtk.Frame frame_image_logo_icon;
        [Widget] Gtk.Image image_logo_icon;
+       [Widget] Gtk.Image image_logo_icon_transp;
        //[Widget] Gtk.Image image_home;
        //[Widget] Gtk.Image image_home1;
        [Widget] Gtk.Image image_settings2;
@@ -84,8 +86,11 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Image image_add_test5;
        [Widget] Gtk.Image image_test_inspect;
        [Widget] Gtk.Image image_test_inspect1;
+
        [Widget] Gtk.Image image_logo_contacts;
+       [Widget] Gtk.Image image_logo_contacts_transp;
        [Widget] Gtk.Image image_logo_encoder;
+       [Widget] Gtk.Frame frame_logo_contacts;
        [Widget] Gtk.Viewport viewport_image_logo_contacts;
        [Widget] Gtk.Viewport viewport_image_logo_encoder;
 
@@ -513,15 +518,20 @@ public partial class ChronoJumpWindow
                 * <------ end of material design icons
                 */
 
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo);
-               image_logo_contacts.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo); //44 px height
                image_logo_encoder.Pixbuf = pixbuf;
 
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogoTransparent40h); 
//40 px heigh
+               image_logo_contacts.Pixbuf = pixbuf;
+               image_logo_contacts_transp.Pixbuf = pixbuf;
+
                UtilGtk.ViewportColor(viewport_image_logo_contacts, UtilGtk.BLUE_CHRONOJUMP);
                UtilGtk.ViewportColor(viewport_image_logo_encoder, UtilGtk.BLUE_CHRONOJUMP);
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameIcon);
                image_logo_icon.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameIconTransp);
+               image_logo_icon_transp.Pixbuf = pixbuf;
 
                pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "selector-jumps.png");
                image_selector_start_jumps.Pixbuf = pixbuf;
diff --git a/src/gui/app1/menu.cs b/src/gui/app1/menu.cs
index 7c084054..95f4a271 100644
--- a/src/gui/app1/menu.cs
+++ b/src/gui/app1/menu.cs
@@ -32,6 +32,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Arrow arrow_menu_show_session_down;
        [Widget] Gtk.Arrow arrow_menu_show_help_up;
        [Widget] Gtk.Arrow arrow_menu_show_help_down;
+       [Widget] Gtk.HBox hbox_radio_show_menu_and_persons;
        [Widget] Gtk.RadioButton radio_show_menu;
        [Widget] Gtk.RadioButton radio_show_persons;
        [Widget] Gtk.HPaned hpaned_contacts_main;
@@ -180,10 +181,30 @@ public partial class ChronoJumpWindow
 
                viewport_menu_top.SetSizeRequest(maxWidth, -1); //-1 is height
 
-               viewport_image_logo_contacts.Visible = true;
+               if(UtilGtk.ColorIsOkWithLogoTransparent 
(UtilGtk.ColorParse(preferences.colorBackgroundString)))
+               {
+                       frame_logo_contacts.Visible = false;
+                       image_logo_contacts_transp.Visible = true;
+                       radio_show_menu_and_persons_adjust_height(true);
+               } else {
+                       frame_logo_contacts.Visible = true;
+                       image_logo_contacts_transp.Visible = false;
+                       radio_show_menu_and_persons_adjust_height(false);
+               }
+
                viewport_image_logo_encoder.Visible = true;
        }
 
+       private void radio_show_menu_and_persons_adjust_height(bool toTransparentImage)
+       {
+               if(toTransparentImage)
+                       hbox_radio_show_menu_and_persons.SetSizeRequest
+                               (-1, image_logo_contacts_transp.SizeRequest().Height);
+               else
+                       hbox_radio_show_menu_and_persons.SetSizeRequest
+                               (-1, frame_logo_contacts.SizeRequest().Height);
+       }
+
        private void menuSetTextAndIcons ()
        {
                //icons
diff --git a/src/gui/app1/menu_tiny.cs b/src/gui/app1/menu_tiny.cs
index 1df3eadc..4dec8119 100644
--- a/src/gui/app1/menu_tiny.cs
+++ b/src/gui/app1/menu_tiny.cs
@@ -76,8 +76,18 @@ public partial class ChronoJumpWindow
                        check_menu_help1.Active = false;
                alignment_menu_help_options1.Visible = false;
 
-               viewport_image_logo_contacts.Visible = false;
+               image_logo_contacts_transp.Visible = false;
+               frame_logo_contacts.Visible = false;
                viewport_image_logo_encoder.Visible = false;
+
+               if(UtilGtk.ColorIsOkWithLogoTransparent 
(UtilGtk.ColorParse(preferences.colorBackgroundString)))
+               {
+                       image_logo_icon_transp.Visible = true;
+                       frame_image_logo_icon.Visible = false;
+               } else {
+                       image_logo_icon_transp.Visible = false;
+                       frame_image_logo_icon.Visible = true;
+               }
        }
 
        private void menuTinySetColors ()
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 5de9f4d7..37ab07cd 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -508,6 +508,24 @@ public class UtilGtk
                return ColorIsDark(ColorParse(colorString));
        }
 
+       //if color is too white or too yellow, it will not be ok
+       public static bool ColorIsOkWithLogoTransparent (Gdk.Color color)
+       {
+               return ( ! colorIsQuiteClear(color) && ! colorIsYellow(color) );
+       }
+
+       //if is very clear it does not show ok the yellow of Boscosystem letters (also if it is clear blue)
+       private static bool colorIsQuiteClear (Gdk.Color color)
+       {
+               return (color.Red > 150 * 256 && color.Green > 150 * 256  && color.Blue > 150 * 256);
+       }
+
+       //yellow is red + green
+       private static bool colorIsYellow (Gdk.Color color)
+       {
+               return (color.Red > 200 * 256 && color.Green > 200 * 256 && color.Blue < 50 * 256);
+       }
+
        public static Gdk.Color GetBackgroundColorSelected() {
                Gtk.Style regularLabel = Gtk.Rc.GetStyle (new Gtk.Label());
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]