Browse Source

Fix initial scroll position for new projects

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 3 years ago
parent
commit
e920e18f1f
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 9 additions and 5 deletions
  1. +5
    -1
      src/CardinalPlugin.cpp
  2. +3
    -0
      src/CardinalUI.cpp
  3. +1
    -4
      src/override/Window.cpp

+ 5
- 1
src/CardinalPlugin.cpp View File

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


+ 3
- 0
src/CardinalUI.cpp View File

@@ -489,6 +489,9 @@ protected:
{ {
UI::onResize(ev); UI::onResize(ev);


if (fContext->window != nullptr)
fContext->window->setSize(rack::math::Vec(ev.size.getWidth(), ev.size.getHeight()));

const double scaleFactor = getScaleFactor(); const double scaleFactor = getScaleFactor();
char sizeString[64]; char sizeString[64];
std::snprintf(sizeString, sizeof(sizeString), "%d:%d", std::snprintf(sizeString, sizeof(sizeString), "%d:%d",


+ 1
- 4
src/override/Window.cpp 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 { struct Window::Internal {
DISTRHO_NAMESPACE::UI* ui = nullptr; DISTRHO_NAMESPACE::UI* ui = nullptr;
DISTRHO_NAMESPACE::WindowParameters params; DISTRHO_NAMESPACE::WindowParameters params;
@@ -131,6 +127,7 @@ void WindowInit(Window* const window, DISTRHO_NAMESPACE::UI* const ui)
INFO("OpenGL: %s", version); INFO("OpenGL: %s", version);


window->internal->ui = ui; window->internal->ui = ui;
window->internal->size = rack::math::Vec(ui->getWidth(), ui->getHeight());


window->vg = ui->getContext(); window->vg = ui->getContext();
#ifdef NANOVG_GLES2 #ifdef NANOVG_GLES2


Loading…
Cancel
Save