中段高度自适应父容器:middle = 父容器高(fillParent 前读到的 dock) − 按钮段 − 日志段(不用 expand);3 次迭代收敛
This commit is contained in:
1 parent
8a1279bf5c
commit
77d6a91422
1 file changed
+43
@@ -51,6 +51,7 @@ public final class ObjectPanel {
|
|||||||
Object target;
|
Object target;
|
||||||
Object root;
|
Object root;
|
||||||
Object content;
|
Object content;
|
||||||
|
Object buttons;
|
||||||
boolean scrollFocusLogged;
|
boolean scrollFocusLogged;
|
||||||
boolean geometryDumped;
|
boolean geometryDumped;
|
||||||
Class<?> tableClass;
|
Class<?> tableClass;
|
||||||
@@ -151,6 +152,7 @@ public final class ObjectPanel {
|
|||||||
System.err.println("[panel] 设置中段高度失败: " + error);
|
System.err.println("[panel] 设置中段高度失败: " + error);
|
||||||
}
|
}
|
||||||
state.listCell = cell;
|
state.listCell = cell;
|
||||||
|
state.buttons = buttons;
|
||||||
call(root, Obf.TABLE_ROW, new Class<?>[0], cellClass);
|
call(root, Obf.TABLE_ROW, new Class<?>[0], cellClass);
|
||||||
Object logCell = call(root, Obf.TABLE_ADD, new Class<?>[] {actorClass}, cellClass, state.status);
|
Object logCell = call(root, Obf.TABLE_ADD, new Class<?>[] {actorClass}, cellClass, state.status);
|
||||||
// 下段 = 日志:只占它需要的高度(1~6 行),贴在面板最下面
|
// 下段 = 日志:只占它需要的高度(1~6 行),贴在面板最下面
|
||||||
@@ -213,6 +215,47 @@ public final class ObjectPanel {
|
|||||||
} catch (Throwable error) {
|
} catch (Throwable error) {
|
||||||
System.err.println("[panel] 开启描边失败: " + error);
|
System.err.println("[panel] 开启描边失败: " + error);
|
||||||
}
|
}
|
||||||
|
// 中段高度 = **父容器(停靠框)高度** − 按钮段 − 日志段(不用 expand)。
|
||||||
|
// 父容器:根表格的 getParent()(载荷里是"无参、返回 Actor/Group 类型"的那个方法)。
|
||||||
|
Thread fit = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Object parent = null;
|
||||||
|
for (Method m : state.root.getClass().getMethods()) {
|
||||||
|
if (m.getParameterTypes().length != 0) continue;
|
||||||
|
String ret = m.getReturnType().getName();
|
||||||
|
if (!ret.equals(Obf.ACTOR) && !ret.equals(Obf.GROUP)) continue;
|
||||||
|
m.setAccessible(true);
|
||||||
|
Object value = m.invoke(state.root);
|
||||||
|
if (value != null) {
|
||||||
|
parent = value;
|
||||||
|
System.err.println("[panel] 面板父容器 = " + value.getClass().getName()
|
||||||
|
+ " via " + m.getDeclaringClass().getName() + "." + m.getName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int pass = 0; pass < 3; pass++) {
|
||||||
|
Thread.sleep(500);
|
||||||
|
float dockHeight = parent == null ? floatOf(state.root, "init") : floatOf(parent, "init");
|
||||||
|
float buttonsHeight = floatOf(state.buttons, "init");
|
||||||
|
float logHeight = floatOf(state.status, "init");
|
||||||
|
float middle = dockHeight - buttonsHeight - logHeight - 12f;
|
||||||
|
if (middle < 120f) middle = 120f;
|
||||||
|
call(state.listCell, "I", new Class<?>[] {float.class}, state.cellClass,
|
||||||
|
Float.valueOf(middle));
|
||||||
|
call(state.root, "b_", new Class<?>[0], void.class);
|
||||||
|
call(state.listScroll, "b_", new Class<?>[0], void.class);
|
||||||
|
System.err.println("[panel] pass" + pass + " dock=" + dockHeight + " buttons="
|
||||||
|
+ buttonsHeight + " log=" + logHeight + " -> middle=" + middle);
|
||||||
|
}
|
||||||
|
} catch (Throwable error) {
|
||||||
|
System.err.println("[panel] 自适应中段高度失败: " + error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "spineview-fit-middle");
|
||||||
|
fit.setDaemon(true);
|
||||||
|
fit.start();
|
||||||
System.err.println("[panel] 增删改查面板已建好");
|
System.err.println("[panel] 增删改查面板已建好");
|
||||||
refreshList(state);
|
refreshList(state);
|
||||||
return root;
|
return root;
|
||||||
|
|||||||
Reference in new issue
Block a user