mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-08 04:20:09 +00:00
Deprecated some old bool notification mode parameters, and replaced them with NotificationType values in the ComboBox and Button classes.
This commit is contained in:
parent
51b9d1ed98
commit
eb646f8c42
24 changed files with 119 additions and 95 deletions
|
|
@ -165,13 +165,13 @@ void ComboBox::changeItemText (const int itemId, const String& newText)
|
|||
jassertfalse;
|
||||
}
|
||||
|
||||
void ComboBox::clear (const bool dontSendChangeMessage)
|
||||
void ComboBox::clear (const NotificationType notification)
|
||||
{
|
||||
items.clear();
|
||||
separatorPending = false;
|
||||
|
||||
if (! label->isEditable())
|
||||
setSelectedItemIndex (-1, dontSendChangeMessage);
|
||||
setSelectedItemIndex (-1, notification);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -257,9 +257,9 @@ int ComboBox::getSelectedItemIndex() const
|
|||
return index;
|
||||
}
|
||||
|
||||
void ComboBox::setSelectedItemIndex (const int index, const bool dontSendChangeMessage)
|
||||
void ComboBox::setSelectedItemIndex (const int index, const NotificationType notification)
|
||||
{
|
||||
setSelectedId (getItemId (index), dontSendChangeMessage);
|
||||
setSelectedId (getItemId (index), notification);
|
||||
}
|
||||
|
||||
int ComboBox::getSelectedId() const noexcept
|
||||
|
|
@ -269,21 +269,20 @@ int ComboBox::getSelectedId() const noexcept
|
|||
return (item != nullptr && getText() == item->name) ? item->itemId : 0;
|
||||
}
|
||||
|
||||
void ComboBox::setSelectedId (const int newItemId, const bool dontSendChangeMessage)
|
||||
void ComboBox::setSelectedId (const int newItemId, const NotificationType notification)
|
||||
{
|
||||
const ItemInfo* const item = getItemForId (newItemId);
|
||||
const String newItemText (item != nullptr ? item->name : String::empty);
|
||||
|
||||
if (lastCurrentId != newItemId || label->getText() != newItemText)
|
||||
{
|
||||
if (! dontSendChangeMessage)
|
||||
triggerAsyncUpdate();
|
||||
|
||||
label->setText (newItemText, dontSendNotification);
|
||||
lastCurrentId = newItemId;
|
||||
currentId = newItemId;
|
||||
|
||||
repaint(); // for the benefit of the 'none selected' text
|
||||
|
||||
sendChange (notification);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +303,7 @@ bool ComboBox::selectIfEnabled (const int index)
|
|||
void ComboBox::valueChanged (Value&)
|
||||
{
|
||||
if (lastCurrentId != (int) currentId.getValue())
|
||||
setSelectedId (currentId.getValue(), false);
|
||||
setSelectedId (currentId.getValue());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -313,7 +312,7 @@ String ComboBox::getText() const
|
|||
return label->getText();
|
||||
}
|
||||
|
||||
void ComboBox::setText (const String& newText, const bool dontSendChangeMessage)
|
||||
void ComboBox::setText (const String& newText, const NotificationType notification)
|
||||
{
|
||||
for (int i = items.size(); --i >= 0;)
|
||||
{
|
||||
|
|
@ -322,23 +321,20 @@ void ComboBox::setText (const String& newText, const bool dontSendChangeMessage)
|
|||
if (item->isRealItem()
|
||||
&& item->name == newText)
|
||||
{
|
||||
setSelectedId (item->itemId, dontSendChangeMessage);
|
||||
setSelectedId (item->itemId, notification);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lastCurrentId = 0;
|
||||
currentId = 0;
|
||||
repaint();
|
||||
|
||||
if (label->getText() != newText)
|
||||
{
|
||||
label->setText (newText, dontSendNotification);
|
||||
|
||||
if (! dontSendChangeMessage)
|
||||
triggerAsyncUpdate();
|
||||
sendChange (notification);
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
void ComboBox::showEditor()
|
||||
|
|
@ -594,3 +590,18 @@ void ComboBox::handleAsyncUpdate()
|
|||
Component::BailOutChecker checker (this);
|
||||
listeners.callChecked (checker, &ComboBoxListener::comboBoxChanged, this); // (can't use ComboBox::Listener due to idiotic VC2005 bug)
|
||||
}
|
||||
|
||||
void ComboBox::sendChange (const NotificationType notification)
|
||||
{
|
||||
if (notification != dontSendNotification)
|
||||
triggerAsyncUpdate();
|
||||
|
||||
if (notification == sendNotificationSync)
|
||||
handleUpdateNowIfNeeded();
|
||||
}
|
||||
|
||||
// Old deprecated methods - remove eventually...
|
||||
void ComboBox::clear (const bool dontSendChange) { clear (dontSendChange ? dontSendNotification : sendNotification); }
|
||||
void ComboBox::setSelectedItemIndex (const int index, const bool dontSendChange) { setSelectedItemIndex (index, dontSendChange ? dontSendNotification : sendNotification); }
|
||||
void ComboBox::setSelectedId (const int newItemId, const bool dontSendChange) { setSelectedId (newItemId, dontSendChange ? dontSendNotification : sendNotification); }
|
||||
void ComboBox::setText (const String& newText, const bool dontSendChange) { setText (newText, dontSendChange ? dontSendNotification : sendNotification); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue