- Library code update

- project update (added Eigen)

git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@94 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-12-20 20:59:48 +00:00
parent 1b4d8e9f54
commit dc5560392f
312 changed files with 6349 additions and 4195 deletions
@@ -49,7 +49,7 @@ ComboBox::ComboBox (const String& name)
noChoicesMessage (TRANS("(no choices)"))
{
setRepaintsOnMouseActivity (true);
ComboBox::lookAndFeelChanged();
lookAndFeelChanged();
currentId.addListener (this);
}
@@ -410,12 +410,22 @@ void ComboBox::enablementChanged()
repaint();
}
void ComboBox::colourChanged()
{
lookAndFeelChanged();
}
void ComboBox::parentHierarchyChanged()
{
lookAndFeelChanged();
}
void ComboBox::lookAndFeelChanged()
{
repaint();
{
ScopedPointer <Label> newLabel (getLookAndFeel().createComboBoxTextBox (*this));
ScopedPointer<Label> newLabel (getLookAndFeel().createComboBoxTextBox (*this));
jassert (newLabel != nullptr);
if (label != nullptr)
@@ -446,11 +456,6 @@ void ComboBox::lookAndFeelChanged()
resized();
}
void ComboBox::colourChanged()
{
lookAndFeelChanged();
}
//==============================================================================
bool ComboBox::keyPressed (const KeyPress& key)
{
@@ -94,7 +94,7 @@ public:
@param newItemId an associated ID number that can be set or retrieved - see
getSelectedId() and setSelectedId(). Note that this value can not
be 0!
@see setItemEnabled, addSeparator, addSectionHeading, removeItem, getNumItems, getItemText, getItemId
@see setItemEnabled, addSeparator, addSectionHeading, getNumItems, getItemText, getItemId
*/
void addItem (const String& newItemText, int newItemId);
@@ -142,7 +142,7 @@ public:
If this call causes the content to be cleared, and a change-message
will be broadcast according to the notification parameter.
@see addItem, removeItem, getNumItems
@see addItem, getNumItems
*/
void clear (NotificationType notification = sendNotificationAsync);
@@ -257,8 +257,11 @@ public:
*/
void showEditor();
/** Pops up the combo box's list. */
void showPopup();
/** Pops up the combo box's list.
This is virtual so that you can override it with your own custom popup
mechanism if you need some really unusual behaviour.
*/
virtual void showPopup();
//==============================================================================
/**
@@ -393,6 +396,8 @@ public:
bool keyPressed (const KeyPress&) override;
/** @internal */
void valueChanged (Value&) override;
/** @internal */
void parentHierarchyChanged() override;
// These methods' bool parameters have changed: see their new method signatures.
JUCE_DEPRECATED (void clear (bool));
@@ -413,7 +418,7 @@ private:
bool isEnabled : 1, isHeading : 1;
};
OwnedArray <ItemInfo> items;
OwnedArray<ItemInfo> items;
Value currentId;
int lastCurrentId;
bool isButtonDown, separatorPending, menuActive, scrollWheelEnabled;
@@ -28,8 +28,7 @@ Label::Label (const String& name, const String& labelText)
lastTextValue (labelText),
font (15.0f),
justification (Justification::centredLeft),
horizontalBorderSize (5),
verticalBorderSize (1),
border (1, 5, 1, 5),
minimumHorizontalScale (0.7f),
editSingleClick (false),
editDoubleClick (false),
@@ -123,12 +122,11 @@ void Label::setJustificationType (Justification newJustification)
}
}
void Label::setBorderSize (int h, int v)
void Label::setBorderSize (BorderSize<int> newBorder)
{
if (horizontalBorderSize != h || verticalBorderSize != v)
if (border != newBorder)
{
horizontalBorderSize = h;
verticalBorderSize = v;
border = newBorder;
repaint();
}
}
@@ -191,7 +189,12 @@ void Label::componentVisibilityChanged (Component& component)
//==============================================================================
void Label::textWasEdited() {}
void Label::textWasChanged() {}
void Label::editorShown (TextEditor*) {}
void Label::editorShown (TextEditor* textEditor)
{
Component::BailOutChecker checker (this);
listeners.callChecked (checker, &LabelListener::editorShown, this, *textEditor);
}
void Label::editorAboutToBeHidden (TextEditor*)
{
@@ -286,11 +289,22 @@ bool Label::isBeingEdited() const noexcept
return editor != nullptr;
}
static void copyColourIfSpecified (Label& l, TextEditor& ed, int colourID, int targetColourID)
{
if (l.isColourSpecified (colourID) || l.getLookAndFeel().isColourSpecified (colourID))
ed.setColour (targetColourID, l.findColour (colourID));
}
TextEditor* Label::createEditorComponent()
{
TextEditor* const ed = new TextEditor (getName());
ed->applyFontToAllText (getLookAndFeel().getLabelFont (*this));
copyAllExplicitColoursTo (*ed);
copyColourIfSpecified (*this, *ed, textWhenEditingColourId, TextEditor::textColourId);
copyColourIfSpecified (*this, *ed, backgroundWhenEditingColourId, TextEditor::backgroundColourId);
copyColourIfSpecified (*this, *ed, outlineWhenEditingColourId, TextEditor::outlineColourId);
return ed;
}
@@ -325,7 +339,7 @@ void Label::mouseDoubleClick (const MouseEvent& e)
void Label::resized()
{
if (editor != nullptr)
editor->setBoundsInset (BorderSize<int> (0));
editor->setBounds (getLocalBounds());
}
void Label::focusGained (FocusChangeType cause)
@@ -74,7 +74,7 @@ public:
You can call Value::referTo() on this object to make the label read and control
a Value object that you supply.
*/
Value& getTextValue() { return textValue; }
Value& getTextValue() noexcept { return textValue; }
//==============================================================================
/** Changes the font to use to draw the text.
@@ -101,33 +101,32 @@ public:
*/
enum ColourIds
{
backgroundColourId = 0x1000280, /**< The background colour to fill the label with. */
textColourId = 0x1000281, /**< The colour for the text. */
outlineColourId = 0x1000282 /**< An optional colour to use to draw a border around the label.
Leave this transparent to not have an outline. */
backgroundColourId = 0x1000280, /**< The background colour to fill the label with. */
textColourId = 0x1000281, /**< The colour for the text. */
outlineColourId = 0x1000282, /**< An optional colour to use to draw a border around the label.
Leave this transparent to not have an outline. */
backgroundWhenEditingColourId = 0x1000283, /**< The background colour when the label is being edited. */
textWhenEditingColourId = 0x1000284, /**< The colour for the text when the label is being edited. */
outlineWhenEditingColourId = 0x1000285 /**< An optional border colour when the label is being edited. */
};
//==============================================================================
/** Sets the style of justification to be used for positioning the text.
(The default is Justification::centredLeft)
*/
void setJustificationType (Justification justification);
/** Returns the type of justification, as set in setJustificationType(). */
Justification getJustificationType() const noexcept { return justification; }
Justification getJustificationType() const noexcept { return justification; }
/** Changes the gap that is left between the edge of the component and the text.
/** Changes the border that is left between the edge of the component and the text.
By default there's a small gap left at the sides of the component to allow for
the drawing of the border, but you can change this if necessary.
*/
void setBorderSize (int horizontalBorder, int verticalBorder);
void setBorderSize (BorderSize<int> newBorderSize);
/** Returns the size of the horizontal gap being left around the text. */
int getHorizontalBorderSize() const noexcept { return horizontalBorderSize; }
/** Returns the size of the vertical gap being left around the text. */
int getVerticalBorderSize() const noexcept { return verticalBorderSize; }
/** Returns the size of the border to be left around the text. */
BorderSize<int> getBorderSize() const noexcept { return border; }
/** Makes this label "stick to" another component.
@@ -152,16 +151,17 @@ public:
Returns false if the label is above the other component. This is only relevent if
attachToComponent() has been called.
*/
bool isAttachedOnLeft() const noexcept { return leftOfOwnerComp; }
bool isAttachedOnLeft() const noexcept { return leftOfOwnerComp; }
/** Specifies the minimum amount that the font can be squashed horizantally before it starts
/** Specifies the minimum amount that the font can be squashed horizontally before it starts
using ellipsis.
@see Graphics::drawFittedText
*/
void setMinimumHorizontalScale (float newScale);
float getMinimumHorizontalScale() const noexcept { return minimumHorizontalScale; }
/** Specifies the amount that the font can be squashed horizontally. */
float getMinimumHorizontalScale() const noexcept { return minimumHorizontalScale; }
//==============================================================================
/**
@@ -182,6 +182,9 @@ public:
/** Called when a Label's text has changed. */
virtual void labelTextChanged (Label* labelThatHasChanged) = 0;
/** Called when a Label goes into editing mode and displays a TextEditor. */
virtual void editorShown (Label*, TextEditor&) {}
};
/** Registers a listener that will be called when the label's text changes. */
@@ -228,7 +231,6 @@ public:
bool isEditable() const noexcept { return editSingleClick || editDoubleClick; }
/** Makes the editor appear as if the label had been clicked by the user.
@see textWasEdited, setEditable
*/
void showEditor();
@@ -327,7 +329,7 @@ private:
ScopedPointer<TextEditor> editor;
ListenerList<Listener> listeners;
WeakReference<Component> ownerComponent;
int horizontalBorderSize, verticalBorderSize;
BorderSize<int> border;
float minimumHorizontalScale;
bool editSingleClick;
bool editDoubleClick;
@@ -367,6 +367,7 @@ ListBox::ListBox (const String& name, ListBoxModel* const m)
outlineThickness (0),
lastRowSelected (-1),
multipleSelection (false),
alwaysFlipSelection (false),
hasDoneInitialUpdate (false)
{
addAndMakeVisible (viewport = new ListViewport (*this));
@@ -391,11 +392,16 @@ void ListBox::setModel (ListBoxModel* const newModel)
}
}
void ListBox::setMultipleSelectionEnabled (bool b)
void ListBox::setMultipleSelectionEnabled (bool b) noexcept
{
multipleSelection = b;
}
void ListBox::setClickingTogglesRowSelection (bool b) noexcept
{
alwaysFlipSelection = b;
}
void ListBox::setMouseMoveSelectsRows (bool b)
{
if (b)
@@ -457,7 +463,7 @@ void ListBox::updateContent()
if (selected.size() > 0 && selected [selected.size() - 1] >= totalItems)
{
selected.removeRange (Range <int> (totalItems, std::numeric_limits<int>::max()));
selected.removeRange (Range<int> (totalItems, std::numeric_limits<int>::max()));
lastRowSelected = getSelectedRow (0);
selectionChanged = true;
}
@@ -470,9 +476,7 @@ void ListBox::updateContent()
}
//==============================================================================
void ListBox::selectRow (const int row,
bool dontScroll,
bool deselectOthersFirst)
void ListBox::selectRow (int row, bool dontScroll, bool deselectOthersFirst)
{
selectRowInternal (row, dontScroll, deselectOthersFirst, false);
}
@@ -516,7 +520,7 @@ void ListBox::deselectRow (const int row)
{
if (selected.contains (row))
{
selected.removeRange (Range <int> (row, row + 1));
selected.removeRange (Range<int> (row, row + 1));
if (row == lastRowSelected)
lastRowSelected = getSelectedRow (0);
@@ -530,7 +534,7 @@ void ListBox::setSelectedRows (const SparseSet<int>& setOfRowsToBeSelected,
const NotificationType sendNotificationEventToModel)
{
selected = setOfRowsToBeSelected;
selected.removeRange (Range <int> (totalItems, std::numeric_limits<int>::max()));
selected.removeRange (Range<int> (totalItems, std::numeric_limits<int>::max()));
if (! isRowSelected (lastRowSelected))
lastRowSelected = getSelectedRow (0);
@@ -554,10 +558,10 @@ void ListBox::selectRangeOfRows (int firstRow, int lastRow)
firstRow = jlimit (0, jmax (0, numRows), firstRow);
lastRow = jlimit (0, jmax (0, numRows), lastRow);
selected.addRange (Range <int> (jmin (firstRow, lastRow),
jmax (firstRow, lastRow) + 1));
selected.addRange (Range<int> (jmin (firstRow, lastRow),
jmax (firstRow, lastRow) + 1));
selected.removeRange (Range <int> (lastRow, lastRow + 1));
selected.removeRange (Range<int> (lastRow, lastRow + 1));
}
selectRowInternal (lastRow, false, false, true);
@@ -589,7 +593,7 @@ void ListBox::selectRowsBasedOnModifierKeys (const int row,
ModifierKeys mods,
const bool isMouseUpEvent)
{
if (multipleSelection && mods.isCommandDown())
if (multipleSelection && (mods.isCommandDown() || alwaysFlipSelection))
{
flipRowSelection (row);
}
@@ -652,7 +656,7 @@ int ListBox::getInsertionIndexForPosition (const int x, const int y) const noexc
Component* ListBox::getComponentForRowNumber (const int row) const noexcept
{
if (RowComponent* const listRowComp = viewport->getComponentForRowIfOnscreen (row))
return static_cast <Component*> (listRowComp->customComponent);
return static_cast<Component*> (listRowComp->customComponent);
return nullptr;
}
@@ -809,7 +813,7 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee
void ListBox::mouseUp (const MouseEvent& e)
{
if (e.mouseWasClicked() && model != nullptr)
model->backgroundClicked();
model->backgroundClicked (e);
}
//==============================================================================
@@ -853,6 +857,11 @@ void ListBox::colourChanged()
repaint();
}
void ListBox::parentHierarchyChanged()
{
colourChanged();
}
void ListBox::setOutlineThickness (const int newThickness)
{
outlineThickness = newThickness;
@@ -878,7 +887,7 @@ void ListBox::repaintRow (const int rowNumber) noexcept
Image ListBox::createSnapshotOfSelectedRows (int& imageX, int& imageY)
{
Rectangle<int> imageArea;
const int firstRow = getRowContainingPosition (0, 0);
const int firstRow = getRowContainingPosition (0, viewport->getY());
for (int i = getNumRowsOnScreen() + 2; --i >= 0;)
{
@@ -947,7 +956,7 @@ Component* ListBoxModel::refreshComponentForRow (int, bool, Component* existingC
void ListBoxModel::listBoxItemClicked (int, const MouseEvent&) {}
void ListBoxModel::listBoxItemDoubleClicked (int, const MouseEvent&) {}
void ListBoxModel::backgroundClicked() {}
void ListBoxModel::backgroundClicked (const MouseEvent&) {}
void ListBoxModel::selectedRowsChanged (int) {}
void ListBoxModel::deleteKeyPressed (int) {}
void ListBoxModel::returnKeyPressed (int) {}
@@ -45,7 +45,10 @@ public:
*/
virtual int getNumRows() = 0;
/** This method must be implemented to draw a row of the list. */
/** This method must be implemented to draw a row of the list.
Note that the rowNumber value may be greater than the number of rows in your
list, so be careful that you don't assume it's less than getNumRows().
*/
virtual void paintListBoxItem (int rowNumber,
Graphics& g,
int width, int height,
@@ -84,18 +87,18 @@ public:
/** This can be overridden to react to the user clicking on a row.
@see listBoxItemDoubleClicked
*/
virtual void listBoxItemClicked (int row, const MouseEvent& e);
virtual void listBoxItemClicked (int row, const MouseEvent&);
/** This can be overridden to react to the user double-clicking on a row.
@see listBoxItemClicked
*/
virtual void listBoxItemDoubleClicked (int row, const MouseEvent& e);
virtual void listBoxItemDoubleClicked (int row, const MouseEvent&);
/** This can be overridden to react to the user clicking on a part of the list where
there are no rows.
@see listBoxItemClicked
*/
virtual void backgroundClicked();
virtual void backgroundClicked (const MouseEvent&);
/** Override this to be informed when rows are selected or deselected.
@@ -152,6 +155,12 @@ public:
/** You can override this to return a custom mouse cursor for each row. */
virtual MouseCursor getMouseCursorForRow (int row);
private:
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// This method's signature has changed to take a MouseEvent parameter - please update your code!
JUCE_DEPRECATED_WITH_BODY (virtual int backgroundClicked(), { return 0; })
#endif
};
@@ -210,7 +219,16 @@ public:
clicked and to get it to do the appropriate selection based on whether
the ctrl/shift keys are held down.
*/
void setMultipleSelectionEnabled (bool shouldBeEnabled);
void setMultipleSelectionEnabled (bool shouldBeEnabled) noexcept;
/** If enabled, this makes the listbox flip the selection status of
each row that the user clicks, without affecting other selected rows.
(This only has an effect if multiple selection is also enabled).
If not enabled, you can still get the same row-flipping behaviour by holding
down CMD or CTRL when clicking.
*/
void setClickingTogglesRowSelection (bool flipRowSelection) noexcept;
/** Makes the list react to mouse moves by selecting the row that the mouse if over.
@@ -534,6 +552,8 @@ public:
/** @internal */
void colourChanged() override;
/** @internal */
void parentHierarchyChanged() override;
/** @internal */
void startDragAndDrop (const MouseEvent&, const var& dragDescription, bool allowDraggingToOtherWindows);
private:
@@ -549,7 +569,7 @@ private:
int totalItems, rowHeight, minimumRowWidth;
int outlineThickness;
int lastRowSelected;
bool multipleSelection, hasDoneInitialUpdate;
bool multipleSelection, alwaysFlipSelection, hasDoneInitialUpdate;
SparseSet<int> selected;
void selectRowInternal (int rowNumber, bool dontScrollToShowThisRow,
@@ -320,12 +320,12 @@ public:
{
if (notification != dontSendNotification)
{
owner.valueChanged();
if (notification == sendNotificationSync)
handleAsyncUpdate();
else
triggerAsyncUpdate();
owner.valueChanged();
}
}
@@ -464,9 +464,9 @@ public:
const bool stopAtEnd)
{
// make sure the values are sensible..
jassert (rotaryStart >= 0 && rotaryEnd >= 0);
jassert (rotaryStart < float_Pi * 4.0f && rotaryEnd < float_Pi * 4.0f);
jassert (rotaryStart < rotaryEnd);
jassert (startAngleRadians >= 0 && endAngleRadians >= 0);
jassert (startAngleRadians < float_Pi * 4.0f && endAngleRadians < float_Pi * 4.0f);
jassert (startAngleRadians < endAngleRadians);
rotaryStart = startAngleRadians;
rotaryEnd = endAngleRadians;
@@ -566,6 +566,7 @@ public:
valueBox->setWantsKeyboardFocus (false);
valueBox->setText (previousTextBoxContent, dontSendNotification);
valueBox->setTooltip (owner.getTooltip());
if (valueBox->isEditable() != editableText) // (avoid overriding the single/double click flags unless we have to)
valueBox->setEditable (editableText && owner.isEnabled());
@@ -577,10 +578,6 @@ public:
valueBox->addMouseListener (&owner, false);
valueBox->setMouseCursor (MouseCursor::ParentCursor);
}
else
{
valueBox->setTooltip (owner.getTooltip());
}
}
else
{
@@ -667,7 +664,7 @@ public:
if (isTwoValue || isThreeValue)
{
const float mousePos = (float) (isVertical() ? e.y : e.x);
const float mousePos = isVertical() ? e.position.y : e.position.x;
const float normalPosDistance = std::abs (getLinearSliderPos (currentValue.getValue()) - mousePos);
const float minPosDistance = std::abs (getLinearSliderPos (valueMin.getValue()) - 0.1f - mousePos);
@@ -689,10 +686,10 @@ public:
//==============================================================================
void handleRotaryDrag (const MouseEvent& e)
{
const int dx = e.x - sliderRect.getCentreX();
const int dy = e.y - sliderRect.getCentreY();
const float dx = e.position.x - sliderRect.getCentreX();
const float dy = e.position.y - sliderRect.getCentreY();
if (dx * dx + dy * dy > 25)
if (dx * dx + dy * dy > 25.0f)
{
double angle = std::atan2 ((double) dx, (double) -dy);
while (angle < 0.0)
@@ -736,7 +733,7 @@ public:
void handleAbsoluteDrag (const MouseEvent& e)
{
const int mousePos = (isHorizontal() || style == RotaryHorizontalDrag) ? e.x : e.y;
const float mousePos = (isHorizontal() || style == RotaryHorizontalDrag) ? e.position.x : e.position.y;
double newPos = (mousePos - sliderRegionStart) / (double) sliderRegionSize;
if (style == RotaryHorizontalDrag
@@ -745,12 +742,12 @@ public:
|| ((style == LinearHorizontal || style == LinearVertical || style == LinearBar || style == LinearBarVertical)
&& ! snapsToMousePos))
{
const int mouseDiff = (style == RotaryHorizontalDrag
|| style == LinearHorizontal
|| style == LinearBar
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal()))
? e.x - mouseDragStartPos.x
: mouseDragStartPos.y - e.y;
const float mouseDiff = (style == RotaryHorizontalDrag
|| style == LinearHorizontal
|| style == LinearBar
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal()))
? e.position.x - mouseDragStartPos.x
: mouseDragStartPos.y - e.position.y;
newPos = owner.valueToProportionOfLength (valueOnMouseDown)
+ mouseDiff * (1.0 / pixelsForFullDragExtent);
@@ -763,7 +760,8 @@ public:
}
else if (style == RotaryHorizontalVerticalDrag)
{
const int mouseDiff = (e.x - mouseDragStartPos.x) + (mouseDragStartPos.y - e.y);
const float mouseDiff = (e.position.x - mouseDragStartPos.x)
+ (mouseDragStartPos.y - e.position.y);
newPos = owner.valueToProportionOfLength (valueOnMouseDown)
+ mouseDiff * (1.0 / pixelsForFullDragExtent);
@@ -779,16 +777,16 @@ public:
void handleVelocityDrag (const MouseEvent& e)
{
const int mouseDiff = style == RotaryHorizontalVerticalDrag
? (e.x - mousePosWhenLastDragged.x) + (mousePosWhenLastDragged.y - e.y)
: (isHorizontal()
|| style == RotaryHorizontalDrag
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal()))
? e.x - mousePosWhenLastDragged.x
: e.y - mousePosWhenLastDragged.y;
const float mouseDiff = style == RotaryHorizontalVerticalDrag
? (e.position.x - mousePosWhenLastDragged.x) + (mousePosWhenLastDragged.y - e.position.y)
: (isHorizontal()
|| style == RotaryHorizontalDrag
|| (style == IncDecButtons && incDecDragDirectionIsHorizontal()))
? e.position.x - mousePosWhenLastDragged.x
: e.position.y - mousePosWhenLastDragged.y;
const double maxSpeed = jmax (200, sliderRegionSize);
double speed = jlimit (0.0, maxSpeed, (double) abs (mouseDiff));
double speed = jlimit (0.0, maxSpeed, (double) std::abs (mouseDiff));
if (speed != 0)
{
@@ -816,7 +814,7 @@ public:
{
incDecDragged = false;
useDragEvents = false;
mouseDragStartPos = mousePosWhenLastDragged = e.getPosition();
mouseDragStartPos = mousePosWhenLastDragged = e.position;
currentDrag = nullptr;
if (owner.isEnabled())
@@ -887,7 +885,7 @@ public:
return;
incDecDragged = true;
mouseDragStartPos = e.getPosition();
mouseDragStartPos = e.position;
}
if (isAbsoluteDragMode (e.mods) || (maximum - minimum) / sliderRegionSize < interval)
@@ -930,7 +928,7 @@ public:
minMaxDiff = (double) valueMax.getValue() - (double) valueMin.getValue();
}
mousePosWhenLastDragged = e.getPosition();
mousePosWhenLastDragged = e.position;
}
}
@@ -980,29 +978,45 @@ public:
}
}
double getMouseWheelDelta (double value, double wheelAmount)
{
if (style == IncDecButtons)
return interval * wheelAmount;
const double proportionDelta = wheelAmount * 0.15f;
const double currentPos = owner.valueToProportionOfLength (value);
return owner.proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta)) - value;
}
bool mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& wheel)
{
if (scrollWheelEnabled
&& style != TwoValueHorizontal
&& style != TwoValueVertical)
{
if (maximum > minimum && ! e.mods.isAnyMouseButtonDown())
// sometimes duplicate wheel events seem to be sent, so since we're going to
// bump the value by a minimum of the interval, avoid doing this twice..
if (e.eventTime != lastMouseWheelTime)
{
if (valueBox != nullptr)
valueBox->hideEditor (false);
lastMouseWheelTime = e.eventTime;
const double value = (double) currentValue.getValue();
const double proportionDelta = (wheel.deltaX != 0 ? -wheel.deltaX : wheel.deltaY)
* (wheel.isReversed ? -0.15f : 0.15f);
const double currentPos = owner.valueToProportionOfLength (value);
const double newValue = owner.proportionOfLengthToValue (jlimit (0.0, 1.0, currentPos + proportionDelta));
if (maximum > minimum && ! e.mods.isAnyMouseButtonDown())
{
if (valueBox != nullptr)
valueBox->hideEditor (false);
double delta = (newValue != value) ? jmax (std::abs (newValue - value), interval) : 0;
if (value > newValue)
delta = -delta;
const double value = (double) currentValue.getValue();
const double delta = getMouseWheelDelta (value, (std::abs (wheel.deltaX) > std::abs (wheel.deltaY)
? -wheel.deltaX : wheel.deltaY)
* (wheel.isReversed ? -1.0f : 1.0f));
if (delta != 0)
{
const double newValue = value + jmax (interval, std::abs (delta)) * (delta < 0 ? -1.0 : 1.0);
DragInProgress drag (*this);
setValue (owner.snapValue (value + delta, notDragging), sendNotificationSync);
DragInProgress drag (*this);
setValue (owner.snapValue (newValue, notDragging), sendNotificationSync);
}
}
}
return true;
@@ -1036,29 +1050,29 @@ public:
const double pos = sliderBeingDragged == 2 ? getMaxValue()
: (sliderBeingDragged == 1 ? getMinValue()
: (double) currentValue.getValue());
Point<int> mousePos;
Point<float> mousePos;
if (isRotary())
{
mousePos = mi->getLastMouseDownPosition();
const int delta = roundToInt (pixelsForFullDragExtent * (owner.valueToProportionOfLength (valueOnMouseDown)
- owner.valueToProportionOfLength (pos)));
const float delta = (float) (pixelsForFullDragExtent * (owner.valueToProportionOfLength (valueOnMouseDown)
- owner.valueToProportionOfLength (pos)));
if (style == RotaryHorizontalDrag) mousePos += Point<int> (-delta, 0);
else if (style == RotaryVerticalDrag) mousePos += Point<int> (0, delta);
else mousePos += Point<int> (delta / -2, delta / 2);
if (style == RotaryHorizontalDrag) mousePos += Point<float> (-delta, 0.0f);
else if (style == RotaryVerticalDrag) mousePos += Point<float> (0.0f, delta);
else mousePos += Point<float> (delta / -2.0f, delta / 2.0f);
mousePos = owner.getScreenBounds().reduced (4).getConstrainedPoint (mousePos);
mousePos = owner.getScreenBounds().reduced (4).toFloat().getConstrainedPoint (mousePos);
mouseDragStartPos = mousePosWhenLastDragged = owner.getLocalPoint (nullptr, mousePos);
valueOnMouseDown = valueWhenLastDragged;
}
else
{
const int pixelPos = (int) getLinearSliderPos (pos);
const float pixelPos = (float) getLinearSliderPos (pos);
mousePos = owner.localPointToGlobal (Point<int> (isHorizontal() ? pixelPos : (owner.getWidth() / 2),
isVertical() ? pixelPos : (owner.getHeight() / 2)));
mousePos = owner.localPointToGlobal (Point<float> (isHorizontal() ? pixelPos : (owner.getWidth() / 2.0f),
isVertical() ? pixelPos : (owner.getHeight() / 2.0f)));
}
mi->setScreenPosition (mousePos);
@@ -1231,10 +1245,11 @@ public:
double velocityModeSensitivity, velocityModeOffset, minMaxDiff;
int velocityModeThreshold;
float rotaryStart, rotaryEnd;
Point<int> mouseDragStartPos, mousePosWhenLastDragged;
Point<float> mouseDragStartPos, mousePosWhenLastDragged;
int sliderRegionStart, sliderRegionSize;
int sliderBeingDragged;
int pixelsForFullDragExtent;
Time lastMouseWheelTime;
Rectangle<int> sliderRect;
ScopedPointer<DragInProgress> currentDrag;
@@ -1272,6 +1287,7 @@ public:
{
setAlwaysOnTop (true);
setAllowedPlacement (owner.getLookAndFeel().getSliderPopupPlacement (s));
setLookAndFeel (&s.getLookAndFeel());
}
void paintContent (Graphics& g, int w, int h)
@@ -623,7 +623,7 @@ void TableHeaderComponent::mouseDrag (const MouseEvent& e)
minWidthOnRight += columns.getUnchecked (i)->minimumWidth;
const Rectangle<int> currentPos (getColumnPosition (getIndexOfColumnId (columnIdBeingResized, true)));
w = jmax (ci->minimumWidth, jmin (w, getWidth() - minWidthOnRight - currentPos.getX()));
w = jmax (ci->minimumWidth, jmin (w, lastDeliberateWidth - minWidthOnRight - currentPos.getX()));
}
setColumnWidth (columnIdBeingResized, w);
@@ -26,7 +26,7 @@ class TableListBox::RowComp : public Component,
public TooltipClient
{
public:
RowComp (TableListBox& tlb) : owner (tlb), row (-1), isSelected (false)
RowComp (TableListBox& tlb) noexcept : owner (tlb), row (-1), isSelected (false)
{
}
@@ -192,7 +192,7 @@ public:
if (TableListBoxModel* m = owner.getModel())
return m->getCellTooltip (row, columnId);
return String::empty;
return String();
}
Component* findChildComponentForColumn (const int columnId) const
@@ -275,7 +275,7 @@ void TableListBox::setHeader (TableHeaderComponent* newHeader)
{
jassert (newHeader != nullptr); // you need to supply a real header for a table!
Rectangle<int> newBounds (0, 0, 100, 28);
Rectangle<int> newBounds (100, 28);
if (header != nullptr)
newBounds = header->getBounds();
@@ -287,7 +287,7 @@ void TableListBox::setHeader (TableHeaderComponent* newHeader)
header->addListener (this);
}
int TableListBox::getHeaderHeight() const
int TableListBox::getHeaderHeight() const noexcept
{
return header->getHeight();
}
@@ -312,16 +312,11 @@ void TableListBox::autoSizeAllColumns()
autoSizeColumn (header->getColumnIdOfIndex (i, true));
}
void TableListBox::setAutoSizeMenuOptionShown (const bool shouldBeShown)
void TableListBox::setAutoSizeMenuOptionShown (const bool shouldBeShown) noexcept
{
autoSizeOptionsShown = shouldBeShown;
}
bool TableListBox::isAutoSizeMenuOptionShown() const
{
return autoSizeOptionsShown;
}
Rectangle<int> TableListBox::getCellPosition (const int columnId, const int rowNumber,
const bool relativeToComponentTopLeft) const
{
@@ -337,7 +332,7 @@ Rectangle<int> TableListBox::getCellPosition (const int columnId, const int rowN
Component* TableListBox::getCellComponent (int columnId, int rowNumber) const
{
if (RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (rowNumber)))
if (RowComp* const rowComp = dynamic_cast<RowComp*> (getComponentForRowNumber (rowNumber)))
return rowComp->findChildComponentForColumn (columnId);
return nullptr;
@@ -370,12 +365,12 @@ void TableListBox::paintListBoxItem (int, Graphics&, int, int, bool)
{
}
Component* TableListBox::refreshComponentForRow (int rowNumber, bool isRowSelected_, Component* existingComponentToUpdate)
Component* TableListBox::refreshComponentForRow (int rowNumber, bool rowSelected, Component* existingComponentToUpdate)
{
if (existingComponentToUpdate == nullptr)
existingComponentToUpdate = new RowComp (*this);
static_cast <RowComp*> (existingComponentToUpdate)->update (rowNumber, isRowSelected_);
static_cast<RowComp*> (existingComponentToUpdate)->update (rowNumber, rowSelected);
return existingComponentToUpdate;
}
@@ -398,10 +393,10 @@ void TableListBox::returnKeyPressed (int row)
model->returnKeyPressed (row);
}
void TableListBox::backgroundClicked()
void TableListBox::backgroundClicked (const MouseEvent& e)
{
if (model != nullptr)
model->backgroundClicked();
model->backgroundClicked (e);
}
void TableListBox::listWasScrolled()
@@ -450,14 +445,14 @@ void TableListBox::updateColumnComponents() const
const int firstRow = getRowContainingPosition (0, 0);
for (int i = firstRow + getNumRowsOnScreen() + 2; --i >= firstRow;)
if (RowComp* const rowComp = dynamic_cast <RowComp*> (getComponentForRowNumber (i)))
if (RowComp* const rowComp = dynamic_cast<RowComp*> (getComponentForRowNumber (i)))
rowComp->resized();
}
//==============================================================================
void TableListBoxModel::cellClicked (int, int, const MouseEvent&) {}
void TableListBoxModel::cellDoubleClicked (int, int, const MouseEvent&) {}
void TableListBoxModel::backgroundClicked() {}
void TableListBoxModel::backgroundClicked (const MouseEvent&) {}
void TableListBoxModel::sortOrderChanged (int, const bool) {}
int TableListBoxModel::getColumnAutoSizeWidth (int) { return 0; }
void TableListBoxModel::selectedRowsChanged (int) {}
@@ -465,7 +460,7 @@ void TableListBoxModel::deleteKeyPressed (int) {}
void TableListBoxModel::returnKeyPressed (int) {}
void TableListBoxModel::listWasScrolled() {}
String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String::empty; }
String TableListBoxModel::getCellTooltip (int /*rowNumber*/, int /*columnId*/) { return String(); }
var TableListBoxModel::getDragSourceDescription (const SparseSet<int>&) { return var(); }
Component* TableListBoxModel::refreshComponentForCell (int, int, bool, Component* existingComponentToUpdate)
@@ -57,7 +57,7 @@ public:
The graphics context has its origin at the row's top-left, and your method
should fill the area specified by the width and height parameters.
*/
virtual void paintRowBackground (Graphics& g,
virtual void paintRowBackground (Graphics&,
int rowNumber,
int width, int height,
bool rowIsSelected) = 0;
@@ -66,8 +66,11 @@ public:
The graphics context's origin will already be set to the top-left of the cell,
whose size is specified by (width, height).
Note that the rowNumber value may be greater than the number of rows in your
list, so be careful that you don't assume it's less than getNumRows().
*/
virtual void paintCell (Graphics& g,
virtual void paintCell (Graphics&,
int rowNumber,
int columnId,
int width, int height,
@@ -103,21 +106,21 @@ public:
The mouse event's coordinates will be relative to the entire table row.
@see cellDoubleClicked, backgroundClicked
*/
virtual void cellClicked (int rowNumber, int columnId, const MouseEvent& e);
virtual void cellClicked (int rowNumber, int columnId, const MouseEvent&);
/** This callback is made when the user clicks on one of the cells in the table.
The mouse event's coordinates will be relative to the entire table row.
@see cellClicked, backgroundClicked
*/
virtual void cellDoubleClicked (int rowNumber, int columnId, const MouseEvent& e);
virtual void cellDoubleClicked (int rowNumber, int columnId, const MouseEvent&);
/** This can be overridden to react to the user double-clicking on a part of the list where
there are no rows.
@see cellClicked
*/
virtual void backgroundClicked();
virtual void backgroundClicked (const MouseEvent&);
//==============================================================================
/** This callback is made when the table's sort order is changed.
@@ -142,25 +145,21 @@ public:
*/
virtual int getColumnAutoSizeWidth (int columnId);
/** Returns a tooltip for a particular cell in the table.
*/
/** Returns a tooltip for a particular cell in the table. */
virtual String getCellTooltip (int rowNumber, int columnId);
//==============================================================================
/** Override this to be informed when rows are selected or deselected.
@see ListBox::selectedRowsChanged()
*/
virtual void selectedRowsChanged (int lastRowSelected);
/** Override this to be informed when the delete key is pressed.
@see ListBox::deleteKeyPressed()
*/
virtual void deleteKeyPressed (int lastRowSelected);
/** Override this to be informed when the return key is pressed.
@see ListBox::returnKeyPressed()
*/
virtual void returnKeyPressed (int lastRowSelected);
@@ -182,6 +181,12 @@ public:
@see getDragSourceCustomData, DragAndDropContainer::startDragging
*/
virtual var getDragSourceDescription (const SparseSet<int>& currentlySelectedRows);
private:
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE
// This method's signature has changed to take a MouseEvent parameter - please update your code!
JUCE_DEPRECATED_WITH_BODY (virtual int backgroundClicked(), { return 0; })
#endif
};
@@ -204,29 +209,34 @@ public:
/** Creates a TableListBox.
The model pointer passed-in can be null, in which case you can set it later
with setModel().
with setModel(). The TableListBox does not take ownership of the model - it's
the caller's responsibility to manage its lifetime and make sure it
doesn't get deleted while still being used.
*/
TableListBox (const String& componentName = String::empty,
TableListBoxModel* model = 0);
TableListBox (const String& componentName = String(),
TableListBoxModel* model = nullptr);
/** Destructor. */
~TableListBox();
//==============================================================================
/** Changes the TableListBoxModel that is being used for this table.
The TableListBox does not take ownership of the model - it's the caller's responsibility
to manage its lifetime and make sure it doesn't get deleted while still being used.
*/
void setModel (TableListBoxModel* newModel);
/** Returns the model currently in use. */
TableListBoxModel* getModel() const { return model; }
TableListBoxModel* getModel() const noexcept { return model; }
//==============================================================================
/** Returns the header component being used in this table. */
TableHeaderComponent& getHeader() const { return *header; }
TableHeaderComponent& getHeader() const noexcept { return *header; }
/** Sets the header component to use for the table.
The table will take ownership of the component that you pass in, and will delete it
when it's no longer needed.
The pointer passed in may not be null.
*/
void setHeader (TableHeaderComponent* newHeader);
@@ -238,7 +248,7 @@ public:
/** Returns the height of the table header.
@see setHeaderHeight
*/
int getHeaderHeight() const;
int getHeaderHeight() const noexcept;
//==============================================================================
/** Resizes a column to fit its contents.
@@ -254,15 +264,14 @@ public:
void autoSizeAllColumns();
/** Enables or disables the auto size options on the popup menu.
By default, these are enabled.
*/
void setAutoSizeMenuOptionShown (bool shouldBeShown);
void setAutoSizeMenuOptionShown (bool shouldBeShown) noexcept;
/** True if the auto-size options should be shown on the menu.
@see setAutoSizeMenuOptionsShown
@see setAutoSizeMenuOptionShown
*/
bool isAutoSizeMenuOptionShown() const;
bool isAutoSizeMenuOptionShown() const noexcept { return autoSizeOptionsShown; }
/** Returns the position of one of the cells in the table.
@@ -303,7 +312,7 @@ public:
/** @internal */
void returnKeyPressed (int currentSelectedRow) override;
/** @internal */
void backgroundClicked() override;
void backgroundClicked (const MouseEvent&) override;
/** @internal */
void listWasScrolled() override;
/** @internal */
@@ -1931,7 +1931,7 @@ bool TextEditor::deleteBackwards (bool moveInWholeWordSteps)
if (moveInWholeWordSteps)
moveCaretTo (findWordBreakBefore (getCaretPosition()), true);
else if (selection.isEmpty() && selection.getStart() > 0)
selection.setStart (selection.getEnd() - 1);
selection = Range<int> (selection.getEnd() - 1, selection.getEnd());
cut();
return true;
@@ -1940,7 +1940,7 @@ bool TextEditor::deleteBackwards (bool moveInWholeWordSteps)
bool TextEditor::deleteForwards (bool /*moveInWholeWordSteps*/)
{
if (selection.isEmpty() && selection.getStart() < getTotalNumChars())
selection.setEnd (selection.getStart() + 1);
selection = Range<int> (selection.getStart(), selection.getStart() + 1);
cut();
return true;
@@ -2059,7 +2059,7 @@ void TextEditor::focusGained (FocusChangeType)
if (ComponentPeer* const peer = getPeer())
if (! isReadOnly())
peer->textInputRequired (peer->globalToLocal (getScreenPosition()));
peer->textInputRequired (peer->globalToLocal (getScreenPosition()), *this);
}
void TextEditor::focusLost (FocusChangeType)
@@ -568,6 +568,9 @@ public:
*/
void setInputFilter (InputFilter* newFilter, bool takeOwnership);
/** Returns the current InputFilter, as set by setInputFilter(). */
InputFilter* getInputFilter() const noexcept { return inputFilter; }
/** Sets limits on the characters that can be entered.
This is just a shortcut that passes an instance of the LengthAndCharacterRestriction
class to setInputFilter().
@@ -591,8 +591,8 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{
const Rectangle<int> previousPos (animator.getComponentDestination (prev));
if (abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX())
< abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight()))))
if (std::abs (dragObjectLeft - (vertical ? previousPos.getY() : previousPos.getX()))
< std::abs (dragObjectRight - (vertical ? current.getBottom() : current.getRight())))
{
newIndex = getIndexOfChildComponent (prev);
}
@@ -602,8 +602,8 @@ void Toolbar::itemDragMove (const SourceDetails& dragSourceDetails)
{
const Rectangle<int> nextPos (animator.getComponentDestination (next));
if (abs (dragObjectLeft - (vertical ? current.getY() : current.getX())
> abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight()))))
if (std::abs (dragObjectLeft - (vertical ? current.getY() : current.getX()))
> std::abs (dragObjectRight - (vertical ? nextPos.getBottom() : nextPos.getRight())))
{
newIndex = getIndexOfChildComponent (next) + 1;
}
@@ -67,7 +67,7 @@ public:
selectBasedOnModifiers (item, e.mods);
if (e.x >= pos.getX())
item->itemClicked (e.withNewPosition (e.getPosition() - pos.getPosition()));
item->itemClicked (e.withNewPosition (e.position - pos.getPosition().toFloat()));
}
}
}
@@ -92,7 +92,7 @@ public:
Rectangle<int> pos;
if (TreeViewItem* const item = findItemAt (e.y, pos))
if (e.x >= pos.getX() || ! owner.openCloseButtonsVisible)
item->itemDoubleClicked (e.withNewPosition (e.getPosition() - pos.getPosition()));
item->itemDoubleClicked (e.withNewPosition (e.position - pos.getPosition().toFloat()));
}
}
@@ -1773,6 +1773,11 @@ TreeViewItem* TreeViewItem::getNextVisibleItem (const bool recurse) const noexce
return nullptr;
}
static String escapeSlashesInTreeViewItemName (const String& s)
{
return s.replaceCharacter ('/', '\\');
}
String TreeViewItem::getItemIdentifierString() const
{
String s;
@@ -1780,12 +1785,12 @@ String TreeViewItem::getItemIdentifierString() const
if (parentItem != nullptr)
s = parentItem->getItemIdentifierString();
return s + "/" + getUniqueName().replaceCharacter ('/', '\\');
return s + "/" + escapeSlashesInTreeViewItemName (getUniqueName());
}
TreeViewItem* TreeViewItem::findItemFromIdentifierString (const String& identifierString)
{
const String thisId ("/" + getUniqueName());
const String thisId ("/" + escapeSlashesInTreeViewItemName (getUniqueName()));
if (thisId == identifierString)
return this;
@@ -744,7 +744,7 @@ public:
void setIndentSize (int newIndentSize);
/** Searches the tree for an item with the specified identifier.
The identifer string must have been created by calling TreeViewItem::getItemIdentifierString().
The identifier string must have been created by calling TreeViewItem::getItemIdentifierString().
If no such item exists, this will return false. If the item is found, all of its items
will be automatically opened.
*/