Change LuaWindow into an ArdourWindow

* remember window visibility, size and position
* Show as toggle in the window-menu (rather than show action)
* reduce specialization, use WM and ArdourWindow infrastructure
  (transient parent, window-type, etc)
This commit is contained in:
Robin Gareus 2021-09-20 04:26:24 +02:00
parent 23c5793173
commit 747b24f063
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
7 changed files with 24 additions and 69 deletions

View File

@ -328,7 +328,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, last_key_press_time (0)
, save_as_dialog (0)
, meterbridge (0)
, luawindow (0)
, rc_option_editor (0)
, speaker_config_window (X_("speaker-config"), _("Speaker Configuration"))
, add_route_dialog (X_("add-routes"), _("Add Tracks/Busses"))
@ -352,6 +351,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, audio_port_matrix (X_("audio-connection-manager"), _("Audio Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::AUDIO))
, midi_port_matrix (X_("midi-connection-manager"), _("MIDI Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::MIDI))
, key_editor (X_("key-editor"), _("Keyboard Shortcuts"), boost::bind (&ARDOUR_UI::create_key_editor, this))
, luawindow (X_("luawindow"), S_("Window|Scripting"), boost::bind (&ARDOUR_UI::create_luawindow, this))
, video_server_process (0)
, have_configure_timeout (false)
, last_configure_time (0)
@ -507,6 +507,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
virtual_keyboard_window.set_state (*ui_xml, 0);
audio_port_matrix.set_state (*ui_xml, 0);
midi_port_matrix.set_state (*ui_xml, 0);
luawindow.set_state (*ui_xml, 0);
export_video_dialog.set_state (*ui_xml, 0);
lua_script_window.set_state (*ui_xml, 0);
idleometer.set_state (*ui_xml, 0);
@ -538,6 +539,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
WM::Manager::instance().register_window (&virtual_keyboard_window);
WM::Manager::instance().register_window (&audio_port_matrix);
WM::Manager::instance().register_window (&midi_port_matrix);
WM::Manager::instance().register_window (&luawindow);
WM::Manager::instance().register_window (&idleometer);
WM::Manager::instance().register_window (&plugin_manager_ui);
WM::Manager::instance().register_window (&plugin_dsp_load_window);
@ -858,7 +860,6 @@ ARDOUR_UI::~ARDOUR_UI ()
delete _process_thread; _process_thread = 0;
delete time_info_box; time_info_box = 0;
delete meterbridge; meterbridge = 0;
delete luawindow; luawindow = 0;
delete recorder; recorder = 0;
delete editor; editor = 0;
delete mixer; mixer = 0;

View File

@ -112,6 +112,7 @@
#include "keyeditor.h"
#include "location_ui.h"
#include "lua_script_manager.h"
#include "luawindow.h"
#include "plugin_dspload_window.h"
#include "plugin_manager_ui.h"
#include "rc_option_editor.h"
@ -133,6 +134,7 @@ class ExportVideoDialog;
class KeyEditor;
class LocationUIWindow;
class LuaScriptManager;
class LuaWindow;
class RCOptionEditor;
class RouteParams_UI;
class SessionOptionEditor;
@ -437,7 +439,6 @@ private:
void tabbable_state_change (ArdourWidgets::Tabbable&);
void toggle_meterbridge ();
void toggle_luawindow ();
int setup_windows ();
void setup_transport ();
@ -710,12 +711,10 @@ private:
int create_mixer ();
int create_editor ();
int create_meterbridge ();
int create_luawindow ();
int create_masters ();
int create_recorder ();
Meterbridge *meterbridge;
LuaWindow *luawindow;
/* Dialogs that can be created via new<T> */
@ -747,6 +746,7 @@ private:
WM::ProxyWithConstructor<GlobalPortMatrixWindow> audio_port_matrix;
WM::ProxyWithConstructor<GlobalPortMatrixWindow> midi_port_matrix;
WM::ProxyWithConstructor<KeyEditor> key_editor;
WM::ProxyWithConstructor<LuaWindow> luawindow;
/* creator methods */
@ -758,6 +758,7 @@ private:
VirtualKeyboardWindow* create_virtual_keyboard_window();
GlobalPortMatrixWindow* create_global_port_matrix (ARDOUR::DataType);
KeyEditor* create_key_editor ();
LuaWindow* create_luawindow ();
ARDOUR::SystemExec *video_server_process;

View File

@ -133,7 +133,6 @@ ARDOUR_UI::connect_dependents_to_session (ARDOUR::Session *s)
mixer->set_session (s);
recorder->set_session (s);
meterbridge->set_session (s);
luawindow->set_session (s);
/* its safe to do this now */
@ -273,11 +272,6 @@ ARDOUR_UI::setup_windows ()
return -1;
}
if (create_luawindow ()) {
error << _("UI: cannot setup luawindow") << endmsg;
return -1;
}
time_info_box = new TimeInfoBox ("ToolbarTimeInfo", false);
/* all other dialogs are created conditionally */

View File

@ -153,7 +153,6 @@ ARDOUR_UI::set_session (Session *s)
secondary_clock->set_session (s);
big_clock->set_session (s);
video_timeline->set_session (s);
lua_script_window->set_session (s);
rc_option_editor->set_session (s);
roll_controllable->set_session (s);
@ -878,28 +877,6 @@ ARDOUR_UI::toggle_meterbridge ()
}
}
void
ARDOUR_UI::toggle_luawindow ()
{
assert (editor && luawindow);
bool show = false;
if (luawindow->not_visible ()) {
show = true;
}
// TODO check overlap
if (show) {
luawindow->show_window ();
luawindow->present ();
luawindow->raise ();
} else {
luawindow->hide_window (NULL);
}
}
void
ARDOUR_UI::new_midi_tracer_window ()
{
@ -974,6 +951,13 @@ ARDOUR_UI::create_virtual_keyboard_window ()
return vkbd;
}
LuaWindow*
ARDOUR_UI::create_luawindow ()
{
LuaWindow* luawindow = LuaWindow::instance ();
return luawindow;
}
void
ARDOUR_UI::handle_locations_change (Location *)
{

View File

@ -108,20 +108,6 @@ ARDOUR_UI::create_editor ()
return 0;
}
int
ARDOUR_UI::create_luawindow ()
{
try {
luawindow = LuaWindow::instance ();
}
catch (failed_constructor& err) {
return -1;
}
return 0;
}
int
ARDOUR_UI::create_recorder ()
{
@ -278,7 +264,6 @@ ARDOUR_UI::install_actions ()
ActionManager::register_action (common_actions, X_("show-ui-prefs"), _("Show more UI preferences"), sigc::mem_fun (*this, &ARDOUR_UI::show_ui_prefs));
}
ActionManager::register_action (common_actions, X_("toggle-luawindow"), S_("Window|Scripting"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_luawindow));
ActionManager::register_action (common_actions, X_("toggle-meterbridge"), S_("Window|Meterbridge"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_meterbridge));
act = ActionManager::register_action (common_actions, X_("NewMIDITracer"), _("MIDI Tracer"), sigc::mem_fun(*this, &ARDOUR_UI::new_midi_tracer_window));

View File

@ -88,8 +88,7 @@ LuaWindow::instance ()
}
LuaWindow::LuaWindow ()
: Window (Gtk::WINDOW_TOPLEVEL)
, VisibilityTracker (*((Gtk::Window*) this))
: ArdourWindow ("Lua")
, lua (0)
, _visible (false)
, _menu_scratch (0)
@ -107,17 +106,7 @@ LuaWindow::LuaWindow ()
reinit_lua ();
update_title ();
set_wmclass (X_("ardour_mixer"), PROGRAM_NAME);
#ifdef __APPLE__
set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG);
#else
if (UIConfiguration::instance().get_all_floating_windows_are_dialogs()) {
set_type_hint (Gdk::WINDOW_TYPE_HINT_DIALOG);
} else {
set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
}
#endif
set_wmclass (X_("ardour_lua"), PROGRAM_NAME);
script_select.disable_scrolling ();
@ -220,10 +209,13 @@ void LuaWindow::reinit_lua ()
void LuaWindow::set_session (Session* s)
{
SessionHandlePtr::set_session (s);
if (!_session) {
if (!s) {
return;
}
/* only call SessionHandlePtr::set_session if session is not NULL,
* otherwise LuaWindow::session_going_away will never be invoked.
*/
ArdourWindow::set_session (s);
update_title ();
_session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&LuaWindow::update_title, this), gui_context());
@ -238,7 +230,7 @@ LuaWindow::session_going_away ()
ENSURE_GUI_THREAD (*this, &LuaWindow::session_going_away);
reinit_lua (); // drop state (all variables, session references)
SessionHandlePtr::session_going_away ();
ArdourWindow::session_going_away ();
_session = 0;
update_title ();

View File

@ -42,10 +42,8 @@
#include "widgets/ardour_dropdown.h"
class LuaWindow :
public Gtk::Window,
public PBD::ScopedConnectionList,
public ARDOUR::SessionHandlePtr,
public Gtkmm2ext::VisibilityTracker
public ArdourWindow,
public PBD::ScopedConnectionList
{
public:
static LuaWindow* instance();