bank tags: invoke only the scrollbar update after removing separators
Invoking the tab separator removal allowed tab separators to be visible
and interactable for a frame. On slower computers, users could click and
navigate to a tab during that period. The removal no longer needs to be
invoked after e4b43d9 so we can just invoke the script run.
This commit is contained in:
@@ -505,69 +505,67 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allow time for the tab interface to become active
|
if (!tabInterface.isActive())
|
||||||
clientThread.invokeLater(() ->
|
|
||||||
{
|
{
|
||||||
if (!tabInterface.isActive())
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
|
||||||
|
if (itemContainer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int items = 0;
|
||||||
|
|
||||||
|
Widget[] containerChildren = itemContainer.getDynamicChildren();
|
||||||
|
|
||||||
|
// sort the child array as the items are not in the displayed order
|
||||||
|
Arrays.sort(containerChildren, Comparator.comparing(Widget::getOriginalY)
|
||||||
|
.thenComparing(Widget::getOriginalX));
|
||||||
|
|
||||||
|
for (Widget child : containerChildren)
|
||||||
|
{
|
||||||
|
if (child.getItemId() != -1 && !child.isHidden())
|
||||||
{
|
{
|
||||||
return;
|
// calculate correct item position as if this was a normal tab
|
||||||
}
|
int adjYOffset = (items / ITEMS_PER_ROW) * ITEM_VERTICAL_SPACING;
|
||||||
|
int adjXOffset = (items % ITEMS_PER_ROW) * ITEM_HORIZONTAL_SPACING + ITEM_ROW_START;
|
||||||
|
|
||||||
Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
|
if (child.getOriginalY() != adjYOffset)
|
||||||
if (itemContainer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int items = 0;
|
|
||||||
|
|
||||||
Widget[] containerChildren = itemContainer.getDynamicChildren();
|
|
||||||
|
|
||||||
// sort the child array as the items are not in the displayed order
|
|
||||||
Arrays.sort(containerChildren, Comparator.comparing(Widget::getOriginalY)
|
|
||||||
.thenComparing(Widget::getOriginalX));
|
|
||||||
|
|
||||||
for (Widget child : containerChildren)
|
|
||||||
{
|
|
||||||
if (child.getItemId() != -1 && !child.isHidden())
|
|
||||||
{
|
{
|
||||||
// calculate correct item position as if this was a normal tab
|
child.setOriginalY(adjYOffset);
|
||||||
int adjYOffset = (items / ITEMS_PER_ROW) * ITEM_VERTICAL_SPACING;
|
child.revalidate();
|
||||||
int adjXOffset = (items % ITEMS_PER_ROW) * ITEM_HORIZONTAL_SPACING + ITEM_ROW_START;
|
|
||||||
|
|
||||||
if (child.getOriginalY() != adjYOffset)
|
|
||||||
{
|
|
||||||
child.setOriginalY(adjYOffset);
|
|
||||||
child.revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (child.getOriginalX() != adjXOffset)
|
|
||||||
{
|
|
||||||
child.setOriginalX(adjXOffset);
|
|
||||||
child.revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
items++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// separator line or tab text
|
if (child.getOriginalX() != adjXOffset)
|
||||||
if (child.getSpriteId() == SpriteID.RESIZEABLE_MODE_SIDE_PANEL_BACKGROUND
|
|
||||||
|| child.getText().contains("Tab"))
|
|
||||||
{
|
{
|
||||||
child.setHidden(true);
|
child.setOriginalX(adjXOffset);
|
||||||
|
child.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
items++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int itemContainerHeight = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER).getHeight();
|
// separator line or tab text
|
||||||
// add a second row of height here to allow users to scroll down when the last row is partially visible
|
if (child.getSpriteId() == SpriteID.RESIZEABLE_MODE_SIDE_PANEL_BACKGROUND
|
||||||
int adjustedScrollHeight = (items / ITEMS_PER_ROW) * ITEM_VERTICAL_SPACING + ITEM_VERTICAL_SPACING;
|
|| child.getText().contains("Tab"))
|
||||||
itemContainer.setScrollHeight(Math.max(adjustedScrollHeight, itemContainerHeight));
|
{
|
||||||
|
child.setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int itemContainerHeight = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER).getHeight();
|
||||||
|
// add a second row of height here to allow users to scroll down when the last row is partially visible
|
||||||
|
int adjustedScrollHeight = (items / ITEMS_PER_ROW) * ITEM_VERTICAL_SPACING + ITEM_VERTICAL_SPACING;
|
||||||
|
itemContainer.setScrollHeight(Math.max(adjustedScrollHeight, itemContainerHeight));
|
||||||
|
|
||||||
|
clientThread.invokeLater(() ->
|
||||||
client.runScript(ScriptID.UPDATE_SCROLLBAR,
|
client.runScript(ScriptID.UPDATE_SCROLLBAR,
|
||||||
WidgetInfo.BANK_SCROLLBAR.getId(),
|
WidgetInfo.BANK_SCROLLBAR.getId(),
|
||||||
WidgetInfo.BANK_ITEM_CONTAINER.getId(),
|
WidgetInfo.BANK_ITEM_CONTAINER.getId(),
|
||||||
0);
|
0));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user