- Library code update
- project update (added Eigen) git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@94 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -125,11 +125,12 @@ void Button::setTooltip (const String& newTooltip)
|
||||
generateTooltip = false;
|
||||
}
|
||||
|
||||
String Button::getTooltip()
|
||||
void Button::updateAutomaticTooltip (const ApplicationCommandInfo& info)
|
||||
{
|
||||
if (generateTooltip && commandManagerToUse != nullptr && commandID != 0)
|
||||
if (generateTooltip && commandManagerToUse != nullptr)
|
||||
{
|
||||
String tt (commandManagerToUse->getDescriptionOfCommand (commandID));
|
||||
String tt (info.description.isNotEmpty() ? info.description
|
||||
: info.shortName);
|
||||
|
||||
Array<KeyPress> keyPresses (commandManagerToUse->getKeyMappings()->getKeyPressesAssignedToCommand (commandID));
|
||||
|
||||
@@ -145,10 +146,8 @@ String Button::getTooltip()
|
||||
tt << key << ']';
|
||||
}
|
||||
|
||||
return tt;
|
||||
SettableTooltipClient::setTooltip (tt);
|
||||
}
|
||||
|
||||
return SettableTooltipClient::getTooltip();
|
||||
}
|
||||
|
||||
void Button::setConnectedEdges (const int newFlags)
|
||||
@@ -542,6 +541,7 @@ void Button::applicationCommandListChangeCallback()
|
||||
|
||||
if (commandManagerToUse->getTargetForCommand (commandID, info) != nullptr)
|
||||
{
|
||||
updateAutomaticTooltip (info);
|
||||
setEnabled ((info.flags & ApplicationCommandInfo::isDisabled) == 0);
|
||||
setToggleState ((info.flags & ApplicationCommandInfo::isTicked) != 0, dontSendNotification);
|
||||
}
|
||||
|
||||
@@ -277,12 +277,6 @@ public:
|
||||
*/
|
||||
void setTooltip (const String& newTooltip) override;
|
||||
|
||||
/** Returns the tooltip set by setTooltip(), or the description corresponding to
|
||||
the currently mapped command if one is enabled (see setCommandToTrigger).
|
||||
*/
|
||||
String getTooltip() override;
|
||||
|
||||
|
||||
//==============================================================================
|
||||
/** A combination of these flags are used by setConnectedEdges(). */
|
||||
enum ConnectedEdgeFlags
|
||||
@@ -349,6 +343,9 @@ public:
|
||||
*/
|
||||
void setState (ButtonState newState);
|
||||
|
||||
/** Returns the button's current over/down/up state. */
|
||||
ButtonState getState() const noexcept { return buttonState; }
|
||||
|
||||
// This method's parameters have changed - see the new version.
|
||||
JUCE_DEPRECATED (void setToggleState (bool, bool));
|
||||
|
||||
@@ -363,9 +360,8 @@ public:
|
||||
virtual void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
|
||||
bool isMouseOverButton, bool isButtonDown) = 0;
|
||||
|
||||
virtual Font getTextButtonFont (TextButton&) = 0;
|
||||
|
||||
virtual void changeTextButtonWidthToFitText (TextButton&, int newHeight) = 0;
|
||||
virtual Font getTextButtonFont (TextButton&, int buttonHeight) = 0;
|
||||
virtual int getTextButtonWidthToFitText (TextButton&, int buttonHeight) = 0;
|
||||
|
||||
/** Draws the text for a TextButton. */
|
||||
virtual void drawButtonText (Graphics&, TextButton&, bool isMouseOverButton, bool isButtonDown) = 0;
|
||||
@@ -379,6 +375,13 @@ public:
|
||||
bool ticked, bool isEnabled, bool isMouseOverButton, bool isButtonDown) = 0;
|
||||
|
||||
virtual void drawDrawableButton (Graphics&, DrawableButton&, bool isMouseOverButton, bool isButtonDown) = 0;
|
||||
|
||||
private:
|
||||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
|
||||
// These method have been deprecated: see their replacements above.
|
||||
virtual int getTextButtonFont (TextButton&) { return 0; }
|
||||
virtual int changeTextButtonWidthToFitText (TextButton&, int) { return 0; }
|
||||
#endif
|
||||
};
|
||||
|
||||
protected:
|
||||
@@ -489,6 +492,7 @@ private:
|
||||
void repeatTimerCallback();
|
||||
bool keyStateChangedCallback();
|
||||
void applicationCommandListChangeCallback();
|
||||
void updateAutomaticTooltip (const ApplicationCommandInfo&);
|
||||
|
||||
ButtonState updateState();
|
||||
ButtonState updateState (bool isOver, bool isDown);
|
||||
|
||||
@@ -80,6 +80,31 @@ void DrawableButton::setEdgeIndent (const int numPixelsIndent)
|
||||
resized();
|
||||
}
|
||||
|
||||
Rectangle<float> DrawableButton::getImageBounds() const
|
||||
{
|
||||
Rectangle<int> r (getLocalBounds());
|
||||
|
||||
if (style != ImageStretched)
|
||||
{
|
||||
int indentX = jmin (edgeIndent, proportionOfWidth (0.3f));
|
||||
int indentY = jmin (edgeIndent, proportionOfHeight (0.3f));
|
||||
|
||||
if (style == ImageOnButtonBackground)
|
||||
{
|
||||
indentX = jmax (getWidth() / 4, indentX);
|
||||
indentY = jmax (getHeight() / 4, indentY);
|
||||
}
|
||||
else if (style == ImageAboveTextLabel)
|
||||
{
|
||||
r = r.withTrimmedBottom (jmin (16, proportionOfHeight (0.25f)));
|
||||
}
|
||||
|
||||
r = r.reduced (indentX, indentY);
|
||||
}
|
||||
|
||||
return r.toFloat();
|
||||
}
|
||||
|
||||
void DrawableButton::resized()
|
||||
{
|
||||
Button::resized();
|
||||
@@ -87,36 +112,11 @@ void DrawableButton::resized()
|
||||
if (currentImage != nullptr)
|
||||
{
|
||||
if (style == ImageRaw)
|
||||
{
|
||||
currentImage->setOriginWithOriginalSize (Point<float>());
|
||||
}
|
||||
else if (style == ImageStretched)
|
||||
{
|
||||
currentImage->setTransformToFit (getLocalBounds().toFloat(), RectanglePlacement::stretchToFit);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle<int> imageSpace;
|
||||
|
||||
const int indentX = jmin (edgeIndent, proportionOfWidth (0.3f));
|
||||
const int indentY = jmin (edgeIndent, proportionOfHeight (0.3f));
|
||||
|
||||
if (style == ImageOnButtonBackground)
|
||||
{
|
||||
imageSpace = getLocalBounds().reduced (jmax (getWidth() / 4, indentX),
|
||||
jmax (getHeight() / 4, indentY));
|
||||
}
|
||||
else
|
||||
{
|
||||
const int textH = (style == ImageAboveTextLabel) ? jmin (16, proportionOfHeight (0.25f)) : 0;
|
||||
|
||||
imageSpace.setBounds (indentX, indentY,
|
||||
getWidth() - indentX * 2,
|
||||
getHeight() - indentY * 2 - textH);
|
||||
}
|
||||
|
||||
currentImage->setTransformToFit (imageSpace.toFloat(), RectanglePlacement::centred);
|
||||
}
|
||||
currentImage->setTransformToFit (getImageBounds(),
|
||||
style == ImageStretched ? RectanglePlacement::stretchToFit
|
||||
: RectanglePlacement::centred);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ void DrawableButton::buttonStateChanged()
|
||||
{
|
||||
currentImage->setInterceptsMouseClicks (false, false);
|
||||
addAndMakeVisible (currentImage);
|
||||
DrawableButton::resized();
|
||||
resized();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,6 +132,9 @@ public:
|
||||
/** Returns the image that the button will use when the mouse is held down on it. */
|
||||
Drawable* getDownImage() const noexcept;
|
||||
|
||||
/** Can be overridden to specify a custom position for the image within the button. */
|
||||
virtual Rectangle<float> getImageBounds() const;
|
||||
|
||||
//==============================================================================
|
||||
/** A set of colour IDs to use to change the colour of various aspects of the link.
|
||||
|
||||
@@ -173,8 +176,8 @@ public:
|
||||
private:
|
||||
//==============================================================================
|
||||
ButtonStyle style;
|
||||
ScopedPointer <Drawable> normalImage, overImage, downImage, disabledImage,
|
||||
normalImageOn, overImageOn, downImageOn, disabledImageOn;
|
||||
ScopedPointer<Drawable> normalImage, overImage, downImage, disabledImage,
|
||||
normalImageOn, overImageOn, downImageOn, disabledImageOn;
|
||||
Drawable* currentImage;
|
||||
int edgeIndent;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
file is part of the JUCE library.
|
||||
Copyright (c) 2013 - Raw Material Software Ltd.
|
||||
|
||||
Permission is granted to use this software under the terms of either:
|
||||
@@ -26,8 +25,11 @@ TextButton::TextButton() : Button (String())
|
||||
{
|
||||
}
|
||||
|
||||
TextButton::TextButton (const String& name, const String& toolTip)
|
||||
: Button (name)
|
||||
TextButton::TextButton (const String& name) : Button (name)
|
||||
{
|
||||
}
|
||||
|
||||
TextButton::TextButton (const String& name, const String& toolTip) : Button (name)
|
||||
{
|
||||
setTooltip (toolTip);
|
||||
}
|
||||
@@ -52,12 +54,17 @@ void TextButton::colourChanged()
|
||||
repaint();
|
||||
}
|
||||
|
||||
Font TextButton::getFont()
|
||||
void TextButton::changeWidthToFitText()
|
||||
{
|
||||
return Font (jmin (15.0f, getHeight() * 0.6f));
|
||||
changeWidthToFitText (getHeight());
|
||||
}
|
||||
|
||||
void TextButton::changeWidthToFitText (const int newHeight)
|
||||
{
|
||||
getLookAndFeel().changeTextButtonWidthToFitText (*this, newHeight);
|
||||
setSize (getBestWidthForHeight (newHeight), newHeight);
|
||||
}
|
||||
|
||||
int TextButton::getBestWidthForHeight (int buttonHeight)
|
||||
{
|
||||
return getLookAndFeel().getTextButtonWidthToFitText (*this, buttonHeight);
|
||||
}
|
||||
|
||||
@@ -44,11 +44,16 @@ public:
|
||||
@param buttonName the text to put in the button (the component's name is also
|
||||
initially set to this string, but these can be changed later
|
||||
using the setName() and setButtonText() methods)
|
||||
@param toolTip an optional string to use as a toolip
|
||||
@see Button
|
||||
*/
|
||||
explicit TextButton (const String& buttonName,
|
||||
const String& toolTip = String::empty);
|
||||
explicit TextButton (const String& buttonName);
|
||||
|
||||
/** Creates a TextButton.
|
||||
@param buttonName the text to put in the button (the component's name is also
|
||||
initially set to this string, but these can be changed later
|
||||
using the setName() and setButtonText() methods)
|
||||
@param toolTip an optional string to use as a toolip
|
||||
*/
|
||||
TextButton (const String& buttonName, const String& toolTip);
|
||||
|
||||
/** Destructor. */
|
||||
~TextButton();
|
||||
@@ -74,17 +79,20 @@ public:
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
/** Resizes the button to fit neatly around its current text.
|
||||
If newHeight is >= 0, the button's height will be changed to this
|
||||
value. If it's less than zero, its height will be unaffected.
|
||||
/** Changes this button's width to fit neatly around its current text, without
|
||||
changing its height.
|
||||
*/
|
||||
void changeWidthToFitText (int newHeight = -1);
|
||||
void changeWidthToFitText();
|
||||
|
||||
/** This can be overridden to use different fonts than the default one.
|
||||
Note that you'll need to set the font's size appropriately, too.
|
||||
/** Resizes the button's width to fit neatly around its current text, and gives it
|
||||
the specified height.
|
||||
*/
|
||||
virtual Font getFont();
|
||||
void changeWidthToFitText (int newHeight);
|
||||
|
||||
/** Returns the width that the LookAndFeel suggests would be best for this button if it
|
||||
had the given height.
|
||||
*/
|
||||
int getBestWidthForHeight (int buttonHeight);
|
||||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
@@ -93,6 +101,11 @@ public:
|
||||
void colourChanged() override;
|
||||
|
||||
private:
|
||||
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
|
||||
// Note that this method has been removed - instead, see LookAndFeel::getTextButtonWidthToFitText()
|
||||
virtual int getFont() { return 0; }
|
||||
#endif
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton)
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user