Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a typo; Add a basic stylesheet name dump #50

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/component-demo/CustomStyleDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct CustomStyleDemo : public sst::jucegui::components::WindowPanel
}
}
std::vector<std::unique_ptr<sst::jucegui::components::HSlider>> knobs;
std::vector<std::unique_ptr<sst::jucegui::data::ContinunousModulatable>> sources;
std::vector<std::unique_ptr<sst::jucegui::data::ContinuousModulatable>> sources;
};

CustomStyleDemo()
Expand Down
2 changes: 1 addition & 1 deletion examples/component-demo/DraggableTextDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct DraggableTextDemo : public sst::jucegui::components::WindowPanel
}
}
std::vector<std::unique_ptr<sst::jucegui::components::DraggableTextEditableValue>> knobs;
std::vector<std::unique_ptr<sst::jucegui::data::ContinunousModulatable>> sources;
std::vector<std::unique_ptr<sst::jucegui::data::ContinuousModulatable>> sources;
};

DraggableTextDemo()
Expand Down
4 changes: 2 additions & 2 deletions examples/component-demo/ExampleUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ struct Solid : public juce::Component
bool isHover{false};
};

struct ConcreteCM : sst::jucegui::data::ContinunousModulatable
struct ConcreteCM : sst::jucegui::data::ContinuousModulatable
{
std::string label{"A Knob"};
std::string getLabel() const override { return label; }
float value{0};
float getValue() const override { return value; }
float getDefaultValue() const override { return (getMax()-getMin())/2.0; }
float getDefaultValue() const override { return (getMax() - getMin()) / 2.0; }
void setValueFromGUI(const float &f) override
{
value = f;
Expand Down
2 changes: 1 addition & 1 deletion examples/component-demo/HSliderDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct HSliderDemo : public sst::jucegui::components::WindowPanel
}
}
std::vector<std::unique_ptr<sst::jucegui::components::HSlider>> knobs;
std::vector<std::unique_ptr<sst::jucegui::data::ContinunousModulatable>> sources;
std::vector<std::unique_ptr<sst::jucegui::data::ContinuousModulatable>> sources;
};

HSliderDemo()
Expand Down
2 changes: 1 addition & 1 deletion examples/component-demo/KnobDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct KnobDemo : public sst::jucegui::components::WindowPanel
}
}
std::vector<std::unique_ptr<sst::jucegui::components::Knob>> knobs;
std::vector<std::unique_ptr<sst::jucegui::data::ContinunousModulatable>> sources;
std::vector<std::unique_ptr<sst::jucegui::data::ContinuousModulatable>> sources;
};

KnobDemo()
Expand Down
4 changes: 4 additions & 0 deletions examples/component-demo/SSTJuceGuiDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ struct SSTJuceGuiDemo : public juce::JUCEApplication
auto newt = new T();
newt->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet(
sst::jucegui::style::StyleSheet::LIGHT));

auto ss = sst::jucegui::style::StyleSheet::getBuiltInStyleSheet(
sst::jucegui::style::StyleSheet::LIGHT);
ss->dumpStyleSheetTo(std::cout);
newt->setSettings(std::make_shared<sst::jucegui::style::Settings>());
w->setContentOwned(newt, false);

Expand Down
2 changes: 1 addition & 1 deletion examples/component-demo/VSliderDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct VSliderDemo : public sst::jucegui::components::WindowPanel
}
}
std::vector<std::unique_ptr<sst::jucegui::components::VSlider>> knobs;
std::vector<std::unique_ptr<sst::jucegui::data::ContinunousModulatable>> sources;
std::vector<std::unique_ptr<sst::jucegui::data::ContinuousModulatable>> sources;
};

VSliderDemo()
Expand Down
10 changes: 5 additions & 5 deletions include/sst/jucegui/components/ComponentBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ template <typename T> struct Modulatable : public data::Continuous::DataListener
assert(false);
return nullptr;
}
data::ContinunousModulatable *continuousModulatable()
data::ContinuousModulatable *continuousModulatable()
{
if (std::holds_alternative<data::ContinunousModulatable *>(source))
if (std::holds_alternative<data::ContinuousModulatable *>(source))
{
return std::get<data::ContinunousModulatable *>(source);
return std::get<data::ContinuousModulatable *>(source);
}
return nullptr;
}
Expand All @@ -158,7 +158,7 @@ template <typename T> struct Modulatable : public data::Continuous::DataListener
{
if (continuous())
continuous()->removeGUIDataListener(this);
source = (data::ContinunousModulatable *)nullptr;
source = (data::ContinuousModulatable *)nullptr;
}

void dataChanged() override { asT()->repaint(); }
Expand All @@ -170,7 +170,7 @@ template <typename T> struct Modulatable : public data::Continuous::DataListener

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Modulatable<T>)

