push2: splash screen
Coded while the paint prep dries in the sun
This commit is contained in:
parent
169cf294c5
commit
1448be481f
@ -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 ();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user