Browse Source

Added a virtual getPopupMenuBorderSize() to PopupMenu::LookAndFeelMethods

tags/2021-05-28
ed 8 years ago
parent
commit
b7a7563a59
4 changed files with 13 additions and 7 deletions
  1. +2
    -0
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
  2. +2
    -0
      modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h
  3. +7
    -7
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp
  4. +2
    -0
      modules/juce_gui_basics/menus/juce_PopupMenu.h

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

@@ -1104,6 +1104,8 @@ void LookAndFeel_V2::preparePopupMenuWindow (Component&) {}
bool LookAndFeel_V2::shouldPopupMenuScaleWithTargetComponent (const PopupMenu::Options&) { return true; }
int LookAndFeel_V2::getPopupMenuBorderSize() { return 2; }
//==============================================================================
void LookAndFeel_V2::fillTextEditorBackground (Graphics& g, int /*width*/, int /*height*/, TextEditor& textEditor)
{


+ 2
- 0
modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.h View File

@@ -182,6 +182,8 @@ public:
bool shouldPopupMenuScaleWithTargetComponent (const PopupMenu::Options& options) override;
int getPopupMenuBorderSize() override;
//==============================================================================
void drawComboBox (Graphics&, int width, int height, bool isButtonDown,
int buttonX, int buttonY, int buttonW, int buttonH,


+ 7
- 7
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

@@ -27,7 +27,6 @@
namespace PopupMenuSettings
{
const int scrollZone = 24;
const int borderSize = 2;
const int dismissCommandId = 0x6287345f;
static bool menuWasHiddenBecauseOfAppChange = false;
@@ -290,7 +289,8 @@ public:
auto& lf = getLookAndFeel();
if (parentComponent != nullptr)
lf.drawResizableFrame (g, getWidth(), getHeight(), BorderSize<int> (PopupMenuSettings::borderSize));
lf.drawResizableFrame (g, getWidth(), getHeight(),
BorderSize<int> (getLookAndFeel().getPopupMenuBorderSize()));
if (canScroll())
{
@@ -598,7 +598,7 @@ public:
return parentComponent->getLocalArea (nullptr,
parentComponent->getScreenBounds()
.reduced (PopupMenuSettings::borderSize)
.reduced (getLookAndFeel().getPopupMenuBorderSize())
.getIntersection (parentArea));
}
@@ -711,7 +711,7 @@ public:
needsToScroll = contentHeight > actualH;
width = updateYPositions();
height = actualH + PopupMenuSettings::borderSize * 2;
height = actualH + getLookAndFeel().getPopupMenuBorderSize() * 2;
}
int workOutBestSize (const int maxMenuW)
@@ -733,7 +733,7 @@ public:
colH += items.getUnchecked (childNum + i)->getHeight();
}
colW = jmin (maxMenuW / jmax (1, numColumns - 2), colW + PopupMenuSettings::borderSize * 2);
colW = jmin (maxMenuW / jmax (1, numColumns - 2), colW + getLookAndFeel().getPopupMenuBorderSize() * 2);
columnWidths.set (col, colW);
totalW += colW;
@@ -832,7 +832,7 @@ public:
childYOffset = jmax (childYOffset, 0);
else if (delta > 0)
childYOffset = jmin (childYOffset,
contentHeight - windowPos.getHeight() + PopupMenuSettings::borderSize);
contentHeight - windowPos.getHeight() + getLookAndFeel().getPopupMenuBorderSize());
updateYPositions();
}
@@ -857,7 +857,7 @@ public:
const int colW = columnWidths [col];
int y = PopupMenuSettings::borderSize - (childYOffset + (getY() - windowPos.getY()));
int y = getLookAndFeel().getPopupMenuBorderSize() - (childYOffset + (getY() - windowPos.getY()));
for (int i = 0; i < numChildren; ++i)
{


+ 2
- 0
modules/juce_gui_basics/menus/juce_PopupMenu.h View File

@@ -727,6 +727,8 @@ public:
/** Return true if you want your popup menus to scale with the target component's AffineTransform
or scale factor */
virtual bool shouldPopupMenuScaleWithTargetComponent (const PopupMenu::Options& options) = 0;
virtual int getPopupMenuBorderSize() = 0;
};
private:


Loading…
Cancel
Save