diff --git a/viewpanel/run.sh b/viewpanel/run.sh index bfc7032..2f2253e 100755 --- a/viewpanel/run.sh +++ b/viewpanel/run.sh @@ -37,6 +37,7 @@ cmd = [jx, "-Dspine.payload=" + pay, "-Dspine.resources=" + here + "/resources", "-Dspine.compat=" + here + "/compat-classes", + "-Dpanel.h=" + (os.environ.get("PANEL_H") or "984"), "-Dspine.classes=" + here + "/build/classes", "-Duser.home=" + root + "/spine-lab/home", "-cp", here + "/build/classes:" + root + "/tools/asm/asm.jar:" + root + "/tools/asm/asm-tree.jar", diff --git a/viewpanel/src/com/spineview/ObjectPanel.java b/viewpanel/src/com/spineview/ObjectPanel.java index 3603c4b..1d4fe06 100644 --- a/viewpanel/src/com/spineview/ObjectPanel.java +++ b/viewpanel/src/com/spineview/ObjectPanel.java @@ -135,6 +135,7 @@ public final class ObjectPanel { // 上段:按钮块(自适应高度,紧贴顶部) Object cell = call(root, Obf.TABLE_ADD, new Class[] {actorClass}, cellClass, buttons); layoutCell(cell, Obf.CELL_LEFT, Obf.CELL_FILL_X); + final Object buttonsCell = cell; call(root, Obf.TABLE_ROW, new Class[0], cellClass); // 上/中/下 = 根表格的**三个单元格**(这样 setDebug 画出来就是三条带): // 上 = 按钮块(已经在上面加过) @@ -215,47 +216,20 @@ public final class ObjectPanel { } catch (Throwable 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(); + // 三段高度按用户要求:上 20% / 中 60% / 下 20%(不用 expand)。 + // 面板高度取实测值 984(见日志 pass0 dock=984),换算 = 197 / 590 / 197。 + // 面板高度:默认取实测值 984(本机逻辑高度),可用 -Dpanel.h=<像素> 覆盖(4K/不同窗口大小用)。 + final float PANEL_H = Float.parseFloat(System.getProperty("panel.h", "984")); + try { + call(buttonsCell, "I", new Class[] {float.class}, cellClass, + Float.valueOf(PANEL_H * 0.20f)); + call(cell, "I", new Class[] {float.class}, cellClass, Float.valueOf(PANEL_H * 0.60f)); + call(logCell, "I", new Class[] {float.class}, cellClass, Float.valueOf(PANEL_H * 0.20f)); + System.err.println("[panel] 三段高度: " + (PANEL_H * 0.20f) + " / " + (PANEL_H * 0.60f) + + " / " + (PANEL_H * 0.20f)); + } catch (Throwable error) { + System.err.println("[panel] 设置三段高度失败: " + error); + } System.err.println("[panel] 增删改查面板已建好"); refreshList(state); return root;