2012-06-01 15:49:40 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2008-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2012-2014 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
* Copyright (C) 2012-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2012-06-01 15:49:40 -04:00
|
|
|
|
2008-01-18 22:49:52 -05:00
|
|
|
#include <string>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/failed_constructor.h"
|
|
|
|
#include "pbd/file_utils.h"
|
2012-07-09 21:04:36 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/ardour.h"
|
|
|
|
#include "ardour/filesystem_paths.h"
|
2008-01-18 22:49:52 -05:00
|
|
|
|
2015-10-15 05:24:15 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2013-04-30 13:50:15 -04:00
|
|
|
#ifdef check
|
|
|
|
#undef check
|
|
|
|
#endif
|
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
#include "gui_thread.h"
|
2021-07-04 15:48:12 -04:00
|
|
|
#include "opts.h"
|
2008-01-18 22:49:52 -05:00
|
|
|
#include "splash.h"
|
2021-07-04 15:48:12 -04:00
|
|
|
#include "ui_config.h"
|
2008-01-18 22:49:52 -05:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2008-01-18 22:49:52 -05:00
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Glib;
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace PBD;
|
2008-01-18 22:49:52 -05:00
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
2008-02-02 12:22:04 -05:00
|
|
|
Splash* Splash::the_splash = 0;
|
|
|
|
|
2019-10-11 16:29:55 -04:00
|
|
|
Splash*
|
|
|
|
Splash::instance()
|
|
|
|
{
|
|
|
|
if (!the_splash) {
|
|
|
|
the_splash = new Splash;
|
|
|
|
}
|
|
|
|
return the_splash;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Splash::exists ()
|
|
|
|
{
|
|
|
|
return the_splash;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::drop ()
|
|
|
|
{
|
|
|
|
delete the_splash;
|
|
|
|
the_splash = 0;
|
|
|
|
}
|
|
|
|
|
2008-01-18 22:49:52 -05:00
|
|
|
Splash::Splash ()
|
|
|
|
{
|
2012-06-01 16:01:37 -04:00
|
|
|
assert (the_splash == 0);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-23 01:06:54 -04:00
|
|
|
std::string splash_file;
|
2008-01-18 22:49:52 -05:00
|
|
|
|
2016-05-17 07:12:05 -04:00
|
|
|
Searchpath rc (ARDOUR::ardour_data_search_path());
|
|
|
|
rc.add_subdirectory_to_paths ("resources");
|
|
|
|
|
|
|
|
if (!find_file (rc, PROGRAM_NAME "-splash.png", splash_file)) {
|
2017-04-01 09:50:48 -04:00
|
|
|
cerr << "Cannot find splash screen image file\n";
|
2008-01-18 22:49:52 -05:00
|
|
|
throw failed_constructor();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2012-06-23 01:06:54 -04:00
|
|
|
pixbuf = Gdk::Pixbuf::create_from_file (splash_file);
|
2008-01-18 22:49:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
catch (...) {
|
2017-04-01 09:50:48 -04:00
|
|
|
cerr << "Cannot construct splash screen image\n";
|
2008-01-18 22:49:52 -05:00
|
|
|
throw failed_constructor();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-01-19 00:06:33 -05:00
|
|
|
darea.set_size_request (pixbuf->get_width(), pixbuf->get_height());
|
2012-01-10 13:21:39 -05:00
|
|
|
pop_front ();
|
2008-01-18 22:49:52 -05:00
|
|
|
set_position (WIN_POS_CENTER);
|
2008-01-19 00:06:33 -05:00
|
|
|
darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
|
2008-02-16 17:43:18 -05:00
|
|
|
darea.set_double_buffered (false);
|
2008-01-19 00:06:33 -05:00
|
|
|
|
|
|
|
layout = create_pango_layout ("");
|
2008-02-01 22:57:35 -05:00
|
|
|
string str = "<b>";
|
2010-03-14 22:31:27 -04:00
|
|
|
string i18n = string_compose (_("%1 loading ..."), PROGRAM_NAME);
|
2008-02-01 22:57:35 -05:00
|
|
|
str += i18n;
|
|
|
|
str += "</b>";
|
|
|
|
|
|
|
|
layout->set_markup (str);
|
2008-01-19 00:06:33 -05:00
|
|
|
|
|
|
|
darea.show ();
|
2009-12-11 18:29:48 -05:00
|
|
|
darea.signal_expose_event().connect (sigc::mem_fun (*this, &Splash::expose));
|
2008-01-19 00:06:33 -05:00
|
|
|
|
|
|
|
add (darea);
|
2008-02-02 12:22:04 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
set_default_size (pixbuf->get_width(), pixbuf->get_height());
|
2012-08-07 19:56:17 -04:00
|
|
|
set_resizable (false);
|
2012-11-13 22:35:25 -05:00
|
|
|
set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
|
2008-02-02 12:22:04 -05:00
|
|
|
the_splash = this;
|
2008-02-16 17:43:18 -05:00
|
|
|
|
2017-04-01 09:50:48 -04:00
|
|
|
expose_done = false;
|
|
|
|
expose_is_the_one = false;
|
2012-07-09 21:04:36 -04:00
|
|
|
|
2021-07-04 15:48:12 -04:00
|
|
|
if (!ARDOUR_COMMAND_LINE::no_splash) {
|
|
|
|
ARDOUR::BootMessage.connect (msg_connection, invalidator (*this), boost::bind (&Splash::boot_message, this, _1), gui_context());
|
|
|
|
present ();
|
|
|
|
}
|
2008-02-02 12:22:04 -05:00
|
|
|
}
|
|
|
|
|
2012-06-01 15:49:40 -04:00
|
|
|
Splash::~Splash ()
|
|
|
|
{
|
2017-05-11 08:20:33 -04:00
|
|
|
idle_connection.disconnect ();
|
|
|
|
expose_done = true;
|
|
|
|
hide ();
|
2012-06-01 15:49:40 -04:00
|
|
|
the_splash = 0;
|
|
|
|
}
|
|
|
|
|
2008-02-02 12:22:04 -05:00
|
|
|
void
|
2012-01-10 13:21:39 -05:00
|
|
|
Splash::pop_back_for (Gtk::Window& win)
|
2008-02-02 12:22:04 -05:00
|
|
|
{
|
2021-07-04 15:48:12 -04:00
|
|
|
set_keep_above (false);
|
2014-10-22 08:29:33 -04:00
|
|
|
#if defined __APPLE__ || defined PLATFORM_WINDOWS
|
2017-04-01 09:50:48 -04:00
|
|
|
/* April 2013: window layering on OS X is a bit different to X Window. at present,
|
|
|
|
* the "restack()" functionality in GDK will only operate on windows in the same
|
|
|
|
* "level" (e.g. two normal top level windows, or two utility windows) and will not
|
|
|
|
* work across them. The splashscreen is on its own "StatusWindowLevel" so restacking
|
|
|
|
* is not going to work.
|
|
|
|
*
|
|
|
|
* So for OS X, we just hide ourselves.
|
|
|
|
*
|
|
|
|
* Oct 2014: The Windows situation is similar, although it should be possible
|
|
|
|
* to play tricks with gdk's set_type_hint() or directly hack things using
|
|
|
|
* SetWindowLong() and UpdateLayeredWindow()
|
|
|
|
*/
|
|
|
|
(void) win;
|
|
|
|
hide();
|
2013-04-30 13:50:15 -04:00
|
|
|
#else
|
2021-07-04 15:48:12 -04:00
|
|
|
if (UIConfiguration::instance().get_hide_splash_screen ()) {
|
|
|
|
hide ();
|
2022-01-26 15:17:53 -05:00
|
|
|
} else if (get_mapped ()) {
|
2019-11-08 18:56:59 -05:00
|
|
|
get_window()->restack (win.get_window(), false);
|
2021-07-06 18:33:50 -04:00
|
|
|
if (0 == win.get_transient_for ()) {
|
|
|
|
win.set_transient_for (*this);
|
|
|
|
}
|
2019-11-08 18:56:59 -05:00
|
|
|
}
|
2021-06-23 06:52:16 -04:00
|
|
|
#endif
|
|
|
|
_window_stack.insert (&win);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::pop_front_for (Gtk::Window& win)
|
|
|
|
{
|
|
|
|
#ifndef NDEBUG
|
|
|
|
assert (1 == _window_stack.erase (&win));
|
|
|
|
#else
|
|
|
|
_window_stack.erase (&win);
|
2013-04-30 13:50:15 -04:00
|
|
|
#endif
|
2021-06-25 13:50:36 -04:00
|
|
|
if (_window_stack.empty ()) {
|
|
|
|
display ();
|
|
|
|
}
|
2012-01-10 13:21:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::pop_front ()
|
|
|
|
{
|
2021-06-23 06:52:16 -04:00
|
|
|
if (!_window_stack.empty ()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-04 15:48:12 -04:00
|
|
|
if (ARDOUR_COMMAND_LINE::no_splash) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-01 09:50:48 -04:00
|
|
|
if (get_window()) {
|
2017-05-11 08:20:33 -04:00
|
|
|
#if defined __APPLE__ || defined PLATFORM_WINDOWS
|
2017-04-01 09:50:48 -04:00
|
|
|
show ();
|
2017-05-11 08:20:33 -04:00
|
|
|
#else
|
2021-07-04 15:48:12 -04:00
|
|
|
if (UIConfiguration::instance().get_hide_splash_screen ()) {
|
|
|
|
show ();
|
|
|
|
} else {
|
|
|
|
unset_transient_for ();
|
|
|
|
gdk_window_restack (get_window()->gobj(), NULL, true);
|
|
|
|
}
|
2013-04-30 13:50:15 -04:00
|
|
|
#endif
|
2021-07-04 15:48:12 -04:00
|
|
|
set_keep_above (true);
|
2017-05-11 08:20:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::hide ()
|
|
|
|
{
|
|
|
|
Gtk::Window::hide();
|
2008-01-19 00:06:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::on_realize ()
|
|
|
|
{
|
|
|
|
Window::on_realize ();
|
2008-02-01 22:57:35 -05:00
|
|
|
get_window()->set_decorations (Gdk::WMDecoration(0));
|
2008-01-19 00:06:33 -05:00
|
|
|
layout->set_font_description (get_style()->get_font());
|
2008-01-18 22:49:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-07-09 21:04:36 -04:00
|
|
|
Splash::on_button_release_event (GdkEventButton* ev)
|
2008-01-18 22:49:52 -05:00
|
|
|
{
|
2012-07-09 21:04:36 -04:00
|
|
|
RefPtr<Gdk::Window> window = get_window();
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2017-04-01 09:50:48 -04:00
|
|
|
if (!window || ev->window != window->gobj()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2008-01-18 22:49:52 -05:00
|
|
|
hide ();
|
2008-01-19 00:06:33 -05:00
|
|
|
return true;
|
2008-01-18 22:49:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2008-01-19 00:06:33 -05:00
|
|
|
Splash::expose (GdkEventExpose* ev)
|
2008-01-18 22:49:52 -05:00
|
|
|
{
|
2008-01-19 00:06:33 -05:00
|
|
|
RefPtr<Gdk::Window> window = darea.get_window();
|
2008-01-18 22:49:52 -05:00
|
|
|
|
2024-04-11 13:42:14 -04:00
|
|
|
/* clear background (for transparent splash images */
|
|
|
|
Glib::RefPtr<Gdk::GC> bg = get_style()->get_bg_gc (STATE_NORMAL);
|
2024-04-11 17:42:13 -04:00
|
|
|
window->draw_rectangle(bg, true, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
2024-04-11 13:42:14 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
/* note: height & width need to be constrained to the pixbuf size
|
|
|
|
in case a WM provides us with a screwy allocation
|
|
|
|
*/
|
|
|
|
|
2008-02-01 22:57:35 -05:00
|
|
|
window->draw_pixbuf (get_style()->get_bg_gc (STATE_NORMAL), pixbuf,
|
2008-01-18 22:49:52 -05:00
|
|
|
ev->area.x, ev->area.y,
|
|
|
|
ev->area.x, ev->area.y,
|
2009-10-14 12:10:01 -04:00
|
|
|
min ((pixbuf->get_width() - ev->area.x), ev->area.width),
|
2008-02-16 17:43:18 -05:00
|
|
|
min ((pixbuf->get_height() - ev->area.y), ev->area.height),
|
2008-01-18 22:49:52 -05:00
|
|
|
Gdk::RGB_DITHER_NONE, 0, 0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-02-01 22:57:35 -05:00
|
|
|
Glib::RefPtr<Gtk::Style> style = darea.get_style();
|
2008-01-19 00:06:33 -05:00
|
|
|
Glib::RefPtr<Gdk::GC> white = style->get_white_gc();
|
|
|
|
|
|
|
|
window->draw_layout (white, 10, pixbuf->get_height() - 30, layout);
|
2012-12-05 18:58:27 -05:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
/* this must execute AFTER the GDK idle update mechanism
|
2012-12-05 18:58:27 -05:00
|
|
|
*/
|
2015-10-04 14:51:05 -04:00
|
|
|
|
2013-03-04 13:19:05 -05:00
|
|
|
if (expose_is_the_one) {
|
2017-05-11 08:20:33 -04:00
|
|
|
idle_connection = Glib::signal_idle().connect (
|
|
|
|
sigc::mem_fun (this, &Splash::idle_after_expose),
|
|
|
|
GDK_PRIORITY_REDRAW+2);
|
2013-03-04 13:19:05 -05:00
|
|
|
}
|
2008-02-01 22:57:35 -05:00
|
|
|
|
2008-01-18 22:49:52 -05:00
|
|
|
return true;
|
|
|
|
}
|
2008-01-19 00:06:33 -05:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
void
|
|
|
|
Splash::boot_message (std::string msg)
|
|
|
|
{
|
2022-01-26 15:21:06 -05:00
|
|
|
if (!get_visible() && _window_stack.empty ()) {
|
2019-10-11 16:29:55 -04:00
|
|
|
display ();
|
|
|
|
}
|
2008-02-16 17:43:18 -05:00
|
|
|
message (msg);
|
|
|
|
}
|
|
|
|
|
2012-07-09 21:04:36 -04:00
|
|
|
bool
|
|
|
|
Splash::idle_after_expose ()
|
|
|
|
{
|
2017-04-01 09:50:48 -04:00
|
|
|
expose_done = true;
|
2012-07-09 21:04:36 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Splash::display ()
|
|
|
|
{
|
2022-01-26 15:17:53 -05:00
|
|
|
bool was_mapped = get_mapped ();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2021-07-04 15:48:12 -04:00
|
|
|
if (ARDOUR_COMMAND_LINE::no_splash) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-09 21:04:36 -04:00
|
|
|
if (!was_mapped) {
|
|
|
|
expose_done = false;
|
2013-03-04 13:19:05 -05:00
|
|
|
expose_is_the_one = false;
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2012-07-09 21:04:36 -04:00
|
|
|
|
|
|
|
pop_front ();
|
|
|
|
present ();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-07-09 21:04:36 -04:00
|
|
|
if (!was_mapped) {
|
2021-03-09 12:26:59 -05:00
|
|
|
int timeout = 50;
|
|
|
|
darea.queue_draw ();
|
|
|
|
while (!expose_done && --timeout) {
|
2012-07-09 21:04:36 -04:00
|
|
|
gtk_main_iteration ();
|
|
|
|
}
|
2013-03-04 13:19:05 -05:00
|
|
|
gdk_display_flush (gdk_display_get_default());
|
2012-07-09 21:04:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-19 00:06:33 -05:00
|
|
|
void
|
|
|
|
Splash::message (const string& msg)
|
|
|
|
{
|
|
|
|
string str ("<b>");
|
2015-10-15 05:24:15 -04:00
|
|
|
str += Gtkmm2ext::markup_escape_text (msg);
|
2008-01-19 00:06:33 -05:00
|
|
|
str += "</b>";
|
|
|
|
|
|
|
|
layout->set_markup (str);
|
2008-02-16 17:43:18 -05:00
|
|
|
Glib::RefPtr<Gdk::Window> win = darea.get_window();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-02-16 17:43:18 -05:00
|
|
|
if (win) {
|
2012-12-10 20:21:17 -05:00
|
|
|
if (win->is_visible ()) {
|
|
|
|
win->invalidate_rect (Gdk::Rectangle (0, darea.get_height() - 30, darea.get_width(), 30), true);
|
|
|
|
} else {
|
|
|
|
darea.queue_draw ();
|
|
|
|
}
|
2017-05-11 08:20:33 -04:00
|
|
|
if (expose_done) {
|
|
|
|
ARDOUR::GUIIdle ();
|
|
|
|
}
|
2008-02-16 17:43:18 -05:00
|
|
|
}
|
2008-01-19 00:06:33 -05:00
|
|
|
}
|
2013-03-04 13:19:05 -05:00
|
|
|
|
|
|
|
bool
|
|
|
|
Splash::on_map_event (GdkEventAny* ev)
|
|
|
|
{
|
|
|
|
expose_is_the_one = true;
|
|
|
|
return Window::on_map_event (ev);
|
|
|
|
}
|