3 #include <pbd/failed_constructor.h>
4 #include <ardour/ardour.h>
6 #include "gui_thread.h"
14 using namespace ARDOUR
;
16 Splash
* Splash::the_splash
= 0;
20 string path
= find_data_file ("splash.png");
23 throw failed_constructor();
27 pixbuf
= Gdk::Pixbuf::create_from_file (path
);
31 throw failed_constructor();
34 darea
.set_size_request (pixbuf
->get_width(), pixbuf
->get_height());
35 set_keep_above (true);
36 set_position (WIN_POS_CENTER
);
37 darea
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
);
38 darea
.set_double_buffered (false);
40 layout
= create_pango_layout ("");
42 string i18n
= string_compose (_("%1 loading ..."), PROGRAM_NAME
);
46 layout
->set_markup (str
);
49 darea
.signal_expose_event().connect (mem_fun (*this, &Splash::expose
));
53 set_default_size (pixbuf
->get_width(), pixbuf
->get_height());
56 ARDOUR::BootMessage
.connect (mem_fun (*this, &Splash::boot_message
));
62 set_keep_above (false);
68 Window::on_realize ();
70 // Without override redirect, splash screen has redraw problems with ion3.
71 // With override redirect, it is not properly on top with some other
72 // popular (metacity for example) window managers.
73 // Maybe setting override redirect and something else (like the splash wm hint)
74 // will make the splash to work for everybody
75 // Override redirect only does not work on OS X too.
76 // Until we find solution that works for everybody this env var kludge is used
77 if (getenv ("ARDOUR_USE_OVERRIDE_REDIRECT_SPLASH") != 0) {
78 get_window()->set_override_redirect (true);
80 get_window()->set_decorations (Gdk::WMDecoration (0));
83 layout
->set_font_description (get_style()->get_font());
88 Splash::on_button_release_event (GdkEventButton
* ev
)
95 Splash::expose (GdkEventExpose
* ev
)
97 RefPtr
<Gdk::Window
> window
= darea
.get_window();
99 /* note: height & width need to be constrained to the pixbuf size
100 in case a WM provides us with a screwy allocation
103 window
->draw_pixbuf (get_style()->get_bg_gc (STATE_NORMAL
), pixbuf
,
104 ev
->area
.x
, ev
->area
.y
,
105 ev
->area
.x
, ev
->area
.y
,
106 min ((pixbuf
->get_width() - ev
->area
.x
), ev
->area
.width
),
107 min ((pixbuf
->get_height() - ev
->area
.y
), ev
->area
.height
),
108 Gdk::RGB_DITHER_NONE
, 0, 0);
110 Glib::RefPtr
<Gtk::Style
> style
= darea
.get_style();
111 Glib::RefPtr
<Gdk::GC
> white
= style
->get_white_gc();
113 window
->draw_layout (white
, 10, pixbuf
->get_height() - 30, layout
);
119 Splash::boot_message (std::string msg
)
125 Splash::message (const string
& msg
)
131 layout
->set_markup (str
);
132 Glib::RefPtr
<Gdk::Window
> win
= darea
.get_window();
135 win
->invalidate_rect (Gdk::Rectangle (0, darea
.get_height() - 30,
136 darea
.get_width(), 30), true);
137 win
->process_updates (true);