|
|
|
@@ -157,7 +157,6 @@ public: |
|
|
|
|
|
|
|
Component* const content = new Component();
|
|
|
|
setViewedComponent (content);
|
|
|
|
content->addMouseListener (this, false);
|
|
|
|
content->setWantsKeyboardFocus (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -335,18 +334,42 @@ private: |
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListViewport)
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { defaultListRowHeight = 22 };
|
|
|
|
//==============================================================================
|
|
|
|
class ListBoxMouseMoveSelector : public MouseListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ListBoxMouseMoveSelector (ListBox& lb) : owner (lb)
|
|
|
|
{
|
|
|
|
owner.addMouseListener (this, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mouseMove (const MouseEvent& e)
|
|
|
|
{
|
|
|
|
const MouseEvent e2 (e.getEventRelativeTo (&owner));
|
|
|
|
owner.selectRow (owner.getRowContainingPosition (e2.x, e2.y), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mouseExit (const MouseEvent& e)
|
|
|
|
{
|
|
|
|
mouseMove (e);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
ListBox& owner;
|
|
|
|
|
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ListBoxMouseMoveSelector)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
ListBox::ListBox (const String& name, ListBoxModel* const m)
|
|
|
|
: Component (name),
|
|
|
|
model (m),
|
|
|
|
totalItems (0),
|
|
|
|
rowHeight (defaultListRowHeight),
|
|
|
|
rowHeight (22),
|
|
|
|
minimumRowWidth (0),
|
|
|
|
outlineThickness (0),
|
|
|
|
lastRowSelected (-1),
|
|
|
|
mouseMoveSelects (false),
|
|
|
|
multipleSelection (false),
|
|
|
|
hasDoneInitialUpdate (false)
|
|
|
|
{
|
|
|
|
@@ -379,10 +402,15 @@ void ListBox::setMultipleSelectionEnabled (bool b) |
|
|
|
|
|
|
|
void ListBox::setMouseMoveSelectsRows (bool b)
|
|
|
|
{
|
|
|
|
mouseMoveSelects = b;
|
|
|
|
|
|
|
|
if (b)
|
|
|
|
addMouseListener (this, true);
|
|
|
|
{
|
|
|
|
if (mouseMoveSelector == nullptr)
|
|
|
|
mouseMoveSelector = new ListBoxMouseMoveSelector (*this);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mouseMoveSelector = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
@@ -528,7 +556,7 @@ void ListBox::selectRangeOfRows (int firstRow, int lastRow) |
|
|
|
{
|
|
|
|
const int numRows = totalItems - 1;
|
|
|
|
firstRow = jlimit (0, jmax (0, numRows), firstRow);
|
|
|
|
lastRow = jlimit (0, jmax (0, numRows), lastRow);
|
|
|
|
lastRow = jlimit (0, jmax (0, numRows), lastRow);
|
|
|
|
|
|
|
|
selected.addRange (Range <int> (jmin (firstRow, lastRow),
|
|
|
|
jmax (firstRow, lastRow) + 1));
|
|
|
|
@@ -766,13 +794,13 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee |
|
|
|
{
|
|
|
|
bool eventWasUsed = false;
|
|
|
|
|
|
|
|
if (viewport->getHorizontalScrollBar()->isVisible() && wheel.deltaX != 0)
|
|
|
|
if (wheel.deltaX != 0 && viewport->getHorizontalScrollBar()->isVisible())
|
|
|
|
{
|
|
|
|
eventWasUsed = true;
|
|
|
|
viewport->getHorizontalScrollBar()->mouseWheelMove (e, wheel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewport->getVerticalScrollBar()->isVisible() && wheel.deltaY != 0)
|
|
|
|
if (wheel.deltaY != 0 && viewport->getVerticalScrollBar()->isVisible())
|
|
|
|
{
|
|
|
|
eventWasUsed = true;
|
|
|
|
viewport->getVerticalScrollBar()->mouseWheelMove (e, wheel);
|
|
|
|
@@ -782,20 +810,6 @@ void ListBox::mouseWheelMove (const MouseEvent& e, const MouseWheelDetails& whee |
|
|
|
Component::mouseWheelMove (e, wheel);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ListBox::mouseMove (const MouseEvent& e)
|
|
|
|
{
|
|
|
|
if (mouseMoveSelects)
|
|
|
|
{
|
|
|
|
const MouseEvent e2 (e.getEventRelativeTo (this));
|
|
|
|
selectRow (getRowContainingPosition (e2.x, e2.y), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ListBox::mouseExit (const MouseEvent& e)
|
|
|
|
{
|
|
|
|
mouseMove (e);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ListBox::mouseUp (const MouseEvent& e)
|
|
|
|
{
|
|
|
|
if (e.mouseWasClicked() && model != nullptr)
|
|
|
|
|