Browse Source

Added AlertWindow LookAndFeel methods to offer more control on button widths

tags/2021-05-28
hogliux 9 years ago
parent
commit
ee373af944
4 changed files with 23 additions and 6 deletions
  1. +10
    -2
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
  2. +1
    -1
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h
  3. +11
    -2
      modules/juce_gui_basics/windows/juce_AlertWindow.cpp
  4. +1
    -1
      modules/juce_gui_basics/windows/juce_AlertWindow.h

+ 10
- 2
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp View File

@@ -489,9 +489,17 @@ int LookAndFeel_V2::getAlertBoxWindowFlags()
| ComponentPeer::windowHasDropShadow;
}
int LookAndFeel_V2::getAlertWindowButtonWidth (TextButton& b)
Array<int> LookAndFeel_V2::getWidthsForTextButtons (AlertWindow&, const Array<TextButton*>& buttons)
{
return getTextButtonWidthToFitText (b, getAlertWindowButtonHeight());
const int n = buttons.size();
Array<int> buttonWidths;
const int buttonHeight = getAlertWindowButtonHeight();
for (int i = 0; i < n; ++i)
buttonWidths.add (getTextButtonWidthToFitText (*buttons.getReference (i), buttonHeight));
return buttonWidths;
}
int LookAndFeel_V2::getAlertWindowButtonHeight()


+ 1
- 1
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h View File

@@ -67,7 +67,7 @@ public:
void drawAlertBox (Graphics&, AlertWindow&, const Rectangle<int>& textArea, TextLayout&) override;
int getAlertBoxWindowFlags() override;
int getAlertWindowButtonWidth (TextButton&) override;
Array<int> getWidthsForTextButtons (AlertWindow&, const Array<TextButton*>&) override;
int getAlertWindowButtonHeight() override;
/** Override this function to supply a custom font for the alert window title.


+ 11
- 2
modules/juce_gui_basics/windows/juce_AlertWindow.cpp View File

@@ -99,8 +99,17 @@ void AlertWindow::addButton (const String& name,
b->addShortcut (shortcutKey2);
b->addListener (this);
b->setSize (getLookAndFeel().getAlertWindowButtonWidth (*b),
getLookAndFeel().getAlertWindowButtonHeight());
Array<TextButton*> buttonsArray (buttons.begin(), buttons.size());
const int buttonHeight = getLookAndFeel().getAlertWindowButtonHeight();
const Array<int> buttonWidths = getLookAndFeel().getWidthsForTextButtons (*this, buttonsArray);
jassert (buttonWidths.size() == buttons.size());
const int n = buttonWidths.size();
for (int i = 0; i < n; ++i)
buttons.getUnchecked (i)->setSize (buttonWidths.getReference (i), buttonHeight);
addAndMakeVisible (b, 0);


+ 1
- 1
modules/juce_gui_basics/windows/juce_AlertWindow.h View File

@@ -435,7 +435,7 @@ public:
virtual int getAlertBoxWindowFlags() = 0;
virtual int getAlertWindowButtonWidth (TextButton&) = 0;
virtual Array<int> getWidthsForTextButtons (AlertWindow&, const Array<TextButton*>&) = 0;
virtual int getAlertWindowButtonHeight() = 0;
virtual Font getAlertWindowTitleFont() = 0;


Loading…
Cancel
Save