2 Copyright (C) 2016 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <pangomm/layout.h>
21 #include "pbd/compose.h"
22 #include "pbd/failed_constructor.h"
23 #include "pbd/file_utils.h"
25 #include "pbd/search_path.h"
27 #include "ardour/debug.h"
28 #include "ardour/filesystem_paths.h"
33 #define Rect ArdourCanvas::Rect
36 using namespace ARDOUR;
39 using namespace ArdourSurface;
40 using namespace ArdourCanvas;
42 SplashLayout::SplashLayout (Push2& p, Session& s, std::string const & name)
43 : Push2Layout (p, s, name)
45 std::string splash_file;
47 Searchpath rc (ARDOUR::ardour_data_search_path());
48 rc.add_subdirectory_to_paths ("resources");
50 if (!find_file (rc, PROGRAM_NAME "-splash.png", splash_file)) {
51 cerr << "Cannot find splash screen image file\n";
52 throw failed_constructor();
55 img = Cairo::ImageSurface::create_from_png (splash_file);
58 SplashLayout::~SplashLayout ()
63 SplashLayout::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
65 DEBUG_TRACE (DEBUG::Push2, string_compose ("splash render %1\n", area));
67 int rows = display_height ();
68 int cols = display_width ();
70 double x_ratio = (double) img->get_width() / (cols - 20);
71 double y_ratio = (double) img->get_height() / (rows - 20);
72 double scale = min (x_ratio, y_ratio);
76 context->set_source_rgb (0.764, 0.882, 0.882);
82 context->translate (5, 5);
83 context->scale (scale, scale);
84 context->set_source (img, 0, 0);
90 Glib::RefPtr<Pango::Layout> some_text = Pango::Layout::create (context);
92 Pango::FontDescription fd ("Sans 38");
93 some_text->set_font_description (fd);
94 some_text->set_text (string_compose ("%1 %2", PROGRAM_NAME, VERSIONSTRING));
96 context->move_to (200, 10);
97 context->set_source_rgb (0, 0, 0);
98 some_text->update_from_cairo_context (context);
99 some_text->show_in_cairo_context (context);
101 Pango::FontDescription fd2 ("Sans Italic 18");
102 some_text->set_font_description (fd2);
103 some_text->set_text (_("Ableton Push 2 Support"));
105 context->move_to (200, 80);
106 context->set_source_rgb (0, 0, 0);
107 some_text->update_from_cairo_context (context);
108 some_text->show_in_cairo_context (context);