Browse Source

Minor clean-ups.

tags/2021-05-28
jules 10 years ago
parent
commit
60f2b0a233
3 changed files with 27 additions and 28 deletions
  1. +24
    -24
      modules/juce_gui_basics/layout/juce_ScrollBar.cpp
  2. +1
    -2
      modules/juce_gui_basics/layout/juce_ScrollBar.h
  3. +2
    -2
      modules/juce_gui_basics/mouse/juce_TooltipClient.h

+ 24
- 24
modules/juce_gui_basics/layout/juce_ScrollBar.cpp View File

@@ -25,8 +25,8 @@
class ScrollBar::ScrollbarButton : public Button class ScrollBar::ScrollbarButton : public Button
{ {
public: public:
ScrollbarButton (const int direction_, ScrollBar& owner_)
: Button (String::empty), direction (direction_), owner (owner_)
ScrollbarButton (int direc, ScrollBar& s)
: Button (String()), direction (direc), owner (s)
{ {
setWantsKeyboardFocus (false); setWantsKeyboardFocus (false);
} }
@@ -52,7 +52,7 @@ private:
//============================================================================== //==============================================================================
ScrollBar::ScrollBar (const bool vertical_)
ScrollBar::ScrollBar (const bool shouldBeVertical)
: totalRange (0.0, 1.0), : totalRange (0.0, 1.0),
visibleRange (0.0, 0.1), visibleRange (0.0, 0.1),
singleStepSize (0.1), singleStepSize (0.1),
@@ -60,16 +60,13 @@ ScrollBar::ScrollBar (const bool vertical_)
thumbAreaSize (0), thumbAreaSize (0),
thumbStart (0), thumbStart (0),
thumbSize (0), thumbSize (0),
minimumScrollBarThumbSize (0),
initialDelayInMillisecs (100), initialDelayInMillisecs (100),
repeatDelayInMillisecs (50), repeatDelayInMillisecs (50),
minimumDelayInMillisecs (10), minimumDelayInMillisecs (10),
vertical (vertical_),
vertical (shouldBeVertical),
isDraggingThumb (false), isDraggingThumb (false),
autohides (true) autohides (true)
{ {
minimumScrollBarThumbSize = getLookAndFeel().getMinimumScrollbarThumbSize (*this);
setRepaintsOnMouseActivity (true); setRepaintsOnMouseActivity (true);
setFocusContainer (true); setFocusContainer (true);
} }
@@ -97,8 +94,7 @@ void ScrollBar::setRangeLimits (const double newMinimum, const double newMaximum
setRangeLimits (Range<double> (newMinimum, newMaximum), notification); setRangeLimits (Range<double> (newMinimum, newMaximum), notification);
} }
bool ScrollBar::setCurrentRange (Range<double> newRange,
const NotificationType notification)
bool ScrollBar::setCurrentRange (Range<double> newRange, const NotificationType notification)
{ {
const Range<double> constrainedRange (totalRange.constrainRange (newRange)); const Range<double> constrainedRange (totalRange.constrainRange (newRange));
@@ -155,18 +151,18 @@ bool ScrollBar::scrollToBottom (NotificationType notification)
return setCurrentRange (visibleRange.movedToEndAt (getMaximumRangeLimit()), notification); return setCurrentRange (visibleRange.movedToEndAt (getMaximumRangeLimit()), notification);
} }
void ScrollBar::setButtonRepeatSpeed (const int initialDelayInMillisecs_,
const int repeatDelayInMillisecs_,
const int minimumDelayInMillisecs_)
void ScrollBar::setButtonRepeatSpeed (const int newInitialDelay,
const int newRepeatDelay,
const int newMinimumDelay)
{ {
initialDelayInMillisecs = initialDelayInMillisecs_;
repeatDelayInMillisecs = repeatDelayInMillisecs_;
minimumDelayInMillisecs = minimumDelayInMillisecs_;
initialDelayInMillisecs = newInitialDelay;
repeatDelayInMillisecs = newRepeatDelay;
minimumDelayInMillisecs = newMinimumDelay;
if (upButton != nullptr) if (upButton != nullptr)
{ {
upButton ->setRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs);
downButton->setRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs);
upButton ->setRepeatSpeed (newInitialDelay, newRepeatDelay, newMinimumDelay);
downButton->setRepeatSpeed (newInitialDelay, newRepeatDelay, newMinimumDelay);
} }
} }
@@ -190,6 +186,8 @@ void ScrollBar::handleAsyncUpdate()
//============================================================================== //==============================================================================
void ScrollBar::updateThumbPosition() void ScrollBar::updateThumbPosition()
{ {
const int minimumScrollBarThumbSize = getLookAndFeel().getMinimumScrollbarThumbSize (*this);
int newThumbSize = roundToInt (totalRange.getLength() > 0 ? (visibleRange.getLength() * thumbAreaSize) / totalRange.getLength() int newThumbSize = roundToInt (totalRange.getLength() > 0 ? (visibleRange.getLength() * thumbAreaSize) / totalRange.getLength()
: thumbAreaSize); : thumbAreaSize);
@@ -205,7 +203,8 @@ void ScrollBar::updateThumbPosition()
newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize)) newThumbStart += roundToInt (((visibleRange.getStart() - totalRange.getStart()) * (thumbAreaSize - newThumbSize))
/ (totalRange.getLength() - visibleRange.getLength())); / (totalRange.getLength() - visibleRange.getLength()));
setVisible ((! autohides) || (totalRange.getLength() > visibleRange.getLength() && visibleRange.getLength() > 0.0));
setVisible ((! autohides) || (totalRange.getLength() > visibleRange.getLength()
&& visibleRange.getLength() > 0.0));
if (thumbStart != newThumbStart || thumbSize != newThumbSize) if (thumbStart != newThumbStart || thumbSize != newThumbSize)
{ {
@@ -281,7 +280,6 @@ void ScrollBar::resized()
const int length = vertical ? getHeight() : getWidth(); const int length = vertical ? getHeight() : getWidth();
LookAndFeel& lf = getLookAndFeel(); LookAndFeel& lf = getLookAndFeel();
minimumScrollBarThumbSize = lf.getMinimumScrollbarThumbSize (*this);
const bool buttonsVisible = lf.areScrollbarButtonsVisible(); const bool buttonsVisible = lf.areScrollbarButtonsVisible();
int buttonSize = 0; int buttonSize = 0;
@@ -311,20 +309,22 @@ void ScrollBar::resized()
else else
{ {
thumbAreaStart = buttonSize; thumbAreaStart = buttonSize;
thumbAreaSize = length - (buttonSize << 1);
thumbAreaSize = length - 2 * buttonSize;
} }
if (upButton != nullptr) if (upButton != nullptr)
{ {
Rectangle<int> r (getLocalBounds());
if (vertical) if (vertical)
{ {
upButton->setBounds (0, 0, getWidth(), buttonSize);
downButton->setBounds (0, thumbAreaStart + thumbAreaSize, getWidth(), buttonSize);
upButton->setBounds (r.removeFromTop (buttonSize));
downButton->setBounds (r.removeFromBottom (buttonSize));
} }
else else
{ {
upButton->setBounds (0, 0, buttonSize, getHeight());
downButton->setBounds (thumbAreaStart + thumbAreaSize, 0, buttonSize, getHeight());
upButton->setBounds (r.removeFromLeft (buttonSize));
downButton->setBounds (r.removeFromRight (buttonSize));
} }
} }


+ 1
- 2
modules/juce_gui_basics/layout/juce_ScrollBar.h View File

@@ -381,10 +381,9 @@ public:
private: private:
//============================================================================== //==============================================================================
Range <double> totalRange, visibleRange;
Range<double> totalRange, visibleRange;
double singleStepSize, dragStartRange; double singleStepSize, dragStartRange;
int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize; int thumbAreaStart, thumbAreaSize, thumbStart, thumbSize;
int minimumScrollBarThumbSize;
int dragStartMousePos, lastMousePos; int dragStartMousePos, lastMousePos;
int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs; int initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs;
bool vertical, isDraggingThumb, autohides; bool vertical, isDraggingThumb, autohides;


+ 2
- 2
modules/juce_gui_basics/mouse/juce_TooltipClient.h View File

@@ -65,14 +65,14 @@ class JUCE_API SettableTooltipClient : public TooltipClient
public: public:
//============================================================================== //==============================================================================
/** Destructor. */ /** Destructor. */
virtual ~SettableTooltipClient() {}
~SettableTooltipClient() {}
//============================================================================== //==============================================================================
/** Assigns a new tooltip to this object. */ /** Assigns a new tooltip to this object. */
virtual void setTooltip (const String& newTooltip) { tooltipString = newTooltip; } virtual void setTooltip (const String& newTooltip) { tooltipString = newTooltip; }
/** Returns the tooltip assigned to this object. */ /** Returns the tooltip assigned to this object. */
virtual String getTooltip() { return tooltipString; }
String getTooltip() override { return tooltipString; }
protected: protected:
SettableTooltipClient() {} SettableTooltipClient() {}


Loading…
Cancel
Save