Move editor UI into the app and release verified Core dependencies (#14)
Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
This commit was merged in pull request #14.
This commit is contained in:
1 parent
abc1868550
commit
06f1c26681
452 files changed
+43806
-2329
No files matched your search
@@ -0,0 +1,226 @@
|
||||
import 'package:cutdex/l10n/l10n.dart';
|
||||
import 'package:cutdex_core/editor.dart';
|
||||
import 'package:cutdex_ui/theme.dart';
|
||||
import 'package:cutdex_ui/widgets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widget_previews.dart';
|
||||
import 'package:cutdex_core/timeline/model.dart';
|
||||
import 'package:cutdex_core/timeline/engine.dart';
|
||||
|
||||
import 'property_keyframe_controls.dart';
|
||||
import 'property_color_input.dart';
|
||||
import 'property_number_input.dart';
|
||||
|
||||
class StrokeParameterEditor extends StatelessWidget {
|
||||
const StrokeParameterEditor({
|
||||
super.key,
|
||||
required this.layer,
|
||||
required this.stack,
|
||||
required this.enabled,
|
||||
required this.editContext,
|
||||
required this.keyframes,
|
||||
required this.onChange,
|
||||
});
|
||||
final ClipStrokeLayer layer;
|
||||
final ClipStrokeStack stack;
|
||||
final bool enabled;
|
||||
final Object editContext;
|
||||
final PropertyKeyframeControls keyframes;
|
||||
final Future<bool> Function(Map<String, double>) onChange;
|
||||
|
||||
String _fieldLabel(BuildContext context, String field) => switch (field) {
|
||||
'width' => context.l10n.strokeWidth,
|
||||
'opacity' => context.l10n.shadowOpacity,
|
||||
'dashLength' => context.l10n.strokeDashLength,
|
||||
'dashGap' => context.l10n.strokeDashGap,
|
||||
_ => field,
|
||||
};
|
||||
Widget _number(BuildContext context, String field) {
|
||||
final label = _fieldLabel(context, field);
|
||||
final structural = StrokeParameterTarget.structural.contains(field);
|
||||
final percentage = {
|
||||
'opacity',
|
||||
'density',
|
||||
'lightIntensity',
|
||||
'splay',
|
||||
}.contains(field);
|
||||
final factor = percentage ? 100.0 : 1.0;
|
||||
final definition = StrokeParameterTarget.definition(field);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PropertyNumberInput(
|
||||
key: ValueKey('stroke-${layer.id}-$field'),
|
||||
label: label,
|
||||
value: layer.values[field]! * factor,
|
||||
unit: percentage ? '%' : null,
|
||||
enabled: enabled && layer.enabled,
|
||||
readOnly: false,
|
||||
scrubbing: false,
|
||||
editContext: (editContext, layer.id),
|
||||
onScrubUpdate: (_) {},
|
||||
onScrubEnd: () {},
|
||||
onScrubCancel: () {},
|
||||
submit: (v) => !definition.accepts(v / factor)
|
||||
? Future.value(false)
|
||||
: onChange({field: v / factor}),
|
||||
),
|
||||
),
|
||||
if (!structural) ...[
|
||||
keyframes.button(
|
||||
context,
|
||||
[layer.target(field)],
|
||||
label,
|
||||
'stroke-${layer.id}-$field-key',
|
||||
),
|
||||
keyframes.menu(
|
||||
context,
|
||||
[layer.target(field)],
|
||||
label,
|
||||
'stroke-${layer.id}-$field',
|
||||
),
|
||||
] else
|
||||
const SizedBox(width: 48),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _color(BuildContext context, String prefix, String label) {
|
||||
final fields = ['${prefix}r', '${prefix}g', '${prefix}b'];
|
||||
final values = fields.map((f) => layer.values[f]!).toList();
|
||||
final hex = values
|
||||
.map((v) => (v * 255).round().toRadixString(16).padLeft(2, '0'))
|
||||
.join()
|
||||
.toUpperCase();
|
||||
final ids = fields.map(layer.target).toList();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(label, style: AppTheme.propertyLabelStyle(context)),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PropertyColorInput(
|
||||
key: ValueKey('stroke-${layer.id}-$prefix'),
|
||||
value: hex,
|
||||
color: Color.from(
|
||||
alpha: 1,
|
||||
red: values[0],
|
||||
green: values[1],
|
||||
blue: values[2],
|
||||
),
|
||||
enabled: enabled && layer.enabled,
|
||||
editContext: (editContext, layer.id),
|
||||
submit: (rgb) => onChange({
|
||||
fields[0]: ((rgb >> 16) & 255) / 255,
|
||||
fields[1]: ((rgb >> 8) & 255) / 255,
|
||||
fields[2]: (rgb & 255) / 255,
|
||||
}),
|
||||
),
|
||||
),
|
||||
keyframes.button(
|
||||
context,
|
||||
ids,
|
||||
label,
|
||||
'stroke-${layer.id}-$prefix-key',
|
||||
),
|
||||
keyframes.menu(context, ids, label, 'stroke-${layer.id}-$prefix'),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _mode(BuildContext context, String field, List<String> labels) =>
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
child: AppSelect<int>(
|
||||
closeAncestors: false,
|
||||
key: ValueKey('stroke-${layer.id}-$field'),
|
||||
value: layer.values[field]!.round(),
|
||||
label: field == 'alignment'
|
||||
? context.l10n.alignment
|
||||
: context.l10n.strokeStyle,
|
||||
emptyLabel: context.l10n.strokes,
|
||||
options: [
|
||||
for (var i = 0; i < labels.length; i++)
|
||||
AppSelectOption(i, labels[i]),
|
||||
],
|
||||
onChanged: enabled && layer.enabled
|
||||
? (v) => onChange({field: v.toDouble()})
|
||||
: null,
|
||||
),
|
||||
),
|
||||
);
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_color(context, 'color.', context.l10n.color),
|
||||
_number(context, 'opacity'),
|
||||
_number(context, 'width'),
|
||||
_mode(context, 'alignment', [
|
||||
context.l10n.strokeInside,
|
||||
context.l10n.strokeCenter,
|
||||
context.l10n.strokeOutside,
|
||||
]),
|
||||
_mode(context, 'style', [
|
||||
context.l10n.strokeSolid,
|
||||
context.l10n.strokeDashed,
|
||||
]),
|
||||
if (layer.style == ClipStrokeStyle.dashed) ...[
|
||||
_number(context, 'dashLength'),
|
||||
_number(context, 'dashGap'),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@Preview(name: 'Stroke editor / desktop', size: Size(240, 360))
|
||||
Widget strokeEditorPreview() {
|
||||
final stack = ClipStrokeStack(
|
||||
ElementRecord(
|
||||
id: ElementId('preview'),
|
||||
structure: ElementStructure.content,
|
||||
duration: 1,
|
||||
sourceStart: 0,
|
||||
sourceDuration: 1,
|
||||
enabled: true,
|
||||
),
|
||||
0,
|
||||
);
|
||||
return MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
theme: AppTheme.propertiesPanelTheme(
|
||||
AppTheme.desktopWorkspaceTheme(AppTheme.penDark),
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: StrokeParameterEditor(
|
||||
layer: const ClipStrokeLayer(id: 'preview', values: strokeDefaults),
|
||||
stack: stack,
|
||||
enabled: true,
|
||||
editContext: 'preview',
|
||||
keyframes: PropertyKeyframeControls(
|
||||
stack: stack,
|
||||
enabled: true,
|
||||
onEdit: (ids, {action, interpolation}) async => true,
|
||||
onSeek: (_) async => true,
|
||||
),
|
||||
onChange: (_) async => true,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user