push2: splash screen
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 19 Jun 2016 16:26:28 +0000 (12:26 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Sep 2016 19:59:29 +0000 (14:59 -0500)
Coded while the paint prep dries in the sun

libs/surfaces/push2/push2.cc
libs/surfaces/push2/push2.h
libs/surfaces/push2/wscript

index 16254f62159b3bb257c0122a0921528c8cdccdb0..31734441843f139342b04a2c5ddf34f3dfe03f66 100644 (file)
@@ -24,6 +24,8 @@
 #include "pbd/convert.h"
 #include "pbd/debug.h"
 #include "pbd/failed_constructor.h"
+#include "pbd/file_utils.h"
+#include "pbd/search_path.h"
 
 #include "midi++/parser.h"
 #include "timecode/time.h"
@@ -32,6 +34,7 @@
 #include "ardour/async_midi_port.h"
 #include "ardour/audioengine.h"
 #include "ardour/debug.h"
+#include "ardour/filesystem_paths.h"
 #include "ardour/midiport_manager.h"
 #include "ardour/session.h"
 #include "ardour/tempo.h"
@@ -62,6 +65,7 @@ Push2::Push2 (ARDOUR::Session& s)
        , device_buffer (0)
        , frame_buffer (Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, cols, rows))
        , modifier_state (None)
+       , splash_start (0)
        , bank_start (0)
 {
        context = Cairo::Context::create (frame_buffer);
@@ -353,6 +357,14 @@ Push2::redraw ()
        string tc_clock_text;
        string bbt_clock_text;
 
+       if (splash_start) {
+               if (get_microseconds() - splash_start > 4000000) {
+                       splash_start = 0;
+               } else {
+                       return false;
+               }
+       }
+
        if (session) {
                framepos_t audible = session->audible_frame();
                Timecode::Time TC;
@@ -526,6 +538,7 @@ Push2::set_active (bool yn)
                init_buttons (true);
                init_touch_strip ();
                switch_bank (0);
+               splash ();
 
        } else {
 
@@ -1296,3 +1309,62 @@ Push2::end_select ()
                write (b->state_msg());
        }
 }
+
+void
+Push2::splash ()
+{
+       std::string splash_file;
+
+       Searchpath rc (ARDOUR::ardour_data_search_path());
+       rc.add_subdirectory_to_paths ("resources");
+
+       if (!find_file (rc, PROGRAM_NAME "-splash.png", splash_file)) {
+               cerr << "Cannot find splash screen image file\n";
+               throw failed_constructor();
+       }
+
+       Cairo::RefPtr<Cairo::ImageSurface> img = Cairo::ImageSurface::create_from_png (splash_file);
+
+       double x_ratio = (double) img->get_width() / (cols - 20);
+       double y_ratio = (double) img->get_height() / (rows - 20);
+       double scale = min (x_ratio, y_ratio);
+
+       /* background */
+
+       context->set_source_rgb (0.764, 0.882, 0.882);
+       context->paint ();
+
+       /* image */
+
+       context->save ();
+       context->translate (5, 5);
+       context->scale (scale, scale);
+       context->set_source (img, 0, 0);
+       context->paint ();
+       context->restore ();
+
+       /* text */
+
+       Glib::RefPtr<Pango::Layout> some_text = Pango::Layout::create (context);
+
+       Pango::FontDescription fd ("Sans 38");
+       some_text->set_font_description (fd);
+       some_text->set_text (string_compose ("%1 %2", PROGRAM_NAME, VERSIONSTRING));
+
+       context->move_to (200, 10);
+       context->set_source_rgb (0, 0, 0);
+       some_text->update_from_cairo_context (context);
+       some_text->show_in_cairo_context (context);
+
+       Pango::FontDescription fd2 ("Sans Italic 18");
+       some_text->set_font_description (fd2);
+       some_text->set_text (_("Ableton Push 2 Support"));
+
+       context->move_to (200, 80);
+       context->set_source_rgb (0, 0, 0);
+       some_text->update_from_cairo_context (context);
+       some_text->show_in_cairo_context (context);
+
+       splash_start = get_microseconds ();
+       blit_to_device_frame_buffer ();
+}
index b401d7e136bb6b574e5e4af2e02581609f53ac91..2d130b9d66eed6b034cff83276830e8e3ef2c3d7 100644 (file)
@@ -431,6 +431,9 @@ class Push2 : public ARDOUR::ControlProtocol
        Glib::RefPtr<Pango::Layout> mid_layout[8];
        Glib::RefPtr<Pango::Layout> lower_layout[8];
 
+       void splash ();
+       ARDOUR::microseconds_t splash_start;
+
        /* stripables */
 
        int32_t bank_start;
index d72af4e885e2fbd653343e124967d871334c594a..36e9a644c4bb66bfae9625e97b25694a1388169e 100644 (file)
@@ -16,7 +16,7 @@ def configure(conf):
     autowaf.configure(conf)
     autowaf.check_pkg(conf, 'pangomm-1.4', uselib_store='PANGOMM', atleast_version='1.4', mandatory=True)
     autowaf.check_pkg(conf, 'cairomm-1.0', uselib_store='CAIROMM', atleast_version='1.8.4', mandatory=True)
-
+    
 def build(bld):
     obj = bld(features = 'cxx cxxshlib')
     obj.source = '''
@@ -29,6 +29,7 @@ def build(bld):
     obj.export_includes = ['.']
     obj.defines      = [ 'PACKAGE="ardour_push2"' ]
     obj.defines     += [ 'ARDOURSURFACE_DLL_EXPORTS' ]
+    obj.defines     += [ 'VERSIONSTRING="' + bld.env['VERSION'] + '"' ]
     obj.includes     = [ '.', './push2']
     obj.name         = 'libardour_push2'
     obj.target       = 'ardour_push2'