Java Code Examples for net.runelite.api.widgets.Widget#setScrollHeight()
The following examples show how to use
net.runelite.api.widgets.Widget#setScrollHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MusicPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateList(Widget musicList, String filter) { if (tracks == null) { tracks = Arrays.stream(musicList.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .collect(Collectors.toList()); } tracks.forEach(w -> w.setHidden(true)); Collection<Widget> relevantTracks = tracks.stream() .filter(w -> w.getText().toLowerCase().contains(filter)) .filter(w -> currentMusicFilter == MusicState.ALL || w.getTextColor() == currentMusicFilter.getColor()) .collect(Collectors.toList()); // Original music track list has a little offset int y = 3; for (Widget track : relevantTracks) { track.setHidden(false); track.setOriginalY(y); track.revalidate(); y += track.getHeight(); } y += 3; int newHeight = 0; if (musicList.getScrollHeight() > 0) { newHeight = (musicList.getScrollY() * y) / musicList.getScrollHeight(); } musicList.setScrollHeight(y); musicList.revalidateScroll(); client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.MUSIC_TRACK_SCROLLBAR.getId(), WidgetInfo.MUSIC_TRACK_LIST.getId(), newHeight ); }
Example 2
Source File: BronzeManPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateList(Widget collectionView, String filter) { if (itemEntries == null) { itemEntries = Arrays.stream(collectionView.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .collect(Collectors.toList()); } itemEntries.forEach(w -> w.setHidden(true)); Collection<Widget> matchingItems = itemEntries.stream() .filter(w -> w.getName().toLowerCase().contains(filter)) .collect(Collectors.toList()); int x = 0; int y = 0; for (Widget entry : matchingItems) { entry.setHidden(false); entry.setOriginalY(y); entry.setOriginalX(x); entry.revalidate(); x = x + 42; if (x > 210) { x = 0; y = y + 40; } } y += 3; int newHeight = 0; if (collectionView.getScrollHeight() > 0) { newHeight = (collectionView.getScrollY() * y) / collectionView.getScrollHeight(); } collectionView.setScrollHeight(y); collectionView.revalidateScroll(); Widget scrollbar = client.getWidget(COLLECTION_LOG_GROUP_ID, COLLECTION_VIEW_SCROLLBAR); client.runScript( ScriptID.UPDATE_SCROLLBAR, scrollbar.getId(), collectionView.getId(), newHeight ); }
Example 3
Source File: QuestListPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateFilter(String filter) { filter = filter.toLowerCase(); final Widget container = client.getWidget(WidgetInfo.QUESTLIST_CONTAINER); final Widget freeList = client.getWidget(QuestContainer.FREE_QUESTS.widgetInfo); final Widget memberList = client.getWidget(QuestContainer.MEMBER_QUESTS.widgetInfo); final Widget miniList = client.getWidget(QuestContainer.MINI_QUESTS.widgetInfo); if (container == null || freeList == null || memberList == null || miniList == null) { return; } updateList(QuestContainer.FREE_QUESTS, filter); updateList(QuestContainer.MEMBER_QUESTS, filter); updateList(QuestContainer.MINI_QUESTS, filter); memberList.setOriginalY(freeList.getOriginalY() + freeList.getOriginalHeight() + (freeList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING)); miniList.setOriginalY(memberList.getOriginalY() + memberList.getOriginalHeight() + (memberList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING)); // originalHeight is changed within updateList so revalidate all lists freeList.revalidate(); memberList.revalidate(); miniList.revalidate(); int y = miniList.getRelativeY() + miniList.getHeight() + 10; int newHeight; if (container.getScrollHeight() > 0) { newHeight = (container.getScrollY() * y) / container.getScrollHeight(); } else { newHeight = 0; } container.setScrollHeight(y); container.revalidateScroll(); clientThread.invokeLater(() -> client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.QUESTLIST_SCROLLBAR.getId(), WidgetInfo.QUESTLIST_CONTAINER.getId(), newHeight )); }
Example 4
Source File: MusicPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void updateList(Widget musicList, String filter) { if (tracks == null) { tracks = Arrays.stream(musicList.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .collect(Collectors.toList()); } tracks.forEach(w -> w.setHidden(true)); Collection<Widget> relevantTracks = tracks.stream() .filter(w -> w.getText().toLowerCase().contains(filter)) .filter(w -> currentMusicFilter == MusicState.ALL || w.getTextColor() == currentMusicFilter.getColor()) .collect(Collectors.toList()); // Original music track list has a little offset int y = 3; for (Widget track : relevantTracks) { track.setHidden(false); track.setOriginalY(y); track.revalidate(); y += track.getHeight(); } y += 3; int newHeight = 0; if (musicList.getScrollHeight() > 0) { newHeight = (musicList.getScrollY() * y) / musicList.getScrollHeight(); } musicList.setScrollHeight(y); musicList.revalidateScroll(); client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.MUSIC_TRACK_SCROLLBAR.getId(), WidgetInfo.MUSIC_TRACK_LIST.getId(), newHeight ); }
Example 5
Source File: QuestListPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void updateFilter(String filter) { filter = filter.toLowerCase(); final Widget container = client.getWidget(WidgetInfo.QUESTLIST_CONTAINER); final Widget freeList = client.getWidget(QuestContainer.FREE_QUESTS.widgetInfo); final Widget memberList = client.getWidget(QuestContainer.MEMBER_QUESTS.widgetInfo); final Widget miniList = client.getWidget(QuestContainer.MINI_QUESTS.widgetInfo); if (container == null || freeList == null || memberList == null || miniList == null) { return; } updateList(QuestContainer.FREE_QUESTS, filter); updateList(QuestContainer.MEMBER_QUESTS, filter); updateList(QuestContainer.MINI_QUESTS, filter); memberList.setOriginalY(freeList.getOriginalY() + freeList.getOriginalHeight() + ENTRY_PADDING); miniList.setOriginalY(memberList.getOriginalY() + memberList.getOriginalHeight() + ENTRY_PADDING); // originalHeight is changed within updateList so revalidate all lists freeList.revalidate(); memberList.revalidate(); miniList.revalidate(); int y = miniList.getRelativeY() + miniList.getHeight() + 10; int newHeight; if (container.getScrollHeight() > 0) { newHeight = (container.getScrollY() * y) / container.getScrollHeight(); } else { newHeight = 0; } container.setScrollHeight(y); container.revalidateScroll(); clientThread.invokeLater(() -> client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.QUESTLIST_SCROLLBAR.getId(), WidgetInfo.QUESTLIST_CONTAINER.getId(), newHeight )); }