@@ -13,7 +13,7 @@ | |||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
#include <plugin.hpp> | #include <plugin.hpp> | ||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <patch.hpp> | #include <patch.hpp> | ||||
#include <history.hpp> | #include <history.hpp> | ||||
#include <ui/common.hpp> | #include <ui/common.hpp> | ||||
@@ -179,7 +179,7 @@ int main(int argc, char* argv[]) { | |||||
discord::init(); | discord::init(); | ||||
if (!settings::headless) { | if (!settings::headless) { | ||||
ui::init(); | ui::init(); | ||||
windowInit(); | |||||
window::init(); | |||||
} | } | ||||
// Initialize context | // Initialize context | ||||
@@ -192,7 +192,7 @@ int main(int argc, char* argv[]) { | |||||
APP->event->rootWidget = APP->scene; | APP->event->rootWidget = APP->scene; | ||||
APP->patch = new PatchManager; | APP->patch = new PatchManager; | ||||
if (!settings::headless) { | 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. | // 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; | // delete APP->window; | ||||
// APP->window = NULL; | // APP->window = NULL; | ||||
// INFO("Re-creating window"); | // INFO("Re-creating window"); | ||||
// APP->window = new Window; | |||||
// APP->window = new window::Window; | |||||
// APP->window->run(); | // APP->window->run(); | ||||
} | } | ||||
@@ -252,7 +252,7 @@ int main(int argc, char* argv[]) { | |||||
// Destroy environment | // Destroy environment | ||||
INFO("Destroying environment"); | INFO("Destroying environment"); | ||||
if (!settings::headless) { | if (!settings::headless) { | ||||
windowDestroy(); | |||||
window::destroy(); | |||||
ui::destroy(); | ui::destroy(); | ||||
} | } | ||||
discord::destroy(); | discord::destroy(); | ||||
@@ -15,7 +15,11 @@ struct Engine; | |||||
} // namespace engine | } // namespace engine | ||||
namespace window { | |||||
struct Window; | struct Window; | ||||
} // namespace window | |||||
struct PatchManager; | struct PatchManager; | ||||
@@ -35,7 +39,7 @@ struct Context { | |||||
widget::EventState* event = NULL; | widget::EventState* event = NULL; | ||||
app::Scene* scene = NULL; | app::Scene* scene = NULL; | ||||
engine::Engine* engine = NULL; | engine::Engine* engine = NULL; | ||||
Window* window = NULL; | |||||
window::Window* window = NULL; | |||||
history::State* history = NULL; | history::State* history = NULL; | ||||
PatchManager* patch = NULL; | PatchManager* patch = NULL; | ||||
@@ -9,7 +9,7 @@ | |||||
#include <random.hpp> | #include <random.hpp> | ||||
#include <network.hpp> | #include <network.hpp> | ||||
#include <asset.hpp> | #include <asset.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <midi.hpp> | #include <midi.hpp> | ||||
#include <settings.hpp> | #include <settings.hpp> | ||||
@@ -114,6 +114,7 @@ namespace rack { | |||||
// Import some namespaces for convenience | // Import some namespaces for convenience | ||||
using namespace logger; | using namespace logger; | ||||
using namespace math; | using namespace math; | ||||
using namespace window; | |||||
using namespace widget; | using namespace widget; | ||||
using namespace ui; | using namespace ui; | ||||
using namespace app; | using namespace app; | ||||
@@ -3,7 +3,7 @@ | |||||
#include <common.hpp> | #include <common.hpp> | ||||
#include <math.hpp> | #include <math.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <color.hpp> | #include <color.hpp> | ||||
#include <widget/event.hpp> | #include <widget/event.hpp> | ||||
#include <weakptr.hpp> | #include <weakptr.hpp> | ||||
@@ -19,10 +19,12 @@ | |||||
namespace rack { | 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. | // 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 { | struct Font { | ||||
NVGcontext* vg; | NVGcontext* vg; | ||||
int handle = -1; | int handle = -1; | ||||
@@ -33,6 +35,8 @@ struct Font { | |||||
DEPRECATED static std::shared_ptr<Font> load(const std::string& filename); | DEPRECATED static std::shared_ptr<Font> load(const std::string& filename); | ||||
}; | }; | ||||
/** Bitmap/raster image loaded in a particular Window context. */ | |||||
struct Image { | struct Image { | ||||
NVGcontext* vg; | NVGcontext* vg; | ||||
int handle = -1; | int handle = -1; | ||||
@@ -99,8 +103,9 @@ struct Window { | |||||
}; | }; | ||||
void windowInit(); | |||||
void windowDestroy(); | |||||
void init(); | |||||
void destroy(); | |||||
} // namespace window | |||||
} // namespace rack | } // namespace rack |
@@ -1,6 +1,6 @@ | |||||
#include <app/LedDisplay.hpp> | #include <app/LedDisplay.hpp> | ||||
#include <asset.hpp> | #include <asset.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <context.hpp> | #include <context.hpp> | ||||
@@ -53,7 +53,7 @@ void LedDisplayChoice::draw(const DrawArgs& args) { | |||||
nvgFill(args.vg); | nvgFill(args.vg); | ||||
} | } | ||||
std::shared_ptr<Font> font = APP->window->loadFont(fontPath); | |||||
std::shared_ptr<window::Font> font = APP->window->loadFont(fontPath); | |||||
nvgGlobalAlpha(args.vg, 1.0); | nvgGlobalAlpha(args.vg, 1.0); | ||||
if (font && font->handle >= 0) { | if (font && font->handle >= 0) { | ||||
nvgFillColor(args.vg, color); | nvgFillColor(args.vg, color); | ||||
@@ -98,7 +98,7 @@ void LedDisplayTextField::draw(const DrawArgs& args) { | |||||
} | } | ||||
// Text | // Text | ||||
std::shared_ptr<Font> font = APP->window->loadFont(fontPath); | |||||
std::shared_ptr<window::Font> font = APP->window->loadFont(fontPath); | |||||
nvgGlobalAlpha(args.vg, 1.0); | nvgGlobalAlpha(args.vg, 1.0); | ||||
if (font && font->handle >= 0) { | if (font && font->handle >= 0) { | ||||
bndSetFont(font->handle); | bndSetFont(font->handle); | ||||
@@ -120,7 +120,7 @@ void LedDisplayTextField::draw(const DrawArgs& args) { | |||||
int LedDisplayTextField::getTextPosition(math::Vec mousePos) { | int LedDisplayTextField::getTextPosition(math::Vec mousePos) { | ||||
std::shared_ptr<Font> font = APP->window->loadFont(fontPath); | |||||
std::shared_ptr<window::Font> font = APP->window->loadFont(fontPath); | |||||
if (!font || !font->handle) | if (!font || !font->handle) | ||||
return 0; | return 0; | ||||
@@ -16,7 +16,7 @@ | |||||
#include <ui/ProgressBar.hpp> | #include <ui/ProgressBar.hpp> | ||||
#include <ui/Label.hpp> | #include <ui/Label.hpp> | ||||
#include <engine/Engine.hpp> | #include <engine/Engine.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <asset.hpp> | #include <asset.hpp> | ||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <settings.hpp> | #include <settings.hpp> | ||||
@@ -1,6 +1,6 @@ | |||||
#include <app/PortWidget.hpp> | #include <app/PortWidget.hpp> | ||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <history.hpp> | #include <history.hpp> | ||||
#include <engine/Engine.hpp> | #include <engine/Engine.hpp> | ||||
@@ -1,6 +1,6 @@ | |||||
#include <app/RackScrollWidget.hpp> | #include <app/RackScrollWidget.hpp> | ||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <settings.hpp> | #include <settings.hpp> | ||||
@@ -1,5 +1,5 @@ | |||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <patch.hpp> | #include <patch.hpp> | ||||
#include <engine/Engine.hpp> | #include <engine/Engine.hpp> | ||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
@@ -1,7 +1,7 @@ | |||||
#include <gamepad.hpp> | #include <gamepad.hpp> | ||||
#include <midi.hpp> | #include <midi.hpp> | ||||
#include <string.hpp> | #include <string.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
namespace rack { | namespace rack { | ||||
@@ -2,7 +2,7 @@ | |||||
#include <keyboard.hpp> | #include <keyboard.hpp> | ||||
#include <midi.hpp> | #include <midi.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
namespace rack { | namespace rack { | ||||
@@ -8,7 +8,7 @@ | |||||
#include <network.hpp> | #include <network.hpp> | ||||
#include <system.hpp> | #include <system.hpp> | ||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <asset.hpp> | #include <asset.hpp> | ||||
#include <settings.hpp> | #include <settings.hpp> | ||||
#include <plugin.hpp> | #include <plugin.hpp> | ||||
@@ -1,7 +1,7 @@ | |||||
#include <jansson.h> | #include <jansson.h> | ||||
#include <settings.hpp> | #include <settings.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <plugin.hpp> | #include <plugin.hpp> | ||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
#include <engine/Engine.hpp> | #include <engine/Engine.hpp> | ||||
@@ -1,7 +1,7 @@ | |||||
#include <ui/Scrollbar.hpp> | #include <ui/Scrollbar.hpp> | ||||
#include <ui/ScrollWidget.hpp> | #include <ui/ScrollWidget.hpp> | ||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
namespace rack { | namespace rack { | ||||
@@ -1,7 +1,7 @@ | |||||
#include <widget/event.hpp> | #include <widget/event.hpp> | ||||
#include <widget/Widget.hpp> | #include <widget/Widget.hpp> | ||||
#include <context.hpp> | #include <context.hpp> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <system.hpp> | #include <system.hpp> | ||||
@@ -10,7 +10,7 @@ | |||||
#include <stb_image_write.h> | #include <stb_image_write.h> | ||||
#include <osdialog.h> | #include <osdialog.h> | ||||
#include <Window.hpp> | |||||
#include <window.hpp> | |||||
#include <asset.hpp> | #include <asset.hpp> | ||||
#include <widget/Widget.hpp> | #include <widget/Widget.hpp> | ||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
@@ -24,6 +24,7 @@ | |||||
namespace rack { | namespace rack { | ||||
namespace window { | |||||
static const math::Vec minWindowSize = math::Vec(640, 480); | static const math::Vec minWindowSize = math::Vec(640, 480); | ||||
@@ -722,7 +723,7 @@ bool& Window::fbDirtyOnSubpixelChange() { | |||||
} | } | ||||
void windowInit() { | |||||
void init() { | |||||
int err; | int err; | ||||
// Set up GLFW | // Set up GLFW | ||||
@@ -740,9 +741,10 @@ void windowInit() { | |||||
} | } | ||||
void windowDestroy() { | |||||
void destroy() { | |||||
glfwTerminate(); | glfwTerminate(); | ||||
} | } | ||||
} // namespace window | |||||
} // namespace rack | } // namespace rack |