Add serialize option for the splitter window sash position.
This commit is contained in:
parent
1210b5e6ce
commit
ccda509068
|
|
@ -86,10 +86,14 @@ wx_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
|||
'CMAKE_BUILD_TYPE': 'Release',
|
||||
'CMAKE_CXX_COMPILER': 'g++',
|
||||
'wxBUILD_SHARED': 'ON',
|
||||
'wxBUILD_MONOLITHIC': 'OFF',
|
||||
'wxBUILD_BENCHMARKS': 'OFF',
|
||||
'wxBUILD_PRECOMP': 'OFF',
|
||||
'wxBUILD_TESTS': 'OFF',
|
||||
'wxBUILD_SAMPLES': 'OFF',
|
||||
'wxBUILD_DEMOS': 'OFF',
|
||||
'wxBUILD_COMPATIBILITY': '3.0',
|
||||
'wxBUILD_TOOLKIT': 'gtk3',
|
||||
'wxUSE_UNICODE': 'ON',
|
||||
'wxUSE_AUI': 'OFF',
|
||||
'wxUSE_XML': 'OFF',
|
||||
|
|
@ -100,6 +104,7 @@ wx_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
|||
'wxUSE_RIBBON': 'OFF',
|
||||
'wxUSE_MDI': 'OFF',
|
||||
'wxUSE_MDI_ARCHITECTURE': 'OFF',
|
||||
'wxUSE_POSTSCRIPT': 'ON',
|
||||
'wxUSE_RICHTEXT': 'OFF',
|
||||
'wxUSE_WEBVIEW': 'OFF',
|
||||
'wxUSE_LIBSDL': 'OFF',
|
||||
|
|
|
|||
|
|
@ -426,6 +426,11 @@ MainFrame::MainFrame()
|
|||
Bind(wxEVT_MENU, &MainFrame::OnSelectResetAppData, this, wxID_REFRESH);
|
||||
Bind(wxEVT_MENU, &MainFrame::OnSelectAbout, this, wxID_ABOUT);
|
||||
|
||||
Bind(wxEVT_SPLITTER_SASH_POS_CHANGING, &MainFrame::OnTopSplitterSashPosChanged,
|
||||
this, m_TopSplitter->GetId());
|
||||
Bind(wxEVT_SPLITTER_SASH_POS_CHANGING, &MainFrame::OnBottomSplitterSashPosChanged,
|
||||
this, m_BottomSplitter->GetId());
|
||||
|
||||
this->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnResizeFrame), NULL, this);
|
||||
m_StatusBar->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnResizeStatusBar), NULL, this);
|
||||
|
||||
|
|
@ -3054,10 +3059,30 @@ void MainFrame::OnResizeFrame(wxSizeEvent& event)
|
|||
event.Skip();
|
||||
}
|
||||
|
||||
void MainFrame::OnTopSplitterSashPosChanged(wxSplitterEvent& event)
|
||||
{
|
||||
Serializer serializer;
|
||||
|
||||
SH_LOG_DEBUG("TopSplitter at {}", m_TopSplitter->GetSashPosition());
|
||||
|
||||
serializer.SerializeSplitterSashPos("top", m_TopSplitter->GetSashPosition());
|
||||
}
|
||||
|
||||
void MainFrame::OnBottomSplitterSashPosChanged(wxSplitterEvent& event)
|
||||
{
|
||||
Serializer serializer;
|
||||
|
||||
SH_LOG_DEBUG("BottomSplitter at {}", m_BottomSplitter->GetSashPosition());
|
||||
|
||||
serializer.SerializeSplitterSashPos("bottom", m_BottomSplitter->GetSashPosition());
|
||||
}
|
||||
|
||||
void MainFrame::SetAfterFrameCreate()
|
||||
{
|
||||
m_TopSplitter->SetSashPosition(200);
|
||||
m_BottomSplitter->SetSashPosition(300);
|
||||
Serializer serializer;
|
||||
|
||||
m_TopSplitter->SetSashPosition(serializer.DeserializeSplitterSashPos("top"));
|
||||
m_BottomSplitter->SetSashPosition(serializer.DeserializeSplitterSashPos("bottom"));
|
||||
}
|
||||
|
||||
void MainFrame::OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event)
|
||||
|
|
@ -3146,5 +3171,9 @@ void MainFrame::PlaySample(const std::string& filepath, const std::string& sampl
|
|||
|
||||
MainFrame::~MainFrame()
|
||||
{
|
||||
// Delete wxTimer
|
||||
delete m_Timer;
|
||||
|
||||
// Delete wxFilesystemWatcher
|
||||
delete m_FsWatcher;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,6 +262,10 @@ class MainFrame : public wxFrame
|
|||
// Frame resize event handler
|
||||
void OnResizeFrame(wxSizeEvent& event);
|
||||
|
||||
// Splitter window sash pos event handler
|
||||
void OnTopSplitterSashPosChanged(wxSplitterEvent& event);
|
||||
void OnBottomSplitterSashPosChanged(wxSplitterEvent& event);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Timer update event handler
|
||||
void UpdateElapsedTime(wxTimerEvent& event);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ Serializer::Serializer()
|
|||
m_Emitter << YAML::BeginMap;
|
||||
m_Emitter << YAML::Key << "Width" << YAML::Value << 1280;
|
||||
m_Emitter << YAML::Key << "Height" << YAML::Value << 720;
|
||||
m_Emitter << YAML::Key << "TopSplitterSashPos" << YAML::Value << 200;
|
||||
m_Emitter << YAML::Key << "BottomSplitterSashPos" << YAML::Value << 300;
|
||||
m_Emitter << YAML::Key << "ShowMenuBar" << YAML::Value << true;
|
||||
m_Emitter << YAML::Key << "ShowStatusBar" << YAML::Value << true;
|
||||
m_Emitter << YAML::EndMap << YAML::Newline;
|
||||
|
|
@ -225,6 +227,65 @@ bool Serializer::DeserializeShowMenuAndStatusBar(std::string key) const
|
|||
return show;
|
||||
}
|
||||
|
||||
void Serializer::SerializeSplitterSashPos(std::string key, int pos)
|
||||
{
|
||||
YAML::Emitter out;
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto sash = config["Window"])
|
||||
{
|
||||
if (key == "top")
|
||||
sash["TopSplitterSashPos"] = pos;
|
||||
|
||||
if (key == "bottom")
|
||||
sash["BottomSplitterSashPos"] = pos;
|
||||
|
||||
out << config;
|
||||
|
||||
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
ofstrm << out.c_str();
|
||||
}
|
||||
else
|
||||
SH_LOG_ERROR("Error! Cannot store sash pos values.");
|
||||
}
|
||||
catch(const YAML::ParserException& ex)
|
||||
{
|
||||
SH_LOG_ERROR(ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
int Serializer::DeserializeSplitterSashPos(std::string key) const
|
||||
{
|
||||
int pos = 0;
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
|
||||
|
||||
if (auto bar = config["Window"])
|
||||
{
|
||||
if (key == "top")
|
||||
pos = bar["TopSplitterSashPos"].as<int>();
|
||||
|
||||
if (key == "bottom")
|
||||
pos = bar["BottomSplitterSashPos"].as<int>();
|
||||
}
|
||||
else
|
||||
{
|
||||
SH_LOG_ERROR("Error! Cannot fetch sash pos values.");
|
||||
}
|
||||
}
|
||||
catch(const YAML::ParserException& ex)
|
||||
{
|
||||
SH_LOG_ERROR(ex.what());
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void Serializer::SerializeMediaOptions(std::string key, bool value)
|
||||
{
|
||||
YAML::Emitter out;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ class Serializer
|
|||
void SerializeShowMenuAndStatusBar(std::string key, bool value);
|
||||
bool DeserializeShowMenuAndStatusBar(std::string key) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Splitter window sash pos
|
||||
void SerializeSplitterSashPos(std::string key, int pos);
|
||||
int DeserializeSplitterSashPos(std::string key) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Browser controls
|
||||
void SerializeMediaOptions(std::string key, bool value);
|
||||
|
|
|
|||
Loading…
Reference in New Issue