uiObjectStyle.h (2386B)
1 #pragma once 2 3 #include "juce_gui_basics/juce_gui_basics.h" 4 5 #include <optional> 6 7 namespace genericUI 8 { 9 class Editor; 10 class UiObject; 11 12 class UiObjectStyle : public juce::LookAndFeel_V4 13 { 14 public: 15 UiObjectStyle(Editor& _editor); 16 17 void setTileSize(int _w, int _h); 18 void setDrawable(juce::Drawable* _drawable); 19 void setTextHeight(int _height); 20 21 virtual void apply(Editor& _editor, const UiObject& _object); 22 23 const auto& getColor() const { return m_color; } 24 const auto& getSelectedItemBackgroundColor() const { return m_selectedItemBgColor; } 25 const auto& getAlign() const { return m_align; } 26 27 std::optional<juce::Font> getFont() const; 28 29 bool getAntialiasing() const { return m_antialiasing; } 30 31 static bool parseColor(juce::Colour& _color, const std::string& _colorString); 32 33 void drawLabel(juce::Graphics&, juce::Label&) override; 34 void drawButtonText(juce::Graphics&, juce::TextButton&, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override; 35 36 protected: 37 juce::Font getComboBoxFont(juce::ComboBox&) override; 38 juce::Font getLabelFont(juce::Label&) override; 39 juce::Font getPopupMenuFont() override; 40 juce::Font getTextButtonFont(juce::TextButton&, int buttonHeight) override; 41 bool shouldPopupMenuScaleWithTargetComponent (const juce::PopupMenu::Options&) override; 42 juce::PopupMenu::Options getOptionsForComboBoxPopupMenu(juce::ComboBox&, juce::Label&) override; 43 44 void applyFontProperties(juce::Font& _font) const; 45 46 static void applyColorIfNotZero(juce::Component& _target, int _id, const juce::Colour& _col); 47 48 Editor& m_editor; 49 50 int m_tileSizeX = 0; 51 int m_tileSizeY = 0; 52 53 juce::Drawable* m_drawable = nullptr; 54 55 std::string m_fontFile; 56 std::string m_fontName; 57 int m_textHeight = 0; 58 std::string m_text; 59 bool m_antialiasing = true; 60 61 juce::Colour m_color = juce::Colour(0xffffffff); 62 juce::Colour m_bgColor = juce::Colour(0); 63 juce::Colour m_linesColor = juce::Colour(0); 64 juce::Colour m_selectedItemBgColor = juce::Colour(0); 65 juce::Colour m_dragAndDropIndicatorColor = juce::Colour(0); 66 juce::Colour m_outlineColor = juce::Colour(0); 67 68 juce::Justification m_align = 0; 69 70 bool m_bold = false; 71 bool m_italic = false; 72 int m_offsetL = 0; 73 int m_offsetT = 0; 74 int m_offsetR = 0; 75 int m_offsetB = 0; 76 77 std::string m_url; 78 79 juce::Rectangle<int> m_hitAreaOffset; // only supported for buttons atm 80 }; 81 }