-
Notifications
You must be signed in to change notification settings - Fork 129
fix(windows): 收紧 Capsule 几何契约 #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Issue #142 Placeholder / 占位 | ||
|
|
||
| ## 中文摘要 | ||
|
|
||
| 本 PR 是 issue #142 的 draft 占位,专门跟踪 Windows Capsule 变形、失真与尺寸错位问题。 | ||
| 当前只保留问题边界、几何证据和后续修复准入条件,不引入业务逻辑改动。 | ||
|
|
||
| ## Scope / 范围 | ||
|
|
||
| - Capsule native window bounds | ||
| - visual pill metrics | ||
| - badge position | ||
| - Windows DPI / transparent window clipping | ||
|
|
||
| ## Evidence / 证据入口 | ||
|
|
||
| - `openless-all/app/src-tauri/src/lib.rs` | ||
| - `openless-all/app/src/components/Capsule.tsx` | ||
| - `openless-all/app/src/lib/capsuleLayout.ts` | ||
|
|
||
| ## Merge Rule / 合并规则 | ||
|
|
||
| - 仅当 issue #142 的几何对齐与 Windows smoke 验证完成后才允许从 draft 转为 ready。 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'; | |
| import { useTranslation } from 'react-i18next'; | ||
| import { detectOS, type OS } from './WindowChrome'; | ||
| import { | ||
| getCapsuleHostMetrics, | ||
| getCapsuleMessageLayout, | ||
| getCapsulePillMetrics, | ||
| } from '../lib/capsuleLayout'; | ||
|
|
@@ -259,11 +260,13 @@ function Pill({ os, state, level, insertedChars, message, onCancel, onConfirm }: | |
| export function Capsule() { | ||
| const { t } = useTranslation(); | ||
| const os = detectOS(); | ||
| const metrics = getCapsulePillMetrics(os); | ||
| const [translation, setTranslation] = useState<boolean>(false); | ||
| const hostMetrics = getCapsuleHostMetrics(os, translation); | ||
| const [state, setState] = useState<CapsuleState>(isTauri ? 'idle' : 'recording'); | ||
| const [level, setLevel] = useState<number>(isTauri ? 0 : 0.6); | ||
| const [insertedChars, setInsertedChars] = useState<number>(0); | ||
| const [message, setMessage] = useState<string | undefined>(); | ||
| const [translation, setTranslation] = useState<boolean>(false); | ||
|
|
||
| useEffect(() => { | ||
| if (!isTauri) return; | ||
|
|
@@ -309,7 +312,11 @@ export function Capsule() { | |
| position: 'relative', | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| justifyContent: os === 'win' ? 'flex-end' : 'center', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In this flex container, Useful? React with 👍 / 👎. |
||
| paddingTop: os === 'win' | ||
| ? Math.max(0, hostMetrics.height - metrics.height - hostMetrics.bottomInset) | ||
| : 0, | ||
| paddingBottom: os === 'win' ? hostMetrics.bottomInset : 0, | ||
| background: 'transparent', | ||
| animation: os === 'win' ? 'none' : 'capsule-in .22s cubic-bezier(.2,.9,.3,1.1)', | ||
| }} | ||
|
|
@@ -324,7 +331,7 @@ export function Capsule() { | |
| left: '50%', | ||
| // bottom = 50%(pill 中线)+ pill 半高 21px(capsuleLayout mac=42)+ 8px 间隔。 | ||
| // 只有翻译徽章可见时才需要额外高度;普通录音/转写状态由后端缩到 pill 本体,避免透明死区。 | ||
| bottom: 'calc(50% + 21px + 8px)', | ||
| bottom: `${hostMetrics.bottomInset + metrics.height + hostMetrics.badgeGap}px`, | ||
| transform: 'translateX(-50%)', | ||
| pointerEvents: 'none', | ||
| }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
yposition usescapsule_visual_height(translation_active), but on non-Windows that function is constant (42.0) whilecapsule_window_bounds(true)grows host height to110.0. This means translated state keeps the same top coordinate as non-translated state and drops the larger host 68px lower, so the window bottom no longer respects the prior 80pt clearance behavior on macOS/Linux. Non-Windows positioning should still account for the expanded host height.Useful? React with 👍 / 👎.