Skip to content

Commit

Permalink
glow in the dark
Browse files Browse the repository at this point in the history
  • Loading branch information
kockie69 committed Oct 18, 2021
1 parent 47cfb6a commit 0d6583a
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 67 deletions.
10 changes: 6 additions & 4 deletions src/BootyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ struct RangeChoice : ChoiceButton
}
}

void draw(const DrawArgs& args) override {
nvgGlobalTint(args.vg, color::WHITE);
ChoiceButton::draw(args);
}
void drawLayer(const DrawArgs& args,int layer) override {
if (layer == 1) {
ChoiceButton::draw(args);
}
Widget::drawLayer(args,layer);
}
};

////////////////////
Expand Down
8 changes: 5 additions & 3 deletions src/MultiVUMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class MultiVUMeter : public app::LightWidget {
MultiVUMeter(int* stereo, int* labelMode, int* channel) : isStereo_(stereo), labelMode_(labelMode), channel_(channel) {
box.size = Vec(125, 75);
}
void draw(const DrawArgs& args) override;
void drawLayer(const DrawArgs& args, int layer) override;
float getFakeGain(int channel);
int getNumFakeChannels() {
return 8;
Expand All @@ -159,8 +159,8 @@ inline float MultiVUMeter::getFakeGain(int channel) {
return ret;
}

inline void MultiVUMeter::draw(const DrawArgs& args) {
nvgGlobalTint(args.vg, color::WHITE);
inline void MultiVUMeter::drawLayer(const DrawArgs& args, int layer) {
if (layer == 1) {
nvgBeginPath(args.vg);
nvgRect(args.vg, 0, 0, box.size.x, box.size.y);
nvgFillColor(args.vg, nvgRGB(0, 0, 0));
Expand Down Expand Up @@ -251,4 +251,6 @@ inline void MultiVUMeter::draw(const DrawArgs& args) {
nvgFillColor(args.vg, ltBlue);
nvgFill(args.vg);
}
}
Widget::drawLayer(args, layer);
}
12 changes: 7 additions & 5 deletions src/ctrl/PopupMenuParamWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PopupMenuParamWidget : public ::rack::app::ParamWidget {
void setValueToIndexFunction(ValueToIndexFunction);


void draw(const DrawArgs &arg) override;
void drawLayer(const DrawArgs &arg, int layer) override;
void onButton(const ::rack::event::Button &e) override;
void onChange(const ::rack::event::Change &e) override;
void onAction(const ::rack::event::Action &e) override;
Expand Down Expand Up @@ -100,10 +100,12 @@ inline void PopupMenuParamWidget::onChange(const ::rack::event::Change &e) {
}
}

inline void PopupMenuParamWidget::draw(const DrawArgs &args) {
nvgGlobalTint(args.vg, rack::color::WHITE);
BNDwidgetState state = BND_DEFAULT;
bndChoiceButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str());
inline void PopupMenuParamWidget::drawLayer(const DrawArgs &args, int layer) {
if (layer == 1) {
BNDwidgetState state = BND_DEFAULT;
bndChoiceButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str());
}
ParamWidget::drawLayer(args,layer);
}

inline void PopupMenuParamWidget::onButton(const ::rack::event::Button &e) {
Expand Down
14 changes: 8 additions & 6 deletions src/ctrl/SqToggleLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SqToggleLED : public ModuleLightWidget
void onDragHover(const event::DragHover &e) override;
void onDragEnter(const event::DragEnter &e) override;
void onDragLeave(const event::DragLeave &e) override;
void draw(const DrawArgs &args) override;
void drawLayer(const DrawArgs &args, int layer) override;


private:
Expand Down Expand Up @@ -74,12 +74,14 @@ inline int SqToggleLED::getSvgIndex()
}


inline void SqToggleLED::draw(const DrawArgs &args)
inline void SqToggleLED::drawLayer(const DrawArgs &args, int layer)
{
nvgGlobalTint(args.vg, color::WHITE);
int index = getSvgIndex();
auto svg = svgs[index];
svg->draw(args);
if (layer == 1) {
int index = getSvgIndex();
auto svg = svgs[index];
svg->draw(args);
}
ModuleLightWidget::drawLayer(args, layer);
}


Expand Down
10 changes: 7 additions & 3 deletions src/ctrl/TextDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class TextDisplay : public TextDisplayBase {

class StyledTextDisplay : public TextDisplay {
public:
void draw(const DrawArgs& args) override;
//void draw(const DrawArgs& args) override;
void drawLayer(const DrawArgs& args, int layer) override;
};

#if 0
Expand All @@ -76,8 +77,9 @@ void StyledTextDisplay::draw(const DrawArgs& args) {
}
#endif

void StyledTextDisplay::draw(const DrawArgs& args) {
nvgGlobalTint(args.vg, color::WHITE);
void StyledTextDisplay::drawLayer(const DrawArgs& args, int layer) {

if (layer == 1) {
nvgScissor(args.vg, RECT_ARGS(args.clipBox));

// Background
Expand Down Expand Up @@ -108,6 +110,8 @@ void StyledTextDisplay::draw(const DrawArgs& args) {


nvgResetScissor(args.vg);
}
widget::OpaqueWidget::drawLayer(args, layer);
}

class TextDisplaySamp : public StyledTextDisplay {
Expand Down
24 changes: 14 additions & 10 deletions src/ctrl/ToggleButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ class ToggleButton : public ::rack::app::SvgSwitch
return SqHelper::getValue(this);
}

void draw(const DrawArgs& args) override {
nvgGlobalTint(args.vg, rack::color::WHITE);
::rack::app::SvgSwitch::draw(args);
void drawLayer(const DrawArgs& args,int layer) override {
if (layer ==1) {
::rack::app::SvgSwitch::draw(args);
}
SvgSwitch::drawLayer(args,layer);
}
};

Expand Down Expand Up @@ -85,7 +87,7 @@ class ToggleButton : public ParamWidget
}
void onButton(const event::Button &e) override;
void draw(const DrawArgs &args) override;
void drawLayer(const DrawArgs &args, int layer) override;
void registerManager(std::shared_ptr<ToggleManager>);
void turnOff();
Expand Down Expand Up @@ -134,13 +136,15 @@ inline void ToggleButton::addSvg(const char* resourcePath)
this->box.size.y = std::max(this->box.size.y, svg->box.size.y);
}
inline void ToggleButton::draw(const DrawArgs &args)
inline void ToggleButton::drawLayer(const DrawArgs &args,int layer)
{
nvgGlobalTint(args.vg, color::WHITE);
const float _value = SqHelper::getValue(this);
int index = int(std::round(_value));
auto svg = svgs[index];
svg->draw(args);
if (layer == 1) {
const float _value = SqHelper::getValue(this);
int index = int(std::round(_value));
auto svg = svgs[index];
svg->draw(args);
}
ParamWidget::drawLayer(args,layer);
}
inline void ToggleButton::turnOff()
Expand Down
10 changes: 6 additions & 4 deletions src/ctrl/ToggleButtonV1.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SqSvgParamToggleButton : public ParamWidget
public:
SqSvgParamToggleButton();
void addFrame(std::shared_ptr<Svg> svg);
void draw(const DrawArgs &args) override;
void drawLayer(const DrawArgs &args, int later) override;
void onAdd(const event::Add&) override;

void onDragStart(const event::DragStart &e) override;
Expand Down Expand Up @@ -163,10 +163,12 @@ inline float SqSvgParamToggleButton::getValue()
return button->getValue();
}

inline void SqSvgParamToggleButton::draw(const DrawArgs &args)
inline void SqSvgParamToggleButton::drawLayer(const DrawArgs &args, int layer)
{
nvgGlobalTint(args.vg, color::WHITE);
button->draw(args);
if (layer == 1) {
button->draw(args);
}
ParamWidget::drawLayer(args,layer);
}

void SqSvgParamToggleButton::onButton(const event::Button &e)
Expand Down
11 changes: 6 additions & 5 deletions src/ctrl/WaveformSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class WaveformSwitch : public ::rack::ParamWidget {
WaveformSwitch();
void step() override;
void onButton(const event::Button& e) override;
void draw(const DrawArgs& args) override;
void drawLayer(const DrawArgs& args, int layer) override;
private:
FramebufferWidget* fw = nullptr;

Expand Down Expand Up @@ -82,10 +82,11 @@ inline void WaveformSwitch::onButton(const event::Button& e) {
}
}

void WaveformSwitch::draw(const DrawArgs& args) {
nvgGlobalTint(args.vg, color::WHITE);
::rack::ParamWidget::draw(args);
}
void WaveformSwitch::drawLayer(const DrawArgs& args,int layer) {
if (layer ==1)
::rack::ParamWidget::draw(args);
ParamWidget::drawLayer(args,layer);
}

WaveCell* WaveformSwitch::getCell(int index) {
return cells[index];
Expand Down
16 changes: 9 additions & 7 deletions src/seq/AboveNoteGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,16 @@ void AboveNoteGrid::updateTimeLabels() {
}
}

void AboveNoteGrid::draw(const DrawArgs& args) {
void AboveNoteGrid::drawLayer(const DrawArgs& args, int layer) {
NVGcontext* vg = args.vg;
nvgGlobalTint(args.vg, color::WHITE);
if (layer == 1) {

if (!this->sequencer) {
return;
}
if (!this->sequencer) {
return;
}

filledRect(vg, UIPrefs::NOTE_EDIT_BACKGROUND, 0, 0, box.size.x, box.size.y);
OpaqueWidget::draw(args);
filledRect(vg, UIPrefs::NOTE_EDIT_BACKGROUND, 0, 0, box.size.x, box.size.y);
OpaqueWidget::draw(args);
}
OpaqueWidget::drawLayer(args,layer);
}
2 changes: 1 addition & 1 deletion src/seq/AboveNoteGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct AboveNoteGrid : OpaqueWidget {
void setSequencer(MidiSequencerPtr seq);
void songUpdated();

void draw(const DrawArgs& args) override;
void drawLayer(const DrawArgs& args, int layer) override;
void step() override;

private:
Expand Down
30 changes: 16 additions & 14 deletions src/seq/NoteDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,27 @@ void NoteDisplay::drawCursor(NVGcontext *vg) {
}
}

void NoteDisplay::draw(const Widget::DrawArgs &args) {
void NoteDisplay::drawLayer(const Widget::DrawArgs &args, int layer) {

NVGcontext *vg = args.vg;
nvgGlobalTint(args.vg, color::WHITE);
if (layer == 1) {

if (!this->sequencer) {
return;
}
if (!this->sequencer) {
return;
}

// let's clip everything to our window
nvgScissor(vg, 0, 0, this->box.size.x, this->box.size.y);
drawBackground(vg);
drawGrid(vg);
drawNotes(vg);
// let's clip everything to our window
nvgScissor(vg, 0, 0, this->box.size.x, this->box.size.y);
drawBackground(vg);
drawGrid(vg);
drawNotes(vg);

// if we are dragging, will have something to draw
mouseManager->draw(vg);
drawCursor(vg);
OpaqueWidget::draw(args);
// if we are dragging, will have something to draw
mouseManager->draw(vg);
drawCursor(vg);
OpaqueWidget::draw(args);
}
OpaqueWidget::drawLayer(args,layer);
}

void NoteDisplay::drawBackground(NVGcontext *vg) {
Expand Down
2 changes: 1 addition & 1 deletion src/seq/NoteDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NoteDisplay : public OpaqueWidget

void onSelect(const event::Select &e) override;
void onDeselect(const event::Deselect &e) override;
void draw(const DrawArgs &args) override;
void drawLayer(const DrawArgs &args, int layer) override;
void onDoubleClick(const event::DoubleClick &e) override;
void onButton(const event::Button &e) override;
void onHoverKey(const event::HoverKey &e) override;
Expand Down
8 changes: 5 additions & 3 deletions src/seq/S4Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ void S4Button::onDragHover(const rack::event::DragHover& e) {
sq::consumeEvent(&e, this);
}

void S4Button::draw(const DrawArgs& args) {
nvgGlobalTint(args.vg, color::WHITE);
::rack::app::ParamWidget::draw(args);
void S4Button::drawLayer(const DrawArgs& args, int layer) {
if (layer == 1) {
::rack::app::ParamWidget::draw(args);
}
ParamWidget::drawLayer(args,layer);
}

void S4Button::onButton(const rack::event::Button& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/seq/S4Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class S4Button : public ::rack::app::ParamWidget {
bool isSelected() const {
return _isSelected;
}
void draw(const DrawArgs& args) override;
void drawLayer(const DrawArgs& args, int layer) override;

void step() override;

Expand Down

0 comments on commit 0d6583a

Please sign in to comment.