Skip to content
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

Resolved #44: [MV3] 记住上一次全屏字幕视窗的位置 #75

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/features/jimaku/components/JimakuArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ function JimakuArea({ jimaku }: JimakuAreaProps): JSX.Element {

const shouldPutIntoLivePlayer = screenStatus !== 'normal' || isTheme

const [ dragState, setDragState ] = useState<{
x: number,
y: number,
width: string | number,
height: string | number
}>(() => ({ x: 100, y: -300, width: '50%', height: jimakuStyle.backgroundHeight }))

const rmbState = jimakuStyle.rememberDragState

return (
<Fragment>
<Teleport container={rootContainer}>
Expand All @@ -114,12 +123,19 @@ function JimakuArea({ jimaku }: JimakuAreaProps): JSX.Element {
minHeight={100}
minWidth={200}
scale={0.93}
default={{
x: 100,
y: -300,
width: '50%',
height: jimakuStyle.backgroundHeight,
onDragStop={(e, d) => {
if (!rmbState) return
setDragState(state => ({ ...state, x: d.x, y: d.y }))
}}
onResizeStop={(e, direction, ref, delta, position) => {
if (!rmbState) return
setDragState({
width: ref.style.width,
height: ref.style.height,
...position
})
}}
default={dragState}
>
<JimakuList
jimaku={jimaku}
Expand Down
10 changes: 9 additions & 1 deletion src/settings/features/jimaku/components/JimakuFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type JimakuSchema = {
backgroundOpacity: HundredNumber
filterUserLevel: number
areaDragBoundary: boolean
rememberDragState: boolean
}


Expand All @@ -36,7 +37,8 @@ export const jimakuDefaultSettings: Readonly<JimakuSchema> = {
backgroundColor: '#808080',
backgroundOpacity: 40,
filterUserLevel: 0,
areaDragBoundary: false
areaDragBoundary: false,
rememberDragState: true
}

function JimakuFragment({ state, useHandler }: StateProxy<JimakuSchema>): JSX.Element {
Expand Down Expand Up @@ -121,6 +123,12 @@ function JimakuFragment({ state, useHandler }: StateProxy<JimakuSchema>): JSX.El
onChange={bool('areaDragBoundary')}
value={state.areaDragBoundary}
/>
<SwitchListItem
label="记住全屏时字幕背景的拖拽位置和缩放"
hint="刷新页面后,状态依然会被重设"
onChange={bool('rememberDragState')}
value={state.rememberDragState}
/>
</List>
</Fragment>
)
Expand Down
Loading