@@ -16,7 +16,7 @@ namespace rack { | |||||
//////////////////// | //////////////////// | ||||
// 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. | ||||
// Implemented in gui.cpp | |||||
// Implemented in window.cpp | |||||
struct Font { | struct Font { | ||||
int handle; | int handle; | ||||
@@ -5,9 +5,9 @@ | |||||
#ifdef ARCH_MAC | #ifdef ARCH_MAC | ||||
#define GUI_MOD_KEY_NAME "Cmd" | |||||
#define WINDOW_MOD_KEY_NAME "Cmd" | |||||
#else | #else | ||||
#define GUI_MOD_KEY_NAME "Ctrl" | |||||
#define WINDOW_MOD_KEY_NAME "Ctrl" | |||||
#endif | #endif | ||||
@@ -30,19 +30,19 @@ extern int gGuiFrame; | |||||
extern Vec gMousePos; | extern Vec gMousePos; | ||||
void guiInit(); | |||||
void guiDestroy(); | |||||
void guiRun(); | |||||
void guiClose(); | |||||
void guiCursorLock(); | |||||
void guiCursorUnlock(); | |||||
bool guiIsModPressed(); | |||||
bool guiIsShiftPressed(); | |||||
Vec guiGetWindowSize(); | |||||
void guiSetWindowSize(Vec size); | |||||
Vec guiGetWindowPos(); | |||||
void guiSetWindowPos(Vec pos); | |||||
bool guiIsMaximized(); | |||||
void windowInit(); | |||||
void windowDestroy(); | |||||
void windowRun(); | |||||
void windowClose(); | |||||
void windowCursorLock(); | |||||
void windowCursorUnlock(); | |||||
bool windowIsModPressed(); | |||||
bool windowIsShiftPressed(); | |||||
Vec windowGetWindowSize(); | |||||
void windowSetWindowSize(Vec size); | |||||
Vec windowGetWindowPos(); | |||||
void windowSetWindowPos(Vec pos); | |||||
bool windowIsMaximized(); | |||||
} // namespace rack | } // namespace rack |
@@ -1,5 +1,5 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "engine.hpp" | #include "engine.hpp" | ||||
// For GLFW_KEY_LEFT_CONTROL, etc. | // For GLFW_KEY_LEFT_CONTROL, etc. | ||||
#include <GLFW/glfw3.h> | #include <GLFW/glfw3.h> | ||||
@@ -11,7 +11,7 @@ namespace rack { | |||||
void Knob::onDragStart(EventDragStart &e) { | void Knob::onDragStart(EventDragStart &e) { | ||||
guiCursorLock(); | |||||
windowCursorLock(); | |||||
dragValue = value; | dragValue = value; | ||||
randomizable = false; | randomizable = false; | ||||
} | } | ||||
@@ -23,7 +23,7 @@ void Knob::onDragMove(EventDragMove &e) { | |||||
delta *= range; | delta *= range; | ||||
// Drag slower if Mod is held | // Drag slower if Mod is held | ||||
if (guiIsModPressed()) | |||||
if (windowIsModPressed()) | |||||
delta /= 16.0; | delta /= 16.0; | ||||
dragValue += delta; | dragValue += delta; | ||||
if (snap) | if (snap) | ||||
@@ -33,7 +33,7 @@ void Knob::onDragMove(EventDragMove &e) { | |||||
} | } | ||||
void Knob::onDragEnd(EventDragEnd &e) { | void Knob::onDragEnd(EventDragEnd &e) { | ||||
guiCursorUnlock(); | |||||
windowCursorUnlock(); | |||||
randomizable = true; | randomizable = true; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "engine.hpp" | #include "engine.hpp" | ||||
#include "plugin.hpp" | #include "plugin.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -220,7 +220,7 @@ void ModuleWidget::onMouseMove(EventMouseMove &e) { | |||||
if (!gFocusedWidget) { | if (!gFocusedWidget) { | ||||
// Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | // Instead of checking key-down events, delete the module even if key-repeat hasn't fired yet and the cursor is hovering over the widget. | ||||
if (glfwGetKey(gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { | if (glfwGetKey(gWindow, GLFW_KEY_DELETE) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { | ||||
if (!guiIsModPressed() && !guiIsShiftPressed()) { | |||||
if (!windowIsModPressed() && !windowIsShiftPressed()) { | |||||
gRackWidget->deleteModule(this); | gRackWidget->deleteModule(this); | ||||
this->finalizeEvents(); | this->finalizeEvents(); | ||||
delete this; | delete this; | ||||
@@ -234,21 +234,21 @@ void ModuleWidget::onMouseMove(EventMouseMove &e) { | |||||
void ModuleWidget::onHoverKey(EventHoverKey &e) { | void ModuleWidget::onHoverKey(EventHoverKey &e) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_I: | case GLFW_KEY_I: | ||||
if (guiIsModPressed() && !guiIsShiftPressed()) { | |||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | |||||
reset(); | reset(); | ||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
} | } | ||||
break; | break; | ||||
case GLFW_KEY_R: | case GLFW_KEY_R: | ||||
if (guiIsModPressed() && !guiIsShiftPressed()) { | |||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | |||||
randomize(); | randomize(); | ||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
} | } | ||||
break; | break; | ||||
case GLFW_KEY_D: | case GLFW_KEY_D: | ||||
if (guiIsModPressed() && !guiIsShiftPressed()) { | |||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | |||||
gRackWidget->cloneModule(this); | gRackWidget->cloneModule(this); | ||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
@@ -319,13 +319,13 @@ Menu *ModuleWidget::createContextMenu() { | |||||
ResetMenuItem *resetItem = new ResetMenuItem(); | ResetMenuItem *resetItem = new ResetMenuItem(); | ||||
resetItem->text = "Initialize"; | resetItem->text = "Initialize"; | ||||
resetItem->rightText = GUI_MOD_KEY_NAME "+I"; | |||||
resetItem->rightText = WINDOW_MOD_KEY_NAME "+I"; | |||||
resetItem->moduleWidget = this; | resetItem->moduleWidget = this; | ||||
menu->addChild(resetItem); | menu->addChild(resetItem); | ||||
RandomizeMenuItem *randomizeItem = new RandomizeMenuItem(); | RandomizeMenuItem *randomizeItem = new RandomizeMenuItem(); | ||||
randomizeItem->text = "Randomize"; | randomizeItem->text = "Randomize"; | ||||
randomizeItem->rightText = GUI_MOD_KEY_NAME "+R"; | |||||
randomizeItem->rightText = WINDOW_MOD_KEY_NAME "+R"; | |||||
randomizeItem->moduleWidget = this; | randomizeItem->moduleWidget = this; | ||||
menu->addChild(randomizeItem); | menu->addChild(randomizeItem); | ||||
@@ -336,7 +336,7 @@ Menu *ModuleWidget::createContextMenu() { | |||||
CloneMenuItem *cloneItem = new CloneMenuItem(); | CloneMenuItem *cloneItem = new CloneMenuItem(); | ||||
cloneItem->text = "Duplicate"; | cloneItem->text = "Duplicate"; | ||||
cloneItem->rightText = GUI_MOD_KEY_NAME "+D"; | |||||
cloneItem->rightText = WINDOW_MOD_KEY_NAME "+D"; | |||||
cloneItem->moduleWidget = this; | cloneItem->moduleWidget = this; | ||||
menu->addChild(cloneItem); | menu->addChild(cloneItem); | ||||
@@ -1,7 +1,7 @@ | |||||
#include <thread> | #include <thread> | ||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "plugin.hpp" | #include "plugin.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "../ext/osdialog/osdialog.h" | #include "../ext/osdialog/osdialog.h" | ||||
@@ -24,7 +24,7 @@ struct SyncButton : Button { | |||||
} | } | ||||
if (completed) { | if (completed) { | ||||
if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "All plugins have been updated. Close Rack and re-launch it to load new updates.")) { | if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "All plugins have been updated. Close Rack and re-launch it to load new updates.")) { | ||||
guiClose(); | |||||
windowClose(); | |||||
} | } | ||||
completed = false; | completed = false; | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "engine.hpp" | #include "engine.hpp" | ||||
#include "componentlibrary.hpp" | #include "componentlibrary.hpp" | ||||
@@ -65,7 +65,7 @@ void Port::onMouseDown(EventMouseDown &e) { | |||||
void Port::onDragStart(EventDragStart &e) { | void Port::onDragStart(EventDragStart &e) { | ||||
// Try to grab wire on top of stack | // Try to grab wire on top of stack | ||||
WireWidget *wire = gRackWidget->wireContainer->getTopWire(this); | WireWidget *wire = gRackWidget->wireContainer->getTopWire(this); | ||||
if (type == OUTPUT && guiIsModPressed()) { | |||||
if (type == OUTPUT && windowIsModPressed()) { | |||||
wire = NULL; | wire = NULL; | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "util/request.hpp" | #include "util/request.hpp" | ||||
#include "../ext/osdialog/osdialog.h" | #include "../ext/osdialog/osdialog.h" | ||||
#include <string.h> | #include <string.h> | ||||
@@ -75,7 +75,7 @@ void RackScene::step() { | |||||
if (osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, versionMessage.c_str())) { | if (osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, versionMessage.c_str())) { | ||||
std::thread t(openBrowser, "https://vcvrack.com/"); | std::thread t(openBrowser, "https://vcvrack.com/"); | ||||
t.detach(); | t.detach(); | ||||
guiClose(); | |||||
windowClose(); | |||||
} | } | ||||
newVersion = ""; | newVersion = ""; | ||||
} | } | ||||
@@ -91,33 +91,33 @@ void RackScene::onHoverKey(EventHoverKey &e) { | |||||
if (!e.consumed) { | if (!e.consumed) { | ||||
switch (e.key) { | switch (e.key) { | ||||
case GLFW_KEY_N: { | case GLFW_KEY_N: { | ||||
if (guiIsModPressed() && !guiIsShiftPressed()) { | |||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | |||||
gRackWidget->reset(); | gRackWidget->reset(); | ||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_Q: { | case GLFW_KEY_Q: { | ||||
if (guiIsModPressed() && !guiIsShiftPressed()) { | |||||
guiClose(); | |||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | |||||
windowClose(); | |||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_O: { | case GLFW_KEY_O: { | ||||
if (guiIsModPressed() && !guiIsShiftPressed()) { | |||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | |||||
gRackWidget->openDialog(); | gRackWidget->openDialog(); | ||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
} | } | ||||
} break; | } break; | ||||
case GLFW_KEY_S: { | case GLFW_KEY_S: { | ||||
if (guiIsModPressed() && !guiIsShiftPressed()) { | |||||
if (windowIsModPressed() && !windowIsShiftPressed()) { | |||||
gRackWidget->saveDialog(); | gRackWidget->saveDialog(); | ||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
} | } | ||||
if (guiIsModPressed() && guiIsShiftPressed()) { | |||||
if (windowIsModPressed() && windowIsShiftPressed()) { | |||||
gRackWidget->saveAsDialog(); | gRackWidget->saveAsDialog(); | ||||
e.consumed = true; | e.consumed = true; | ||||
return; | return; | ||||
@@ -1,5 +1,5 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -1,7 +1,7 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "engine.hpp" | #include "engine.hpp" | ||||
#include "plugin.hpp" | #include "plugin.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "settings.hpp" | #include "settings.hpp" | ||||
#include "asset.hpp" | #include "asset.hpp" | ||||
#include <map> | #include <map> | ||||
@@ -1,5 +1,5 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -1,5 +1,5 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "engine.hpp" | #include "engine.hpp" | ||||
@@ -32,7 +32,7 @@ struct SaveAsItem : MenuItem { | |||||
struct QuitItem : MenuItem { | struct QuitItem : MenuItem { | ||||
void onAction(EventAction &e) override { | void onAction(EventAction &e) override { | ||||
guiClose(); | |||||
windowClose(); | |||||
} | } | ||||
}; | }; | ||||
@@ -43,11 +43,11 @@ struct FileChoice : ChoiceButton { | |||||
menu->box.size.x = box.size.x; | menu->box.size.x = box.size.x; | ||||
{ | { | ||||
menu->addChild(construct<NewItem>(&MenuItem::text, "New", &MenuItem::rightText, GUI_MOD_KEY_NAME "+N")); | |||||
menu->addChild(construct<OpenItem>(&MenuItem::text, "Open", &MenuItem::rightText, GUI_MOD_KEY_NAME "+O")); | |||||
menu->addChild(construct<SaveItem>(&MenuItem::text, "Save", &MenuItem::rightText, GUI_MOD_KEY_NAME "+S")); | |||||
menu->addChild(construct<SaveAsItem>(&MenuItem::text, "Save as", &MenuItem::rightText, GUI_MOD_KEY_NAME "+Shift+S")); | |||||
menu->addChild(construct<QuitItem>(&MenuItem::text, "Quit", &MenuItem::rightText, GUI_MOD_KEY_NAME "+Q")); | |||||
menu->addChild(construct<NewItem>(&MenuItem::text, "New", &MenuItem::rightText, WINDOW_MOD_KEY_NAME "+N")); | |||||
menu->addChild(construct<OpenItem>(&MenuItem::text, "Open", &MenuItem::rightText, WINDOW_MOD_KEY_NAME "+O")); | |||||
menu->addChild(construct<SaveItem>(&MenuItem::text, "Save", &MenuItem::rightText, WINDOW_MOD_KEY_NAME "+S")); | |||||
menu->addChild(construct<SaveAsItem>(&MenuItem::text, "Save as", &MenuItem::rightText, WINDOW_MOD_KEY_NAME "+Shift+S")); | |||||
menu->addChild(construct<QuitItem>(&MenuItem::text, "Quit", &MenuItem::rightText, WINDOW_MOD_KEY_NAME "+Q")); | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
@@ -1,7 +1,7 @@ | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "engine.hpp" | #include "engine.hpp" | ||||
#include "componentlibrary.hpp" | #include "componentlibrary.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -62,7 +62,7 @@ void engineInit() { | |||||
} | } | ||||
void engineDestroy() { | void engineDestroy() { | ||||
// Make sure there are no wires or modules in the rack on destruction. This suggests that a module failed to remove itself before the GUI was destroyed. | |||||
// Make sure there are no wires or modules in the rack on destruction. This suggests that a module failed to remove itself before the WINDOW was destroyed. | |||||
assert(wires.empty()); | assert(wires.empty()); | ||||
assert(modules.empty()); | assert(modules.empty()); | ||||
} | } | ||||
@@ -1,6 +1,6 @@ | |||||
#include "util/common.hpp" | #include "util/common.hpp" | ||||
#include "engine.hpp" | #include "engine.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "plugin.hpp" | #include "plugin.hpp" | ||||
#include "settings.hpp" | #include "settings.hpp" | ||||
@@ -33,7 +33,7 @@ int main(int argc, char* argv[]) { | |||||
pluginInit(); | pluginInit(); | ||||
engineInit(); | engineInit(); | ||||
guiInit(); | |||||
windowInit(); | |||||
sceneInit(); | sceneInit(); | ||||
settingsLoad(assetLocal("settings.json")); | settingsLoad(assetLocal("settings.json")); | ||||
@@ -50,13 +50,13 @@ int main(int argc, char* argv[]) { | |||||
} | } | ||||
engineStart(); | engineStart(); | ||||
guiRun(); | |||||
windowRun(); | |||||
engineStop(); | engineStop(); | ||||
gRackWidget->savePatch(assetLocal("autosave.vcv")); | gRackWidget->savePatch(assetLocal("autosave.vcv")); | ||||
settingsSave(assetLocal("settings.json")); | settingsSave(assetLocal("settings.json")); | ||||
sceneDestroy(); | sceneDestroy(); | ||||
guiDestroy(); | |||||
windowDestroy(); | |||||
engineDestroy(); | engineDestroy(); | ||||
pluginDestroy(); | pluginDestroy(); | ||||
@@ -1,6 +1,6 @@ | |||||
#include "settings.hpp" | #include "settings.hpp" | ||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "engine.hpp" | #include "engine.hpp" | ||||
#include "plugin.hpp" | #include "plugin.hpp" | ||||
#include <jansson.h> | #include <jansson.h> | ||||
@@ -20,14 +20,14 @@ static json_t *settingsToJson() { | |||||
json_t *tokenJ = json_string(gToken.c_str()); | json_t *tokenJ = json_string(gToken.c_str()); | ||||
json_object_set_new(rootJ, "token", tokenJ); | json_object_set_new(rootJ, "token", tokenJ); | ||||
if (!guiIsMaximized()) { | |||||
if (!windowIsMaximized()) { | |||||
// windowSize | // windowSize | ||||
Vec windowSize = guiGetWindowSize(); | |||||
Vec windowSize = windowGetWindowSize(); | |||||
json_t *windowSizeJ = json_pack("[f, f]", windowSize.x, windowSize.y); | json_t *windowSizeJ = json_pack("[f, f]", windowSize.x, windowSize.y); | ||||
json_object_set_new(rootJ, "windowSize", windowSizeJ); | json_object_set_new(rootJ, "windowSize", windowSizeJ); | ||||
// windowPos | // windowPos | ||||
Vec windowPos = guiGetWindowPos(); | |||||
Vec windowPos = windowGetWindowPos(); | |||||
json_t *windowPosJ = json_pack("[f, f]", windowPos.x, windowPos.y); | json_t *windowPosJ = json_pack("[f, f]", windowPos.x, windowPos.y); | ||||
json_object_set_new(rootJ, "windowPos", windowPosJ); | json_object_set_new(rootJ, "windowPos", windowPosJ); | ||||
} | } | ||||
@@ -78,7 +78,7 @@ static void settingsFromJson(json_t *rootJ) { | |||||
if (windowSizeJ) { | if (windowSizeJ) { | ||||
double width, height; | double width, height; | ||||
json_unpack(windowSizeJ, "[F, F]", &width, &height); | json_unpack(windowSizeJ, "[F, F]", &width, &height); | ||||
guiSetWindowSize(Vec(width, height)); | |||||
windowSetWindowSize(Vec(width, height)); | |||||
} | } | ||||
// windowPos | // windowPos | ||||
@@ -86,7 +86,7 @@ static void settingsFromJson(json_t *rootJ) { | |||||
if (windowPosJ) { | if (windowPosJ) { | ||||
double x, y; | double x, y; | ||||
json_unpack(windowPosJ, "[F, F]", &x, &y); | json_unpack(windowPosJ, "[F, F]", &x, &y); | ||||
guiSetWindowPos(Vec(x, y)); | |||||
windowSetWindowPos(Vec(x, y)); | |||||
} | } | ||||
// opacity | // opacity | ||||
@@ -1,5 +1,5 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -26,7 +26,7 @@ void MenuItem::draw(NVGcontext *vg) { | |||||
void MenuItem::step() { | void MenuItem::step() { | ||||
// Add 10 more pixels because Retina measurements are sometimes too small | // Add 10 more pixels because Retina measurements are sometimes too small | ||||
const float rightPadding = 10.0; | const float rightPadding = 10.0; | ||||
// HACK use gVg from the gui. | |||||
// HACK use gVg from the window. | |||||
// All this does is inspect the font, so it shouldn't modify gVg and should work when called from a FramebufferWidget for example. | // All this does is inspect the font, so it shouldn't modify gVg and should work when called from a FramebufferWidget for example. | ||||
box.size.x = bndLabelWidth(gVg, -1, text.c_str()) + bndLabelWidth(gVg, -1, rightText.c_str()) + rightPadding; | box.size.x = bndLabelWidth(gVg, -1, text.c_str()) + bndLabelWidth(gVg, -1, rightText.c_str()) + rightPadding; | ||||
Widget::step(); | Widget::step(); | ||||
@@ -1,5 +1,5 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -12,7 +12,7 @@ void MenuLabel::draw(NVGcontext *vg) { | |||||
void MenuLabel::step() { | void MenuLabel::step() { | ||||
// Add 10 more pixels because Retina measurements are sometimes too small | // Add 10 more pixels because Retina measurements are sometimes too small | ||||
const float rightPadding = 10.0; | const float rightPadding = 10.0; | ||||
// HACK use gVg from the gui. | |||||
// HACK use gVg from the window. | |||||
box.size.x = bndLabelWidth(gVg, -1, text.c_str()) + rightPadding; | box.size.x = bndLabelWidth(gVg, -1, text.c_str()) + rightPadding; | ||||
Widget::step(); | Widget::step(); | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
#include "widgets.hpp" | #include "widgets.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -1,5 +1,5 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -11,7 +11,7 @@ void ScrollBar::draw(NVGcontext *vg) { | |||||
void ScrollBar::onDragStart(EventDragStart &e) { | void ScrollBar::onDragStart(EventDragStart &e) { | ||||
state = BND_ACTIVE; | state = BND_ACTIVE; | ||||
guiCursorLock(); | |||||
windowCursorLock(); | |||||
} | } | ||||
void ScrollBar::onDragMove(EventDragMove &e) { | void ScrollBar::onDragMove(EventDragMove &e) { | ||||
@@ -25,7 +25,7 @@ void ScrollBar::onDragMove(EventDragMove &e) { | |||||
void ScrollBar::onDragEnd(EventDragEnd &e) { | void ScrollBar::onDragEnd(EventDragEnd &e) { | ||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
guiCursorUnlock(); | |||||
windowCursorUnlock(); | |||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -61,11 +61,11 @@ void ScrollWidget::onMouseMove(EventMouseMove &e) { | |||||
// Scroll with arrow keys | // Scroll with arrow keys | ||||
if (!gFocusedWidget) { | if (!gFocusedWidget) { | ||||
float arrowSpeed = 30.0; | float arrowSpeed = 30.0; | ||||
if (guiIsShiftPressed() && guiIsModPressed()) | |||||
if (windowIsShiftPressed() && windowIsModPressed()) | |||||
arrowSpeed /= 16.0; | arrowSpeed /= 16.0; | ||||
else if (guiIsShiftPressed()) | |||||
else if (windowIsShiftPressed()) | |||||
arrowSpeed *= 4.0; | arrowSpeed *= 4.0; | ||||
else if (guiIsModPressed()) | |||||
else if (windowIsModPressed()) | |||||
arrowSpeed /= 4.0; | arrowSpeed /= 4.0; | ||||
if (glfwGetKey(gWindow, GLFW_KEY_LEFT) == GLFW_PRESS) { | if (glfwGetKey(gWindow, GLFW_KEY_LEFT) == GLFW_PRESS) { | ||||
@@ -1,5 +1,5 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -13,7 +13,7 @@ void Slider::draw(NVGcontext *vg) { | |||||
void Slider::onDragStart(EventDragStart &e) { | void Slider::onDragStart(EventDragStart &e) { | ||||
state = BND_ACTIVE; | state = BND_ACTIVE; | ||||
guiCursorLock(); | |||||
windowCursorLock(); | |||||
} | } | ||||
void Slider::onDragMove(EventDragMove &e) { | void Slider::onDragMove(EventDragMove &e) { | ||||
@@ -22,7 +22,7 @@ void Slider::onDragMove(EventDragMove &e) { | |||||
void Slider::onDragEnd(EventDragEnd &e) { | void Slider::onDragEnd(EventDragEnd &e) { | ||||
state = BND_DEFAULT; | state = BND_DEFAULT; | ||||
guiCursorUnlock(); | |||||
windowCursorUnlock(); | |||||
EventAction eAction; | EventAction eAction; | ||||
onAction(eAction); | onAction(eAction); | ||||
} | } | ||||
@@ -1,6 +1,6 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
// for gVg | // for gVg | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
// for key codes | // for key codes | ||||
#include <GLFW/glfw3.h> | #include <GLFW/glfw3.h> | ||||
@@ -92,14 +92,14 @@ void TextField::onKey(EventKey &e) { | |||||
end = begin = text.size(); | end = begin = text.size(); | ||||
break; | break; | ||||
case GLFW_KEY_V: | case GLFW_KEY_V: | ||||
if (guiIsModPressed()) { | |||||
if (windowIsModPressed()) { | |||||
const char *newText = glfwGetClipboardString(gWindow); | const char *newText = glfwGetClipboardString(gWindow); | ||||
if (newText) | if (newText) | ||||
insertText(newText); | insertText(newText); | ||||
} | } | ||||
break; | break; | ||||
case GLFW_KEY_C: | case GLFW_KEY_C: | ||||
if (guiIsModPressed()) { | |||||
if (windowIsModPressed()) { | |||||
if (begin < end) { | if (begin < end) { | ||||
std::string selectedText = text.substr(begin, end - begin); | std::string selectedText = text.substr(begin, end - begin); | ||||
glfwSetClipboardString(gWindow, selectedText.c_str()); | glfwSetClipboardString(gWindow, selectedText.c_str()); | ||||
@@ -1,5 +1,5 @@ | |||||
#include "ui.hpp" | #include "ui.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
namespace rack { | namespace rack { | ||||
@@ -1,5 +1,5 @@ | |||||
#include "widgets.hpp" | #include "widgets.hpp" | ||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include <GL/glew.h> | #include <GL/glew.h> | ||||
#include "../ext/nanovg/src/nanovg_gl.h" | #include "../ext/nanovg/src/nanovg_gl.h" | ||||
#include "../ext/nanovg/src/nanovg_gl_utils.h" | #include "../ext/nanovg/src/nanovg_gl_utils.h" | ||||
@@ -1,4 +1,4 @@ | |||||
#include "gui.hpp" | |||||
#include "window.hpp" | |||||
#include "app.hpp" | #include "app.hpp" | ||||
#include "asset.hpp" | #include "asset.hpp" | ||||
@@ -30,6 +30,7 @@ | |||||
namespace rack { | namespace rack { | ||||
GLFWwindow *gWindow = NULL; | GLFWwindow *gWindow = NULL; | ||||
NVGcontext *gVg = NULL; | NVGcontext *gVg = NULL; | ||||
NVGcontext *gFramebufferVg = NULL; | NVGcontext *gFramebufferVg = NULL; | ||||
@@ -236,7 +237,7 @@ void cursorEnterCallback(GLFWwindow* window, int entered) { | |||||
void scrollCallback(GLFWwindow *window, double x, double y) { | void scrollCallback(GLFWwindow *window, double x, double y) { | ||||
Vec scrollRel = Vec(x, y); | Vec scrollRel = Vec(x, y); | ||||
#if ARCH_LIN || ARCH_WIN | #if ARCH_LIN || ARCH_WIN | ||||
if (guiIsShiftPressed()) | |||||
if (windowIsShiftPressed()) | |||||
scrollRel = Vec(y, x); | scrollRel = Vec(y, x); | ||||
#endif | #endif | ||||
// onScroll | // onScroll | ||||
@@ -305,7 +306,7 @@ void renderGui() { | |||||
glfwSwapBuffers(gWindow); | glfwSwapBuffers(gWindow); | ||||
} | } | ||||
void guiInit() { | |||||
void windowInit() { | |||||
int err; | int err; | ||||
// Set up GLFW | // Set up GLFW | ||||
@@ -393,7 +394,7 @@ void guiInit() { | |||||
bndSetTheme(theme); | bndSetTheme(theme); | ||||
} | } | ||||
void guiDestroy() { | |||||
void windowDestroy() { | |||||
gGuiFont.reset(); | gGuiFont.reset(); | ||||
#if defined NANOVG_GL2 | #if defined NANOVG_GL2 | ||||
@@ -416,7 +417,7 @@ void guiDestroy() { | |||||
glfwTerminate(); | glfwTerminate(); | ||||
} | } | ||||
void guiRun() { | |||||
void windowRun() { | |||||
assert(gWindow); | assert(gWindow); | ||||
gGuiFrame = 0; | gGuiFrame = 0; | ||||
while(!glfwWindowShouldClose(gWindow)) { | while(!glfwWindowShouldClose(gWindow)) { | ||||
@@ -483,11 +484,11 @@ void guiRun() { | |||||
} | } | ||||
} | } | ||||
void guiClose() { | |||||
void windowClose() { | |||||
glfwSetWindowShouldClose(gWindow, GLFW_TRUE); | glfwSetWindowShouldClose(gWindow, GLFW_TRUE); | ||||
} | } | ||||
void guiCursorLock() { | |||||
void windowCursorLock() { | |||||
if (gAllowCursorLock) { | if (gAllowCursorLock) { | ||||
#ifdef ARCH_MAC | #ifdef ARCH_MAC | ||||
glfwSetInputMode(gWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | glfwSetInputMode(gWindow, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); | ||||
@@ -497,13 +498,13 @@ void guiCursorLock() { | |||||
} | } | ||||
} | } | ||||
void guiCursorUnlock() { | |||||
void windowCursorUnlock() { | |||||
if (gAllowCursorLock) { | if (gAllowCursorLock) { | ||||
glfwSetInputMode(gWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | glfwSetInputMode(gWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL); | ||||
} | } | ||||
} | } | ||||
bool guiIsModPressed() { | |||||
bool windowIsModPressed() { | |||||
#ifdef ARCH_MAC | #ifdef ARCH_MAC | ||||
return glfwGetKey(gWindow, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS; | return glfwGetKey(gWindow, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS; | ||||
#else | #else | ||||
@@ -511,35 +512,35 @@ bool guiIsModPressed() { | |||||
#endif | #endif | ||||
} | } | ||||
bool guiIsShiftPressed() { | |||||
bool windowIsShiftPressed() { | |||||
return glfwGetKey(gWindow, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; | return glfwGetKey(gWindow, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || glfwGetKey(gWindow, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS; | ||||
} | } | ||||
Vec guiGetWindowSize() { | |||||
Vec windowGetWindowSize() { | |||||
int width, height; | int width, height; | ||||
glfwGetWindowSize(gWindow, &width, &height); | glfwGetWindowSize(gWindow, &width, &height); | ||||
return Vec(width, height); | return Vec(width, height); | ||||
} | } | ||||
void guiSetWindowSize(Vec size) { | |||||
void windowSetWindowSize(Vec size) { | |||||
int width = size.x; | int width = size.x; | ||||
int height = size.y; | int height = size.y; | ||||
glfwSetWindowSize(gWindow, width, height); | glfwSetWindowSize(gWindow, width, height); | ||||
} | } | ||||
Vec guiGetWindowPos() { | |||||
Vec windowGetWindowPos() { | |||||
int x, y; | int x, y; | ||||
glfwGetWindowPos(gWindow, &x, &y); | glfwGetWindowPos(gWindow, &x, &y); | ||||
return Vec(x, y); | return Vec(x, y); | ||||
} | } | ||||
void guiSetWindowPos(Vec pos) { | |||||
void windowSetWindowPos(Vec pos) { | |||||
int x = pos.x; | int x = pos.x; | ||||
int y = pos.y; | int y = pos.y; | ||||
glfwSetWindowPos(gWindow, x, y); | glfwSetWindowPos(gWindow, x, y); | ||||
} | } | ||||
bool guiIsMaximized() { | |||||
bool windowIsMaximized() { | |||||
return glfwGetWindowAttrib(gWindow, GLFW_MAXIMIZED); | return glfwGetWindowAttrib(gWindow, GLFW_MAXIMIZED); | ||||
} | } | ||||