diff --git a/examples/component-demo/CustomStyleDemo.h b/examples/component-demo/CustomStyleDemo.h index 376c4fd..0ed8d7d 100644 --- a/examples/component-demo/CustomStyleDemo.h +++ b/examples/component-demo/CustomStyleDemo.h @@ -110,7 +110,7 @@ struct CustomStyleDemo : public sst::jucegui::components::WindowPanel } } std::vector> knobs; - std::vector> sources; + std::vector> sources; }; CustomStyleDemo() diff --git a/examples/component-demo/DraggableTextDemo.h b/examples/component-demo/DraggableTextDemo.h index a4ff573..89a25b9 100644 --- a/examples/component-demo/DraggableTextDemo.h +++ b/examples/component-demo/DraggableTextDemo.h @@ -68,7 +68,7 @@ struct DraggableTextDemo : public sst::jucegui::components::WindowPanel } } std::vector> knobs; - std::vector> sources; + std::vector> sources; }; DraggableTextDemo() diff --git a/examples/component-demo/ExampleUtils.h b/examples/component-demo/ExampleUtils.h index 1f084d9..359db5c 100644 --- a/examples/component-demo/ExampleUtils.h +++ b/examples/component-demo/ExampleUtils.h @@ -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; diff --git a/examples/component-demo/HSliderDemo.h b/examples/component-demo/HSliderDemo.h index 0786ed8..8a1cc56 100644 --- a/examples/component-demo/HSliderDemo.h +++ b/examples/component-demo/HSliderDemo.h @@ -96,7 +96,7 @@ struct HSliderDemo : public sst::jucegui::components::WindowPanel } } std::vector> knobs; - std::vector> sources; + std::vector> sources; }; HSliderDemo() diff --git a/examples/component-demo/KnobDemo.h b/examples/component-demo/KnobDemo.h index ed3e9cc..286b9d4 100644 --- a/examples/component-demo/KnobDemo.h +++ b/examples/component-demo/KnobDemo.h @@ -91,7 +91,7 @@ struct KnobDemo : public sst::jucegui::components::WindowPanel } } std::vector> knobs; - std::vector> sources; + std::vector> sources; }; KnobDemo() diff --git a/examples/component-demo/SSTJuceGuiDemo.cpp b/examples/component-demo/SSTJuceGuiDemo.cpp index c9e3d31..2109ec7 100644 --- a/examples/component-demo/SSTJuceGuiDemo.cpp +++ b/examples/component-demo/SSTJuceGuiDemo.cpp @@ -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()); w->setContentOwned(newt, false); diff --git a/examples/component-demo/VSliderDemo.h b/examples/component-demo/VSliderDemo.h index dc028a1..24f06d3 100644 --- a/examples/component-demo/VSliderDemo.h +++ b/examples/component-demo/VSliderDemo.h @@ -90,7 +90,7 @@ struct VSliderDemo : public sst::jucegui::components::WindowPanel } } std::vector> knobs; - std::vector> sources; + std::vector> sources; }; VSliderDemo() diff --git a/include/sst/jucegui/components/ComponentBase.h b/include/sst/jucegui/components/ComponentBase.h index 6e32ba2..a699734 100644 --- a/include/sst/jucegui/components/ComponentBase.h +++ b/include/sst/jucegui/components/ComponentBase.h @@ -135,11 +135,11 @@ template struct Modulatable : public data::Continuous::DataListener assert(false); return nullptr; } - data::ContinunousModulatable *continuousModulatable() + data::ContinuousModulatable *continuousModulatable() { - if (std::holds_alternative(source)) + if (std::holds_alternative(source)) { - return std::get(source); + return std::get(source); } return nullptr; } @@ -158,7 +158,7 @@ template struct Modulatable : public data::Continuous::DataListener { if (continuous()) continuous()->removeGUIDataListener(this); - source = (data::ContinunousModulatable *)nullptr; + source = (data::ContinuousModulatable *)nullptr; } void dataChanged() override { asT()->repaint(); } @@ -170,7 +170,7 @@ template struct Modulatable : public data::Continuous::DataListener JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Modulatable) - std::variant source{ + std::variant source{ (data::Continuous *)nullptr}; bool isEditingMod{false}; ModulationDisplay modulationDisplay{NONE}; diff --git a/include/sst/jucegui/data/Continuous.h b/include/sst/jucegui/data/Continuous.h index 56f1e98..9457158 100644 --- a/include/sst/jucegui/data/Continuous.h +++ b/include/sst/jucegui/data/Continuous.h @@ -91,7 +91,7 @@ struct Continuous : public Labeled std::unordered_set guilisteners, modellisteners; }; -struct ContinunousModulatable : public Continuous +struct ContinuousModulatable : public Continuous { virtual float getModulationValuePM1() const = 0; virtual void setModulationValuePM1(const float &f) = 0; diff --git a/include/sst/jucegui/style/StyleSheet.h b/include/sst/jucegui/style/StyleSheet.h index 00ddfda..e7a10e0 100644 --- a/include/sst/jucegui/style/StyleSheet.h +++ b/include/sst/jucegui/style/StyleSheet.h @@ -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> validPairs; diff --git a/src/sst/jucegui/components/KnobPainter.hxx b/src/sst/jucegui/components/KnobPainter.hxx index 813b7f7..be8cfcd 100644 --- a/src/sst/jucegui/components/KnobPainter.hxx +++ b/src/sst/jucegui/components/KnobPainter.hxx @@ -10,10 +10,9 @@ namespace sst::jucegui::components { -template -void knobPainter(juce::Graphics &g, T* that, S *source) +template void knobPainter(juce::Graphics &g, T *that, S *source) { - constexpr bool supportsMod = std::is_base_of_v; + constexpr bool supportsMod = std::is_base_of_v; if (!source) { @@ -51,7 +50,7 @@ void knobPainter(juce::Graphics &g, T* that, S *source) float dAng = juce::MathConstants::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()) @@ -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(); @@ -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))}; }; @@ -222,5 +221,5 @@ void knobPainter(juce::Graphics &g, T* that, S *source) g.fillPath(pOut); } } -} +} // namespace sst::jucegui::components #endif // CONDUIT_KNOBPAINTER_H diff --git a/src/sst/jucegui/style/StyleSheet.cpp b/src/sst/jucegui/style/StyleSheet.cpp index 370dfd7..d50e1da 100644 --- a/src/sst/jucegui/style/StyleSheet.cpp +++ b/src/sst/jucegui/style/StyleSheet.cpp @@ -529,4 +529,34 @@ void StyleSheet::initializeStyleSheets(std::function userClassInitialize userClassInitializers(); } + +std::ostream &StyleSheet::dumpStyleSheetTo(std::ostream &os) +{ + os << "StyleSheet Dump" + << "\n"; + + std::map> 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