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,245 @@
|
||||
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 'property_keyframe_controls.dart';
|
||||
import 'effect_labels.dart';
|
||||
import 'property_color_input.dart';
|
||||
import 'property_number_input.dart';
|
||||
|
||||
class EffectParameterEditor extends StatelessWidget {
|
||||
const EffectParameterEditor({
|
||||
super.key,
|
||||
required this.layer,
|
||||
required this.stack,
|
||||
required this.enabled,
|
||||
required this.editContext,
|
||||
required this.keyframes,
|
||||
required this.onChange,
|
||||
required this.onTypeChange,
|
||||
});
|
||||
final ClipEffectLayer layer;
|
||||
final ClipEffectStack stack;
|
||||
final bool enabled;
|
||||
final Object editContext;
|
||||
final PropertyKeyframeControls keyframes;
|
||||
final Future<bool> Function(Map<String, double>) onChange;
|
||||
final void Function(ClipEffectType) onTypeChange;
|
||||
|
||||
String _fieldLabel(BuildContext context, String field) => switch (field) {
|
||||
'x' => 'X',
|
||||
'y' => 'Y',
|
||||
'blur' => context.l10n.shadowBlur,
|
||||
'spread' => context.l10n.shadowSpread,
|
||||
'opacity' => context.l10n.shadowOpacity,
|
||||
'blurEnd' => context.l10n.effectBlurEnd,
|
||||
'start.x' => context.l10n.effectStartX,
|
||||
'start.y' => context.l10n.effectStartY,
|
||||
'end.x' => context.l10n.effectEndX,
|
||||
'end.y' => context.l10n.effectEndY,
|
||||
'lightAngle' => context.l10n.effectLightAngle,
|
||||
'lightIntensity' => context.l10n.effectLightIntensity,
|
||||
'refraction' => context.l10n.effectRefraction,
|
||||
'depth' => context.l10n.effectDepth,
|
||||
'dispersion' => context.l10n.effectDispersion,
|
||||
'frost' => context.l10n.effectFrost,
|
||||
'splay' => context.l10n.effectSplay,
|
||||
'size' => context.l10n.effectNoiseSize,
|
||||
'density' => context.l10n.effectDensity,
|
||||
'radius' => context.l10n.effectTextureRadius,
|
||||
'seed' => context.l10n.effectSeed,
|
||||
_ => field,
|
||||
};
|
||||
Widget _number(BuildContext context, String field) {
|
||||
final label = _fieldLabel(context, field);
|
||||
final structural = EffectParameterTarget.structural.contains(field);
|
||||
final percentage = {
|
||||
'opacity',
|
||||
'density',
|
||||
'lightIntensity',
|
||||
'splay',
|
||||
}.contains(field);
|
||||
final factor = percentage ? 100.0 : 1.0;
|
||||
final definition = EffectParameterTarget.definition(field);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PropertyNumberInput(
|
||||
key: ValueKey('effect-${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, layer.type),
|
||||
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,
|
||||
'effect-${layer.id}-$field-key',
|
||||
),
|
||||
keyframes.menu(
|
||||
context,
|
||||
[layer.target(field)],
|
||||
label,
|
||||
'effect-${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('effect-${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, layer.type),
|
||||
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,
|
||||
'effect-${layer.id}-$prefix-key',
|
||||
),
|
||||
keyframes.menu(context, ids, label, 'effect-${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('effect-${layer.id}-$field'),
|
||||
value: layer.values[field]!.round(),
|
||||
label: field == 'noiseMode'
|
||||
? context.l10n.effectNoiseMode
|
||||
: context.l10n.shadowBlur,
|
||||
emptyLabel: context.l10n.effects,
|
||||
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: [
|
||||
SizedBox(
|
||||
height: 24,
|
||||
child: AppSelect<ClipEffectType>(
|
||||
closeAncestors: false,
|
||||
key: ValueKey('effect-${layer.id}-type'),
|
||||
value: layer.type,
|
||||
label: context.l10n.effects,
|
||||
emptyLabel: context.l10n.effects,
|
||||
options: [
|
||||
for (final type in ClipEffectType.values)
|
||||
if (stack.canAdd(type, excludingId: layer.id))
|
||||
AppSelectOption(type, type.label(context)),
|
||||
],
|
||||
onChanged: enabled ? onTypeChange : null,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (layer.values.containsKey('progressive'))
|
||||
_mode(context, 'progressive', [
|
||||
context.l10n.effectUniform,
|
||||
context.l10n.effectProgressive,
|
||||
]),
|
||||
if (layer.values.containsKey('noiseMode'))
|
||||
_mode(context, 'noiseMode', [
|
||||
context.l10n.effectMono,
|
||||
context.l10n.effectDuo,
|
||||
context.l10n.effectMulti,
|
||||
]),
|
||||
for (final field in layer.values.keys)
|
||||
if (!field.startsWith('color') &&
|
||||
!{'progressive', 'noiseMode', 'clipToShape'}.contains(field) &&
|
||||
!(layer.values['progressive'] == 0 &&
|
||||
{
|
||||
'blurEnd',
|
||||
'start.x',
|
||||
'start.y',
|
||||
'end.x',
|
||||
'end.y',
|
||||
}.contains(field)))
|
||||
_number(context, field),
|
||||
if (layer.values.containsKey('color.r') && layer.values['noiseMode'] != 2)
|
||||
_color(context, 'color.', context.l10n.color),
|
||||
if (layer.values['noiseMode'] == 1)
|
||||
_color(context, 'color2.', context.l10n.effectSecondColor),
|
||||
if (layer.values.containsKey('clipToShape'))
|
||||
CheckboxListTile(
|
||||
key: ValueKey('effect-${layer.id}-clipToShape'),
|
||||
dense: true,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
context.l10n.effectClipToShape,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
value: layer.values['clipToShape'] == 1,
|
||||
onChanged: enabled && layer.enabled
|
||||
? (v) => onChange({'clipToShape': v == true ? 1 : 0})
|
||||
: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user