1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

Added a virtual getPopupMenuBorderSize() to PopupMenu::LookAndFeelMethods

This commit is contained in:
ed 2017-08-16 10:50:42 +01:00
parent 8e2ab5eeaa
commit b7a7563a59
4 changed files with 13 additions and 7 deletions

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)
{

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,

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)
{

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: