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"
24 #include "pbd/search_path.h"
26 #include "ardour/debug.h"
27 #include "ardour/filesystem_paths.h"
34 #define Rect ArdourCanvas::Rect
37 using namespace ARDOUR;
40 using namespace ArdourSurface;
41 using namespace ArdourCanvas;
43 SplashLayout::SplashLayout (Push2& p, Session& s, std::string const & name)
44 : Push2Layout (p, s, name)
46 std::string splash_file;
48 Searchpath rc (ARDOUR::ardour_data_search_path());
49 rc.add_subdirectory_to_paths ("resources");
51 if (!find_file (rc, PROGRAM_NAME "-splash.png", splash_file)) {
52 cerr << "Cannot find splash screen image file\n";
53 throw failed_constructor();
56 img = Cairo::ImageSurface::create_from_png (splash_file);
59 SplashLayout::~SplashLayout ()
64 SplashLayout::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
66 DEBUG_TRACE (DEBUG::Push2, string_compose ("splash render %1\n", area));
68 int rows = display_height ();
69 int cols = display_width ();
71 double x_ratio = (double) img->get_width() / (cols - 20);
72 double y_ratio = (double) img->get_height() / (rows - 20);
73 double scale = min (x_ratio, y_ratio);
77 context->set_source_rgb (0.764, 0.882, 0.882);
83 context->translate (5, 5);
84 context->scale (scale, scale);
85 context->set_source (img, 0, 0);
91 Glib::RefPtr<Pango::Layout> some_text = Pango::Layout::create (context);
93 Pango::FontDescription fd ("Sans 38");
94 some_text->set_font_description (fd);
95 some_text->set_text (string_compose ("%1 %2", PROGRAM_NAME, VERSIONSTRING));
97 context->move_to (200, 10);
98 context->set_source_rgb (0, 0, 0);
99 some_text->update_from_cairo_context (context);
100 some_text->show_in_cairo_context (context);
102 Pango::FontDescription fd2 ("Sans Italic 18");
103 some_text->set_font_description (fd2);
104 some_text->set_text (_("Ableton Push 2 Support"));
106 context->move_to (200, 80);
107 context->set_source_rgb (0, 0, 0);
108 some_text->update_from_cairo_context (context);
109 some_text->show_in_cairo_context (context);