Skip to content

GUI:按屏幕尺寸自适应的简约布局,及几个 bug 修复 - #12

Open
Evsio0n wants to merge 5 commits into
BigfootACA:masterfrom
Evsio0n:responsive-minimal
Open

Evsio0n wants to merge 5 commits into
BigfootACA:masterfrom
Evsio0n:responsive-minimal

Conversation

@Evsio0n

@Evsio0n Evsio0n commented Nov 28, 2026

Copy link
Copy Markdown

概要

把 GUI 的布局从「按 DPI 分档」改成「按屏幕可用尺寸(dp)计算」,手机竖屏/横屏、平板、PC 共用一套规则;同时把视觉换成更简约的单色风格。另外附带几个独立的 bug 修复(各自单独提交,可以单独 cherry-pick)。

截图

改前是 master 原版、改后是本分支,都是 SDL2 在同分辨率、同 DPI 下实际运行的截图。

OnePlus 8 竖屏(1080×2400 @402dpi)

OnePlus 8 横屏(2400×1080 @402dpi)

平板横屏(2560×1600 @320dpi)

PC(1920×1080 @140dpi)

小屏(480×854 @240dpi)和平板竖屏(1600×2560 @320dpi)

UEFI AArch64(QEMU virt):开机菜单、桌面、电源菜单

手机没有配置 DPI 时(自动估算)

提交

  1. libs: lvgl: lv_txt.h — _lv_txt_is_break_char() 一直返回 true,英文标签会在单词中间断行(Partition Ma / nager)。现在英文只在空格和标点处断行,中日韩字符照旧可以逐字断行。
  2. main: dump.c — dump_size() 少传了 prefix 参数,%s 读到野指针。在 QEMU AArch64 上 SimpleInitMain 一启动就 Synchronous Exception(AsciiStrLen)。
  3. gui: engine — XML 里解析出来的颜色 alpha 为 0,32 位色深下全部画成黑色;border-side 被当成渐变方向解析;颜色值支持 ? 开头的 lua 表达式(和坐标一样)。
  4. gui: drivers: sdl2.c — 调试用:GUISIZE=WxH 指定任意窗口大小,GUIDPI=N 指定 DPI。
  5. gui: responsive minimal layout — 主要改动,见下。

主要改动

尺寸

  • 新增 src/gui/metrics.c:dp = dpi / 160;按宽度分级(窄 < 600dp、中 < 840dp、宽),横屏且高度 < 480dp 为「矮」;安全区和挖孔来自 gui.safe_area、gui.cutout。
  • 字号按 dp 连续计算(正文 16dp、小字 12dp,另加 24dp 标题字体),不再按 DPI 跳档。
  • DPI:原来 gui.dpi 会被驱动默认值覆盖(只有 gui.dpi_force 生效)。现在优先级是 dpi_force > gui.dpi > 驱动 > 自动估算 > 默认值。没有任何 DPI 配置时,19:9 以上比例的屏幕按短边约 400dp 估算。

界面

  • 状态栏/导航栏:去掉底色;时钟避开挖孔;导航只留返回、主页、电源,有输入框时才出现键盘键;矮横屏改为右侧导航栏。
  • 桌面:列数按可用宽度计算(窄 3–5、中 ≤ 8、宽 ≤ 10,格宽 ≤ 140dp 并居中),一页放得下就不分页,多页显示页点;图标改用自带的 Font Awesome 单色字形。
  • 电源菜单(gui/reboot.xml):窄屏竖屏为底部面板,其余尺寸为居中小卡片,纯文字选项,不再截断。
  • 开机菜单:所有尺寸都是居中单栏,窄屏竖屏贴底部;默认深色;倒数显示为「项目名 … N s」加细进度条。
  • 文件管理:标签页改为数字;工具栏改为固定大小的字形按钮,窄屏只留 6 个常用键 + 「更多」;宽屏两个窗格并排(1–2 / 3–4)。
  • 公共按钮、列表项、对话框:浅色底、无边框;对话框宽度 280–440dp,不再从 dpi * 2 起。
  • 主题主色改为黑/灰,红色只用于关机等危险操作。

