1) 输入框现在是无边框纯色块,视觉上不像可交互区域。
给 7 套皮肤全部 105 个 Edit 显式写上 bordersize="1",
dark 皮肤的边框色从 #FF474755(71,71,85,压在 #2A2A33 上像黑边)
提亮到 #FF565672(86,86,114)—— 看得见是边框,但不刺眼。
注意这次是皮肤里真的有了边框,CaptureBorders 会如实记下 1,
聚焦 2px / 失焦还原 1px,不会再出现上次那种「凭空多一圈」的问题。
2) skins_v4.h 的来路理清
文件头原来写着「由 gen_skins_v4.py 生成,不要手改」,但那个脚本的
最终版已经丢了。现有副本(/tmp/skingen,tmpfs,重启即失)停在 11-23,
生成出来比仓库文件少 112 个 Button、少了 lblTitle —— 是更早的一版,
用它重生成会丢掉设备管理页/公告页之后的所有 UI 改动。
处理:
- skins_v4.h 头部改成「皮肤源文件,直接改这里」
- 三个历史脚本归档到 shell/duilib/scripts/legacy/*.obsolete
- 附 selector/legacy/README.md 说明为什么不能用、改完怎么编译替换
(/tmp 里的脚本本身没进版本控制,这次是从内存盘抢救出来的,
否则下次重启就彻底没了)
实测(wine 截图 + 视觉核对):输入框呈现「淡雅克制的灰色边框」,
可明确识别为输入区域;关闭按钮 × 位置大小均合适,无其他硬伤。
181 lines
9.3 KiB
Python
181 lines
9.3 KiB
Python
#!/usr/bin/env python3
|
||
"""生成 NIM DuiLib 壳用的 6 套皮肤:XML + 透明 PNG → C++ 头文件 skins_data.h"""
|
||
import os, io
|
||
|
||
PNG_DIR = "/tmp/skingen/out"
|
||
OUT_H = "/root/.hermes/cache/scratch/vfyshell/demo/skins_data.h"
|
||
SKIN_DIR = "/tmp/vfyskin" # 本地预览用(Wine 里直接指这里也行)
|
||
|
||
GLOBAL_XML = '''<?xml version="1.0" encoding="UTF-8"?>
|
||
<Global>
|
||
<Font id="f12" name="Microsoft YaHei UI" size="12" default="true"/>
|
||
<Font id="f13" name="Microsoft YaHei UI" size="13"/>
|
||
<Font id="f14" name="Microsoft YaHei UI" size="14"/>
|
||
<Font id="f18" name="Microsoft YaHei UI" size="18" bold="true"/>
|
||
<Font id="f22" name="Microsoft YaHei UI" size="22" bold="true"/>
|
||
<TextColor name="white" value="#FFFFFFFF"/>
|
||
<TextColor name="gray" value="#FF8A8A8A"/>
|
||
</Global>
|
||
'''
|
||
|
||
# ---------------- 纯 XML 皮肤(无图片) ----------------
|
||
DARK = '''<?xml version="1.0" encoding="UTF-8"?>
|
||
<Window size="470,330" caption="0,0,-1,40" mininfo="470,330" bkcolor="#FF1B1B1B">
|
||
<VBox bkcolor="#FF1B1B1B">
|
||
<HBox height="40" bkcolor="#FF252526">
|
||
<Label name="lblTitle" text="软件授权验证" textcolor="#FFE8E8E8" font="f14" padding="16,0,0,0" valign="center"/>
|
||
<Control />
|
||
<Button name="btnClose" width="40" height="40" text="X" textcolor="#FFCCCCCC" bkcolor="#FF252526" font="f14"/>
|
||
</HBox>
|
||
<VBox padding="26,18,26,16">
|
||
<Label name="lblApp" height="26" text="演示程序" textcolor="#FF7FB8E0" font="f18" valign="center"/>
|
||
<Label height="22" text="请输入卡密激活本机" textcolor="#FF9A9A9A" font="f12" valign="center"/>
|
||
<Control height="10"/>
|
||
<RichEdit name="editCard" height="38" bkcolor="#FF2D2D30" textcolor="#FFFFFFFF" font="f13" padding="10,0,0,0" valign="center"/>
|
||
<Control height="14"/>
|
||
<Button name="btnLogin" height="40" text="登 录" textcolor="#FFFFFFFF" bkcolor="#FF0E639C" font="f14"/>
|
||
<Label name="lblTip" height="22" margin="0,12,0,0" text="设备指纹:" textcolor="#FF8A8A8A" font="f12" valign="center"/>
|
||
</VBox>
|
||
</VBox>
|
||
</Window>
|
||
'''
|
||
|
||
LIGHT = '''<?xml version="1.0" encoding="UTF-8"?>
|
||
<Window size="470,330" caption="0,0,-1,40" mininfo="470,330" bkcolor="#FFF7F7F7">
|
||
<VBox bkcolor="#FFF7F7F7">
|
||
<HBox height="40" bkcolor="#FFFFFFFF">
|
||
<Label name="lblTitle" text="软件授权验证" textcolor="#FF1F1F1F" font="f14" padding="16,0,0,0" valign="center"/>
|
||
<Control />
|
||
<Button name="btnClose" width="40" height="40" text="X" textcolor="#FF666666" bkcolor="#FFFFFFFF" font="f14"/>
|
||
</HBox>
|
||
<VBox padding="26,18,26,16">
|
||
<Label name="lblApp" height="26" text="演示程序" textcolor="#FF0067B8" font="f18" valign="center"/>
|
||
<Label height="22" text="请输入卡密激活本机" textcolor="#FF666666" font="f12" valign="center"/>
|
||
<Control height="10"/>
|
||
<RichEdit name="editCard" height="38" bkcolor="#FFFFFFFF" textcolor="#FF1F1F1F" font="f13" padding="10,0,0,0" valign="center"/>
|
||
<Control height="14"/>
|
||
<Button name="btnLogin" height="40" text="登录" textcolor="#FFFFFFFF" bkcolor="#FF0078D4" font="f14"/>
|
||
<Label name="lblTip" height="22" margin="0,12,0,0" text="设备指纹:" textcolor="#FF8A8A8A" font="f12" valign="center"/>
|
||
</VBox>
|
||
</VBox>
|
||
</Window>
|
||
'''
|
||
|
||
INDUSTRIAL = '''<?xml version="1.0" encoding="UTF-8"?>
|
||
<Window size="520,350" caption="0,0,-1,44" mininfo="520,350" bkcolor="#FF0A1622">
|
||
<VBox bkcolor="#FF0A1622">
|
||
<HBox height="44" bkcolor="#FF113250">
|
||
<Label name="lblTitle" text="DEVICE AUTHORIZATION" textcolor="#FF7FD1FF" font="f14" padding="16,0,0,0" valign="center"/>
|
||
<Control />
|
||
<Button name="btnClose" width="44" height="44" text="X" textcolor="#FFBEE3FF" bkcolor="#FF113250" font="f14"/>
|
||
</HBox>
|
||
<VBox padding="28,20,28,18">
|
||
<Label name="lblApp" height="26" text="演示程序 / DEVICE LICENSING" textcolor="#FF6FA8C8" font="f18" valign="center"/>
|
||
<Control height="12"/>
|
||
<HBox height="42" bkcolor="#FF0E2438">
|
||
<Label width="64" text="卡密" textcolor="#FF8FC4E6" font="f13" padding="12,0,0,0" valign="center"/>
|
||
<RichEdit name="editCard" textcolor="#FFFFFFFF" bkcolor="#FF0E2438" font="f13" valign="center"/>
|
||
</HBox>
|
||
<Control height="16"/>
|
||
<HBox height="44">
|
||
<Button name="btnLogin" text="激活本机" textcolor="#FFFFFFFF" bkcolor="#FF1F6FB2" font="f14"/>
|
||
<Control width="12"/>
|
||
<Button name="btnQuit" text="退出" textcolor="#FFBEE3FF" bkcolor="#FF22384F" font="f14"/>
|
||
</HBox>
|
||
<Label name="lblTip" height="22" margin="0,12,0,0" text="设备指纹:" textcolor="#FF5F89A6" font="f12" valign="center"/>
|
||
</VBox>
|
||
</VBox>
|
||
</Window>
|
||
'''
|
||
|
||
# ---------------- PNG 皮肤(整窗像素 alpha) ----------------
|
||
def png_skin(theme, title, title_color, app_color, tip_color, prompt, btn_text, btn_color, has_quit, title_font="f14"):
|
||
quit_btn = ('<Control width="10"/>\n <Button name="btnQuit" width="120" height="44" text="退出" '
|
||
'textcolor="#FFD8D8D8" bkcolor="#33FFFFFF" font="f13"/>') if has_quit else ""
|
||
return f'''<?xml version="1.0" encoding="UTF-8"?>
|
||
<Window size="520,356" caption="0,0,520,46" mininfo="520,356" bktrans="true" bkimage="file='{theme}_bg.png'">
|
||
<VBox>
|
||
<HBox height="46">
|
||
<Label name="lblTitle" text="{title}" textcolor="{title_color}" font="{title_font}" padding="20,0,0,0" valign="center"/>
|
||
<Control />
|
||
<Button name="btnClose" width="34" height="22" margin="0,12,16,0" bkimage="file='{theme}_close.png'"/>
|
||
</HBox>
|
||
<VBox padding="34,12,34,20">
|
||
<Label name="lblApp" height="28" text="演示程序" textcolor="{app_color}" font="f18" valign="center"/>
|
||
<Label height="20" text="{prompt}" textcolor="{tip_color}" font="f12" valign="center"/>
|
||
<Control height="12"/>
|
||
<RichEdit name="editCard" height="42" bkimage="file='{theme}_edit.png'" textcolor="#FFFFFFFF" font="f13" padding="12,0,0,0" valign="center"/>
|
||
<Control height="16"/>
|
||
<HBox height="44">
|
||
<Button name="btnLogin" width="240" height="44" text="{btn_text}" textcolor="{btn_color}" font="f14"
|
||
bkimage="file='{theme}_btn.png'" hotbkimage="file='{theme}_btn_hot.png'" pushedbkimage="file='{theme}_btn_down.png'"/>
|
||
{quit_btn}
|
||
</HBox>
|
||
<Label name="lblTip" height="22" margin="0,14,0,0" text="设备指纹:" textcolor="{tip_color}" font="f12" valign="center"/>
|
||
</VBox>
|
||
</VBox>
|
||
</Window>
|
||
'''
|
||
|
||
NEBULA = png_skin("nebula", "NEBULA · 授权验证", "#FFD9CCFF", "#FFB9A6FF", "#FF9C8FC7",
|
||
"请输入卡密激活本机", "激活授权", "#FFFFFFFF", True)
|
||
ONYX = png_skin("onyx", "ONYX · 授权验证", "#FFE6C55C", "#FFE6C55C", "#FF9C8A5A",
|
||
"请输入卡密激活本机", "激 活", "#FF12100A", True)
|
||
AURORA = png_skin("aurora", "AURORA · 授权验证", "#FFA8F0DC", "#FF7FF0CC", "#FF6FA898",
|
||
"请输入卡密激活本机", "激活授权", "#FF04231F", True)
|
||
|
||
THEMES = {
|
||
"dark": (DARK, []),
|
||
"light": (LIGHT, []),
|
||
"industrial": (INDUSTRIAL, []),
|
||
"nebula": (NEBULA, ["nebula_bg.png", "nebula_btn.png", "nebula_btn_hot.png", "nebula_btn_down.png", "nebula_edit.png", "nebula_close.png"]),
|
||
"onyx": (ONYX, ["onyx_bg.png", "onyx_btn.png", "onyx_btn_hot.png", "onyx_btn_down.png", "onyx_edit.png", "onyx_close.png"]),
|
||
"aurora": (AURORA, ["aurora_bg.png", "aurora_btn.png", "aurora_btn_hot.png", "aurora_btn_down.png", "aurora_edit.png", "aurora_close.png"]),
|
||
}
|
||
|
||
# ---------------- 输出 C++ 头 ----------------
|
||
files = [] # (name, bytes)
|
||
files.append(("global.xml", GLOBAL_XML.encode("utf-8")))
|
||
for theme, (xml, pngs) in THEMES.items():
|
||
files.append((f"{theme}.xml", xml.encode("utf-8")))
|
||
for p in pngs:
|
||
path = os.path.join(PNG_DIR, p)
|
||
if not os.path.exists(path):
|
||
raise SystemExit(f"缺图片: {path}")
|
||
files.append((p, open(path, "rb").read()))
|
||
|
||
def c_array(name, data):
|
||
lines = [f"static const unsigned char {name}[] = {{"]
|
||
for i in range(0, len(data), 20):
|
||
lines.append(" " + ",".join(str(b) for b in data[i:i+20]) + ",")
|
||
lines.append("};")
|
||
return "\n".join(lines)
|
||
|
||
with io.open(OUT_H, "w", encoding="utf-8") as f:
|
||
f.write("// 由 gen_skins.py 自动生成,不要手改\n")
|
||
f.write("#pragma once\n\n")
|
||
for idx, (name, data) in enumerate(files):
|
||
var = "s" + str(idx)
|
||
f.write(c_array(var, data) + "\n")
|
||
f.write(f"// {name} ({len(data)} B)\n\n")
|
||
f.write("struct SkinFile { const char *name; const unsigned char *data; unsigned int size; };\n")
|
||
f.write("static const SkinFile kSkins[] = {\n")
|
||
for idx, (name, data) in enumerate(files):
|
||
f.write(f' {{ "{name}", s{idx}, {len(data)} }},\n')
|
||
f.write(" { NULL, NULL, 0 },\n};\n\n")
|
||
f.write(f'static const char *kThemeList[] = {{ "dark","light","industrial","nebula","onyx","aurora", NULL }};\n')
|
||
|
||
# ---------------- 同时铺一份到本地目录,方便 Wine 里直接看 ----------------
|
||
for theme, (xml, pngs) in THEMES.items():
|
||
d = os.path.join(SKIN_DIR, theme)
|
||
os.makedirs(d, exist_ok=True)
|
||
open(os.path.join(d, "global.xml"), "w", encoding="utf-8").write(GLOBAL_XML)
|
||
open(os.path.join(d, theme + ".xml"), "w", encoding="utf-8").write(xml)
|
||
for p in pngs:
|
||
open(os.path.join(d, p), "wb").write(open(os.path.join(PNG_DIR, p), "rb").read())
|
||
|
||
total = sum(len(d) for _, d in files)
|
||
print(f"skins_data.h: {len(files)} 个文件 / {total/1024:.0f} KB")
|
||
for n, d in files:
|
||
print(f" {n:22s} {len(d):>7} B")
|