diff --git a/adapters/standalone.cpp b/adapters/standalone.cpp index 9e5dc2aa..08996021 100644 --- a/adapters/standalone.cpp +++ b/adapters/standalone.cpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -179,7 +179,7 @@ int main(int argc, char* argv[]) { discord::init(); if (!settings::headless) { ui::init(); - windowInit(); + window::init(); } // Initialize context @@ -192,7 +192,7 @@ int main(int argc, char* argv[]) { APP->event->rootWidget = APP->scene; APP->patch = new PatchManager; if (!settings::headless) { - APP->window = new Window; + APP->window = new window::Window; } // On Mac, use a hacked-in GLFW addition to get the launched path. @@ -234,7 +234,7 @@ int main(int argc, char* argv[]) { // delete APP->window; // APP->window = NULL; // INFO("Re-creating window"); - // APP->window = new Window; + // APP->window = new window::Window; // APP->window->run(); } @@ -252,7 +252,7 @@ int main(int argc, char* argv[]) { // Destroy environment INFO("Destroying environment"); if (!settings::headless) { - windowDestroy(); + window::destroy(); ui::destroy(); } discord::destroy(); diff --git a/include/context.hpp b/include/context.hpp index 244aba9d..8cc34a14 100644 --- a/include/context.hpp +++ b/include/context.hpp @@ -15,7 +15,11 @@ struct Engine; } // namespace engine +namespace window { struct Window; +} // namespace window + + struct PatchManager; @@ -35,7 +39,7 @@ struct Context { widget::EventState* event = NULL; app::Scene* scene = NULL; engine::Engine* engine = NULL; - Window* window = NULL; + window::Window* window = NULL; history::State* history = NULL; PatchManager* patch = NULL; diff --git a/include/rack.hpp b/include/rack.hpp index f729b9c2..eb1b7b86 100644 --- a/include/rack.hpp +++ b/include/rack.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -114,6 +114,7 @@ namespace rack { // Import some namespaces for convenience using namespace logger; using namespace math; +using namespace window; using namespace widget; using namespace ui; using namespace app; diff --git a/include/widget/Widget.hpp b/include/widget/Widget.hpp index 6de5ec71..61237b12 100644 --- a/include/widget/Widget.hpp +++ b/include/widget/Widget.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/Window.hpp b/include/window.hpp similarity index 93% rename from include/Window.hpp rename to include/window.hpp index e719d923..927dab08 100644 --- a/include/Window.hpp +++ b/include/window.hpp @@ -19,10 +19,12 @@ namespace rack { +namespace window { // Constructing these directly will load from the disk each time. Use the load() functions to load from disk and cache them as long as the shared_ptr is held. +/** Text font loaded in a particular Window context. */ struct Font { NVGcontext* vg; int handle = -1; @@ -33,6 +35,8 @@ struct Font { DEPRECATED static std::shared_ptr load(const std::string& filename); }; + +/** Bitmap/raster image loaded in a particular Window context. */ struct Image { NVGcontext* vg; int handle = -1; @@ -99,8 +103,9 @@ struct Window { }; -void windowInit(); -void windowDestroy(); +void init(); +void destroy(); +} // namespace window } // namespace rack diff --git a/src/app/LedDisplay.cpp b/src/app/LedDisplay.cpp index c3227704..d0a98ca8 100644 --- a/src/app/LedDisplay.cpp +++ b/src/app/LedDisplay.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include @@ -53,7 +53,7 @@ void LedDisplayChoice::draw(const DrawArgs& args) { nvgFill(args.vg); } - std::shared_ptr font = APP->window->loadFont(fontPath); + std::shared_ptr font = APP->window->loadFont(fontPath); nvgGlobalAlpha(args.vg, 1.0); if (font && font->handle >= 0) { nvgFillColor(args.vg, color); @@ -98,7 +98,7 @@ void LedDisplayTextField::draw(const DrawArgs& args) { } // Text - std::shared_ptr font = APP->window->loadFont(fontPath); + std::shared_ptr font = APP->window->loadFont(fontPath); nvgGlobalAlpha(args.vg, 1.0); if (font && font->handle >= 0) { bndSetFont(font->handle); @@ -120,7 +120,7 @@ void LedDisplayTextField::draw(const DrawArgs& args) { int LedDisplayTextField::getTextPosition(math::Vec mousePos) { - std::shared_ptr font = APP->window->loadFont(fontPath); + std::shared_ptr font = APP->window->loadFont(fontPath); if (!font || !font->handle) return 0; diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 847d615f..f5ff4466 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/app/PortWidget.cpp b/src/app/PortWidget.cpp index 7e2d3ce6..b978ba88 100644 --- a/src/app/PortWidget.cpp +++ b/src/app/PortWidget.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index f25ed5ea..6145c597 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/src/context.cpp b/src/context.cpp index cf29e32a..beaeceab 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/gamepad.cpp b/src/gamepad.cpp index 208faaad..deff9224 100644 --- a/src/gamepad.cpp +++ b/src/gamepad.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include namespace rack { diff --git a/src/keyboard.cpp b/src/keyboard.cpp index 6043f3eb..3e731f87 100644 --- a/src/keyboard.cpp +++ b/src/keyboard.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include namespace rack { diff --git a/src/library.cpp b/src/library.cpp index 5b144539..89ca002a 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/settings.cpp b/src/settings.cpp index b20df298..47ee9dc8 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/ui/Scrollbar.cpp b/src/ui/Scrollbar.cpp index 83ecde2c..0e6f6ea9 100644 --- a/src/ui/Scrollbar.cpp +++ b/src/ui/Scrollbar.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include namespace rack { diff --git a/src/widget/event.cpp b/src/widget/event.cpp index 582879a2..7cb87909 100644 --- a/src/widget/event.cpp +++ b/src/widget/event.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include diff --git a/src/Window.cpp b/src/window.cpp similarity index 99% rename from src/Window.cpp rename to src/window.cpp index 05448673..fed8429f 100644 --- a/src/Window.cpp +++ b/src/window.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -24,6 +24,7 @@ namespace rack { +namespace window { static const math::Vec minWindowSize = math::Vec(640, 480); @@ -722,7 +723,7 @@ bool& Window::fbDirtyOnSubpixelChange() { } -void windowInit() { +void init() { int err; // Set up GLFW @@ -740,9 +741,10 @@ void windowInit() { } -void windowDestroy() { +void destroy() { glfwTerminate(); } +} // namespace window } // namespace rack