std::variant<data::Continuous *, data::ContinunousModulatable *> source{
std::variant<data::Continuous *, data::ContinuousModulatable *> source{
(data::Continuous *)nullptr};
bool isEditingMod{false};
ModulationDisplay modulationDisplay{NONE};
Expand Down
2 changes: 1 addition & 1 deletion include/sst/jucegui/data/Continuous.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct Continuous : public Labeled
std::unordered_set<DataListener *> guilisteners, modellisteners;
};

struct ContinunousModulatable : public Continuous
struct ContinuousModulatable : public Continuous
{
virtual float getModulationValuePM1() const = 0;
virtual void setModulationValuePM1(const float &f) = 0;
Expand Down
2 changes: 2 additions & 0 deletions include/sst/jucegui/style/StyleSheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ struct StyleSheet
friend struct StyleConsumer;
friend struct Declaration;

std::ostream &dumpStyleSheetTo(std::ostream &os);

private:
static void extendInheritanceMap(const StyleSheet::Class &from, const StyleSheet::Class &to);
static std::set<std::pair<std::string, std::string>> validPairs;
Expand Down
35 changes: 17 additions & 18 deletions src/sst/jucegui/components/KnobPainter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

namespace sst::jucegui::components
{
template<typename T, typename S>
void knobPainter(juce::Graphics &g, T* that, S *source)
template <typename T, typename S> void knobPainter(juce::Graphics &g, T *that, S *source)
{
constexpr bool supportsMod = std::is_base_of_v<data::ContinunousModulatable, S>;
constexpr bool supportsMod = std::is_base_of_v<data::ContinuousModulatable, S>;

if (!source)
{
Expand Down Expand Up @@ -51,7 +50,7 @@ void knobPainter(juce::Graphics &g, T* that, S *source)
float dAng = juce::MathConstants<float>::pi * (1 - dPath);
float start = dAng * (2 * v - 1); // 1 -> dAng; 0 -> -dAng so dAng * 2 * v - dAng
float end = -dAng;
switch(that->pathDrawMode)
switch (that->pathDrawMode)
{
case T::FOLLOW_BIPOLAR:
if (source->isBipolar())
Expand All @@ -73,19 +72,19 @@ void knobPainter(juce::Graphics &g, T* that, S *source)
start = dAng;
end = t;
}
break;
break;
case T::ALWAYS_FROM_DEFAULT:
{
auto v0 = v;
v = 2 * v - 1;
// split between dAng and -dAnd
float zero01 = (source->getDefaultValue() - source->getMin()) / (source->getMax() - source->getMin());
// 1 -> dAng; 0 -> -dAng again so
start = dAng * (2 * zero01 - 1);
end = dAng * v;
}
break;

{
auto v0 = v;
v = 2 * v - 1;
// split between dAng and -dAnd
float zero01 = (source->getDefaultValue() - source->getMin()) /
(source->getMax() - source->getMin());
// 1 -> dAng; 0 -> -dAng again so
start = dAng * (2 * zero01 - 1);
end = dAng * v;
}
break;
}
auto region = knobarea.reduced(r);
auto p = juce::Path();
Expand Down Expand Up @@ -118,7 +117,7 @@ void knobPainter(juce::Graphics &g, T* that, S *source)
auto region = knobarea.reduced(r);

auto cp = region.getCentre().toFloat();
auto rad = std::min(region.getWidth()/2, region.getHeight()/2);
auto rad = std::min(region.getWidth() / 2, region.getHeight() / 2);

return {(float)(cp.getX() + rad * sin(pt)), (float)(cp.getY() - rad * cos(pt))};
};
Expand Down Expand Up @@ -222,5 +221,5 @@ void knobPainter(juce::Graphics &g, T* that, S *source)
g.fillPath(pOut);
}
}
}
} // namespace sst::jucegui::components
#endif // CONDUIT_KNOBPAINTER_H
30 changes: 30 additions & 0 deletions src/sst/jucegui/style/StyleSheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,34 @@ void StyleSheet::initializeStyleSheets(std::function<void()> userClassInitialize

userClassInitializers();
}

std::ostream &StyleSheet::dumpStyleSheetTo(std::ostream &os)
{
os << "StyleSheet Dump"
<< "\n";

std::map<std::string, std::vector<std::string>> props;
for (const auto &[a, b] : validPairs)
{
props[a].push_back(b);
}
for (const auto &[a, b] : props)
{
os << "--- " << a << "\n";
for (const auto &p : b)
std::cout << " |-- " << p << "\n";
}
os << "\n";

for (const auto &[k, c] : inheritFromTo)
{
os << k << " : ";
for (const auto &p : c)
os << p << " ";
os << "\n";
}

os << std::flush;
return os;
}
} // namespace sst::jucegui::style
Loading