Browse Source

Added methods LookAndFeel::getSliderPopupFont and getSliderPopupPlacement.

LookAndFeel::drawFileBrowserRow improvement.
tags/2021-05-28
jules 12 years ago
parent
commit
8e5268a1f8
3 changed files with 33 additions and 12 deletions
  1. +20
    -3
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp
  2. +3
    -0
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h
  3. +10
    -9
      modules/juce_gui_basics/widgets/juce_Slider.cpp

+ 20
- 3
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.cpp View File

@@ -1602,6 +1602,19 @@ ImageEffectFilter* LookAndFeel::getSliderEffect()
return nullptr; return nullptr;
} }
Font LookAndFeel::getSliderPopupFont()
{
return Font (15.0f, Font::bold);
}
int LookAndFeel::getSliderPopupPlacement()
{
return BubbleComponent::above
| BubbleComponent::below
| BubbleComponent::left
| BubbleComponent::right;
}
//============================================================================== //==============================================================================
void LookAndFeel::getTooltipSize (const String& tipText, int& width, int& height) void LookAndFeel::getTooltipSize (const String& tipText, int& width, int& height)
{ {
@@ -2510,10 +2523,13 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height,
const bool isDirectory, const bool isDirectory,
const bool isItemSelected, const bool isItemSelected,
const int /*itemIndex*/, const int /*itemIndex*/,
DirectoryContentsDisplayComponent&)
DirectoryContentsDisplayComponent& dcc)
{ {
Component* const fileListComp = dynamic_cast<Component*> (&dcc);
if (isItemSelected) if (isItemSelected)
g.fillAll (findColour (DirectoryContentsDisplayComponent::highlightColourId));
g.fillAll (fileListComp != nullptr ? fileListComp->findColour (DirectoryContentsDisplayComponent::highlightColourId)
: findColour (DirectoryContentsDisplayComponent::highlightColourId));
const int x = 32; const int x = 32;
g.setColour (Colours::black); g.setColour (Colours::black);
@@ -2532,7 +2548,8 @@ void LookAndFeel::drawFileBrowserRow (Graphics& g, int width, int height,
RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f); RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize, 1.0f);
} }
g.setColour (findColour (DirectoryContentsDisplayComponent::textColourId));
g.setColour (fileListComp != nullptr ? fileListComp->findColour (DirectoryContentsDisplayComponent::textColourId)
: findColour (DirectoryContentsDisplayComponent::textColourId));
g.setFont (height * 0.7f); g.setFont (height * 0.7f);
if (width > 450 && ! isDirectory) if (width > 450 && ! isDirectory)


+ 3
- 0
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h View File

@@ -450,6 +450,9 @@ public:
virtual ImageEffectFilter* getSliderEffect(); virtual ImageEffectFilter* getSliderEffect();
virtual Font getSliderPopupFont();
virtual int getSliderPopupPlacement();
//============================================================================== //==============================================================================
virtual void getTooltipSize (const String& tipText, int& width, int& height); virtual void getTooltipSize (const String& tipText, int& width, int& height);


+ 10
- 9
modules/juce_gui_basics/widgets/juce_Slider.cpp View File

@@ -28,9 +28,9 @@ class Slider::Pimpl : public AsyncUpdater,
public ValueListener public ValueListener
{ {
public: public:
Pimpl (Slider& owner_, SliderStyle style_, TextEntryBoxPosition textBoxPosition)
: owner (owner_),
style (style_),
Pimpl (Slider& s, SliderStyle sliderStyle, TextEntryBoxPosition textBoxPosition)
: owner (s),
style (sliderStyle),
lastCurrentValue (0), lastValueMin (0), lastValueMax (0), lastCurrentValue (0), lastValueMin (0), lastValueMax (0),
minimum (0), maximum (10), interval (0), doubleClickReturnValue (0), minimum (0), maximum (10), interval (0), doubleClickReturnValue (0),
skewFactor (1.0), velocityModeSensitivity (1.0), skewFactor (1.0), velocityModeSensitivity (1.0),
@@ -1256,11 +1256,12 @@ public:
public Timer public Timer
{ {
public: public:
PopupDisplayComponent (Slider& owner_)
: owner (owner_),
font (15.0f, Font::bold)
PopupDisplayComponent (Slider& s)
: owner (s),
font (s.getLookAndFeel().getSliderPopupFont())
{ {
setAlwaysOnTop (true); setAlwaysOnTop (true);
setAllowedPlacement (owner.getLookAndFeel().getSliderPopupPlacement());
} }
void paintContent (Graphics& g, int w, int h) void paintContent (Graphics& g, int w, int h)
@@ -1470,9 +1471,9 @@ void Slider::setDoubleClickReturnValue (bool isDoubleClickEnabled, double value
pimpl->doubleClickReturnValue = valueToSetOnDoubleClick; pimpl->doubleClickReturnValue = valueToSetOnDoubleClick;
} }
double Slider::getDoubleClickReturnValue (bool& isEnabled_) const
double Slider::getDoubleClickReturnValue (bool& isEnabledResult) const
{ {
isEnabled_ = pimpl->doubleClickToValue;
isEnabledResult = pimpl->doubleClickToValue;
return pimpl->doubleClickReturnValue; return pimpl->doubleClickReturnValue;
} }
@@ -1546,7 +1547,7 @@ void Slider::stoppedDragging() {}
void Slider::valueChanged() {} void Slider::valueChanged() {}
//============================================================================== //==============================================================================
void Slider::setPopupMenuEnabled (const bool menuEnabled_) { pimpl->menuEnabled = menuEnabled_; }
void Slider::setPopupMenuEnabled (const bool menuEnabled) { pimpl->menuEnabled = menuEnabled; }
void Slider::setScrollWheelEnabled (const bool enabled) { pimpl->scrollWheelEnabled = enabled; } void Slider::setScrollWheelEnabled (const bool enabled) { pimpl->scrollWheelEnabled = enabled; }
bool Slider::isHorizontal() const noexcept { return pimpl->isHorizontal(); } bool Slider::isHorizontal() const noexcept { return pimpl->isHorizontal(); }


Loading…
Cancel
Save