summaryrefslogtreecommitdiff
path: root/libs/surfaces/push2
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-06-19 12:26:28 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-09-27 14:59:29 -0500
commit1448be481f8ba11eb9401fb9024a506a7241b64a (patch)
tree446d2a7b0316e6634b1a9d8b4ae4ac2865885a04 /libs/surfaces/push2
parent169cf294c58979419a2e19e5a9c005d84ff0f021 (diff)
push2: splash screen
Coded while the paint prep dries in the sun
Diffstat (limited to 'libs/surfaces/push2')
-rw-r--r--libs/surfaces/push2/push2.cc72
-rw-r--r--libs/surfaces/push2/push2.h3
-rw-r--r--libs/surfaces/push2/wscript3
3 files changed, 77 insertions, 1 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc
index 16254f6215..3173444184 100644
--- a/libs/surfaces/push2/push2.cc
+++ b/libs/surfaces/push2/push2.cc
@@ -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 ();
+}
diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h
index b401d7e136..2d130b9d66 100644
--- a/libs/surfaces/push2/push2.h
+++ b/libs/surfaces/push2/push2.h
@@ -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;
diff --git a/libs/surfaces/push2/wscript b/libs/surfaces/push2/wscript
index d72af4e885..36e9a644c4 100644
--- a/libs/surfaces/push2/wscript
+++ b/libs/surfaces/push2/wscript
@@ -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'