[chronojump] First code for a chronojump dinamic logo at start



commit 1868673d15e5f9a2282703f979e8a94e2863d5de
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Mar 4 16:16:32 2020 +0100

    First code for a chronojump dinamic logo at start

 glade/app1.glade               | 68 +++++++++++++++++++++++--------
 src/Makefile.am                |  1 +
 src/gui/app1/chronojump.cs     |  7 ++++
 src/gui/app1/chronojumpLogo.cs | 90 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 150 insertions(+), 16 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 2f83797f..260c6b7b 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -782,7 +782,6 @@
                     <property name="spacing">10</property>
                     <child>
                       <widget class="GtkViewport" id="viewport_chronojump_logo">
-                        <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <child>
                           <widget class="GtkAlignment" id="alignment5">
@@ -880,6 +879,19 @@
                         <property name="position">0</property>
                       </packing>
                     </child>
+                    <child>
+                      <widget class="GtkDrawingArea" id="drawingarea_chronojump_logo">
+                        <property name="height_request">90</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <signal name="expose_event" handler="on_drawingarea_chronojump_logo_expose_event" 
swapped="no"/>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
                     <child>
                       <widget class="GtkAlignment" id="alignment_start_window">
                         <property name="visible">True</property>
@@ -2996,7 +3008,7 @@ EncoderInertialCapture</property>
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
-                        <property name="position">1</property>
+                        <property name="position">2</property>
                       </packing>
                     </child>
                   </widget>
@@ -23285,6 +23297,15 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -24780,7 +24801,6 @@ Concentric</property>
                                                       <widget class="GtkHBox" 
id="hbox_encoder_capture_actions">
                                                         <property name="visible">True</property>
                                                         <property name="can_focus">False</property>
-                                                        <property name="spacing">16</property>
                                                         <child>
                                                           <widget class="GtkHBox" 
id="hbox_encoder_capture_wait">
                                                             <property name="visible">True</property>
@@ -25106,7 +25126,12 @@ Concentric</property>
                                                           </packing>
                                                         </child>
                                                         <child>
-                                                          <widget class="GtkNotebook" 
id="notebook_encoder_signal_comment_rhythm_and_triggers">
+                                                          <widget class="GtkAlignment" id="alignment12">
+                                                            <property name="visible">True</property>
+                                                            <property name="can_focus">False</property>
+                                                            <property name="left_padding">16</property>
+                                                            <child>
+                                                            <widget class="GtkNotebook" 
id="notebook_encoder_signal_comment_rhythm_and_triggers">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="show_tabs">False</property>
@@ -25341,6 +25366,8 @@ Concentric</property>
                                                             <property name="type">tab</property>
                                                             </packing>
                                                             </child>
+                                                            </widget>
+                                                            </child>
                                                           </widget>
                                                           <packing>
                                                             <property name="expand">False</property>
@@ -25574,18 +25601,6 @@ Concentric</property>
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">6</property>
                                                             <child>
-                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
-                                                            <property name="can_focus">False</property>
-                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="pack_type">end</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_capturing">
                                                             <property name="can_focus">False</property>
                                                             <property name="spacing">4</property>
@@ -25622,6 +25637,18 @@ Concentric</property>
                                                             </packing>
                                                             </child>
                                                             <child>
+                                                            <widget class="GtkLabel" 
id="label_video_encoder_tests_will_be_filmed">
+                                                            <property name="can_focus">False</property>
+                                                            <property name="label" translatable="yes">Tests 
will be filmed</property>
+                                                            </widget>
+                                                            <packing>
+                                                            <property name="expand">False</property>
+                                                            <property name="fill">False</property>
+                                                            <property name="pack_type">end</property>
+                                                            <property name="position">0</property>
+                                                            </packing>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkHBox" 
id="hbox_video_encoder_no_capturing">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -32980,6 +33007,15 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index 3d65ca6a..d1b0bf00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,7 @@ LINK = $(REF_DEP_CHRONOJUMP)
 
 SOURCES = \
        gui/app1/chronojump.cs\