字体

  • default.ttf 改为 wqy-microhei.ttc(同版本 0.2.0-beta,同许可),界面用其中的比例字面,终端用同一文件里的等宽字面(FT_FONT_FACE(n) 选择 TTC 字面)。rootfs 增加约 0.7MB。

新配置项(都有默认值,不配置也能用)

键 默认 说明
gui.cutout 无 挖孔圆 "x,y,半径"(像素,当前方向)
gui.safe_area 无 额外安全边距 "左,上,右,下"(像素)
gui.dpi_auto true 没有配置 DPI 时按屏幕比例估算
gui.nav_rail true 矮横屏使用侧边导航栏
gui.launcher.glyph true 桌面使用单色字形图标,false 保留原图片图标
gui.bootmenu.dark true 开机菜单深色
gui.font_size 无 手动指定正文字号(像素)

XML 中可用的 lua 函数:dp(n)、ui_sheet()、ui_short()、ui_color(name)。

测试

  • Linux(SDL2,-Werror):上面 6 组分辨率逐一截图;依次打开桌面上的各个 App,没有崩溃。
  • UEFI AArch64(edk2-stable202211,GCC 12,RELEASE)编译通过;在 QEMU virt(AAVMF)中实际启动,测试了开机菜单、按键导航、进入 Simple Init、电源菜单。
  • OnePlus 8 实机运行过 UEFI 版的开机菜单。

未测试:UEFI 的 X64 / ARM / IA32 编译,Linux 的 DRM / fbdev 驱动。

🤖 Generated with Claude Code

Evsio0n and others added 5 commits November 29, 2026 01:21
_lv_txt_is_break_char() always returned true, so every letter was a
break point and app labels wrapped in the middle of words
("Partition Ma / nager"). Break latin text only at LV_TXT_BREAK_CHARS,
and keep breaking anywhere in CJK text (U+2E80 and above), which has
no spaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dump_loaded_image() called dump_size() with a "%s" format but no
argument, so the logger read a garbage pointer. On QEMU AArch64
(edk2 virt firmware) this is a Synchronous Exception in AsciiStrLen
right after "image base:", before the GUI starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- color.c: parsed colors left the alpha channel at 0, so on 32 bit
  color depth every color from xml was drawn as black
- style_props.c: border-side was parsed as a gradient direction
- style_set_type.c: a color value starting with "?" is a lua
  expression that returns a color string, like coordinates already do

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For testing layouts on the desktop: GUISIZE=WxH picks any window size
(not only the builtin modes) and GUIDPI=N sets the reported dpi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lay the gui out by screen size in dp instead of by dpi steps, and
give it a quieter, monochrome look.

Sizes
- metrics.c: dp = dpi / 160, size classes by width (compact < 600dp,
  medium < 840dp, expanded), "short" for landscape under 480dp,
  safe area and display cutout from gui.safe_area and gui.cutout
- font sizes follow dp (body 16dp, small 12dp) plus a 24dp title font
- dpi: gui.dpi was overwritten by the driver default; now the order is
  dpi_force > gui.dpi > driver > guess > default. Without any dpi, a
  phone shaped panel (19:9 or taller) is guessed as 400dp wide
  (gui.dpi_auto = false turns this off)

Screens
- sysbar: no bar backgrounds, clock clear of the cutout, only back,
  home and power keys (keyboard key while a text input has focus),
  a side rail on short landscape screens
- launcher: columns from the usable width (3-5 / 8 / 10), rows from
  the height, one page when everything fits, page dots otherwise,
  monochrome glyph icons from the bundled Font Awesome
  (gui.launcher.glyph = false keeps the image icons)
- reboot menu: a bottom sheet on compact portrait screens, a small
  centered card elsewhere, text rows only
- boot menu: one centered column, at the bottom on compact portrait,
  dark by default (gui.bootmenu.dark), countdown with a thin bar
- file manager: numbered tabs, fixed size glyph tool buttons,
  six keys and "more" on compact screens, two panes on wide screens
- shared buttons, list items and dialogs: tonal, no frames; dialog
  width 280dp to 440dp instead of starting at dpi * 2

Fonts
- default.ttf is wqy-microhei.ttc (the proportional face) and
  terminals use the mono face of the same collection
  (FT_FONT_FACE selects a face of a collection)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant