mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-14 03:39:57 +01:00
Improved vimix first launch (or after upgrade)
Changed Mixer Load behavior at init, detect change of version and do not load settings if different, show About Vimix after change of version, fixed initial position of windows at first run.
This commit is contained in:
@@ -671,7 +671,7 @@ void InputMappingWindow::Render()
|
||||
const float fixed_height = keyLetterItemSize.y * 5.f + g.Style.WindowBorderSize + g.FontSize + g.Style.FramePadding.y * 2.0f + keyItemSpacing.y;
|
||||
const float inputarea_width = keyLetterItemSize.x * 5.f;
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(600, 400), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(ImVec2(530, 600), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(1000, fixed_height), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(900, fixed_height), ImVec2(FLT_MAX, fixed_height));
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ struct AppLog
|
||||
void Draw(const char* title, bool* p_open = NULL)
|
||||
{
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(430, 660), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(ImVec2(440, 700), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(1150, 220), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(600, 180), ImVec2(FLT_MAX, FLT_MAX));
|
||||
|
||||
@@ -196,7 +196,6 @@ void Log::Info(const char* fmt, ...)
|
||||
|
||||
void Log::ShowLogWindow(bool* p_open)
|
||||
{
|
||||
ImGui::SetNextWindowSize(ImVec2(700, 600), ImGuiCond_FirstUseEver);
|
||||
logs.Draw( IMGUI_TITLE_LOGS, p_open);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,24 +73,12 @@ Mixer::Mixer() : session_(nullptr), back_session_(nullptr), sessionSwapRequested
|
||||
current_view_(nullptr), busy_(false), dt_(16.f), dt__(16.f)
|
||||
{
|
||||
// unsused initial empty session
|
||||
session_ = new Session;
|
||||
current_source_ = session_->end();
|
||||
current_source_index_ = -1;
|
||||
|
||||
// auto load if Settings ask to
|
||||
if ( Settings::application.recentSessions.load_at_start &&
|
||||
Settings::application.recentSessions.front_is_valid &&
|
||||
Settings::application.recentSessions.filenames.size() > 0 &&
|
||||
Settings::application.fresh_start) {
|
||||
load( Settings::application.recentSessions.filenames.front() );
|
||||
// initialize with the current view
|
||||
setView( (View::Mode) Settings::application.current_view );
|
||||
}
|
||||
else {
|
||||
// initialize with a new empty session
|
||||
clear();
|
||||
setView( View::MIXING );
|
||||
}
|
||||
}
|
||||
|
||||
void Mixer::update()
|
||||
@@ -1236,6 +1224,7 @@ void Mixer::setView(View::Mode m)
|
||||
Settings::application.current_view = (int) m;
|
||||
|
||||
// selection might have to change
|
||||
if (session_) {
|
||||
for (auto sit = session_->begin(); sit != session_->end(); ++sit) {
|
||||
Source *s = *sit;
|
||||
if ( s != nullptr && !current_view_->canSelect( s ) ) {
|
||||
@@ -1244,6 +1233,7 @@ void Mixer::setView(View::Mode m)
|
||||
Mixer::selection().remove( s );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// need to deeply update view to apply eventual changes
|
||||
++View::need_deep_update_;
|
||||
@@ -1299,8 +1289,22 @@ void Mixer::saveas(const std::string& filename, bool with_version)
|
||||
|
||||
void Mixer::load(const std::string& filename)
|
||||
{
|
||||
if (filename.empty())
|
||||
std::string sessionfile = filename;
|
||||
|
||||
// given an empty filename, try to revert to recent file according to user settings
|
||||
if (filename.empty() && Settings::application.recentSessions.load_at_start
|
||||
&& Settings::application.recentSessions.front_is_valid
|
||||
&& Settings::application.recentSessions.filenames.size() > 0) {
|
||||
sessionfile = Settings::application.recentSessions.filenames.front();
|
||||
setView((View::Mode) Settings::application.current_view);
|
||||
}
|
||||
|
||||
// ignore invalid file name
|
||||
if (!SystemToolkit::file_exists(sessionfile)) {
|
||||
if (!sessionfile.empty())
|
||||
Log::Notify("Invalid filename '%s'", sessionfile.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef THREADED_LOADING
|
||||
// load only one at a time
|
||||
@@ -1308,7 +1312,7 @@ void Mixer::load(const std::string& filename)
|
||||
busy_ = true;
|
||||
// Start async thread for loading the session
|
||||
// Will be obtained in the future in update()
|
||||
sessionLoaders_.emplace_back( std::async(std::launch::async, Session::load, filename, 0) );
|
||||
sessionLoaders_.emplace_back( std::async(std::launch::async, Session::load, sessionfile, 0) );
|
||||
}
|
||||
#else
|
||||
set( Session::load(filename) );
|
||||
@@ -1548,9 +1552,14 @@ void Mixer::swap()
|
||||
Action::manager().init();
|
||||
|
||||
// notification
|
||||
if (session_->filename().empty())
|
||||
Log::Info("New session ready.");
|
||||
else {
|
||||
uint N = session_->size();
|
||||
std::string numsource = ( N>0 ? std::to_string(N) : "no" ) + " source" + (N>1 ? "s" : "");
|
||||
Log::Notify("Session '%s' loaded with %s.", session_->filename().c_str(), numsource.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Mixer::close(bool smooth)
|
||||
@@ -1568,6 +1577,9 @@ void Mixer::close(bool smooth)
|
||||
}
|
||||
else
|
||||
clear();
|
||||
|
||||
// closing session : filename at font in history should not be reloaded
|
||||
Settings::application.recentSessions.front_is_valid = false;
|
||||
}
|
||||
|
||||
void Mixer::clear()
|
||||
@@ -1584,9 +1596,6 @@ void Mixer::clear()
|
||||
|
||||
// need to deeply update view to apply eventual changes
|
||||
++View::need_deep_update_;
|
||||
|
||||
Settings::application.recentSessions.front_is_valid = false;
|
||||
Log::Info("New session ready.");
|
||||
}
|
||||
|
||||
void Mixer::set(Session *s)
|
||||
|
||||
@@ -83,9 +83,10 @@ void Settings::Save(uint64_t runtime)
|
||||
#ifdef VIMIX_VERSION_MAJOR
|
||||
pRoot->SetAttribute("major", VIMIX_VERSION_MAJOR);
|
||||
pRoot->SetAttribute("minor", VIMIX_VERSION_MINOR);
|
||||
pRoot->SetAttribute("patch", VIMIX_VERSION_PATCH);
|
||||
#endif
|
||||
|
||||
// runtime
|
||||
if (runtime>0)
|
||||
pRoot->SetAttribute("runtime", runtime + application.total_runtime);
|
||||
|
||||
string comment = "Settings for " + application.name;
|
||||
@@ -414,11 +415,25 @@ void Settings::Load()
|
||||
else if (XMLResultError(eResult))
|
||||
return;
|
||||
|
||||
|
||||
// first element should be called by the application name
|
||||
XMLElement *pRoot = xmlDoc.FirstChildElement(application.name.c_str());
|
||||
if (pRoot == nullptr)
|
||||
return;
|
||||
|
||||
// version
|
||||
int major, minor, patch;
|
||||
pRoot->QueryIntAttribute("major", &major);
|
||||
pRoot->QueryIntAttribute("minor", &minor);
|
||||
pRoot->QueryIntAttribute("patch", &patch);
|
||||
bool version_same = (major == VIMIX_VERSION_MAJOR)
|
||||
&& (minor == VIMIX_VERSION_MINOR)
|
||||
&& (patch == VIMIX_VERSION_PATCH);
|
||||
|
||||
//
|
||||
// Restore settings only if version is same
|
||||
//
|
||||
if (version_same) {
|
||||
|
||||
// runtime
|
||||
pRoot->QueryUnsigned64Attribute("runtime", &application.total_runtime);
|
||||
|
||||
@@ -591,7 +606,6 @@ void Settings::Load()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
application.windows[i] = w;
|
||||
}
|
||||
}
|
||||
@@ -645,12 +659,35 @@ void Settings::Load()
|
||||
if (translationNode)
|
||||
tinyxml2::XMLElementToGLM( translationNode->FirstChildElement("vec3"),
|
||||
application.views[id].default_translation);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mapping
|
||||
XMLElement * mappingconfnode = pRoot->FirstChildElement("Mapping");
|
||||
if (mappingconfnode != nullptr) {
|
||||
mappingconfnode->QueryUnsigned64Attribute("mode", &application.mapping.mode);
|
||||
mappingconfnode->QueryUnsignedAttribute("current", &application.mapping.current);
|
||||
mappingconfnode->QueryBoolAttribute("disabled", &application.mapping.disabled);
|
||||
}
|
||||
|
||||
// Timer Metronome
|
||||
XMLElement * timerconfnode = pRoot->FirstChildElement("Timer");
|
||||
if (timerconfnode != nullptr) {
|
||||
timerconfnode->QueryUnsigned64Attribute("mode", &application.timer.mode);
|
||||
timerconfnode->QueryBoolAttribute("link_enabled", &application.timer.link_enabled);
|
||||
timerconfnode->QueryDoubleAttribute("link_tempo", &application.timer.link_tempo);
|
||||
timerconfnode->QueryDoubleAttribute("link_quantum", &application.timer.link_quantum);
|
||||
timerconfnode->QueryBoolAttribute("link_start_stop_sync", &application.timer.link_start_stop_sync);
|
||||
timerconfnode->QueryUnsigned64Attribute("stopwatch_duration", &application.timer.stopwatch_duration);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Restore history and user entries
|
||||
//
|
||||
|
||||
// bloc history of recent
|
||||
{
|
||||
XMLElement * pElement = pRoot->FirstChildElement("Recent");
|
||||
@@ -702,27 +739,8 @@ void Settings::Load()
|
||||
}
|
||||
}
|
||||
|
||||
// Timer Metronome
|
||||
XMLElement * timerconfnode = pRoot->FirstChildElement("Timer");
|
||||
if (timerconfnode != nullptr) {
|
||||
timerconfnode->QueryUnsigned64Attribute("mode", &application.timer.mode);
|
||||
timerconfnode->QueryBoolAttribute("link_enabled", &application.timer.link_enabled);
|
||||
timerconfnode->QueryDoubleAttribute("link_tempo", &application.timer.link_tempo);
|
||||
timerconfnode->QueryDoubleAttribute("link_quantum", &application.timer.link_quantum);
|
||||
timerconfnode->QueryBoolAttribute("link_start_stop_sync", &application.timer.link_start_stop_sync);
|
||||
timerconfnode->QueryUnsigned64Attribute("stopwatch_duration", &application.timer.stopwatch_duration);
|
||||
}
|
||||
|
||||
// Mapping
|
||||
XMLElement * mappingconfnode = pRoot->FirstChildElement("Mapping");
|
||||
if (mappingconfnode != nullptr) {
|
||||
mappingconfnode->QueryUnsigned64Attribute("mode", &application.mapping.mode);
|
||||
mappingconfnode->QueryUnsignedAttribute("current", &application.mapping.current);
|
||||
mappingconfnode->QueryBoolAttribute("disabled", &application.mapping.disabled);
|
||||
}
|
||||
|
||||
// bloc Controller
|
||||
XMLElement *controlconfnode = pRoot->FirstChildElement("Control");
|
||||
XMLElement * controlconfnode = pRoot->FirstChildElement("Control");
|
||||
if (controlconfnode != nullptr) {
|
||||
controlconfnode->QueryIntAttribute("osc_port_receive", &application.control.osc_port_receive);
|
||||
controlconfnode->QueryIntAttribute("osc_port_send", &application.control.osc_port_send);
|
||||
|
||||
@@ -349,6 +349,7 @@ struct Application
|
||||
InputMappingConfig mapping;
|
||||
|
||||
Application() : fresh_start(false), instance_id(0), name(APP_NAME), executable(APP_NAME) {
|
||||
total_runtime = 0;
|
||||
scale = 1.f;
|
||||
accent_color = 0;
|
||||
smooth_transition = true;
|
||||
|
||||
@@ -223,6 +223,9 @@ bool UserInterface::Init()
|
||||
// init tooltips
|
||||
ImGuiToolkit::setToolTipsEnabled(Settings::application.show_tooptips);
|
||||
|
||||
// show about dialog on first run
|
||||
show_vimix_about = (Settings::application.total_runtime < 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2084,7 +2087,7 @@ void UserInterface::RenderSourceToolbar(bool *p_open, int* p_border, int *p_mode
|
||||
|
||||
void UserInterface::RenderAbout(bool* p_open)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(1100, 20), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowPos(ImVec2(600, 40), ImGuiCond_FirstUseEver);
|
||||
if (!ImGui::Begin("About " APP_TITLE, p_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
ImGui::End();
|
||||
@@ -2092,15 +2095,13 @@ void UserInterface::RenderAbout(bool* p_open)
|
||||
}
|
||||
|
||||
ImVec2 top = ImGui::GetCursorScreenPos();
|
||||
#ifdef VIMIX_VERSION_MAJOR
|
||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
|
||||
#ifdef VIMIX_VERSION_MAJOR
|
||||
ImGui::Text("%s %d.%d.%d", APP_NAME, VIMIX_VERSION_MAJOR, VIMIX_VERSION_MINOR, VIMIX_VERSION_PATCH);
|
||||
ImGui::PopFont();
|
||||
#else
|
||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_BOLD);
|
||||
ImGui::Text("%s", APP_NAME);
|
||||
ImGui::PopFont();
|
||||
#endif
|
||||
ImGui::PopFont();
|
||||
|
||||
#ifdef VIMIX_GIT
|
||||
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_ITALIC);
|
||||
|
||||
@@ -102,6 +102,8 @@ int main(int argc, char *argv[])
|
||||
else {
|
||||
// try to open the file
|
||||
_openfile = argument;
|
||||
if (!_openfile.empty())
|
||||
fprintf(stderr, "Loading '%s' ...\n", _openfile.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,11 +116,6 @@ int main(int argc, char *argv[])
|
||||
/// lock to inform an instance is running
|
||||
Settings::Lock();
|
||||
|
||||
if (!_openfile.empty()) {
|
||||
Settings::application.fresh_start = false;
|
||||
fprintf(stderr, "Loading %s\n", _openfile.c_str());
|
||||
}
|
||||
|
||||
///
|
||||
/// CONNECTION INIT
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user