+       gui/app1/chronojumpLogo.cs\
        gui/app1/encoder.cs\
        gui/app1/icons.cs\
        gui/app1/jumpsProfile.cs\
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 497867c8..ee5652c9 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -57,6 +57,7 @@ public partial class ChronoJumpWindow
        
        [Widget] Gtk.Viewport viewport_chronojump_logo;
        [Widget] Gtk.Image image_chronojump_logo;
+       [Widget] Gtk.DrawingArea drawingarea_chronojump_logo;
 
        [Widget] Gtk.ImageMenuItem menuitem_mode_jumps_simple;
        [Widget] Gtk.ImageMenuItem menuitem_mode_jumps_reactive;
@@ -721,6 +722,9 @@ public partial class ChronoJumpWindow
                        LogB.Information("Show chronopic resgister win");
                        chronopicRegisterWin.Show();
                }
+
+               reset_chronojump_logo();
+               GLib.Timeout.Add(14, new GLib.TimeoutHandler(OnTimer_chronojump_logo));
                LogB.Information("Chronojump window started");
        }
 
@@ -3086,6 +3090,9 @@ public partial class ChronoJumpWindow
                        tempSessionName = currentSession.Name;
 
                setApp1Title(tempSessionName, Constants.Menuitem_modes.UNDEFINED);
+
+               reset_chronojump_logo();
+               GLib.Timeout.Add(14, new GLib.TimeoutHandler(OnTimer_chronojump_logo));
        }       
        
        private Constants.Menuitem_modes current_menuitem_mode;
diff --git a/src/gui/app1/chronojumpLogo.cs b/src/gui/app1/chronojumpLogo.cs
new file mode 100644
index 00000000..07359885
--- /dev/null
+++ b/src/gui/app1/chronojumpLogo.cs
@@ -0,0 +1,90 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2017-2020   Xavier de Blas <xaviblas gmail com>
+ */
+
+using Gtk;
+using Cairo;
+using System;
+
+//code based on puff
+//http://zetcode.com/gui/gtksharp/drawingII/
+
+
+public partial class ChronoJumpWindow 
+{
+       private bool timer_chronojump_logo = true;
+       private double alpha_chronojump_logo = 1.0;
+       private double size_chronojump_logo = 1.0;
+
+       void reset_chronojump_logo()
+       {
+               timer_chronojump_logo = true;
+               alpha_chronojump_logo = 1.0;
+               size_chronojump_logo = 1.0;
+       }
+
+       bool OnTimer_chronojump_logo()
+       { 
+                if (! timer_chronojump_logo)
+                       return false;
+
+               drawingarea_chronojump_logo.QueueDraw();
+                return true;
+        } 
+
+        void on_drawingarea_chronojump_logo_expose_event (object sender, ExposeEventArgs args)
+        {
+                DrawingArea area = (DrawingArea) sender;
+                Cairo.Context cr =  Gdk.CairoHelper.Create(area.GdkWindow);
+
+                int x = area.Allocation.Width / 2;
+                int y = area.Allocation.Height / 2;
+
+                cr.SetSourceRGB(.055, .118, .275);
+                cr.Paint();
+
+               //cr.SelectFontFace("Courier", FontSlant.Normal, FontWeight.Bold);
+                cr.SelectFontFace("Ubuntu", FontSlant.Normal, FontWeight.Bold);
+
+                size_chronojump_logo += 0.8;
+
+                if (size_chronojump_logo > 20) {
+                        alpha_chronojump_logo -= 0.01;
+                }
+
+                cr.SetFontSize(size_chronojump_logo);
+                cr.SetSourceRGB(1, 1, 1);
+
+                string message = "Chronojump";
+                TextExtents extents = cr.TextExtents(message);
+
+                cr.MoveTo(x - extents.Width/2, y + extents.Height/4);
+                cr.TextPath(message);
+                cr.Clip();
+                cr.Stroke();
+                cr.PaintWithAlpha(alpha_chronojump_logo);
+
+                if (alpha_chronojump_logo <= 0) {
+                        timer_chronojump_logo = false;
+                }
+
+                ((IDisposable) cr.Target).Dispose();
+                ((IDisposable) cr).Dispose();
+        }
+}


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