diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/LashDriver.cpp | 1 | ||||
-rw-r--r-- | src/Patchage.cpp | 28 | ||||
-rw-r--r-- | src/Patchage.hpp | 1 | ||||
-rw-r--r-- | src/StateManager.cpp | 20 | ||||
-rw-r--r-- | src/StateManager.hpp | 7 |
5 files changed, 54 insertions, 3 deletions
diff --git a/src/LashDriver.cpp b/src/LashDriver.cpp index d29261d..eeab10c 100644 --- a/src/LashDriver.cpp +++ b/src/LashDriver.cpp @@ -88,6 +88,7 @@ void LashDriver::on_save_file(const string& directory) { cout << "[LashDriver] LASH Save File - " << directory << endl; + _app->store_window_location(); _app->state_manager()->save(directory + "/locations"); } diff --git a/src/Patchage.cpp b/src/Patchage.cpp index e008bed..8a0a3ed 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -237,6 +237,14 @@ Patchage::Patchage(int argc, char** argv) // Idle callback, check if we need to refresh Glib::signal_timeout().connect( sigc::mem_fun(this, &Patchage::idle_callback), 100); + + _main_win->resize( + static_cast<int>(_state_manager->get_window_size().x), + static_cast<int>(_state_manager->get_window_size().y)); + + _main_win->move( + static_cast<int>(_state_manager->get_window_location().x), + static_cast<int>(_state_manager->get_window_location().y)); _update_pane_position = true; } @@ -409,6 +417,25 @@ Patchage::refresh() } +/** Update the stored window location and size in the StateManager (in memory). + */ +void +Patchage::store_window_location() +{ + int loc_x, loc_y, size_x, size_y; + _main_win->get_position(loc_x, loc_y); + _main_win->get_size(size_x, size_y); + Coord window_location; + window_location.x = loc_x; + window_location.y = loc_y; + Coord window_size; + window_size.x = size_x; + window_size.y = size_y; + _state_manager->set_window_location(window_location); + _state_manager->set_window_size(window_size); +} + + void Patchage::clear_load() { @@ -665,6 +692,7 @@ Patchage::on_show_messages() void Patchage::on_store_positions() { + store_window_location(); _state_manager->save(_settings_filename); } diff --git a/src/Patchage.hpp b/src/Patchage.hpp index bbf6854..7548aec 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -59,6 +59,7 @@ public: void clear_load(); void status_message(const std::string& msg); void update_state(); + void store_window_location(); int max_pane_position() { return _main_paned->property_max_position() diff --git a/src/StateManager.cpp b/src/StateManager.cpp index 86fe07c..9753a18 100644 --- a/src/StateManager.cpp +++ b/src/StateManager.cpp @@ -27,6 +27,10 @@ using namespace std; StateManager::StateManager() { + _window_location.x = 0; + _window_location.y = 0; + _window_size.x = 640; + _window_size.y = 480; _zoom = 1.0; } @@ -100,16 +104,24 @@ StateManager::load(const string& filename) } string s; - is >> s; + is >> s; if (s == "window_location") { - is >> s; is >> s; is >> s;// skip + is >> s; + _window_location.x = atoi(s.c_str()); + is >> s; + _window_location.y = atoi(s.c_str()); } + is >> s; if (s == "window_size") { - is >> s; is >> s; is >> s;// skip + is >> s; + _window_size.x = atoi(s.c_str()); + is >> s; + _window_size.y = atoi(s.c_str()); } + is >> s; if (s != "zoom_level") { std::string msg = "Corrupt settings file: expected \"zoom_level\", found \""; msg.append(s).append("\""); @@ -165,6 +177,8 @@ StateManager::save(const string& filename) std::ofstream os; os.open(filename.c_str(), std::ios::out); + os << "window_location " << _window_location.x << " " << _window_location.y << std::endl; + os << "window_size " << _window_size.x << " " << _window_size.y << std::endl; os << "zoom_level " << _zoom << std::endl; ModuleLocation ml; diff --git a/src/StateManager.hpp b/src/StateManager.hpp index 63b47ec..63676a6 100644 --- a/src/StateManager.hpp +++ b/src/StateManager.hpp @@ -46,6 +46,11 @@ public: int get_port_color(PortType type); + Coord get_window_location() { return _window_location; } + void set_window_location(Coord loc) { _window_location = loc; } + Coord get_window_size() { return _window_size; } + void set_window_size(Coord size) { _window_size = size; } + private: struct ModuleLocation { std::string name; @@ -55,6 +60,8 @@ private: std::list<ModuleLocation> _module_locations; std::map<std::string,bool> _module_splits; + Coord _window_location; + Coord _window_size; float _zoom; }; |