Merge pull request #445 from orz12/feat-danmaku-strokewidth

feat: 新增弹幕描边粗细设置,默认值降低
This commit is contained in:
guozhigq
2024-01-27 13:25:28 +08:00
committed by GitHub
4 changed files with 51 additions and 1 deletions

View File

@ -35,6 +35,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
late double opacityVal;
late double fontSizeVal;
late double danmakuDurationVal;
late double strokeWidth;
int latestAddedPosition = -1;
@override
@ -65,6 +66,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
showArea = playerController.showArea;
opacityVal = playerController.opacityVal;
fontSizeVal = playerController.fontSizeVal;
strokeWidth = playerController.strokeWidth;
danmakuDurationVal = playerController.danmakuDurationVal;
}
@ -136,6 +138,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
hideBottom: blockTypes.contains(4),
duration:
danmakuDurationVal / playerController.playbackSpeed,
strokeWidth: strokeWidth,
// initDuration /
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
),

View File

@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:math';
import 'package:floating/floating.dart';
import 'package:flutter/material.dart';
@ -724,6 +725,8 @@ class _HeaderControlState extends State<HeaderControl> {
double fontSizeVal = widget.controller!.fontSizeVal;
// 弹幕速度
double danmakuDurationVal = widget.controller!.danmakuDurationVal;
// 弹幕描边
double strokeWidth = widget.controller!.strokeWidth;
final DanmakuController danmakuController =
widget.controller!.danmakuController!;
@ -857,6 +860,44 @@ class _HeaderControlState extends State<HeaderControl> {
),
),
),
Text('描边粗细 $strokeWidth'),
Padding(
padding: const EdgeInsets.only(
top: 0,
bottom: 6,
left: 10,
right: 10,
),
child: SliderTheme(
data: SliderThemeData(
trackShape: MSliderTrackShape(),
thumbColor: Theme.of(context).colorScheme.primary,
activeTrackColor: Theme.of(context).colorScheme.primary,
trackHeight: 10,
thumbShape: const RoundSliderThumbShape(
enabledThumbRadius: 6.0),
),
child: Slider(
min: 0,
max: 3,
value: strokeWidth,
divisions: 6,
label: '$strokeWidth',
onChanged: (double val) {
strokeWidth = val;
widget.controller!.strokeWidth = val;
setState(() {});
try {
final DanmakuOption currentOption =
danmakuController.option;
final DanmakuOption updatedOption =
currentOption.copyWith(strokeWidth: val);
danmakuController.updateOption(updatedOption);
} catch (_) {}
},
),
),
),
Text('字体大小 ${(fontSizeVal * 100).toStringAsFixed(1)}%'),
Padding(
padding: const EdgeInsets.only(