只修列表:beginRender 改回复用同一个 Table(换新 ScrollPane 会抛 InvocationTargetException 导致列表渲染失败);invalidate 后再调 ScrollPane(boolean,boolean)=setForceScroll 让它按新内容高度重算可滚动范围
This commit is contained in:
1 parent
b8fe2f98d1
commit
320f537a60
1 file changed
+15
-12
@@ -524,19 +524,9 @@ public final class ObjectPanel {
|
||||
* 加/删行,它记的高度还是旧的 —— maxY 一直是 0,滚轮就滚不动(你看到的现象)。
|
||||
* 换一个新的 ScrollPane 最省事也最稳(只做这一件事,不改任何别的行为)。
|
||||
*/
|
||||
/** 每次渲染:清空列表里的旧行(复用同一个 Table / ScrollPane,避免换控件引起的异常)。 */
|
||||
private static void beginRender(State state) throws Exception {
|
||||
Object table = state.tableClass.getConstructor().newInstance();
|
||||
call(table, Obf.TABLE_TOP, new Class<?>[0], state.tableClass);
|
||||
call(table, Obf.TABLE_LEFT, new Class<?>[0], state.tableClass);
|
||||
Class<?> skinClass = Class.forName("com.badlogic.gdx.scenes.scene2d.ui.Skin", true, state.loader);
|
||||
Object scroll = state.scrollClass.getConstructor(state.actorClass, skinClass)
|
||||
.newInstance(table, state.skin);
|
||||
state.listTable = table;
|
||||
state.listScroll = scroll;
|
||||
if (state.listCell != null) {
|
||||
// Cell.setActor(Actor):把旧 ScrollPane 换成新的
|
||||
call(state.listCell, "D", new Class<?>[] {state.actorClass}, state.cellClass, scroll);
|
||||
}
|
||||
call(state.listTable, Obf.TABLE_CLEAR_CHILDREN, new Class<?>[0], void.class);
|
||||
state.logBlockStarted = false;
|
||||
}
|
||||
|
||||
@@ -551,6 +541,19 @@ public final class ObjectPanel {
|
||||
} catch (Throwable ignored) {
|
||||
// 同上
|
||||
}
|
||||
try {
|
||||
// ScrollPane.setForceScroll(boolean, boolean):让它按新的内容高度重算可滚动范围
|
||||
for (Method method : state.listScroll.getClass().getMethods()) {
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
if (types.length != 2 || types[0] != boolean.class || types[1] != boolean.class) continue;
|
||||
if (method.getReturnType() != void.class) continue;
|
||||
method.setAccessible(true);
|
||||
method.invoke(state.listScroll, Boolean.FALSE, Boolean.TRUE);
|
||||
break;
|
||||
}
|
||||
} catch (Throwable error) {
|
||||
System.err.println("[panel] 重算滚动范围失败: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user