Browse Source

Fix for ListBox::getRowNumberOfComponent

tags/2021-05-28
jules 10 years ago
parent
commit
898080d187
1 changed files with 10 additions and 8 deletions
  1. +10
    -8
      modules/juce_gui_basics/widgets/juce_ListBox.cpp

+ 10
- 8
modules/juce_gui_basics/widgets/juce_ListBox.cpp View File

@@ -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());
}


Loading…
Cancel
Save