Skip to content

Commit

Permalink
Implemented Switch.hh struct (#131)
Browse files Browse the repository at this point in the history
* Implemented Switch.hh struct

* Made Improvements to switch.hh

* make constructor api match knob

* typo?

---------

Co-authored-by: Edward Wang <edawordwang@gmail.com>
  • Loading branch information
richardsha19 and wang-edward authored Dec 25, 2024
1 parent 72db56e commit 9a985b2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions include/component/switch.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once
#include "core/util.hh"
#include "core/parameter.hh"

// instead of using cv.hh, we directly use juce::CachedValue<bool>

namespace box
{

struct Switch
{
juce::CachedValue<bool> &value_;
uint8_t x_, y_;
Color color_;
std::string name_;

Switch(juce::CachedValue<bool> &value, uint8_t x, uint8_t y, Color color, std::string name)
: value_{value}, x_{x}, y_{y}, color_{color}, name_{name}
{}

virtual void Render(Interface &interface)
{
Color text_color = value_ ? color_ : WHITE;
const int font_size = 10;
int width = MeasureText(name_.c_str(), font_size);
DrawText(name_.c_str(), x - (width / 2), y + 20, font_size, text_color);
}

virtual void HandleEvent(const Event& event)
{

}
};

} // namespace box

0 comments on commit 9a985b2

Please sign in to comment.