@@ -1,7 +1,7 @@ | |||
RACK_DIR ?= . | |||
VERSION = 1.dev | |||
FLAGS += -DVERSION=$(VERSION) | |||
FLAGS += -DAPP_VERSION=$(VERSION) | |||
FLAGS += -Iinclude | |||
FLAGS += -Idep/include -Idep/lib/libzip/include | |||
@@ -13,12 +13,18 @@ namespace history { | |||
struct State; | |||
} | |||
struct Scene; | |||
struct Engine; | |||
struct Window; | |||
struct PatchManager; | |||
namespace app { | |||
struct Scene; | |||
/** Contains the application state */ | |||
struct App { | |||
event::State *event = NULL; | |||
@@ -33,10 +39,15 @@ struct App { | |||
}; | |||
void appInit(); | |||
void appDestroy(); | |||
/** Returns the global context */ | |||
App *app(); | |||
void init(); | |||
void destroy(); | |||
/** Returns the global App pointer */ | |||
App *get(); | |||
/** Accesses the global App pointer */ | |||
#define APP rack::app::get() | |||
} // namespace app | |||
} // namespace rack |
@@ -11,6 +11,9 @@ namespace audio { | |||
} | |||
namespace app { | |||
struct AudioWidget : LedDisplay { | |||
/** Not owned */ | |||
audio::IO *audioIO = NULL; | |||
@@ -26,4 +29,5 @@ struct AudioWidget : LedDisplay { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,6 +1,6 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "app/PortWidget.hpp" | |||
#include "app/ModuleWidget.hpp" | |||
#include "engine/Cable.hpp" | |||
@@ -8,9 +8,10 @@ | |||
namespace rack { | |||
namespace app { | |||
struct CableWidget : OpaqueWidget { | |||
struct CableWidget : widget::OpaqueWidget { | |||
PortWidget *outputPort = NULL; | |||
PortWidget *inputPort = NULL; | |||
PortWidget *hoveredOutputPort = NULL; | |||
@@ -27,9 +28,10 @@ struct CableWidget : OpaqueWidget { | |||
math::Vec getInputPos(); | |||
json_t *toJson(); | |||
void fromJson(json_t *rootJ, const std::map<int, ModuleWidget*> &moduleWidgets); | |||
void draw(const DrawContext &ctx) override; | |||
void drawPlugs(const DrawContext &ctx); | |||
void draw(const widget::DrawContext &ctx) override; | |||
void drawPlugs(const widget::DrawContext &ctx); | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,17 +1,19 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct CircularShadow : TransparentWidget { | |||
struct CircularShadow : widget::TransparentWidget { | |||
float blurRadius; | |||
float opacity; | |||
CircularShadow(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -5,6 +5,7 @@ | |||
namespace rack { | |||
namespace app { | |||
/** Implements vertical dragging behavior for ParamWidgets */ | |||
@@ -27,4 +28,5 @@ struct Knob : ParamWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,40 +1,42 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/Widget.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widget/Widget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
#include "ui/TextField.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct LedDisplay : Widget { | |||
void draw(const DrawContext &ctx) override; | |||
struct LedDisplay : widget::Widget { | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
struct LedDisplaySeparator : TransparentWidget { | |||
struct LedDisplaySeparator : widget::TransparentWidget { | |||
LedDisplaySeparator(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
struct LedDisplayChoice : TransparentWidget { | |||
struct LedDisplayChoice : widget::TransparentWidget { | |||
std::string text; | |||
std::shared_ptr<Font> font; | |||
math::Vec textOffset; | |||
NVGcolor color; | |||
LedDisplayChoice(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onButton(const event::Button &e) override; | |||
}; | |||
struct LedDisplayTextField : TextField { | |||
struct LedDisplayTextField : ui::TextField { | |||
std::shared_ptr<Font> font; | |||
math::Vec textOffset; | |||
NVGcolor color; | |||
LedDisplayTextField(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
int getTextPosition(math::Vec mousePos) override; | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,19 +1,21 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct LightWidget : TransparentWidget { | |||
struct LightWidget : widget::TransparentWidget { | |||
NVGcolor bgColor = nvgRGBA(0, 0, 0, 0); | |||
NVGcolor color = nvgRGBA(0, 0, 0, 0); | |||
NVGcolor borderColor = nvgRGBA(0, 0, 0, 0); | |||
void draw(const DrawContext &ctx) override; | |||
virtual void drawLight(const DrawContext &ctx); | |||
virtual void drawHalo(const DrawContext &ctx); | |||
void draw(const widget::DrawContext &ctx) override; | |||
virtual void drawLight(const widget::DrawContext &ctx); | |||
virtual void drawHalo(const widget::DrawContext &ctx); | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -11,6 +11,9 @@ namespace midi { | |||
} | |||
namespace app { | |||
struct MidiWidget : LedDisplay { | |||
/** Not owned */ | |||
midi::IO *midiIO = NULL; | |||
@@ -24,4 +27,5 @@ struct MidiWidget : LedDisplay { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,14 +1,16 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
namespace rack { | |||
namespace app { | |||
Widget *moduleBrowserCreate(); | |||
widget::Widget *moduleBrowserCreate(); | |||
json_t *moduleBrowserToJson(); | |||
void moduleBrowserFromJson(json_t *rootJ); | |||
} // namespace app | |||
} // namespace rack |
@@ -5,6 +5,7 @@ | |||
namespace rack { | |||
namespace app { | |||
/** A MultiLightWidget that points to a module's Light or a range of lights | |||
@@ -17,4 +18,5 @@ struct ModuleLightWidget : MultiLightWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,6 +1,6 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/Menu.hpp" | |||
#include "app/PortWidget.hpp" | |||
#include "app/ParamWidget.hpp" | |||
@@ -9,14 +9,15 @@ | |||
namespace rack { | |||
namespace app { | |||
struct ModuleWidget : OpaqueWidget { | |||
struct ModuleWidget : widget::OpaqueWidget { | |||
Model *model = NULL; | |||
/** Owns the module pointer */ | |||
Module *module = NULL; | |||
Widget *panel = NULL; | |||
widget::Widget *panel = NULL; | |||
std::vector<ParamWidget*> params; | |||
std::vector<PortWidget*> outputs; | |||
std::vector<PortWidget*> inputs; | |||
@@ -30,8 +31,8 @@ struct ModuleWidget : OpaqueWidget { | |||
} | |||
~ModuleWidget(); | |||
void draw(const DrawContext &ctx) override; | |||
void drawShadow(const DrawContext &ctx); | |||
void draw(const widget::DrawContext &ctx) override; | |||
void drawShadow(const widget::DrawContext &ctx); | |||
void onHover(const event::Hover &e) override; | |||
void onButton(const event::Button &e) override; | |||
@@ -88,10 +89,11 @@ struct ModuleWidget : OpaqueWidget { | |||
void removeAction(); | |||
void createContextMenu(); | |||
/** Override to add context menu entries to your subclass. | |||
It is recommended to add a blank MenuEntry first for spacing. | |||
It is recommended to add a blank ui::MenuEntry first for spacing. | |||
*/ | |||
virtual void appendContextMenu(Menu *menu) {} | |||
virtual void appendContextMenu(ui::Menu *menu) {} | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -4,6 +4,7 @@ | |||
namespace rack { | |||
namespace app { | |||
/** Mixes a list of colors based on a list of brightness values */ | |||
@@ -16,4 +17,5 @@ struct MultiLightWidget : LightWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -5,10 +5,11 @@ | |||
namespace rack { | |||
namespace app { | |||
/** A Quantity that wraps an engine Param */ | |||
struct ParamQuantity : Quantity { | |||
/** A ui::Quantity that wraps an engine Param */ | |||
struct ParamQuantity : ui::Quantity { | |||
Module *module = NULL; | |||
int paramId = 0; | |||
@@ -32,4 +33,5 @@ struct ParamQuantity : Quantity { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,22 +1,23 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/Tooltip.hpp" | |||
#include "app/ParamQuantity.hpp" | |||
#include "history.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct ParamWidget : OpaqueWidget { | |||
struct ParamWidget : widget::OpaqueWidget { | |||
ParamQuantity *paramQuantity = NULL; | |||
float dirtyValue = NAN; | |||
Tooltip *tooltip = NULL; | |||
ui::Tooltip *tooltip = NULL; | |||
~ParamWidget(); | |||
void step() override; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onButton(const event::Button &e) override; | |||
void onEnter(const event::Enter &e) override; | |||
void onLeave(const event::Leave &e) override; | |||
@@ -28,4 +29,5 @@ struct ParamWidget : OpaqueWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,14 +1,15 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "app/MultiLightWidget.hpp" | |||
#include "engine/Module.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct PortWidget : OpaqueWidget { | |||
struct PortWidget : widget::OpaqueWidget { | |||
Module *module = NULL; | |||
int portId; | |||
@@ -23,7 +24,7 @@ struct PortWidget : OpaqueWidget { | |||
~PortWidget(); | |||
void step() override; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onButton(const event::Button &e) override; | |||
void onDragStart(const event::DragStart &e) override; | |||
@@ -34,4 +35,5 @@ struct PortWidget : OpaqueWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,14 +1,16 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct RackRail : TransparentWidget { | |||
void draw(const DrawContext &ctx) override; | |||
struct RackRail : widget::TransparentWidget { | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -4,12 +4,14 @@ | |||
namespace rack { | |||
namespace app { | |||
struct RackScrollWidget : ScrollWidget { | |||
struct RackScrollWidget : ui::ScrollWidget { | |||
void step() override; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,19 +1,20 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "app/ModuleWidget.hpp" | |||
#include "app/CableWidget.hpp" | |||
#include "app/PortWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct RackWidget : OpaqueWidget { | |||
FramebufferWidget *rails; | |||
Widget *moduleContainer; | |||
Widget *cableContainer; | |||
struct RackWidget : widget::OpaqueWidget { | |||
widget::FramebufferWidget *rails; | |||
widget::Widget *moduleContainer; | |||
widget::Widget *cableContainer; | |||
CableWidget *incompleteCable = NULL; | |||
/** The last mouse position in the RackWidget */ | |||
math::Vec mousePos; | |||
@@ -22,7 +23,7 @@ struct RackWidget : OpaqueWidget { | |||
~RackWidget(); | |||
void step() override; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onHover(const event::Hover &e) override; | |||
void onHoverKey(const event::HoverKey &e) override; | |||
@@ -74,4 +75,5 @@ struct RackWidget : OpaqueWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,16 +1,17 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct SVGButton : OpaqueWidget { | |||
FramebufferWidget *fb; | |||
SVGWidget *sw; | |||
struct SVGButton : widget::OpaqueWidget { | |||
widget::FramebufferWidget *fb; | |||
widget::SVGWidget *sw; | |||
std::vector<std::shared_ptr<SVG>> frames; | |||
SVGButton(); | |||
@@ -21,4 +22,5 @@ struct SVGButton : OpaqueWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,20 +1,21 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "app/Knob.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/TransformWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/TransformWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
#include "app/CircularShadow.hpp" | |||
namespace rack { | |||
namespace app { | |||
/** A knob which rotates an SVG and caches it in a framebuffer */ | |||
struct SVGKnob : Knob { | |||
FramebufferWidget *fb; | |||
TransformWidget *tw; | |||
SVGWidget *sw; | |||
widget::FramebufferWidget *fb; | |||
widget::TransformWidget *tw; | |||
widget::SVGWidget *sw; | |||
CircularShadow *shadow; | |||
/** Angles in radians */ | |||
float minAngle, maxAngle; | |||
@@ -25,4 +26,5 @@ struct SVGKnob : Knob { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,24 +1,26 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
#include "app.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct PanelBorder : TransparentWidget { | |||
void draw(const DrawContext &ctx) override; | |||
struct PanelBorder : widget::TransparentWidget { | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
struct SVGPanel : FramebufferWidget { | |||
struct SVGPanel : widget::FramebufferWidget { | |||
void step() override; | |||
void setBackground(std::shared_ptr<SVG> svg); | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,17 +1,18 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "app/PortWidget.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
#include "app/CircularShadow.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct SVGPort : PortWidget { | |||
FramebufferWidget *fb; | |||
SVGWidget *sw; | |||
widget::FramebufferWidget *fb; | |||
widget::SVGWidget *sw; | |||
CircularShadow *shadow; | |||
SVGPort(); | |||
@@ -19,4 +20,5 @@ struct SVGPort : PortWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,18 +1,20 @@ | |||
#pragma once | |||
#include "common.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
/** If you don't add these to your ModuleWidget, they will fall out of the rack... */ | |||
struct SVGScrew : FramebufferWidget { | |||
SVGWidget *sw; | |||
struct SVGScrew : widget::FramebufferWidget { | |||
widget::SVGWidget *sw; | |||
SVGScrew(); | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,20 +1,21 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "app/SliderKnob.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
/** Behaves like a knob but linearly moves an SVGWidget between two points. | |||
/** Behaves like a knob but linearly moves an widget::SVGWidget between two points. | |||
Can be used for horizontal or vertical linear faders. | |||
*/ | |||
struct SVGSlider : SliderKnob { | |||
FramebufferWidget *fb; | |||
SVGWidget *background; | |||
SVGWidget *handle; | |||
struct SVGSlider : app::SliderKnob { | |||
widget::FramebufferWidget *fb; | |||
widget::SVGWidget *background; | |||
widget::SVGWidget *handle; | |||
/** Intermediate positions will be interpolated between these positions */ | |||
math::Vec minHandlePos, maxHandlePos; | |||
@@ -30,4 +31,5 @@ struct SVGSlider : SliderKnob { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,17 +1,18 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
#include "app/Switch.hpp" | |||
namespace rack { | |||
namespace app { | |||
/** A ParamWidget with multiple frames corresponding to its value */ | |||
struct SVGSwitch : Switch { | |||
FramebufferWidget *fb; | |||
SVGWidget *sw; | |||
widget::FramebufferWidget *fb; | |||
widget::SVGWidget *sw; | |||
std::vector<std::shared_ptr<SVG>> frames; | |||
SVGSwitch(); | |||
@@ -21,4 +22,5 @@ struct SVGSwitch : Switch { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,22 +1,23 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widgets/ZoomWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "widget/ZoomWidget.hpp" | |||
#include "ui/ScrollWidget.hpp" | |||
#include "app/RackWidget.hpp" | |||
#include "app/Toolbar.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct Scene : OpaqueWidget { | |||
struct Scene : widget::OpaqueWidget { | |||
// Convenience variables for accessing important widgets | |||
ScrollWidget *scrollWidget; | |||
ZoomWidget *zoomWidget; | |||
ui::ScrollWidget *scrollWidget; | |||
widget::ZoomWidget *zoomWidget; | |||
RackWidget *rackWidget; | |||
Toolbar *toolbar; | |||
Widget *moduleBrowser; | |||
widget::Widget *moduleBrowser; | |||
// Version checking | |||
bool devMode = false; | |||
@@ -27,7 +28,7 @@ struct Scene : OpaqueWidget { | |||
Scene(); | |||
~Scene(); | |||
void step() override; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onHoverKey(const event::HoverKey &e) override; | |||
void onPathDrop(const event::PathDrop &e) override; | |||
@@ -35,4 +36,5 @@ struct Scene : OpaqueWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -4,6 +4,7 @@ | |||
namespace rack { | |||
namespace app { | |||
struct SliderKnob : Knob { | |||
@@ -17,4 +18,5 @@ struct SliderKnob : Knob { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -4,6 +4,7 @@ | |||
namespace rack { | |||
namespace app { | |||
/** A ParamWidget that controls */ | |||
@@ -20,4 +21,5 @@ struct Switch : ParamWidget { | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -1,19 +1,21 @@ | |||
#pragma once | |||
#include "app/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
namespace rack { | |||
namespace app { | |||
struct Toolbar : OpaqueWidget { | |||
struct Toolbar : widget::OpaqueWidget { | |||
// TODO Move these to future Rack app state | |||
float cableOpacity = 0.5; | |||
float cableTension = 0.5; | |||
Toolbar(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace app | |||
} // namespace rack |
@@ -5,32 +5,33 @@ | |||
namespace rack { | |||
namespace app { | |||
static const char APP_NAME[] = "VCV Rack"; | |||
static const char APP_VERSION[] = TOSTRING(VERSION); | |||
static const char APP_API_URL[] = "https://api.vcvrack.com"; | |||
static const char NAME[] = "VCV Rack"; | |||
static const char VERSION[] = TOSTRING(APP_VERSION); | |||
static const char API_URL[] = "https://api.vcvrack.com"; | |||
static const float APP_SVG_DPI = 75.0; | |||
static const float SVG_DPI = 75.0; | |||
static const float MM_PER_IN = 25.4; | |||
/** Converts inch measurements to pixels */ | |||
inline float in2px(float in) { | |||
return in * APP_SVG_DPI; | |||
return in * SVG_DPI; | |||
} | |||
inline math::Vec in2px(math::Vec in) { | |||
return in.mult(APP_SVG_DPI); | |||
return in.mult(SVG_DPI); | |||
} | |||
/** Converts millimeter measurements to pixels */ | |||
inline float mm2px(float mm) { | |||
return mm * (APP_SVG_DPI / MM_PER_IN); | |||
return mm * (SVG_DPI / MM_PER_IN); | |||
} | |||
inline math::Vec mm2px(math::Vec mm) { | |||
return mm.mult(APP_SVG_DPI / MM_PER_IN); | |||
return mm.mult(SVG_DPI / MM_PER_IN); | |||
} | |||
@@ -40,4 +41,5 @@ static const float RACK_GRID_HEIGHT = 380; | |||
static const math::Vec RACK_GRID_SIZE = math::Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT); | |||
} // namespace app | |||
} // namespace rack |
@@ -26,7 +26,7 @@ static const NVGcolor SCHEME_DARK_GRAY = nvgRGB(0x17, 0x17, 0x17); | |||
// Knobs | |||
//////////////////// | |||
struct RoundKnob : SVGKnob { | |||
struct RoundKnob : app::SVGKnob { | |||
RoundKnob() { | |||
minAngle = -0.83*M_PI; | |||
maxAngle = 0.83*M_PI; | |||
@@ -64,7 +64,7 @@ struct RoundBlackSnapKnob : RoundBlackKnob { | |||
}; | |||
struct Davies1900hKnob : SVGKnob { | |||
struct Davies1900hKnob : app::SVGKnob { | |||
Davies1900hKnob() { | |||
minAngle = -0.83*M_PI; | |||
maxAngle = 0.83*M_PI; | |||
@@ -108,7 +108,7 @@ struct Davies1900hLargeRedKnob : Davies1900hKnob { | |||
}; | |||
struct Rogan : SVGKnob { | |||
struct Rogan : app::SVGKnob { | |||
Rogan() { | |||
minAngle = -0.83*M_PI; | |||
maxAngle = 0.83*M_PI; | |||
@@ -278,7 +278,7 @@ struct Rogan1PWhite : Rogan { | |||
}; | |||
struct SynthTechAlco : SVGKnob { | |||
struct SynthTechAlco : app::SVGKnob { | |||
SynthTechAlco() { | |||
minAngle = -0.82*M_PI; | |||
maxAngle = 0.82*M_PI; | |||
@@ -289,7 +289,7 @@ struct SynthTechAlco : SVGKnob { | |||
} | |||
}; | |||
struct Trimpot : SVGKnob { | |||
struct Trimpot : app::SVGKnob { | |||
Trimpot() { | |||
minAngle = -0.75*M_PI; | |||
maxAngle = 0.75*M_PI; | |||
@@ -297,7 +297,7 @@ struct Trimpot : SVGKnob { | |||
} | |||
}; | |||
struct BefacoBigKnob : SVGKnob { | |||
struct BefacoBigKnob : app::SVGKnob { | |||
BefacoBigKnob() { | |||
minAngle = -0.75*M_PI; | |||
maxAngle = 0.75*M_PI; | |||
@@ -311,7 +311,7 @@ struct BefacoBigSnapKnob : BefacoBigKnob { | |||
} | |||
}; | |||
struct BefacoTinyKnob : SVGKnob { | |||
struct BefacoTinyKnob : app::SVGKnob { | |||
BefacoTinyKnob() { | |||
minAngle = -0.75*M_PI; | |||
maxAngle = 0.75*M_PI; | |||
@@ -319,7 +319,7 @@ struct BefacoTinyKnob : SVGKnob { | |||
} | |||
}; | |||
struct BefacoSlidePot : SVGSlider { | |||
struct BefacoSlidePot : app::SVGSlider { | |||
BefacoSlidePot() { | |||
math::Vec margin = math::Vec(3.5, 3.5); | |||
maxHandlePos = math::Vec(-1, -2).plus(margin); | |||
@@ -331,7 +331,7 @@ struct BefacoSlidePot : SVGSlider { | |||
} | |||
}; | |||
struct LEDSlider : SVGSlider { | |||
struct LEDSlider : app::SVGSlider { | |||
LEDSlider() { | |||
maxHandlePos = mm2px(math::Vec(0.738, 0.738).plus(math::Vec(2, 0))); | |||
minHandlePos = mm2px(math::Vec(0.738, 22.078).plus(math::Vec(2, 0))); | |||
@@ -374,19 +374,19 @@ struct LEDSliderWhite : LEDSlider { | |||
// Ports | |||
//////////////////// | |||
struct PJ301MPort : SVGPort { | |||
struct PJ301MPort : app::SVGPort { | |||
PJ301MPort() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ301M.svg"))); | |||
} | |||
}; | |||
struct PJ3410Port : SVGPort { | |||
struct PJ3410Port : app::SVGPort { | |||
PJ3410Port() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/PJ3410.svg"))); | |||
} | |||
}; | |||
struct CL1362Port : SVGPort { | |||
struct CL1362Port : app::SVGPort { | |||
CL1362Port() { | |||
setSVG(SVG::load(asset::system("res/ComponentLibrary/CL1362.svg"))); | |||
} | |||
@@ -396,7 +396,7 @@ struct CL1362Port : SVGPort { | |||
// Lights | |||
//////////////////// | |||
struct GrayModuleLightWidget : ModuleLightWidget { | |||
struct GrayModuleLightWidget : app::ModuleLightWidget { | |||
GrayModuleLightWidget() { | |||
bgColor = nvgRGB(0x5a, 0x5a, 0x5a); | |||
borderColor = nvgRGBA(0, 0, 0, 0x60); | |||
@@ -443,7 +443,7 @@ struct RedGreenBlueLight : GrayModuleLightWidget { | |||
} | |||
}; | |||
struct RGBLight : ModuleLightWidget { | |||
struct RGBLight : app::ModuleLightWidget { | |||
RGBLight() { | |||
addBaseColor(nvgRGBf(1, 0, 0)); | |||
addBaseColor(nvgRGBf(0, 1, 0)); | |||
@@ -509,7 +509,7 @@ struct PB61303Light : BASE { | |||
// Switches | |||
//////////////////// | |||
struct NKK : SVGSwitch { | |||
struct NKK : app::SVGSwitch { | |||
NKK() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/NKK_1.svg"))); | |||
@@ -517,14 +517,14 @@ struct NKK : SVGSwitch { | |||
} | |||
}; | |||
struct CKSS : SVGSwitch { | |||
struct CKSS : app::SVGSwitch { | |||
CKSS() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSS_1.svg"))); | |||
} | |||
}; | |||
struct CKSSThree : SVGSwitch { | |||
struct CKSSThree : app::SVGSwitch { | |||
CKSSThree() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKSSThree_1.svg"))); | |||
@@ -532,7 +532,7 @@ struct CKSSThree : SVGSwitch { | |||
} | |||
}; | |||
struct CKD6 : SVGSwitch { | |||
struct CKD6 : app::SVGSwitch { | |||
CKD6() { | |||
momentary = true; | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/CKD6_0.svg"))); | |||
@@ -540,7 +540,7 @@ struct CKD6 : SVGSwitch { | |||
} | |||
}; | |||
struct TL1105 : SVGSwitch { | |||
struct TL1105 : app::SVGSwitch { | |||
TL1105() { | |||
momentary = true; | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/TL1105_0.svg"))); | |||
@@ -548,14 +548,14 @@ struct TL1105 : SVGSwitch { | |||
} | |||
}; | |||
struct LEDButton : SVGSwitch { | |||
struct LEDButton : app::SVGSwitch { | |||
LEDButton() { | |||
momentary = true; | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDButton.svg"))); | |||
} | |||
}; | |||
struct BefacoSwitch : SVGSwitch { | |||
struct BefacoSwitch : app::SVGSwitch { | |||
BefacoSwitch() { | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoSwitch_0.svg"))); | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoSwitch_1.svg"))); | |||
@@ -563,7 +563,7 @@ struct BefacoSwitch : SVGSwitch { | |||
} | |||
}; | |||
struct BefacoPush : SVGSwitch { | |||
struct BefacoPush : app::SVGSwitch { | |||
BefacoPush() { | |||
momentary = true; | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/BefacoPush_0.svg"))); | |||
@@ -571,14 +571,14 @@ struct BefacoPush : SVGSwitch { | |||
} | |||
}; | |||
struct LEDBezel : SVGSwitch { | |||
struct LEDBezel : app::SVGSwitch { | |||
LEDBezel() { | |||
momentary = true; | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/LEDBezel.svg"))); | |||
} | |||
}; | |||
struct PB61303 : SVGSwitch { | |||
struct PB61303 : app::SVGSwitch { | |||
PB61303() { | |||
momentary = true; | |||
addFrame(SVG::load(asset::system("res/ComponentLibrary/PB61303.svg"))); | |||
@@ -589,14 +589,14 @@ struct PB61303 : SVGSwitch { | |||
// Misc | |||
//////////////////// | |||
struct ScrewSilver : SVGScrew { | |||
struct ScrewSilver : app::SVGScrew { | |||
ScrewSilver() { | |||
sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewSilver.svg"))); | |||
box.size = sw->box.size; | |||
} | |||
}; | |||
struct ScrewBlack : SVGScrew { | |||
struct ScrewBlack : app::SVGScrew { | |||
ScrewBlack() { | |||
sw->setSVG(SVG::load(asset::system("res/ComponentLibrary/ScrewBlack.svg"))); | |||
box.size = sw->box.size; | |||
@@ -7,12 +7,14 @@ | |||
namespace rack { | |||
struct ParamQuantity; | |||
namespace app { | |||
struct ParamQuantity; | |||
} // namespace app | |||
struct ParamQuantityFactory { | |||
virtual ~ParamQuantityFactory() {} | |||
virtual ParamQuantity *create() = 0; | |||
virtual app::ParamQuantity *create() = 0; | |||
}; | |||
@@ -48,7 +50,7 @@ struct Param { | |||
delete paramQuantityFactory; | |||
} | |||
template<class TParamQuantity = ParamQuantity> | |||
template<class TParamQuantity = app::ParamQuantity> | |||
void config(float minValue, float maxValue, float defaultValue, std::string label = "", std::string unit = "", float displayBase = 0.f, float displayMultiplier = 1.f, float displayOffset = 0.f) { | |||
this->value = defaultValue; | |||
this->minValue = minValue; | |||
@@ -62,7 +64,7 @@ struct Param { | |||
this->displayOffset = displayOffset; | |||
struct TParamQuantityFactory : ParamQuantityFactory { | |||
ParamQuantity *create() override {return new TParamQuantity;} | |||
app::ParamQuantity *create() override {return new TParamQuantity;} | |||
}; | |||
if (paramQuantityFactory) | |||
delete paramQuantityFactory; | |||
@@ -7,7 +7,9 @@ | |||
namespace rack { | |||
struct Widget; | |||
namespace widget { | |||
struct Widget; | |||
} // namespace widget | |||
namespace event { | |||
@@ -17,7 +19,7 @@ struct Context { | |||
/** The Widget that consumes the event. | |||
This stops propagation of the event if applicable. | |||
*/ | |||
Widget *consumed = NULL; | |||
widget::Widget *consumed = NULL; | |||
}; | |||
@@ -25,11 +27,11 @@ struct Context { | |||
struct Event { | |||
Context *context = NULL; | |||
void consume(Widget *w) const { | |||
void consume(widget::Widget *w) const { | |||
if (context) | |||
context->consumed = w; | |||
} | |||
Widget *getConsumed() const { | |||
widget::Widget *getConsumed() const { | |||
return context ? context->consumed : NULL; | |||
} | |||
}; | |||
@@ -169,7 +171,7 @@ Recurses until consumed. | |||
*/ | |||
struct DragHover : Event, Position { | |||
/** The dragged widget */ | |||
Widget *origin = NULL; | |||
widget::Widget *origin = NULL; | |||
/** Change in mouse position since the last frame. Can be zero. */ | |||
math::Vec mouseDelta; | |||
}; | |||
@@ -178,7 +180,7 @@ struct DragHover : Event, Position { | |||
*/ | |||
struct DragEnter : Event { | |||
/** The dragged widget */ | |||
Widget *origin = NULL; | |||
widget::Widget *origin = NULL; | |||
}; | |||
@@ -186,7 +188,7 @@ struct DragEnter : Event { | |||
*/ | |||
struct DragLeave : Event { | |||
/** The dragged widget */ | |||
Widget *origin = NULL; | |||
widget::Widget *origin = NULL; | |||
}; | |||
@@ -194,7 +196,7 @@ struct DragLeave : Event { | |||
*/ | |||
struct DragDrop : Event { | |||
/** The dragged widget */ | |||
Widget *origin = NULL; | |||
widget::Widget *origin = NULL; | |||
}; | |||
@@ -229,23 +231,23 @@ struct Zoom : Event { | |||
struct State { | |||
Widget *rootWidget = NULL; | |||
widget::Widget *rootWidget = NULL; | |||
/** State widgets | |||
Don't set these directly unless you know what you're doing. Use the set*() methods instead. | |||
*/ | |||
Widget *hoveredWidget = NULL; | |||
Widget *draggedWidget = NULL; | |||
Widget *dragHoveredWidget = NULL; | |||
Widget *selectedWidget = NULL; | |||
widget::Widget *hoveredWidget = NULL; | |||
widget::Widget *draggedWidget = NULL; | |||
widget::Widget *dragHoveredWidget = NULL; | |||
widget::Widget *selectedWidget = NULL; | |||
/** For middle-click dragging */ | |||
Widget *scrollWidget = NULL; | |||
widget::Widget *scrollWidget = NULL; | |||
void setHovered(Widget *w); | |||
void setDragged(Widget *w); | |||
void setDragHovered(Widget *w); | |||
void setSelected(Widget *w); | |||
void setHovered(widget::Widget *w); | |||
void setDragged(widget::Widget *w); | |||
void setDragHovered(widget::Widget *w); | |||
void setSelected(widget::Widget *w); | |||
/** Prepares a widget for deletion */ | |||
void finalizeWidget(Widget *w); | |||
void finalizeWidget(widget::Widget *w); | |||
void handleButton(math::Vec pos, int button, int action, int mods); | |||
void handleHover(math::Vec pos, math::Vec mouseDelta); | |||
@@ -21,13 +21,13 @@ Model *createModel(std::string slug) { | |||
TModule *o = new TModule; | |||
return o; | |||
} | |||
ModuleWidget *createModuleWidget() override { | |||
app::ModuleWidget *createModuleWidget() override { | |||
TModule *module = new TModule; | |||
TModuleWidget *o = new TModuleWidget(module); | |||
o->model = this; | |||
return o; | |||
} | |||
ModuleWidget *createModuleWidgetNull() override { | |||
app::ModuleWidget *createModuleWidgetNull() override { | |||
TModuleWidget *o = new TModuleWidget(NULL); | |||
o->model = this; | |||
return o; | |||
@@ -62,7 +62,7 @@ TParamWidget *createParam(math::Vec pos, Module *module, int paramId) { | |||
if (f) | |||
o->paramQuantity = f->create(); | |||
else | |||
o->paramQuantity = new ParamQuantity; | |||
o->paramQuantity = new app::ParamQuantity; | |||
o->paramQuantity->module = module; | |||
o->paramQuantity->paramId = paramId; | |||
} | |||
@@ -81,7 +81,7 @@ TPortWidget *createInput(math::Vec pos, Module *module, int inputId) { | |||
TPortWidget *o = new TPortWidget; | |||
o->box.pos = pos; | |||
o->module = module; | |||
o->type = PortWidget::INPUT; | |||
o->type = app::PortWidget::INPUT; | |||
o->portId = inputId; | |||
return o; | |||
} | |||
@@ -91,7 +91,7 @@ TPortWidget *createInputCentered(math::Vec pos, Module *module, int inputId) { | |||
TPortWidget *o = new TPortWidget; | |||
o->box.pos = pos.minus(o->box.size.div(2)); | |||
o->module = module; | |||
o->type = PortWidget::INPUT; | |||
o->type = app::PortWidget::INPUT; | |||
o->portId = inputId; | |||
return o; | |||
} | |||
@@ -101,7 +101,7 @@ TPortWidget *createOutput(math::Vec pos, Module *module, int outputId) { | |||
TPortWidget *o = new TPortWidget; | |||
o->box.pos = pos; | |||
o->module = module; | |||
o->type = PortWidget::OUTPUT; | |||
o->type = app::PortWidget::OUTPUT; | |||
o->portId = outputId; | |||
return o; | |||
} | |||
@@ -111,7 +111,7 @@ TPortWidget *createOutputCentered(math::Vec pos, Module *module, int outputId) { | |||
TPortWidget *o = new TPortWidget; | |||
o->box.pos = pos.minus(o->box.size.div(2)); | |||
o->module = module; | |||
o->type = PortWidget::OUTPUT; | |||
o->type = app::PortWidget::OUTPUT; | |||
o->portId = outputId; | |||
return o; | |||
} | |||
@@ -134,14 +134,14 @@ TModuleLightWidget *createLightCentered(math::Vec pos, Module *module, int first | |||
return o; | |||
} | |||
template <class TMenuLabel = MenuLabel> | |||
template <class TMenuLabel = ui::MenuLabel> | |||
TMenuLabel *createMenuLabel(std::string text) { | |||
TMenuLabel *o = new TMenuLabel; | |||
o->text = text; | |||
return o; | |||
} | |||
template <class TMenuItem = MenuItem> | |||
template <class TMenuItem = ui::MenuItem> | |||
TMenuItem *createMenuItem(std::string text, std::string rightText = "") { | |||
TMenuItem *o = new TMenuItem; | |||
o->text = text; | |||
@@ -149,14 +149,14 @@ TMenuItem *createMenuItem(std::string text, std::string rightText = "") { | |||
return o; | |||
} | |||
inline Menu *createMenu() { | |||
Menu *o = new Menu; | |||
o->box.pos = app()->window->mousePos; | |||
inline ui::Menu *createMenu() { | |||
ui::Menu *o = new ui::Menu; | |||
o->box.pos = APP->window->mousePos; | |||
MenuOverlay *menuOverlay = new MenuOverlay; | |||
ui::MenuOverlay *menuOverlay = new ui::MenuOverlay; | |||
menuOverlay->addChild(o); | |||
app()->scene->addChild(menuOverlay); | |||
APP->scene->addChild(menuOverlay); | |||
return o; | |||
} | |||
@@ -10,8 +10,10 @@ | |||
namespace rack { | |||
struct ModuleWidget; | |||
struct CableWidget; | |||
namespace app { | |||
struct ModuleWidget; | |||
struct CableWidget; | |||
} // namespace app | |||
namespace history { | |||
@@ -59,7 +61,7 @@ struct ModuleAdd : ModuleAction { | |||
math::Vec pos; | |||
json_t *moduleJ; | |||
~ModuleAdd(); | |||
void setModule(ModuleWidget *mw); | |||
void setModule(app::ModuleWidget *mw); | |||
void undo() override; | |||
void redo() override; | |||
}; | |||
@@ -108,7 +110,7 @@ struct CableAdd : Action { | |||
int inputModuleId; | |||
int inputId; | |||
NVGcolor color; | |||
void setCable(CableWidget *cw); | |||
void setCable(app::CableWidget *cw); | |||
void undo() override; | |||
void redo() override; | |||
}; | |||
@@ -8,7 +8,10 @@ | |||
namespace rack { | |||
struct ModuleWidget; | |||
namespace app { | |||
struct ModuleWidget; | |||
} // namespace app | |||
struct Module; | |||
@@ -30,9 +33,9 @@ struct Model { | |||
/** Creates a headless Module */ | |||
virtual Module *createModule() { return NULL; } | |||
/** Creates a ModuleWidget with a Module attached */ | |||
virtual ModuleWidget *createModuleWidget() { return NULL; } | |||
virtual app::ModuleWidget *createModuleWidget() { return NULL; } | |||
/** Creates a ModuleWidget with no Module, useful for previews */ | |||
virtual ModuleWidget *createModuleWidgetNull() { return NULL; } | |||
virtual app::ModuleWidget *createModuleWidgetNull() { return NULL; } | |||
void fromJson(json_t *rootJ); | |||
}; | |||
@@ -12,14 +12,14 @@ | |||
#include "midi.hpp" | |||
#include "helpers.hpp" | |||
#include "widgets/Widget.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widgets/TransformWidget.hpp" | |||
#include "widgets/ZoomWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/GLWidget.hpp" | |||
#include "widget/Widget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "widget/TransformWidget.hpp" | |||
#include "widget/ZoomWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/GLWidget.hpp" | |||
#include "ui/SequentialLayout.hpp" | |||
#include "ui/Label.hpp" | |||
@@ -92,8 +92,11 @@ | |||
namespace rack { | |||
// Import math:: namespace for convenience | |||
// Import some namespaces for convenience | |||
using namespace math; | |||
using namespace widget; | |||
using namespace ui; | |||
using namespace app; | |||
} // namespace rack |
@@ -142,11 +142,11 @@ DEPRECATED TPortWidget *createPort(math::Vec pos, PortWidget::Type type, Module | |||
//////////////////// | |||
DEPRECATED inline float engineGetSampleRate() { | |||
return app()->engine->getSampleRate(); | |||
return APP->engine->getSampleRate(); | |||
} | |||
DEPRECATED inline float engineGetSampleTime() { | |||
return app()->engine->getSampleTime(); | |||
return APP->engine->getSampleTime(); | |||
} | |||
//////////////////// | |||
@@ -1,13 +1,14 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/common.hpp" | |||
#include "ui/Quantity.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct Button : OpaqueWidget { | |||
struct Button : widget::OpaqueWidget { | |||
std::string text; | |||
BNDwidgetState state = BND_DEFAULT; | |||
/** Optional, owned. Tracks the pressed state of the button.*/ | |||
@@ -15,7 +16,7 @@ struct Button : OpaqueWidget { | |||
Button(); | |||
~Button(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onEnter(const event::Enter &e) override; | |||
void onLeave(const event::Leave &e) override; | |||
void onDragStart(const event::DragStart &e) override; | |||
@@ -24,4 +25,5 @@ struct Button : OpaqueWidget { | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -4,11 +4,13 @@ | |||
namespace rack { | |||
namespace ui { | |||
struct ChoiceButton : Button { | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,20 +1,22 @@ | |||
#pragma once | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widgets/SVGWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
#include "widget/SVGWidget.hpp" | |||
#include "ui/common.hpp" | |||
#include "ui/Button.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct IconButton : Button { | |||
FramebufferWidget *fw; | |||
SVGWidget *sw; | |||
widget::FramebufferWidget *fw; | |||
widget::SVGWidget *sw; | |||
IconButton(); | |||
void setSVG(std::shared_ptr<SVG> svg); | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,12 +1,13 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct Label : Widget { | |||
struct Label : widget::Widget { | |||
enum Alignment { | |||
LEFT_ALIGNMENT, | |||
CENTER_ALIGNMENT, | |||
@@ -19,8 +20,9 @@ struct Label : Widget { | |||
Alignment alignment = LEFT_ALIGNMENT; | |||
Label(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,14 +1,16 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct List : OpaqueWidget { | |||
struct List : widget::OpaqueWidget { | |||
void step() override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,13 +1,14 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/common.hpp" | |||
#include "ui/MenuEntry.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct Menu : OpaqueWidget { | |||
struct Menu : widget::OpaqueWidget { | |||
Menu *parentMenu = NULL; | |||
Menu *childMenu = NULL; | |||
/** The entry which created the child menu */ | |||
@@ -17,9 +18,10 @@ struct Menu : OpaqueWidget { | |||
~Menu(); | |||
void setChildMenu(Menu *menu); | |||
void step() override; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onHoverScroll(const event::HoverScroll &e) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,14 +1,16 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct MenuEntry : OpaqueWidget { | |||
struct MenuEntry : widget::OpaqueWidget { | |||
MenuEntry(); | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -7,6 +7,7 @@ | |||
namespace rack { | |||
namespace ui { | |||
#define BND_LABEL_FONT_SIZE 13 | |||
@@ -17,7 +18,7 @@ struct MenuItem : MenuEntry { | |||
std::string rightText; | |||
bool disabled = false; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void step() override; | |||
void onEnter(const event::Enter &e) override; | |||
void onDragDrop(const event::DragDrop &e) override; | |||
@@ -26,4 +27,5 @@ struct MenuItem : MenuEntry { | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -4,14 +4,16 @@ | |||
namespace rack { | |||
namespace ui { | |||
struct MenuLabel : MenuEntry { | |||
std::string text; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void step() override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,17 +1,19 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
/** Deletes itself from parent when clicked */ | |||
struct MenuOverlay : OpaqueWidget { | |||
struct MenuOverlay : widget::OpaqueWidget { | |||
void step() override; | |||
void onButton(const event::Button &e) override; | |||
void onHoverKey(const event::HoverKey &e) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -4,12 +4,14 @@ | |||
namespace rack { | |||
namespace ui { | |||
struct MenuSeparator : MenuEntry { | |||
MenuSeparator(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -4,11 +4,13 @@ | |||
namespace rack { | |||
namespace ui { | |||
struct PasswordField : TextField { | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,19 +1,21 @@ | |||
#pragma once | |||
#include "ui/common.hpp" | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
#include "ui/Quantity.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct ProgressBar : Widget { | |||
struct ProgressBar : widget::Widget { | |||
Quantity *quantity = NULL; | |||
ProgressBar(); | |||
~ProgressBar(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -4,10 +4,11 @@ | |||
namespace rack { | |||
namespace ui { | |||
/** A controller for manipulating a float value (which subclasses must store somehow) with limits and labels | |||
Often used as a decorator component for Widgets that read or write a quantity. | |||
Often used as a decorator component for widget::Widgets that read or write a quantity. | |||
*/ | |||
struct Quantity { | |||
virtual ~Quantity() {} | |||
@@ -118,4 +119,5 @@ struct Quantity { | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,23 +1,25 @@ | |||
#pragma once | |||
#include "ui/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/Quantity.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct RadioButton : OpaqueWidget { | |||
struct RadioButton : widget::OpaqueWidget { | |||
BNDwidgetState state = BND_DEFAULT; | |||
Quantity *quantity = NULL; | |||
RadioButton(); | |||
~RadioButton(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onEnter(const event::Enter &e) override; | |||
void onLeave(const event::Leave &e) override; | |||
void onDragDrop(const event::DragDrop &e) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,13 +1,14 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
/** Parent must be a ScrollWidget */ | |||
struct ScrollBar : OpaqueWidget { | |||
struct ScrollBar : widget::OpaqueWidget { | |||
enum Orientation { | |||
VERTICAL, | |||
HORIZONTAL | |||
@@ -18,11 +19,12 @@ struct ScrollBar : OpaqueWidget { | |||
float size = 0.0; | |||
ScrollBar(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onDragStart(const event::DragStart &e) override; | |||
void onDragMove(const event::DragMove &e) override; | |||
void onDragEnd(const event::DragEnd &e) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,26 +1,28 @@ | |||
#pragma once | |||
#include "ui/common.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/ScrollBar.hpp" | |||
namespace rack { | |||
namespace ui { | |||
/** Handles a container with ScrollBar */ | |||
struct ScrollWidget : OpaqueWidget { | |||
Widget *container; | |||
struct ScrollWidget : widget::OpaqueWidget { | |||
widget::Widget *container; | |||
ScrollBar *horizontalScrollBar; | |||
ScrollBar *verticalScrollBar; | |||
math::Vec offset; | |||
ScrollWidget(); | |||
void scrollTo(math::Rect r); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void step() override; | |||
void onHover(const event::Hover &e) override; | |||
void onHoverScroll(const event::HoverScroll &e) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,13 +1,14 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
/** Positions children in a row/column based on their widths/heights */ | |||
struct SequentialLayout : Widget { | |||
struct SequentialLayout : widget::Widget { | |||
enum Orientation { | |||
HORIZONTAL_ORIENTATION, | |||
VERTICAL_ORIENTATION, | |||
@@ -27,4 +28,5 @@ struct SequentialLayout : Widget { | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,20 +1,21 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/Quantity.hpp" | |||
#include "ui/common.hpp" | |||
#include "app.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct Slider : OpaqueWidget { | |||
struct Slider : widget::OpaqueWidget { | |||
BNDwidgetState state = BND_DEFAULT; | |||
Quantity *quantity = NULL; | |||
Slider(); | |||
~Slider(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onDragStart(const event::DragStart &e) override; | |||
void onDragMove(const event::DragMove &e) override; | |||
void onDragEnd(const event::DragEnd &e) override; | |||
@@ -22,4 +23,5 @@ struct Slider : OpaqueWidget { | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,14 +1,15 @@ | |||
#pragma once | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "ui/common.hpp" | |||
#include "event.hpp" | |||
#include "app.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct TextField : OpaqueWidget { | |||
struct TextField : widget::OpaqueWidget { | |||
std::string text; | |||
std::string placeholder; | |||
bool multiline = false; | |||
@@ -20,7 +21,7 @@ struct TextField : OpaqueWidget { | |||
int selection = 0; | |||
TextField(); | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
void onButton(const event::Button &e) override; | |||
void onHover(const event::Hover &e) override; | |||
void onEnter(const event::Enter &e) override; | |||
@@ -37,4 +38,5 @@ struct TextField : OpaqueWidget { | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,17 +1,19 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct Tooltip : Widget { | |||
struct Tooltip : widget::Widget { | |||
std::string text; | |||
void step() override; | |||
void draw(const DrawContext &ctx) override; | |||
void draw(const widget::DrawContext &ctx) override; | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,13 +1,15 @@ | |||
#pragma once | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
#include "ui/common.hpp" | |||
namespace rack { | |||
namespace ui { | |||
struct TooltipOverlay : TransparentWidget { | |||
struct TooltipOverlay : widget::TransparentWidget { | |||
}; | |||
} // namespace ui | |||
} // namespace rack |
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
namespace rack { | |||
namespace widget { | |||
/** Caches a widget's draw() result to a framebuffer so it is called less frequently | |||
@@ -38,4 +39,5 @@ struct FramebufferWidget : Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "widgets/FramebufferWidget.hpp" | |||
#include "widget/FramebufferWidget.hpp" | |||
namespace rack { | |||
namespace widget { | |||
struct GLWidget : FramebufferWidget { | |||
@@ -14,4 +15,5 @@ struct GLWidget : FramebufferWidget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
namespace rack { | |||
namespace widget { | |||
/** Widget that consumes recursing events without giving a chance for children to consume. | |||
@@ -32,4 +33,5 @@ struct ObstructWidget : Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
namespace rack { | |||
namespace widget { | |||
/** Widget that consumes recursing events but gives a chance for children to consume first. | |||
@@ -48,4 +49,5 @@ struct OpaqueWidget : Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -1,9 +1,10 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
#include "svg.hpp" | |||
namespace rack { | |||
namespace widget { | |||
/** Draws an SVG */ | |||
@@ -34,4 +35,5 @@ struct SVGWidget : Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
namespace rack { | |||
namespace widget { | |||
/** Transforms appearance only, not positions of events */ | |||
@@ -44,4 +45,5 @@ struct TransformWidget : Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
namespace rack { | |||
namespace widget { | |||
/** Widget that does not respond to events and does not pass events to children */ | |||
@@ -18,4 +19,5 @@ struct TransparentWidget : Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -8,6 +8,7 @@ | |||
namespace rack { | |||
namespace widget { | |||
struct DrawContext { | |||
@@ -144,4 +145,5 @@ struct Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -1,8 +1,9 @@ | |||
#pragma once | |||
#include "widgets/Widget.hpp" | |||
#include "widget/Widget.hpp" | |||
namespace rack { | |||
namespace widget { | |||
struct ZoomWidget : Widget { | |||
@@ -51,4 +52,5 @@ struct ZoomWidget : Widget { | |||
}; | |||
} // namespace widget | |||
} // namespace rack |
@@ -124,7 +124,7 @@ struct AudioInterface : Module { | |||
void step() override { | |||
// Update SRC states | |||
int sampleRate = (int) app()->engine->getSampleRate(); | |||
int sampleRate = (int) APP->engine->getSampleRate(); | |||
inputSrc.setRates(audioIO.sampleRate, sampleRate); | |||
outputSrc.setRates(sampleRate, audioIO.sampleRate); | |||
@@ -39,14 +39,14 @@ struct ModuleResizeHandle : Widget { | |||
} | |||
} | |||
void onDragStart(const event::DragStart &e) override { | |||
dragX = app()->scene->rackWidget->mousePos.x; | |||
dragX = APP->scene->rackWidget->mousePos.x; | |||
ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | |||
originalBox = m->box; | |||
} | |||
void onDragMove(const event::DragMove &e) override { | |||
ModuleWidget *m = getAncestorOfType<ModuleWidget>(); | |||
float newDragX = app()->scene->rackWidget->mousePos.x; | |||
float newDragX = APP->scene->rackWidget->mousePos.x; | |||
float deltaX = newDragX - dragX; | |||
Rect newBox = originalBox; | |||
@@ -62,7 +62,7 @@ struct ModuleResizeHandle : Widget { | |||
newBox.size.x = roundf(newBox.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; | |||
newBox.pos.x = originalBox.pos.x + originalBox.size.x - newBox.size.x; | |||
} | |||
app()->scene->rackWidget->requestModuleBox(m, newBox); | |||
APP->scene->rackWidget->requestModuleBox(m, newBox); | |||
} | |||
void draw(const DrawContext &ctx) override { | |||
for (float x = 5.0; x <= 10.0; x += 5.0) { | |||
@@ -64,7 +64,7 @@ struct CV_CC : Module { | |||
void step() override { | |||
const float rateLimiterPeriod = 0.010f; | |||
rateLimiterPhase += app()->engine->getSampleTime() / rateLimiterPeriod; | |||
rateLimiterPhase += APP->engine->getSampleTime() / rateLimiterPeriod; | |||
if (rateLimiterPhase >= 1.f) { | |||
rateLimiterPhase -= 1.f; | |||
} | |||
@@ -243,7 +243,7 @@ struct CV_MIDI : Module { | |||
void step() override { | |||
const float rateLimiterPeriod = 0.005f; | |||
rateLimiterPhase += app()->engine->getSampleTime() / rateLimiterPeriod; | |||
rateLimiterPhase += APP->engine->getSampleTime() / rateLimiterPeriod; | |||
if (rateLimiterPhase >= 1.f) { | |||
rateLimiterPhase -= 1.f; | |||
} | |||
@@ -102,8 +102,8 @@ struct CcChoice : LedDisplayChoice { | |||
else { | |||
text = string::f("%d", module->learnedCcs[id]); | |||
color.a = 1.0; | |||
if (app()->event->selectedWidget == this) | |||
app()->event->selectedWidget = NULL; | |||
if (APP->event->selectedWidget == this) | |||
APP->event->selectedWidget = NULL; | |||
} | |||
} | |||
@@ -140,7 +140,7 @@ struct CcChoice : LedDisplayChoice { | |||
if ((e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) && e.action == GLFW_PRESS && (e.mods & WINDOW_MOD_MASK) == 0) { | |||
event::Deselect eDeselect; | |||
onDeselect(eDeselect); | |||
app()->event->selectedWidget = NULL; | |||
APP->event->selectedWidget = NULL; | |||
e.consume(this); | |||
} | |||
} | |||
@@ -179,8 +179,8 @@ struct NoteChoice : LedDisplayChoice { | |||
text = string::f("%s%d", noteNames[semi], oct); | |||
color.a = 1.0; | |||
if (app()->event->selectedWidget == this) | |||
app()->event->selectedWidget = NULL; | |||
if (APP->event->selectedWidget == this) | |||
APP->event->selectedWidget = NULL; | |||
} | |||
} | |||
@@ -45,7 +45,7 @@ struct MIDI_CC : Module { | |||
processMessage(msg); | |||
} | |||
float lambda = app()->engine->getSampleTime() * 100.f; | |||
float lambda = APP->engine->getSampleTime() * 100.f; | |||
for (int i = 0; i < 16; i++) { | |||
if (!outputs[CC_OUTPUT + i].isConnected()) | |||
continue; | |||
@@ -76,7 +76,7 @@ struct MIDI_CV : Module { | |||
while (midiInput.shift(&msg)) { | |||
processMessage(msg); | |||
} | |||
float deltaTime = app()->engine->getSampleTime(); | |||
float deltaTime = APP->engine->getSampleTime(); | |||
outputs[CV_OUTPUT].setVoltage((lastNote - 60) / 12.f); | |||
outputs[GATE_OUTPUT].setVoltage(gate ? 10.f : 0.f); | |||
@@ -70,7 +70,7 @@ struct MIDI_Gate : Module { | |||
while (midiInput.shift(&msg)) { | |||
processMessage(msg); | |||
} | |||
float deltaTime = app()->engine->getSampleTime(); | |||
float deltaTime = APP->engine->getSampleTime(); | |||
for (int i = 0; i < 16; i++) { | |||
if (gateTimes[i] > 0.f) { | |||
@@ -8,6 +8,7 @@ | |||
namespace rack { | |||
namespace app { | |||
App::App() { | |||
@@ -33,20 +34,21 @@ App::~App() { | |||
static App *c = NULL; | |||
void appInit() { | |||
void init() { | |||
assert(!c); | |||
c = new App; | |||
} | |||
void appDestroy() { | |||
void destroy() { | |||
assert(c); | |||
delete c; | |||
c = NULL; | |||
} | |||
App *app() { | |||
App *get() { | |||
return c; | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -4,9 +4,10 @@ | |||
namespace rack { | |||
namespace app { | |||
struct AudioDriverItem : MenuItem { | |||
struct AudioDriverItem : ui::MenuItem { | |||
audio::IO *audioIO; | |||
int driver; | |||
void onAction(const event::Action &e) override { | |||
@@ -20,7 +21,7 @@ struct AudioDriverChoice : LedDisplayChoice { | |||
if (!audioWidget->audioIO) | |||
return; | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
menu->addChild(createMenuLabel("Audio driver")); | |||
for (int driver : audioWidget->audioIO->getDrivers()) { | |||
AudioDriverItem *item = new AudioDriverItem; | |||
@@ -40,7 +41,7 @@ struct AudioDriverChoice : LedDisplayChoice { | |||
}; | |||
struct AudioDeviceItem : MenuItem { | |||
struct AudioDeviceItem : ui::MenuItem { | |||
audio::IO *audioIO; | |||
int device; | |||
int offset; | |||
@@ -58,7 +59,7 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||
if (!audioWidget->audioIO) | |||
return; | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
menu->addChild(createMenuLabel("Audio device")); | |||
int deviceCount = audioWidget->audioIO->getDeviceCount(); | |||
{ | |||
@@ -99,7 +100,7 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||
}; | |||
struct AudioSampleRateItem : MenuItem { | |||
struct AudioSampleRateItem : ui::MenuItem { | |||
audio::IO *audioIO; | |||
int sampleRate; | |||
void onAction(const event::Action &e) override { | |||
@@ -113,7 +114,7 @@ struct AudioSampleRateChoice : LedDisplayChoice { | |||
if (!audioWidget->audioIO) | |||
return; | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
menu->addChild(createMenuLabel("Sample rate")); | |||
std::vector<int> sampleRates = audioWidget->audioIO->getSampleRates(); | |||
if (sampleRates.empty()) { | |||
@@ -137,7 +138,7 @@ struct AudioSampleRateChoice : LedDisplayChoice { | |||
}; | |||
struct AudioBlockSizeItem : MenuItem { | |||
struct AudioBlockSizeItem : ui::MenuItem { | |||
audio::IO *audioIO; | |||
int blockSize; | |||
void onAction(const event::Action &e) override { | |||
@@ -151,7 +152,7 @@ struct AudioBlockSizeChoice : LedDisplayChoice { | |||
if (!audioWidget->audioIO) | |||
return; | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
menu->addChild(createMenuLabel("Block size")); | |||
std::vector<int> blockSizes = audioWidget->audioIO->getBlockSizes(); | |||
if (blockSizes.empty()) { | |||
@@ -227,4 +228,5 @@ void AudioWidget::step() { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -9,8 +9,9 @@ | |||
namespace rack { | |||
namespace app { | |||
static void drawPlug(const DrawContext &ctx, math::Vec pos, NVGcolor color) { | |||
static void drawPlug(const widget::DrawContext &ctx, math::Vec pos, NVGcolor color) { | |||
NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | |||
// Plug solid | |||
@@ -31,7 +32,7 @@ static void drawPlug(const DrawContext &ctx, math::Vec pos, NVGcolor color) { | |||
nvgFill(ctx.vg); | |||
} | |||
static void drawCable(const DrawContext &ctx, math::Vec pos1, math::Vec pos2, NVGcolor color, float thickness, float tension, float opacity) { | |||
static void drawCable(const widget::DrawContext &ctx, math::Vec pos1, math::Vec pos2, NVGcolor color, float thickness, float tension, float opacity) { | |||
NVGcolor colorShadow = nvgRGBAf(0, 0, 0, 0.10); | |||
NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | |||
@@ -119,25 +120,25 @@ void CableWidget::setInput(PortWidget *inputPort) { | |||
math::Vec CableWidget::getOutputPos() { | |||
if (outputPort) { | |||
return outputPort->getRelativeOffset(outputPort->box.zeroPos().getCenter(), app()->scene->rackWidget); | |||
return outputPort->getRelativeOffset(outputPort->box.zeroPos().getCenter(), APP->scene->rackWidget); | |||
} | |||
else if (hoveredOutputPort) { | |||
return hoveredOutputPort->getRelativeOffset(hoveredOutputPort->box.zeroPos().getCenter(), app()->scene->rackWidget); | |||
return hoveredOutputPort->getRelativeOffset(hoveredOutputPort->box.zeroPos().getCenter(), APP->scene->rackWidget); | |||
} | |||
else { | |||
return app()->scene->rackWidget->mousePos; | |||
return APP->scene->rackWidget->mousePos; | |||
} | |||
} | |||
math::Vec CableWidget::getInputPos() { | |||
if (inputPort) { | |||
return inputPort->getRelativeOffset(inputPort->box.zeroPos().getCenter(), app()->scene->rackWidget); | |||
return inputPort->getRelativeOffset(inputPort->box.zeroPos().getCenter(), APP->scene->rackWidget); | |||
} | |||
else if (hoveredInputPort) { | |||
return hoveredInputPort->getRelativeOffset(hoveredInputPort->box.zeroPos().getCenter(), app()->scene->rackWidget); | |||
return hoveredInputPort->getRelativeOffset(hoveredInputPort->box.zeroPos().getCenter(), APP->scene->rackWidget); | |||
} | |||
else { | |||
return app()->scene->rackWidget->mousePos; | |||
return APP->scene->rackWidget->mousePos; | |||
} | |||
} | |||
@@ -175,7 +176,7 @@ void CableWidget::fromJson(json_t *rootJ, const std::map<int, ModuleWidget*> &mo | |||
ModuleWidget *inputModule = inputModuleIt->second; | |||
// Set ports | |||
if (app()->patch->isLegacy(1)) { | |||
if (APP->patch->isLegacy(1)) { | |||
// Before 0.6, the index of the "ports" array was the index of the PortWidget in the `outputs` and `inputs` vector. | |||
setOutput(outputModule->outputs[outputId]); | |||
setInput(inputModule->inputs[inputId]); | |||
@@ -205,7 +206,7 @@ void CableWidget::fromJson(json_t *rootJ, const std::map<int, ModuleWidget*> &mo | |||
} | |||
} | |||
void CableWidget::draw(const DrawContext &ctx) { | |||
void CableWidget::draw(const widget::DrawContext &ctx) { | |||
float opacity = settings::cableOpacity; | |||
float tension = settings::cableTension; | |||
@@ -215,7 +216,7 @@ void CableWidget::draw(const DrawContext &ctx) { | |||
} | |||
else { | |||
// Draw opaque if mouse is hovering over a connected port | |||
PortWidget *hoveredPort = dynamic_cast<PortWidget*>(app()->event->hoveredWidget); | |||
PortWidget *hoveredPort = dynamic_cast<PortWidget*>(APP->event->hoveredWidget); | |||
if (hoveredPort && (hoveredPort == outputPort || hoveredPort == inputPort)) | |||
opacity = 1.0; | |||
} | |||
@@ -238,13 +239,13 @@ void CableWidget::draw(const DrawContext &ctx) { | |||
drawCable(ctx, outputPos, inputPos, color, thickness, tension, opacity); | |||
} | |||
void CableWidget::drawPlugs(const DrawContext &ctx) { | |||
void CableWidget::drawPlugs(const widget::DrawContext &ctx) { | |||
// TODO Figure out a way to draw plugs first and cables last, and cut the plug portion of the cable off. | |||
math::Vec outputPos = getOutputPos(); | |||
math::Vec inputPos = getInputPos(); | |||
// Draw plug if the cable is on top, or if the cable is incomplete | |||
if (!isComplete() || app()->scene->rackWidget->getTopCable(outputPort) == this) { | |||
if (!isComplete() || APP->scene->rackWidget->getTopCable(outputPort) == this) { | |||
drawPlug(ctx, outputPos, color); | |||
if (isComplete()) { | |||
// Draw plug light | |||
@@ -255,7 +256,7 @@ void CableWidget::drawPlugs(const DrawContext &ctx) { | |||
} | |||
} | |||
if (!isComplete() || app()->scene->rackWidget->getTopCable(inputPort) == this) { | |||
if (!isComplete() || APP->scene->rackWidget->getTopCable(inputPort) == this) { | |||
drawPlug(ctx, inputPos, color); | |||
if (isComplete()) { | |||
nvgSave(ctx.vg); | |||
@@ -267,4 +268,5 @@ void CableWidget::drawPlugs(const DrawContext &ctx) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -2,6 +2,7 @@ | |||
namespace rack { | |||
namespace app { | |||
CircularShadow::CircularShadow() { | |||
@@ -9,7 +10,7 @@ CircularShadow::CircularShadow() { | |||
opacity = 0.15; | |||
} | |||
void CircularShadow::draw(const DrawContext &ctx) { | |||
void CircularShadow::draw(const widget::DrawContext &ctx) { | |||
if (opacity <= 0.0) | |||
return; | |||
@@ -25,4 +26,5 @@ void CircularShadow::draw(const DrawContext &ctx) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -5,6 +5,7 @@ | |||
namespace rack { | |||
namespace app { | |||
static const float KNOB_SENSITIVITY = 0.0015f; | |||
@@ -34,11 +35,11 @@ void Knob::onDragStart(const event::DragStart &e) { | |||
} | |||
} | |||
app()->window->cursorLock(); | |||
APP->window->cursorLock(); | |||
} | |||
void Knob::onDragEnd(const event::DragEnd &e) { | |||
app()->window->cursorUnlock(); | |||
APP->window->cursorUnlock(); | |||
if (paramQuantity) { | |||
float newValue = paramQuantity->getSmoothValue(); | |||
@@ -49,7 +50,7 @@ void Knob::onDragEnd(const event::DragEnd &e) { | |||
h->paramId = paramQuantity->paramId; | |||
h->oldValue = oldValue; | |||
h->newValue = newValue; | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
} | |||
} | |||
@@ -70,7 +71,7 @@ void Knob::onDragMove(const event::DragMove &e) { | |||
delta *= range; | |||
// Drag slower if mod is held | |||
int mods = app()->window->getMods(); | |||
int mods = APP->window->getMods(); | |||
if ((mods & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||
delta /= 16.f; | |||
} | |||
@@ -96,4 +97,5 @@ void Knob::onDragMove(const event::DragMove &e) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -6,15 +6,16 @@ | |||
namespace rack { | |||
namespace app { | |||
void LedDisplay::draw(const DrawContext &ctx) { | |||
void LedDisplay::draw(const widget::DrawContext &ctx) { | |||
nvgBeginPath(ctx.vg); | |||
nvgRoundedRect(ctx.vg, 0, 0, box.size.x, box.size.y, 5.0); | |||
nvgFillColor(ctx.vg, nvgRGB(0x00, 0x00, 0x00)); | |||
nvgFill(ctx.vg); | |||
Widget::draw(ctx); | |||
widget::Widget::draw(ctx); | |||
} | |||
@@ -22,7 +23,7 @@ LedDisplaySeparator::LedDisplaySeparator() { | |||
box.size = math::Vec(); | |||
} | |||
void LedDisplaySeparator::draw(const DrawContext &ctx) { | |||
void LedDisplaySeparator::draw(const widget::DrawContext &ctx) { | |||
nvgBeginPath(ctx.vg); | |||
nvgMoveTo(ctx.vg, 0, 0); | |||
nvgLineTo(ctx.vg, box.size.x, box.size.y); | |||
@@ -39,7 +40,7 @@ LedDisplayChoice::LedDisplayChoice() { | |||
textOffset = math::Vec(10, 18); | |||
} | |||
void LedDisplayChoice::draw(const DrawContext &ctx) { | |||
void LedDisplayChoice::draw(const widget::DrawContext &ctx) { | |||
nvgScissor(ctx.vg, 0, 0, box.size.x, box.size.y); | |||
if (font->handle >= 0) { | |||
@@ -70,7 +71,7 @@ LedDisplayTextField::LedDisplayTextField() { | |||
} | |||
void LedDisplayTextField::draw(const DrawContext &ctx) { | |||
void LedDisplayTextField::draw(const widget::DrawContext &ctx) { | |||
nvgScissor(ctx.vg, 0, 0, box.size.x, box.size.y); | |||
// Background | |||
@@ -86,12 +87,12 @@ void LedDisplayTextField::draw(const DrawContext &ctx) { | |||
NVGcolor highlightColor = color; | |||
highlightColor.a = 0.5; | |||
int begin = std::min(cursor, selection); | |||
int end = (this == app()->event->selectedWidget) ? std::max(cursor, selection) : -1; | |||
int end = (this == APP->event->selectedWidget) ? std::max(cursor, selection) : -1; | |||
bndIconLabelCaret(ctx.vg, textOffset.x, textOffset.y, | |||
box.size.x - 2*textOffset.x, box.size.y - 2*textOffset.y, | |||
-1, color, 12, text.c_str(), highlightColor, begin, end); | |||
bndSetFont(app()->window->uiFont->handle); | |||
bndSetFont(APP->window->uiFont->handle); | |||
} | |||
nvgResetScissor(ctx.vg); | |||
@@ -99,12 +100,13 @@ void LedDisplayTextField::draw(const DrawContext &ctx) { | |||
int LedDisplayTextField::getTextPosition(math::Vec mousePos) { | |||
bndSetFont(font->handle); | |||
int textPos = bndIconLabelTextPosition(app()->window->vg, textOffset.x, textOffset.y, | |||
int textPos = bndIconLabelTextPosition(APP->window->vg, textOffset.x, textOffset.y, | |||
box.size.x - 2*textOffset.x, box.size.y - 2*textOffset.y, | |||
-1, 12, text.c_str(), mousePos.x, mousePos.y); | |||
bndSetFont(app()->window->uiFont->handle); | |||
bndSetFont(APP->window->uiFont->handle); | |||
return textPos; | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -3,14 +3,15 @@ | |||
namespace rack { | |||
namespace app { | |||
void LightWidget::draw(const DrawContext &ctx) { | |||
void LightWidget::draw(const widget::DrawContext &ctx) { | |||
drawLight(ctx); | |||
drawHalo(ctx); | |||
} | |||
void LightWidget::drawLight(const DrawContext &ctx) { | |||
void LightWidget::drawLight(const widget::DrawContext &ctx) { | |||
float radius = box.size.x / 2.0; | |||
nvgBeginPath(ctx.vg); | |||
@@ -30,7 +31,7 @@ void LightWidget::drawLight(const DrawContext &ctx) { | |||
nvgStroke(ctx.vg); | |||
} | |||
void LightWidget::drawHalo(const DrawContext &ctx) { | |||
void LightWidget::drawHalo(const widget::DrawContext &ctx) { | |||
float radius = box.size.x / 2.0; | |||
float oradius = radius + 15.0; | |||
@@ -47,4 +48,5 @@ void LightWidget::drawHalo(const DrawContext &ctx) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -4,9 +4,10 @@ | |||
namespace rack { | |||
namespace app { | |||
struct MidiDriverItem : MenuItem { | |||
struct MidiDriverItem : ui::MenuItem { | |||
midi::IO *midiIO; | |||
int driverId; | |||
void onAction(const event::Action &e) override { | |||
@@ -20,7 +21,7 @@ struct MidiDriverChoice : LedDisplayChoice { | |||
if (!midiWidget->midiIO) | |||
return; | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
menu->addChild(createMenuLabel("MIDI driver")); | |||
for (int driverId : midiWidget->midiIO->getDriverIds()) { | |||
MidiDriverItem *item = new MidiDriverItem; | |||
@@ -47,7 +48,7 @@ struct MidiDriverChoice : LedDisplayChoice { | |||
} | |||
}; | |||
struct MidiDeviceItem : MenuItem { | |||
struct MidiDeviceItem : ui::MenuItem { | |||
midi::IO *midiIO; | |||
int deviceId; | |||
void onAction(const event::Action &e) override { | |||
@@ -61,7 +62,7 @@ struct MidiDeviceChoice : LedDisplayChoice { | |||
if (!midiWidget->midiIO) | |||
return; | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
menu->addChild(createMenuLabel("MIDI device")); | |||
{ | |||
MidiDeviceItem *item = new MidiDeviceItem; | |||
@@ -96,7 +97,7 @@ struct MidiDeviceChoice : LedDisplayChoice { | |||
} | |||
}; | |||
struct MidiChannelItem : MenuItem { | |||
struct MidiChannelItem : ui::MenuItem { | |||
midi::IO *midiIO; | |||
int channel; | |||
void onAction(const event::Action &e) override { | |||
@@ -110,7 +111,7 @@ struct MidiChannelChoice : LedDisplayChoice { | |||
if (!midiWidget->midiIO) | |||
return; | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
menu->addChild(createMenuLabel("MIDI channel")); | |||
for (int channel : midiWidget->midiIO->getChannels()) { | |||
MidiChannelItem *item = new MidiChannelItem; | |||
@@ -169,4 +170,5 @@ void MidiWidget::step() { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -1,7 +1,7 @@ | |||
#include "app/ModuleBrowser.hpp" | |||
#include "widgets/OpaqueWidget.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widgets/ZoomWidget.hpp" | |||
#include "widget/OpaqueWidget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
#include "widget/ZoomWidget.hpp" | |||
#include "ui/ScrollWidget.hpp" | |||
#include "ui/SequentialLayout.hpp" | |||
#include "ui/Label.hpp" | |||
@@ -18,19 +18,20 @@ | |||
namespace rack { | |||
namespace app { | |||
static std::set<Model*> sFavoriteModels; | |||
struct BrowserOverlay : OpaqueWidget { | |||
struct BrowserOverlay : widget::OpaqueWidget { | |||
void step() override { | |||
box = parent->box.zeroPos(); | |||
OpaqueWidget::step(); | |||
widget::OpaqueWidget::step(); | |||
} | |||
void onButton(const event::Button &e) override { | |||
OpaqueWidget::onButton(e); | |||
widget::OpaqueWidget::onButton(e); | |||
if (e.getConsumed() != this) | |||
return; | |||
@@ -50,15 +51,15 @@ struct BrowserOverlay : OpaqueWidget { | |||
} | |||
if (!e.getConsumed()) | |||
OpaqueWidget::onHoverKey(e); | |||
widget::OpaqueWidget::onHoverKey(e); | |||
} | |||
}; | |||
struct ModuleBox : OpaqueWidget { | |||
struct ModuleBox : widget::OpaqueWidget { | |||
Model *model; | |||
/** Lazily created */ | |||
Widget *previewWidget = NULL; | |||
widget::Widget *previewWidget = NULL; | |||
/** Number of frames since draw() has been called */ | |||
int visibleFrames = 0; | |||
@@ -72,13 +73,13 @@ struct ModuleBox : OpaqueWidget { | |||
p.y = box.size.y; | |||
box.size.y += 40.0; | |||
Label *nameLabel = new Label; | |||
ui::Label *nameLabel = new ui::Label; | |||
nameLabel->text = model->name; | |||
nameLabel->box.pos = p; | |||
p.y += nameLabel->box.size.y; | |||
addChild(nameLabel); | |||
Label *pluginLabel = new Label; | |||
ui::Label *pluginLabel = new ui::Label; | |||
pluginLabel->text = model->plugin->name; | |||
pluginLabel->box.pos = p; | |||
p.y += pluginLabel->box.size.y; | |||
@@ -93,22 +94,22 @@ struct ModuleBox : OpaqueWidget { | |||
} | |||
} | |||
void draw(const DrawContext &ctx) override { | |||
void draw(const widget::DrawContext &ctx) override { | |||
visibleFrames = 0; | |||
// Lazily create ModuleWidget when drawn | |||
if (!previewWidget) { | |||
Widget *transparentWidget = new TransparentWidget; | |||
widget::Widget *transparentWidget = new widget::TransparentWidget; | |||
addChild(transparentWidget); | |||
FramebufferWidget *fbWidget = new FramebufferWidget; | |||
if (math::isNear(app()->window->pixelRatio, 1.0)) { | |||
widget::FramebufferWidget *fbWidget = new widget::FramebufferWidget; | |||
if (math::isNear(APP->window->pixelRatio, 1.0)) { | |||
// Small details draw poorly at low DPI, so oversample when drawing to the framebuffer | |||
fbWidget->oversample = 2.0; | |||
} | |||
transparentWidget->addChild(fbWidget); | |||
ZoomWidget *zoomWidget = new ZoomWidget; | |||
widget::ZoomWidget *zoomWidget = new widget::ZoomWidget; | |||
zoomWidget->setZoom(0.5f); | |||
fbWidget->addChild(zoomWidget); | |||
@@ -123,8 +124,8 @@ struct ModuleBox : OpaqueWidget { | |||
previewWidget = transparentWidget; | |||
} | |||
OpaqueWidget::draw(ctx); | |||
if (app()->event->hoveredWidget == this) { | |||
widget::OpaqueWidget::draw(ctx); | |||
if (APP->event->hoveredWidget == this) { | |||
nvgBeginPath(ctx.vg); | |||
nvgRect(ctx.vg, 0.0, 0.0, box.size.x, box.size.y); | |||
nvgFillColor(ctx.vg, nvgRGBAf(1, 1, 1, 0.25)); | |||
@@ -136,11 +137,11 @@ struct ModuleBox : OpaqueWidget { | |||
}; | |||
struct BrowserSearchField : TextField { | |||
struct BrowserSearchField : ui::TextField { | |||
}; | |||
struct BrowserSidebar : Widget { | |||
struct BrowserSidebar : widget::Widget { | |||
BrowserSearchField *searchField; | |||
BrowserSidebar() { | |||
@@ -150,25 +151,25 @@ struct BrowserSidebar : Widget { | |||
void step() override { | |||
searchField->box.size.x = box.size.x; | |||
Widget::step(); | |||
widget::Widget::step(); | |||
} | |||
}; | |||
struct ModuleBrowser : OpaqueWidget { | |||
struct ModuleBrowser : widget::OpaqueWidget { | |||
BrowserSidebar *sidebar; | |||
ScrollWidget *moduleScroll; | |||
SequentialLayout *moduleLayout; | |||
ui::ScrollWidget *moduleScroll; | |||
ui::SequentialLayout *moduleLayout; | |||
ModuleBrowser() { | |||
sidebar = new BrowserSidebar; | |||
sidebar->box.size.x = 300; | |||
addChild(sidebar); | |||
moduleScroll = new ScrollWidget; | |||
moduleScroll = new ui::ScrollWidget; | |||
addChild(moduleScroll); | |||
moduleLayout = new SequentialLayout; | |||
moduleLayout = new ui::SequentialLayout; | |||
moduleLayout->spacing = math::Vec(10, 10); | |||
moduleScroll->container->addChild(moduleLayout); | |||
@@ -192,12 +193,12 @@ struct ModuleBrowser : OpaqueWidget { | |||
moduleLayout->box.size.x = moduleScroll->box.size.x; | |||
moduleLayout->box.size.y = moduleLayout->getChildrenBoundingBox().getBottomRight().y; | |||
OpaqueWidget::step(); | |||
widget::OpaqueWidget::step(); | |||
} | |||
void draw(const DrawContext &ctx) override { | |||
void draw(const widget::DrawContext &ctx) override { | |||
bndMenuBackground(ctx.vg, 0.0, 0.0, box.size.x, box.size.y, 0); | |||
Widget::draw(ctx); | |||
widget::Widget::draw(ctx); | |||
} | |||
}; | |||
@@ -210,7 +211,7 @@ void ModuleBox::onButton(const event::Button &e) { | |||
// Create module | |||
ModuleWidget *moduleWidget = model->createModuleWidget(); | |||
assert(moduleWidget); | |||
app()->scene->rackWidget->addModuleAtMouse(moduleWidget); | |||
APP->scene->rackWidget->addModuleAtMouse(moduleWidget); | |||
// This is a bit nonstandard/unsupported usage, but pretend the moduleWidget was clicked so it can be dragged in the RackWidget | |||
// e.consume(moduleWidget); | |||
@@ -221,16 +222,16 @@ void ModuleBox::onButton(const event::Button &e) { | |||
// Push ModuleAdd history action | |||
history::ModuleAdd *h = new history::ModuleAdd; | |||
h->setModule(moduleWidget); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
OpaqueWidget::onButton(e); | |||
widget::OpaqueWidget::onButton(e); | |||
} | |||
// Global functions | |||
Widget *moduleBrowserCreate() { | |||
widget::Widget *moduleBrowserCreate() { | |||
BrowserOverlay *overlay = new BrowserOverlay; | |||
ModuleBrowser *browser = new ModuleBrowser; | |||
@@ -275,4 +276,5 @@ void moduleBrowserFromJson(json_t *rootJ) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -2,6 +2,7 @@ | |||
namespace rack { | |||
namespace app { | |||
void ModuleLightWidget::step() { | |||
@@ -24,4 +25,5 @@ void ModuleLightWidget::step() { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -13,12 +13,13 @@ | |||
namespace rack { | |||
namespace app { | |||
static const char PRESET_FILTERS[] = "VCV Rack module preset (.vcvm):vcvm"; | |||
struct ModuleDisconnectItem : MenuItem { | |||
struct ModuleDisconnectItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleDisconnectItem() { | |||
text = "Disconnect cables"; | |||
@@ -29,7 +30,7 @@ struct ModuleDisconnectItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleResetItem : MenuItem { | |||
struct ModuleResetItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleResetItem() { | |||
text = "Initialize"; | |||
@@ -40,7 +41,7 @@ struct ModuleResetItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleRandomizeItem : MenuItem { | |||
struct ModuleRandomizeItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleRandomizeItem() { | |||
text = "Randomize"; | |||
@@ -51,7 +52,7 @@ struct ModuleRandomizeItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleCopyItem : MenuItem { | |||
struct ModuleCopyItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleCopyItem() { | |||
text = "Copy preset"; | |||
@@ -62,7 +63,7 @@ struct ModuleCopyItem : MenuItem { | |||
} | |||
}; | |||
struct ModulePasteItem : MenuItem { | |||
struct ModulePasteItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModulePasteItem() { | |||
text = "Paste preset"; | |||
@@ -73,7 +74,7 @@ struct ModulePasteItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleSaveItem : MenuItem { | |||
struct ModuleSaveItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleSaveItem() { | |||
text = "Save preset as"; | |||
@@ -83,7 +84,7 @@ struct ModuleSaveItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleLoadItem : MenuItem { | |||
struct ModuleLoadItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleLoadItem() { | |||
text = "Load preset"; | |||
@@ -93,7 +94,7 @@ struct ModuleLoadItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleCloneItem : MenuItem { | |||
struct ModuleCloneItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleCloneItem() { | |||
text = "Duplicate"; | |||
@@ -104,7 +105,7 @@ struct ModuleCloneItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleBypassItem : MenuItem { | |||
struct ModuleBypassItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleBypassItem() { | |||
text = "Bypass"; | |||
@@ -120,7 +121,7 @@ struct ModuleBypassItem : MenuItem { | |||
} | |||
}; | |||
struct ModuleDeleteItem : MenuItem { | |||
struct ModuleDeleteItem : ui::MenuItem { | |||
ModuleWidget *moduleWidget; | |||
ModuleDeleteItem() { | |||
text = "Delete"; | |||
@@ -136,12 +137,12 @@ ModuleWidget::~ModuleWidget() { | |||
setModule(NULL); | |||
} | |||
void ModuleWidget::draw(const DrawContext &ctx) { | |||
void ModuleWidget::draw(const widget::DrawContext &ctx) { | |||
if (module && module->bypass) { | |||
nvgGlobalAlpha(ctx.vg, 0.25); | |||
} | |||
// nvgScissor(ctx.vg, 0, 0, box.size.x, box.size.y); | |||
Widget::draw(ctx); | |||
widget::Widget::draw(ctx); | |||
// Power meter | |||
if (module && settings::powerMeter) { | |||
@@ -155,7 +156,7 @@ void ModuleWidget::draw(const DrawContext &ctx) { | |||
std::string cpuText = string::f("%.2f ÎĽs", module->cpuTime * 1e6f); | |||
bndLabel(ctx.vg, 2.0, box.size.y - 20.0, INFINITY, INFINITY, -1, cpuText.c_str()); | |||
float p = math::clamp(module->cpuTime / app()->engine->getSampleTime(), 0.f, 1.f); | |||
float p = math::clamp(module->cpuTime / APP->engine->getSampleTime(), 0.f, 1.f); | |||
nvgBeginPath(ctx.vg); | |||
nvgRect(ctx.vg, | |||
0, (1.f - p) * box.size.y, | |||
@@ -177,7 +178,7 @@ void ModuleWidget::draw(const DrawContext &ctx) { | |||
// nvgResetScissor(ctx.vg); | |||
} | |||
void ModuleWidget::drawShadow(const DrawContext &ctx) { | |||
void ModuleWidget::drawShadow(const widget::DrawContext &ctx) { | |||
nvgBeginPath(ctx.vg); | |||
float r = 20; // Blur radius | |||
float c = 20; // Corner radius | |||
@@ -190,12 +191,12 @@ void ModuleWidget::drawShadow(const DrawContext &ctx) { | |||
} | |||
void ModuleWidget::onHover(const event::Hover &e) { | |||
OpaqueWidget::onHover(e); | |||
widget::OpaqueWidget::onHover(e); | |||
// 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(app()->window->win, GLFW_KEY_DELETE) == GLFW_PRESS | |||
|| glfwGetKey(app()->window->win, GLFW_KEY_BACKSPACE) == GLFW_PRESS) | |||
&& (app()->window->getMods() & WINDOW_MOD_MASK) == 0) { | |||
if ((glfwGetKey(APP->window->win, GLFW_KEY_DELETE) == GLFW_PRESS | |||
|| glfwGetKey(APP->window->win, GLFW_KEY_BACKSPACE) == GLFW_PRESS) | |||
&& (APP->window->getMods() & WINDOW_MOD_MASK) == 0) { | |||
removeAction(); | |||
e.consume(NULL); | |||
return; | |||
@@ -203,7 +204,7 @@ void ModuleWidget::onHover(const event::Hover &e) { | |||
} | |||
void ModuleWidget::onButton(const event::Button &e) { | |||
OpaqueWidget::onButton(e); | |||
widget::OpaqueWidget::onButton(e); | |||
if (e.getConsumed() == this) { | |||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | |||
@@ -261,12 +262,12 @@ void ModuleWidget::onHoverKey(const event::HoverKey &e) { | |||
} | |||
if (!e.getConsumed()) | |||
OpaqueWidget::onHoverKey(e); | |||
widget::OpaqueWidget::onHoverKey(e); | |||
} | |||
void ModuleWidget::onDragStart(const event::DragStart &e) { | |||
oldPos = box.pos; | |||
dragPos = app()->scene->rackWidget->mousePos.minus(box.pos); | |||
dragPos = APP->scene->rackWidget->mousePos.minus(box.pos); | |||
} | |||
void ModuleWidget::onDragEnd(const event::DragEnd &e) { | |||
@@ -276,15 +277,15 @@ void ModuleWidget::onDragEnd(const event::DragEnd &e) { | |||
h->moduleId = module->id; | |||
h->oldPos = oldPos; | |||
h->newPos = box.pos; | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
} | |||
void ModuleWidget::onDragMove(const event::DragMove &e) { | |||
if (!settings::lockModules) { | |||
math::Rect newBox = box; | |||
newBox.pos = app()->scene->rackWidget->mousePos.minus(dragPos); | |||
app()->scene->rackWidget->requestModuleBoxNearest(this, newBox); | |||
newBox.pos = APP->scene->rackWidget->mousePos.minus(dragPos); | |||
APP->scene->rackWidget->requestModuleBoxNearest(this, newBox); | |||
} | |||
} | |||
@@ -413,11 +414,11 @@ void ModuleWidget::copyClipboard() { | |||
DEFER({ | |||
free(moduleJson); | |||
}); | |||
glfwSetClipboardString(app()->window->win, moduleJson); | |||
glfwSetClipboardString(APP->window->win, moduleJson); | |||
} | |||
void ModuleWidget::pasteClipboardAction() { | |||
const char *moduleJson = glfwGetClipboardString(app()->window->win); | |||
const char *moduleJson = glfwGetClipboardString(APP->window->win); | |||
if (!moduleJson) { | |||
WARN("Could not get text from clipboard."); | |||
return; | |||
@@ -441,7 +442,7 @@ void ModuleWidget::pasteClipboardAction() { | |||
fromJson(moduleJ); | |||
h->newModuleJ = toJson(); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
void ModuleWidget::loadAction(std::string filename) { | |||
@@ -475,7 +476,7 @@ void ModuleWidget::loadAction(std::string filename) { | |||
fromJson(moduleJ); | |||
h->newModuleJ = toJson(); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
void ModuleWidget::save(std::string filename) { | |||
@@ -548,10 +549,10 @@ void ModuleWidget::saveDialog() { | |||
void ModuleWidget::disconnect() { | |||
for (PortWidget *input : inputs) { | |||
app()->scene->rackWidget->clearCablesOnPort(input); | |||
APP->scene->rackWidget->clearCablesOnPort(input); | |||
} | |||
for (PortWidget *output : outputs) { | |||
app()->scene->rackWidget->clearCablesOnPort(output); | |||
APP->scene->rackWidget->clearCablesOnPort(output); | |||
} | |||
} | |||
@@ -563,10 +564,10 @@ void ModuleWidget::resetAction() { | |||
h->moduleId = module->id; | |||
h->oldModuleJ = toJson(); | |||
app()->engine->resetModule(module); | |||
APP->engine->resetModule(module); | |||
h->newModuleJ = toJson(); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
void ModuleWidget::randomizeAction() { | |||
@@ -577,16 +578,16 @@ void ModuleWidget::randomizeAction() { | |||
h->moduleId = module->id; | |||
h->oldModuleJ = toJson(); | |||
app()->engine->randomizeModule(module); | |||
APP->engine->randomizeModule(module); | |||
h->newModuleJ = toJson(); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
static void disconnectActions(ModuleWidget *mw, history::ComplexAction *complexAction) { | |||
// Add CableRemove action for all cables attached to outputs | |||
for (PortWidget* output : mw->outputs) { | |||
for (CableWidget *cw : app()->scene->rackWidget->getCablesOnPort(output)) { | |||
for (CableWidget *cw : APP->scene->rackWidget->getCablesOnPort(output)) { | |||
if (!cw->isComplete()) | |||
continue; | |||
// history::CableRemove | |||
@@ -597,7 +598,7 @@ static void disconnectActions(ModuleWidget *mw, history::ComplexAction *complexA | |||
} | |||
// Add CableRemove action for all cables attached to inputs | |||
for (PortWidget* input : mw->inputs) { | |||
for (CableWidget *cw : app()->scene->rackWidget->getCablesOnPort(input)) { | |||
for (CableWidget *cw : APP->scene->rackWidget->getCablesOnPort(input)) { | |||
if (!cw->isComplete()) | |||
continue; | |||
// Avoid creating duplicate actions for self-patched cables | |||
@@ -614,7 +615,7 @@ static void disconnectActions(ModuleWidget *mw, history::ComplexAction *complexA | |||
void ModuleWidget::disconnectAction() { | |||
history::ComplexAction *complexAction = new history::ComplexAction; | |||
disconnectActions(this, complexAction); | |||
app()->history->push(complexAction); | |||
APP->history->push(complexAction); | |||
disconnect(); | |||
} | |||
@@ -627,12 +628,12 @@ void ModuleWidget::cloneAction() { | |||
clonedModuleWidget->fromJson(moduleJ); | |||
json_decref(moduleJ); | |||
app()->scene->rackWidget->addModuleAtMouse(clonedModuleWidget); | |||
APP->scene->rackWidget->addModuleAtMouse(clonedModuleWidget); | |||
// history::ModuleAdd | |||
history::ModuleAdd *h = new history::ModuleAdd; | |||
h->setModule(clonedModuleWidget); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
void ModuleWidget::bypassAction() { | |||
@@ -641,7 +642,7 @@ void ModuleWidget::bypassAction() { | |||
history::ModuleBypass *h = new history::ModuleBypass; | |||
h->moduleId = module->id; | |||
h->bypass = !module->bypass; | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
h->redo(); | |||
} | |||
@@ -654,18 +655,18 @@ void ModuleWidget::removeAction() { | |||
moduleRemove->setModule(this); | |||
complexAction->push(moduleRemove); | |||
app()->history->push(complexAction); | |||
APP->history->push(complexAction); | |||
// This disconnects cables, removes the module, and transfers ownership to caller | |||
app()->scene->rackWidget->removeModule(this); | |||
APP->scene->rackWidget->removeModule(this); | |||
delete this; | |||
} | |||
void ModuleWidget::createContextMenu() { | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
assert(model); | |||
MenuLabel *menuLabel = new MenuLabel; | |||
ui::MenuLabel *menuLabel = new ui::MenuLabel; | |||
menuLabel->text = model->plugin->name + " " + model->name + " " + model->plugin->version; | |||
menu->addChild(menuLabel); | |||
@@ -713,4 +714,5 @@ void ModuleWidget::createContextMenu() { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -3,6 +3,7 @@ | |||
namespace rack { | |||
namespace app { | |||
void MultiLightWidget::addBaseColor(NVGcolor baseColor) { | |||
@@ -21,4 +22,5 @@ void MultiLightWidget::setBrightnesses(const std::vector<float> &brightnesses) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -4,6 +4,7 @@ | |||
namespace rack { | |||
namespace app { | |||
Param *ParamQuantity::getParam() { | |||
@@ -15,11 +16,11 @@ void ParamQuantity::setSmoothValue(float smoothValue) { | |||
if (!module) | |||
return; | |||
smoothValue = math::clamp(smoothValue, getMinValue(), getMaxValue()); | |||
app()->engine->setSmoothParam(module, paramId, smoothValue); | |||
APP->engine->setSmoothParam(module, paramId, smoothValue); | |||
} | |||
float ParamQuantity::getSmoothValue() { | |||
return app()->engine->getSmoothParam(module, paramId); | |||
return APP->engine->getSmoothParam(module, paramId); | |||
} | |||
void ParamQuantity::setValue(float value) { | |||
@@ -55,7 +56,7 @@ float ParamQuantity::getDefaultValue() { | |||
float ParamQuantity::getDisplayValue() { | |||
if (!module) | |||
return Quantity::getDisplayValue(); | |||
return ui::Quantity::getDisplayValue(); | |||
float v = getSmoothValue(); | |||
float displayBase = getParam()->displayBase; | |||
if (displayBase == 0.f) { | |||
@@ -92,28 +93,29 @@ void ParamQuantity::setDisplayValue(float displayValue) { | |||
} | |||
int ParamQuantity::getDisplayPrecision() { | |||
return Quantity::getDisplayPrecision(); | |||
return ui::Quantity::getDisplayPrecision(); | |||
} | |||
std::string ParamQuantity::getDisplayValueString() { | |||
return Quantity::getDisplayValueString(); | |||
return ui::Quantity::getDisplayValueString(); | |||
} | |||
void ParamQuantity::setDisplayValueString(std::string s) { | |||
Quantity::setDisplayValueString(s); | |||
ui::Quantity::setDisplayValueString(s); | |||
} | |||
std::string ParamQuantity::getLabel() { | |||
if (!module) | |||
return Quantity::getLabel(); | |||
return ui::Quantity::getLabel(); | |||
return getParam()->label; | |||
} | |||
std::string ParamQuantity::getUnit() { | |||
if (!module) | |||
return Quantity::getUnit(); | |||
return ui::Quantity::getUnit(); | |||
return getParam()->unit; | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -11,15 +11,16 @@ | |||
namespace rack { | |||
namespace app { | |||
struct ParamField : TextField { | |||
struct ParamField : ui::TextField { | |||
ParamWidget *paramWidget; | |||
void step() override { | |||
// Keep selected | |||
app()->event->setSelected(this); | |||
TextField::step(); | |||
APP->event->setSelected(this); | |||
ui::TextField::step(); | |||
} | |||
void setParamWidget(ParamWidget *paramWidget) { | |||
@@ -43,26 +44,26 @@ struct ParamField : TextField { | |||
h->paramId = paramWidget->paramQuantity->paramId; | |||
h->oldValue = oldValue; | |||
h->newValue = newValue; | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
MenuOverlay *overlay = getAncestorOfType<MenuOverlay>(); | |||
ui::MenuOverlay *overlay = getAncestorOfType<ui::MenuOverlay>(); | |||
overlay->requestedDelete = true; | |||
e.consume(this); | |||
} | |||
if (!e.getConsumed()) | |||
TextField::onSelectKey(e); | |||
ui::TextField::onSelectKey(e); | |||
} | |||
}; | |||
struct ParamTooltip : Tooltip { | |||
struct ParamTooltip : ui::Tooltip { | |||
ParamWidget *paramWidget; | |||
void step() override { | |||
if (paramWidget->paramQuantity) { | |||
// Quantity string | |||
// ui::Quantity string | |||
text = paramWidget->paramQuantity->getString(); | |||
// Param description | |||
std::string description = paramWidget->paramQuantity->getParam()->description; | |||
@@ -71,21 +72,21 @@ struct ParamTooltip : Tooltip { | |||
} | |||
// Position at bottom-right of parameter | |||
box.pos = paramWidget->getAbsoluteOffset(paramWidget->box.size).round(); | |||
Tooltip::step(); | |||
ui::Tooltip::step(); | |||
} | |||
}; | |||
struct ParamLabel : MenuLabel { | |||
struct ParamLabel : ui::MenuLabel { | |||
ParamWidget *paramWidget; | |||
void step() override { | |||
text = paramWidget->paramQuantity->getString(); | |||
MenuLabel::step(); | |||
ui::MenuLabel::step(); | |||
} | |||
}; | |||
struct ParamResetItem : MenuItem { | |||
struct ParamResetItem : ui::MenuItem { | |||
ParamWidget *paramWidget; | |||
ParamResetItem() { | |||
text = "Initialize"; | |||
@@ -97,7 +98,7 @@ struct ParamResetItem : MenuItem { | |||
}; | |||
struct ParamFineItem : MenuItem { | |||
struct ParamFineItem : ui::MenuItem { | |||
ParamFineItem() { | |||
text = "Fine adjust"; | |||
rightText = WINDOW_MOD_CTRL_NAME "+Drag"; | |||
@@ -122,11 +123,11 @@ void ParamWidget::step() { | |||
} | |||
} | |||
OpaqueWidget::step(); | |||
widget::OpaqueWidget::step(); | |||
} | |||
void ParamWidget::draw(const DrawContext &ctx) { | |||
Widget::draw(ctx); | |||
void ParamWidget::draw(const widget::DrawContext &ctx) { | |||
widget::Widget::draw(ctx); | |||
// if (paramQuantity) { | |||
// nvgBeginPath(ctx.vg); | |||
@@ -157,21 +158,21 @@ void ParamWidget::onButton(const event::Button &e) { | |||
} | |||
if (!e.getConsumed()) | |||
OpaqueWidget::onButton(e); | |||
widget::OpaqueWidget::onButton(e); | |||
} | |||
void ParamWidget::onEnter(const event::Enter &e) { | |||
if (settings::paramTooltip && !tooltip && paramQuantity) { | |||
ParamTooltip *paramTooltip = new ParamTooltip; | |||
paramTooltip->paramWidget = this; | |||
app()->scene->addChild(paramTooltip); | |||
APP->scene->addChild(paramTooltip); | |||
tooltip = paramTooltip; | |||
} | |||
} | |||
void ParamWidget::onLeave(const event::Leave &e) { | |||
if (tooltip) { | |||
app()->scene->removeChild(tooltip); | |||
APP->scene->removeChild(tooltip); | |||
delete tooltip; | |||
tooltip = NULL; | |||
} | |||
@@ -186,7 +187,7 @@ void ParamWidget::fromJson(json_t *rootJ) { | |||
} | |||
void ParamWidget::createContextMenu() { | |||
Menu *menu = createMenu(); | |||
ui::Menu *menu = createMenu(); | |||
ParamLabel *paramLabel = new ParamLabel; | |||
paramLabel->paramWidget = this; | |||
@@ -218,7 +219,7 @@ void ParamWidget::resetAction() { | |||
h->paramId = paramQuantity->paramId; | |||
h->oldValue = oldValue; | |||
h->newValue = newValue; | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
// Here's another way of doing it, but either works. | |||
@@ -227,4 +228,5 @@ void ParamWidget::resetAction() { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -7,6 +7,7 @@ | |||
namespace rack { | |||
namespace app { | |||
struct PlugLight : MultiLightWidget { | |||
@@ -29,7 +30,7 @@ PortWidget::~PortWidget() { | |||
delete plugLight; | |||
// HACK | |||
if (module) | |||
app()->scene->rackWidget->clearCablesOnPort(this); | |||
APP->scene->rackWidget->clearCablesOnPort(this); | |||
} | |||
void PortWidget::step() { | |||
@@ -51,26 +52,26 @@ void PortWidget::step() { | |||
plugLight->setBrightnesses(values); | |||
} | |||
void PortWidget::draw(const DrawContext &ctx) { | |||
CableWidget *cw = app()->scene->rackWidget->incompleteCable; | |||
void PortWidget::draw(const widget::DrawContext &ctx) { | |||
CableWidget *cw = APP->scene->rackWidget->incompleteCable; | |||
if (cw) { | |||
// Dim the PortWidget if the active cable cannot plug into this PortWidget | |||
if (type == OUTPUT ? cw->outputPort : cw->inputPort) | |||
nvgGlobalAlpha(ctx.vg, 0.5); | |||
} | |||
Widget::draw(ctx); | |||
widget::Widget::draw(ctx); | |||
} | |||
void PortWidget::onButton(const event::Button &e) { | |||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | |||
CableWidget *cw = app()->scene->rackWidget->getTopCable(this); | |||
CableWidget *cw = APP->scene->rackWidget->getTopCable(this); | |||
if (cw) { | |||
// history::CableRemove | |||
history::CableRemove *h = new history::CableRemove; | |||
h->setCable(cw); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
app()->scene->rackWidget->removeCable(cw); | |||
APP->scene->rackWidget->removeCable(cw); | |||
delete cw; | |||
} | |||
} | |||
@@ -79,22 +80,22 @@ void PortWidget::onButton(const event::Button &e) { | |||
void PortWidget::onDragStart(const event::DragStart &e) { | |||
CableWidget *cw = NULL; | |||
if (type == OUTPUT && (app()->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||
if (type == OUTPUT && (APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) { | |||
// Keep cable NULL | |||
} | |||
else { | |||
// Grab cable on top of stack | |||
cw = app()->scene->rackWidget->getTopCable(this); | |||
cw = APP->scene->rackWidget->getTopCable(this); | |||
} | |||
if (cw) { | |||
// history::CableRemove | |||
history::CableRemove *h = new history::CableRemove; | |||
h->setCable(cw); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
// Disconnect and reuse existing cable | |||
app()->scene->rackWidget->removeCable(cw); | |||
APP->scene->rackWidget->removeCable(cw); | |||
if (type == OUTPUT) | |||
cw->setOutput(NULL); | |||
else | |||
@@ -108,18 +109,18 @@ void PortWidget::onDragStart(const event::DragStart &e) { | |||
else | |||
cw->setInput(this); | |||
} | |||
app()->scene->rackWidget->setIncompleteCable(cw); | |||
APP->scene->rackWidget->setIncompleteCable(cw); | |||
} | |||
void PortWidget::onDragEnd(const event::DragEnd &e) { | |||
CableWidget *cw = app()->scene->rackWidget->releaseIncompleteCable(); | |||
CableWidget *cw = APP->scene->rackWidget->releaseIncompleteCable(); | |||
if (cw->isComplete()) { | |||
app()->scene->rackWidget->addCable(cw); | |||
APP->scene->rackWidget->addCable(cw); | |||
// history::CableAdd | |||
history::CableAdd *h = new history::CableAdd; | |||
h->setCable(cw); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
else { | |||
delete cw; | |||
@@ -129,11 +130,11 @@ void PortWidget::onDragEnd(const event::DragEnd &e) { | |||
void PortWidget::onDragDrop(const event::DragDrop &e) { | |||
// Reject ports if this is an input port and something is already plugged into it | |||
if (type == INPUT) { | |||
if (app()->scene->rackWidget->getTopCable(this)) | |||
if (APP->scene->rackWidget->getTopCable(this)) | |||
return; | |||
} | |||
CableWidget *cw = app()->scene->rackWidget->incompleteCable; | |||
CableWidget *cw = APP->scene->rackWidget->incompleteCable; | |||
if (cw) { | |||
cw->hoveredOutputPort = cw->hoveredInputPort = NULL; | |||
if (type == OUTPUT) | |||
@@ -146,11 +147,11 @@ void PortWidget::onDragDrop(const event::DragDrop &e) { | |||
void PortWidget::onDragEnter(const event::DragEnter &e) { | |||
// Reject ports if this is an input port and something is already plugged into it | |||
if (type == INPUT) { | |||
if (app()->scene->rackWidget->getTopCable(this)) | |||
if (APP->scene->rackWidget->getTopCable(this)) | |||
return; | |||
} | |||
CableWidget *cw = app()->scene->rackWidget->incompleteCable; | |||
CableWidget *cw = APP->scene->rackWidget->incompleteCable; | |||
if (cw) { | |||
if (type == OUTPUT) | |||
cw->hoveredOutputPort = this; | |||
@@ -164,7 +165,7 @@ void PortWidget::onDragLeave(const event::DragLeave &e) { | |||
if (!originPort) | |||
return; | |||
CableWidget *cw = app()->scene->rackWidget->incompleteCable; | |||
CableWidget *cw = APP->scene->rackWidget->incompleteCable; | |||
if (cw) { | |||
if (type == OUTPUT) | |||
cw->hoveredOutputPort = NULL; | |||
@@ -174,4 +175,5 @@ void PortWidget::onDragLeave(const event::DragLeave &e) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -2,8 +2,9 @@ | |||
namespace rack { | |||
namespace app { | |||
void RackRail::draw(const DrawContext &ctx) { | |||
void RackRail::draw(const widget::DrawContext &ctx) { | |||
const float railHeight = RACK_GRID_WIDTH; | |||
// Background color | |||
@@ -58,4 +59,5 @@ void RackRail::draw(const DrawContext &ctx) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -5,13 +5,14 @@ | |||
namespace rack { | |||
namespace app { | |||
void RackScrollWidget::step() { | |||
math::Vec pos = app()->window->mousePos; | |||
math::Vec pos = APP->window->mousePos; | |||
math::Rect viewport = getViewport(box.zeroPos()); | |||
// Scroll rack if dragging cable near the edge of the screen | |||
if (app()->scene->rackWidget->incompleteCable) { | |||
if (APP->scene->rackWidget->incompleteCable) { | |||
float margin = 20.0; | |||
float speed = 15.0; | |||
if (pos.x <= viewport.pos.x + margin) | |||
@@ -23,13 +24,14 @@ void RackScrollWidget::step() { | |||
if (pos.y >= viewport.pos.y + viewport.size.y - margin) | |||
offset.y += speed; | |||
} | |||
ScrollWidget::step(); | |||
ui::ScrollWidget::step(); | |||
} | |||
void RackScrollWidget::draw(const DrawContext &ctx) { | |||
ScrollWidget::draw(ctx); | |||
void RackScrollWidget::draw(const widget::DrawContext &ctx) { | |||
ui::ScrollWidget::draw(ctx); | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -1,5 +1,5 @@ | |||
#include "app/RackWidget.hpp" | |||
#include "widgets/TransparentWidget.hpp" | |||
#include "widget/TransparentWidget.hpp" | |||
#include "app/RackRail.hpp" | |||
#include "app/Scene.hpp" | |||
#include "app/ModuleBrowser.hpp" | |||
@@ -15,6 +15,7 @@ | |||
namespace rack { | |||
namespace app { | |||
static ModuleWidget *moduleFromJson(json_t *moduleJ) { | |||
@@ -41,10 +42,10 @@ static ModuleWidget *moduleFromJson(json_t *moduleJ) { | |||
} | |||
struct ModuleContainer : Widget { | |||
void draw(const DrawContext &ctx) override { | |||
struct ModuleContainer : widget::Widget { | |||
void draw(const widget::DrawContext &ctx) override { | |||
// Draw shadows behind each ModuleWidget first, so the shadow doesn't overlap the front of other ModuleWidgets. | |||
for (Widget *child : children) { | |||
for (widget::Widget *child : children) { | |||
ModuleWidget *w = dynamic_cast<ModuleWidget*>(child); | |||
assert(w); | |||
@@ -54,17 +55,17 @@ struct ModuleContainer : Widget { | |||
nvgRestore(ctx.vg); | |||
} | |||
Widget::draw(ctx); | |||
widget::Widget::draw(ctx); | |||
} | |||
}; | |||
struct CableContainer : TransparentWidget { | |||
void draw(const DrawContext &ctx) override { | |||
Widget::draw(ctx); | |||
struct CableContainer : widget::TransparentWidget { | |||
void draw(const widget::DrawContext &ctx) override { | |||
widget::Widget::draw(ctx); | |||
// Draw cable plugs | |||
for (Widget *w : children) { | |||
for (widget::Widget *w : children) { | |||
CableWidget *cw = dynamic_cast<CableWidget*>(w); | |||
assert(cw); | |||
cw->drawPlugs(ctx); | |||
@@ -74,7 +75,7 @@ struct CableContainer : TransparentWidget { | |||
RackWidget::RackWidget() { | |||
rails = new FramebufferWidget; | |||
rails = new widget::FramebufferWidget; | |||
rails->box.size = math::Vec(); | |||
rails->oversample = 1.0; | |||
{ | |||
@@ -102,7 +103,7 @@ void RackWidget::step() { | |||
box.size = box.size.max(moduleSize); | |||
// Adjust size and position of rails | |||
Widget *rail = rails->children.front(); | |||
widget::Widget *rail = rails->children.front(); | |||
math::Rect bound = getViewport(math::Rect(math::Vec(), box.size)); | |||
if (!rails->box.isContaining(bound)) { | |||
math::Vec cellMargin = math::Vec(20, 1); | |||
@@ -113,43 +114,43 @@ void RackWidget::step() { | |||
rail->box.size = rails->box.size; | |||
} | |||
Widget::step(); | |||
widget::Widget::step(); | |||
} | |||
void RackWidget::draw(const DrawContext &ctx) { | |||
Widget::draw(ctx); | |||
void RackWidget::draw(const widget::DrawContext &ctx) { | |||
widget::Widget::draw(ctx); | |||
} | |||
void RackWidget::onHover(const event::Hover &e) { | |||
// Scroll with arrow keys | |||
float arrowSpeed = 30.0; | |||
if ((app()->window->getMods() & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL |GLFW_MOD_SHIFT)) | |||
if ((APP->window->getMods() & WINDOW_MOD_MASK) == (WINDOW_MOD_CTRL |GLFW_MOD_SHIFT)) | |||
arrowSpeed /= 16.0; | |||
else if ((app()->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) | |||
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == WINDOW_MOD_CTRL) | |||
arrowSpeed *= 4.0; | |||
else if ((app()->window->getMods() & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT) | |||
else if ((APP->window->getMods() & WINDOW_MOD_MASK) == GLFW_MOD_SHIFT) | |||
arrowSpeed /= 4.0; | |||
ScrollWidget *scrollWidget = app()->scene->scrollWidget; | |||
if (glfwGetKey(app()->window->win, GLFW_KEY_LEFT) == GLFW_PRESS) { | |||
ui::ScrollWidget *scrollWidget = APP->scene->scrollWidget; | |||
if (glfwGetKey(APP->window->win, GLFW_KEY_LEFT) == GLFW_PRESS) { | |||
scrollWidget->offset.x -= arrowSpeed; | |||
} | |||
if (glfwGetKey(app()->window->win, GLFW_KEY_RIGHT) == GLFW_PRESS) { | |||
if (glfwGetKey(APP->window->win, GLFW_KEY_RIGHT) == GLFW_PRESS) { | |||
scrollWidget->offset.x += arrowSpeed; | |||
} | |||
if (glfwGetKey(app()->window->win, GLFW_KEY_UP) == GLFW_PRESS) { | |||
if (glfwGetKey(APP->window->win, GLFW_KEY_UP) == GLFW_PRESS) { | |||
scrollWidget->offset.y -= arrowSpeed; | |||
} | |||
if (glfwGetKey(app()->window->win, GLFW_KEY_DOWN) == GLFW_PRESS) { | |||
if (glfwGetKey(APP->window->win, GLFW_KEY_DOWN) == GLFW_PRESS) { | |||
scrollWidget->offset.y += arrowSpeed; | |||
} | |||
OpaqueWidget::onHover(e); | |||
widget::OpaqueWidget::onHover(e); | |||
mousePos = e.pos; | |||
} | |||
void RackWidget::onHoverKey(const event::HoverKey &e) { | |||
OpaqueWidget::onHoverKey(e); | |||
widget::OpaqueWidget::onHoverKey(e); | |||
if (e.getConsumed() != this) | |||
return; | |||
@@ -165,30 +166,30 @@ void RackWidget::onHoverKey(const event::HoverKey &e) { | |||
} | |||
void RackWidget::onDragHover(const event::DragHover &e) { | |||
OpaqueWidget::onDragHover(e); | |||
widget::OpaqueWidget::onDragHover(e); | |||
mousePos = e.pos; | |||
} | |||
void RackWidget::onButton(const event::Button &e) { | |||
OpaqueWidget::onButton(e); | |||
widget::OpaqueWidget::onButton(e); | |||
if (e.getConsumed() == this) { | |||
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { | |||
app()->scene->moduleBrowser->visible = true; | |||
APP->scene->moduleBrowser->visible = true; | |||
} | |||
} | |||
} | |||
void RackWidget::onZoom(const event::Zoom &e) { | |||
rails->box.size = math::Vec(); | |||
OpaqueWidget::onZoom(e); | |||
widget::OpaqueWidget::onZoom(e); | |||
} | |||
void RackWidget::clear() { | |||
// This isn't required because removing all ModuleWidgets should remove all cables, but do it just in case. | |||
clearCables(); | |||
// Remove ModuleWidgets | |||
std::list<Widget*> widgets = moduleContainer->children; | |||
for (Widget *w : widgets) { | |||
std::list<widget::Widget*> widgets = moduleContainer->children; | |||
for (widget::Widget *w : widgets) { | |||
ModuleWidget *moduleWidget = dynamic_cast<ModuleWidget*>(w); | |||
assert(moduleWidget); | |||
removeModule(moduleWidget); | |||
@@ -201,7 +202,7 @@ json_t *RackWidget::toJson() { | |||
// modules | |||
json_t *modulesJ = json_array(); | |||
for (Widget *w : moduleContainer->children) { | |||
for (widget::Widget *w : moduleContainer->children) { | |||
ModuleWidget *moduleWidget = dynamic_cast<ModuleWidget*>(w); | |||
assert(moduleWidget); | |||
// module | |||
@@ -220,7 +221,7 @@ json_t *RackWidget::toJson() { | |||
// cables | |||
json_t *cablesJ = json_array(); | |||
for (Widget *w : cableContainer->children) { | |||
for (widget::Widget *w : cableContainer->children) { | |||
CableWidget *cw = dynamic_cast<CableWidget*>(w); | |||
assert(cw); | |||
@@ -257,7 +258,7 @@ void RackWidget::fromJson(json_t *rootJ) { | |||
double x, y; | |||
json_unpack(posJ, "[F, F]", &x, &y); | |||
math::Vec pos = math::Vec(x, y); | |||
if (app()->patch->isLegacy(1)) { | |||
if (APP->patch->isLegacy(1)) { | |||
// Before 0.6, positions were in pixel units | |||
moduleWidget->box.pos = pos; | |||
} | |||
@@ -265,7 +266,7 @@ void RackWidget::fromJson(json_t *rootJ) { | |||
moduleWidget->box.pos = pos.mult(RACK_GRID_SIZE); | |||
} | |||
if (app()->patch->isLegacy(2)) { | |||
if (APP->patch->isLegacy(2)) { | |||
// Before 1.0, the module ID was the index in the "modules" array | |||
moduleWidgets[moduleIndex] = moduleWidget; | |||
} | |||
@@ -279,7 +280,7 @@ void RackWidget::fromJson(json_t *rootJ) { | |||
json_t *modelSlugJ = json_object_get(moduleJ, "model"); | |||
std::string pluginSlug = json_string_value(pluginSlugJ); | |||
std::string modelSlug = json_string_value(modelSlugJ); | |||
app()->patch->warningLog += string::f("Could not find module \"%s\" of plugin \"%s\"\n", modelSlug.c_str(), pluginSlug.c_str()); | |||
APP->patch->warningLog += string::f("Could not find module \"%s\" of plugin \"%s\"\n", modelSlug.c_str(), pluginSlug.c_str()); | |||
} | |||
} | |||
@@ -304,7 +305,7 @@ void RackWidget::fromJson(json_t *rootJ) { | |||
} | |||
void RackWidget::pastePresetClipboardAction() { | |||
const char *moduleJson = glfwGetClipboardString(app()->window->win); | |||
const char *moduleJson = glfwGetClipboardString(APP->window->win); | |||
if (!moduleJson) { | |||
WARN("Could not get text from clipboard."); | |||
return; | |||
@@ -320,7 +321,7 @@ void RackWidget::pastePresetClipboardAction() { | |||
// history::ModuleAdd | |||
history::ModuleAdd *h = new history::ModuleAdd; | |||
h->setModule(mw); | |||
app()->history->push(h); | |||
APP->history->push(h); | |||
} | |||
else { | |||
WARN("JSON parsing error at %s %d:%d %s", error.source, error.line, error.column, error.text); | |||
@@ -334,7 +335,7 @@ void RackWidget::addModule(ModuleWidget *m) { | |||
if (m->module) { | |||
// Add module to Engine | |||
app()->engine->addModule(m->module); | |||
APP->engine->addModule(m->module); | |||
} | |||
} | |||
@@ -352,7 +353,7 @@ void RackWidget::removeModule(ModuleWidget *m) { | |||
if (m->module) { | |||
// Remove module from Engine | |||
app()->engine->removeModule(m->module); | |||
APP->engine->removeModule(m->module); | |||
} | |||
// Remove module from ModuleContainer | |||
@@ -365,7 +366,7 @@ bool RackWidget::requestModuleBox(ModuleWidget *m, math::Rect requestedBox) { | |||
return false; | |||
// Check intersection with other modules | |||
for (Widget *m2 : moduleContainer->children) { | |||
for (widget::Widget *m2 : moduleContainer->children) { | |||
// Don't intersect with self | |||
if (m == m2) | |||
continue; | |||
@@ -407,7 +408,7 @@ bool RackWidget::requestModuleBoxNearest(ModuleWidget *m, math::Rect requestedBo | |||
} | |||
ModuleWidget *RackWidget::getModule(int moduleId) { | |||
for (Widget *w : moduleContainer->children) { | |||
for (widget::Widget *w : moduleContainer->children) { | |||
ModuleWidget *moduleWidget = dynamic_cast<ModuleWidget*>(w); | |||
assert(moduleWidget); | |||
if (moduleWidget->module->id == moduleId) | |||
@@ -421,13 +422,13 @@ bool RackWidget::isEmpty() { | |||
} | |||
void RackWidget::clearCables() { | |||
for (Widget *w : cableContainer->children) { | |||
for (widget::Widget *w : cableContainer->children) { | |||
CableWidget *cw = dynamic_cast<CableWidget*>(w); | |||
assert(cw); | |||
if (!cw->isComplete()) | |||
continue; | |||
app()->engine->removeCable(cw->cable); | |||
APP->engine->removeCable(cw->cable); | |||
} | |||
incompleteCable = NULL; | |||
cableContainer->clearChildren(); | |||
@@ -437,7 +438,7 @@ void RackWidget::clearCablesAction() { | |||
// Add CableRemove for every cable to a ComplexAction | |||
history::ComplexAction *complexAction = new history::ComplexAction; | |||
for (Widget *w : cableContainer->children) { | |||
for (widget::Widget *w : cableContainer->children) { | |||
CableWidget *cw = dynamic_cast<CableWidget*>(w); | |||
assert(cw); | |||
if (!cw->isComplete()) | |||
@@ -449,7 +450,7 @@ void RackWidget::clearCablesAction() { | |||
complexAction->push(h); | |||
} | |||
app()->history->push(complexAction); | |||
APP->history->push(complexAction); | |||
clearCables(); | |||
} | |||
@@ -469,13 +470,13 @@ void RackWidget::clearCablesOnPort(PortWidget *port) { | |||
void RackWidget::addCable(CableWidget *w) { | |||
assert(w->isComplete()); | |||
app()->engine->addCable(w->cable); | |||
APP->engine->addCable(w->cable); | |||
cableContainer->addChild(w); | |||
} | |||
void RackWidget::removeCable(CableWidget *w) { | |||
assert(w->isComplete()); | |||
app()->engine->removeCable(w->cable); | |||
APP->engine->removeCable(w->cable); | |||
cableContainer->removeChild(w); | |||
} | |||
@@ -512,7 +513,7 @@ CableWidget *RackWidget::getTopCable(PortWidget *port) { | |||
} | |||
CableWidget *RackWidget::getCable(int cableId) { | |||
for (Widget *w : cableContainer->children) { | |||
for (widget::Widget *w : cableContainer->children) { | |||
CableWidget *cw = dynamic_cast<CableWidget*>(w); | |||
assert(cw); | |||
if (cw->cable->id == cableId) | |||
@@ -524,7 +525,7 @@ CableWidget *RackWidget::getCable(int cableId) { | |||
std::list<CableWidget*> RackWidget::getCablesOnPort(PortWidget *port) { | |||
assert(port); | |||
std::list<CableWidget*> cables; | |||
for (Widget *w : cableContainer->children) { | |||
for (widget::Widget *w : cableContainer->children) { | |||
CableWidget *cw = dynamic_cast<CableWidget*>(w); | |||
assert(cw); | |||
if (cw->inputPort == port || cw->outputPort == port) { | |||
@@ -535,4 +536,5 @@ std::list<CableWidget*> RackWidget::getCablesOnPort(PortWidget *port) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -2,13 +2,14 @@ | |||
namespace rack { | |||
namespace app { | |||
SVGButton::SVGButton() { | |||
fb = new FramebufferWidget; | |||
fb = new widget::FramebufferWidget; | |||
addChild(fb); | |||
sw = new SVGWidget; | |||
sw = new widget::SVGWidget; | |||
fb->addChild(sw); | |||
} | |||
@@ -44,4 +45,5 @@ void SVGButton::onDragDrop(const event::DragDrop &e) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -2,20 +2,21 @@ | |||
namespace rack { | |||
namespace app { | |||
SVGKnob::SVGKnob() { | |||
fb = new FramebufferWidget; | |||
fb = new widget::FramebufferWidget; | |||
addChild(fb); | |||
shadow = new CircularShadow; | |||
fb->addChild(shadow); | |||
shadow->box.size = math::Vec(); | |||
tw = new TransformWidget; | |||
tw = new widget::TransformWidget; | |||
fb->addChild(tw); | |||
sw = new SVGWidget; | |||
sw = new widget::SVGWidget; | |||
tw->addChild(sw); | |||
} | |||
@@ -31,7 +32,7 @@ void SVGKnob::setSVG(std::shared_ptr<SVG> svg) { | |||
} | |||
void SVGKnob::onChange(const event::Change &e) { | |||
// Re-transform the TransformWidget | |||
// Re-transform the widget::TransformWidget | |||
if (paramQuantity) { | |||
float angle; | |||
if (paramQuantity->isBounded()) { | |||
@@ -53,4 +54,5 @@ void SVGKnob::onChange(const event::Change &e) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -2,9 +2,10 @@ | |||
namespace rack { | |||
namespace app { | |||
void PanelBorder::draw(const DrawContext &ctx) { | |||
void PanelBorder::draw(const widget::DrawContext &ctx) { | |||
NVGcolor borderColor = nvgRGBAf(0.5, 0.5, 0.5, 0.5); | |||
nvgBeginPath(ctx.vg); | |||
nvgRect(ctx.vg, 0.5, 0.5, box.size.x - 1.0, box.size.y - 1.0); | |||
@@ -15,15 +16,15 @@ void PanelBorder::draw(const DrawContext &ctx) { | |||
void SVGPanel::step() { | |||
if (math::isNear(app()->window->pixelRatio, 1.0)) { | |||
if (math::isNear(APP->window->pixelRatio, 1.0)) { | |||
// Small details draw poorly at low DPI, so oversample when drawing to the framebuffer | |||
oversample = 2.0; | |||
} | |||
FramebufferWidget::step(); | |||
widget::FramebufferWidget::step(); | |||
} | |||
void SVGPanel::setBackground(std::shared_ptr<SVG> svg) { | |||
SVGWidget *sw = new SVGWidget; | |||
widget::SVGWidget *sw = new widget::SVGWidget; | |||
sw->setSVG(svg); | |||
addChild(sw); | |||
@@ -36,4 +37,5 @@ void SVGPanel::setBackground(std::shared_ptr<SVG> svg) { | |||
} | |||
} // namespace app | |||
} // namespace rack |
@@ -2,10 +2,11 @@ | |||
namespace rack { | |||
namespace app { | |||
SVGPort::SVGPort() { | |||
fb = new FramebufferWidget; | |||
fb = new widget::FramebufferWidget; | |||
addChild(fb); | |||
shadow = new CircularShadow; | |||
@@ -14,7 +15,7 @@ SVGPort::SVGPort() { | |||
// In that case, just disable the shadow. | |||
shadow->box.size = math::Vec(); | |||
sw = new SVGWidget; | |||
sw = new widget::SVGWidget; | |||
fb->addChild(sw); | |||
} | |||
@@ -30,4 +31,5 @@ void SVGPort::setSVG(std::shared_ptr<SVG> svg) { | |||
} | |||
} // namespace app | |||
} // namespace rack |