Fix initial scroll position for new projects

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-10-29 19:53:59 +01:00
parent 9b9d8f6d4d
commit e920e18f1f
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
3 changed files with 9 additions and 5 deletions

View file

@ -87,6 +87,7 @@ struct Initializer
settings::isPlugin = true;
settings::skipLoadOnLaunch = true;
settings::showTipsOnLaunch = false;
settings::windowPos = math::Vec(0, 0);
#ifdef HEADLESS
settings::headless = true;
#endif
@ -373,6 +374,7 @@ public:
context->scene = new rack::app::Scene;
context->event->rootWidget = context->scene;
context->patch->loadTemplate();
context->scene->rackScroll->reset();
context->engine->startFallbackThread();
#ifdef HAVE_LIBLO
@ -711,7 +713,8 @@ protected:
context->engine->prepareSave();
context->patch->saveAutosave();
context->patch->cleanAutosave();
// context->history->setSaved();
try {
data = rack::system::archiveDirectory(fAutosavePath, 1);
} DISTRHO_SAFE_EXCEPTION_RETURN("getState archiveDirectory", String());
@ -742,6 +745,7 @@ protected:
rack::system::unarchiveToDirectory(data, fAutosavePath);
context->patch->loadAutosave();
// context->history->setSaved();
}
/* --------------------------------------------------------------------------------------------------------

View file

@ -489,6 +489,9 @@ protected:
{
UI::onResize(ev);
if (fContext->window != nullptr)
fContext->window->setSize(rack::math::Vec(ev.size.getWidth(), ev.size.getHeight()));
const double scaleFactor = getScaleFactor();
char sizeString[64];
std::snprintf(sizeString, sizeof(sizeString), "%d:%d",

View file

@ -93,10 +93,6 @@ std::shared_ptr<Image> Image::load(const std::string& filename) {
}
struct WindowParams {
float rackBrightness = 1.0f;
};
struct Window::Internal {
DISTRHO_NAMESPACE::UI* ui = nullptr;
DISTRHO_NAMESPACE::WindowParameters params;
@ -131,6 +127,7 @@ void WindowInit(Window* const window, DISTRHO_NAMESPACE::UI* const ui)
INFO("OpenGL: %s", version);
window->internal->ui = ui;
window->internal->size = rack::math::Vec(ui->getWidth(), ui->getHeight());
window->vg = ui->getContext();
#ifdef NANOVG_GLES2