Faster loading XP Widgets, file loading heleprs and XP widget resetting

This commit is contained in:
downthecrop 2025-08-19 23:56:25 -07:00
parent 7f09263209
commit 7cc56d0e53
5 changed files with 255 additions and 99 deletions

View file

@ -70,6 +70,8 @@ object ReflectiveEditorView {
mainPanel = JPanel(cardLayout)
mainPanel.background = VIEW_BACKGROUND_COLOR
mainPanel.border = BorderFactory.createEmptyBorder(0, 0, 0, 0)
// Help minimize flicker during dynamic swaps
mainPanel.isDoubleBuffered = true
// Create the plugin list view
val pluginListView = createPluginListView()
@ -636,25 +638,35 @@ object ReflectiveEditorView {
}
fun addPlugins(reflectiveEditorView: JPanel) {
// Refresh the plugin list by recreating the plugin list view
// Remove the existing plugin list view
val existingListView = mainPanel.components.find { it.name == PLUGIN_LIST_VIEW }
if (existingListView != null) {
mainPanel.remove(existingListView)
// Ensure we run on the EDT; if not, reschedule and return
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater { addPlugins(reflectiveEditorView) }
return
}
// Batch updates to avoid intermediate repaints/flicker
mainPanel.ignoreRepaint = true
try {
// Remove the existing plugin list view if present
val existingListView = mainPanel.components.find { it.name == PLUGIN_LIST_VIEW }
if (existingListView != null) {
mainPanel.remove(existingListView)
}
// Create a new plugin list view off-EDT (already on EDT here) and add it
val pluginListView = createPluginListView()
pluginListView.name = PLUGIN_LIST_VIEW
mainPanel.add(pluginListView, PLUGIN_LIST_VIEW)
// Switch card after the new component is in place
cardLayout.show(mainPanel, PLUGIN_LIST_VIEW)
// Revalidate/repaint once at the end
mainPanel.revalidate()
mainPanel.repaint()
} finally {
mainPanel.ignoreRepaint = false
}
// Create a new plugin list view
val pluginListView = createPluginListView()
pluginListView.name = PLUGIN_LIST_VIEW
mainPanel.add(pluginListView, PLUGIN_LIST_VIEW)
// Revalidate and repaint the main panel
mainPanel.revalidate()
mainPanel.repaint()
// Show the plugin list view
cardLayout.show(mainPanel, PLUGIN_LIST_VIEW)
}
var customToolTipWindow: JWindow? = null
@ -753,4 +765,4 @@ object ReflectiveEditorView {
g2.fillRoundRect(x, y, width - 1, height - 1, radius, radius)
}
}
}
}