- updated
git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@117 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -473,7 +473,7 @@ bool ComboBox::keyPressed (const KeyPress& key)
|
||||
|
||||
if (key == KeyPress::returnKey)
|
||||
{
|
||||
showPopup();
|
||||
showPopupIfNotActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -512,42 +512,51 @@ void ComboBox::popupMenuFinishedCallback (int result, ComboBox* box)
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBox::showPopup()
|
||||
void ComboBox::showPopupIfNotActive()
|
||||
{
|
||||
if (! menuActive)
|
||||
{
|
||||
const int selectedId = getSelectedId();
|
||||
|
||||
PopupMenu menu;
|
||||
menu.setLookAndFeel (&getLookAndFeel());
|
||||
|
||||
for (int i = 0; i < items.size(); ++i)
|
||||
{
|
||||
const ItemInfo* const item = items.getUnchecked(i);
|
||||
|
||||
if (item->isSeparator())
|
||||
menu.addSeparator();
|
||||
else if (item->isHeading)
|
||||
menu.addSectionHeader (item->name);
|
||||
else
|
||||
menu.addItem (item->itemId, item->name,
|
||||
item->isEnabled, item->itemId == selectedId);
|
||||
}
|
||||
|
||||
if (items.size() == 0)
|
||||
menu.addItem (1, noChoicesMessage, false);
|
||||
|
||||
menuActive = true;
|
||||
|
||||
menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
|
||||
.withItemThatMustBeVisible (selectedId)
|
||||
.withMinimumWidth (getWidth())
|
||||
.withMaximumNumColumns (1)
|
||||
.withStandardItemHeight (jlimit (12, 24, getHeight())),
|
||||
ModalCallbackFunction::forComponent (popupMenuFinishedCallback, this));
|
||||
showPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBox::showPopup()
|
||||
{
|
||||
PopupMenu menu;
|
||||
menu.setLookAndFeel (&getLookAndFeel());
|
||||
addItemsToMenu (menu);
|
||||
|
||||
menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
|
||||
.withItemThatMustBeVisible (getSelectedId())
|
||||
.withMinimumWidth (getWidth())
|
||||
.withMaximumNumColumns (1)
|
||||
.withStandardItemHeight (label->getHeight()),
|
||||
ModalCallbackFunction::forComponent (popupMenuFinishedCallback, this));
|
||||
}
|
||||
|
||||
void ComboBox::addItemsToMenu (PopupMenu& menu) const
|
||||
{
|
||||
const int selectedId = getSelectedId();
|
||||
|
||||
for (int i = 0; i < items.size(); ++i)
|
||||
{
|
||||
const ItemInfo* const item = items.getUnchecked(i);
|
||||
jassert (item != nullptr);
|
||||
|
||||
if (item->isSeparator())
|
||||
menu.addSeparator();
|
||||
else if (item->isHeading)
|
||||
menu.addSectionHeader (item->name);
|
||||
else
|
||||
menu.addItem (item->itemId, item->name,
|
||||
item->isEnabled, item->itemId == selectedId);
|
||||
}
|
||||
|
||||
if (items.size() == 0)
|
||||
menu.addItem (1, noChoicesMessage, false);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void ComboBox::mouseDown (const MouseEvent& e)
|
||||
{
|
||||
@@ -556,7 +565,7 @@ void ComboBox::mouseDown (const MouseEvent& e)
|
||||
isButtonDown = isEnabled() && ! e.mods.isPopupMenu();
|
||||
|
||||
if (isButtonDown && (e.eventComponent == this || ! label->isEditable()))
|
||||
showPopup();
|
||||
showPopupIfNotActive();
|
||||
}
|
||||
|
||||
void ComboBox::mouseDrag (const MouseEvent& e)
|
||||
@@ -564,7 +573,7 @@ void ComboBox::mouseDrag (const MouseEvent& e)
|
||||
beginDragAutoRepeat (50);
|
||||
|
||||
if (isButtonDown && ! e.mouseWasClicked())
|
||||
showPopup();
|
||||
showPopupIfNotActive();
|
||||
}
|
||||
|
||||
void ComboBox::mouseUp (const MouseEvent& e2)
|
||||
@@ -579,7 +588,7 @@ void ComboBox::mouseUp (const MouseEvent& e2)
|
||||
if (reallyContains (e.getPosition(), true)
|
||||
&& (e2.eventComponent == this || ! label->isEditable()))
|
||||
{
|
||||
showPopup();
|
||||
showPopupIfNotActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,9 @@ public:
|
||||
*/
|
||||
virtual void showPopup();
|
||||
|
||||
/** Adds the items in this ComboBox to the given menu. */
|
||||
virtual void addItemsToMenu (PopupMenu&) const;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
A class for receiving events from a ComboBox.
|
||||
@@ -432,6 +435,7 @@ private:
|
||||
bool selectIfEnabled (int index);
|
||||
bool nudgeSelectedItem (int delta);
|
||||
void sendChange (NotificationType);
|
||||
void showPopupIfNotActive();
|
||||
static void popupMenuFinishedCallback (int, ComboBox*);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBox)
|
||||
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
|
||||
int getRowNumberOfComponent (Component* const rowComponent) const noexcept
|
||||
{
|
||||
const int index = getIndexOfChildComponent (rowComponent);
|
||||
const int index = getViewedComponent()->getIndexOfChildComponent (rowComponent);
|
||||
const int num = rows.size();
|
||||
|
||||
for (int i = num; --i >= 0;)
|
||||
@@ -196,15 +196,16 @@ public:
|
||||
{
|
||||
hasUpdated = false;
|
||||
|
||||
const int newX = getViewedComponent()->getX();
|
||||
int newY = getViewedComponent()->getY();
|
||||
Component& content = *getViewedComponent();
|
||||
const int newX = content.getX();
|
||||
int newY = content.getY();
|
||||
const int newW = jmax (owner.minimumRowWidth, getMaximumVisibleWidth());
|
||||
const int newH = owner.totalItems * owner.getRowHeight();
|
||||
|
||||
if (newY + newH < getMaximumVisibleHeight() && newH > getMaximumVisibleHeight())
|
||||
newY = getMaximumVisibleHeight() - newH;
|
||||
|
||||
getViewedComponent()->setBounds (newX, newY, newW, newH);
|
||||
content.setBounds (newX, newY, newW, newH);
|
||||
|
||||
if (makeSureItUpdatesContent && ! hasUpdated)
|
||||
updateContents();
|
||||
@@ -214,11 +215,12 @@ public:
|
||||
{
|
||||
hasUpdated = true;
|
||||
const int rowH = owner.getRowHeight();
|
||||
Component& content = *getViewedComponent();
|
||||
|
||||
if (rowH > 0)
|
||||
{
|
||||
const int y = getViewPositionY();
|
||||
const int w = getViewedComponent()->getWidth();
|
||||
const int w = content.getWidth();
|
||||
|
||||
const int numNeeded = 2 + getMaximumVisibleHeight() / rowH;
|
||||
rows.removeRange (numNeeded, rows.size());
|
||||
@@ -227,7 +229,7 @@ public:
|
||||
{
|
||||
RowComponent* newRow = new RowComponent (owner);
|
||||
rows.add (newRow);
|
||||
getViewedComponent()->addAndMakeVisible (newRow);
|
||||
content.addAndMakeVisible (newRow);
|
||||
}
|
||||
|
||||
firstIndex = y / rowH;
|
||||
@@ -247,10 +249,10 @@ public:
|
||||
}
|
||||
|
||||
if (owner.headerComponent != nullptr)
|
||||
owner.headerComponent->setBounds (owner.outlineThickness + getViewedComponent()->getX(),
|
||||
owner.headerComponent->setBounds (owner.outlineThickness + content.getX(),
|
||||
owner.outlineThickness,
|
||||
jmax (owner.getWidth() - owner.outlineThickness * 2,
|
||||
getViewedComponent()->getWidth()),
|
||||
content.getWidth()),
|
||||
owner.headerComponent->getHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -248,9 +248,7 @@ public:
|
||||
void setSkewFactorFromMidPoint (double sliderValueToShowAtMidPoint);
|
||||
|
||||
/** Returns the current skew factor.
|
||||
|
||||
See setSkewFactor for more info.
|
||||
|
||||
@see setSkewFactor, setSkewFactorFromMidPoint
|
||||
*/
|
||||
double getSkewFactor() const noexcept;
|
||||
@@ -682,6 +680,13 @@ public:
|
||||
/** Returns the suffix that was set by setTextValueSuffix(). */
|
||||
String getTextValueSuffix() const;
|
||||
|
||||
/** Returns the best number of decimal places to use when displaying this
|
||||
slider's value.
|
||||
It calculates the fewest decimal places needed to represent numbers with
|
||||
the slider's interval setting.
|
||||
*/
|
||||
int getNumDecimalPlacesToDisplay() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Allows a user-defined mapping of distance along the slider to its value.
|
||||
|
||||
@@ -831,7 +836,6 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void paint (Graphics&) override;
|
||||
@@ -858,11 +862,6 @@ protected:
|
||||
/** @internal */
|
||||
void colourChanged() override;
|
||||
|
||||
/** Returns the best number of decimal places to use when displaying numbers.
|
||||
This is calculated from the slider's interval setting.
|
||||
*/
|
||||
int getNumDecimalPlacesToDisplay() const noexcept;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
JUCE_PUBLIC_IN_DLL_BUILD (class Pimpl)
|
||||
|
||||
Reference in New Issue
Block a user