Replies: 2 comments 1 reply
-
|
Great to hear you like my package!
Exampleconfigs: ProImageEditorConfigs(
layerInteraction: LayerInteractionConfigs(
widgets: LayerInteractionWidgets(
children: [
(rebuildStream, layer, interactions) => ReactiveWidget(
stream: rebuildStream,
builder: (_) => Positioned(
top: 0,
left: 0,
child: Transform.rotate(
angle: -layer.rotation,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Listener(
child: GestureDetector(
onTap: interactions.edit,
child: Tooltip(
message: 'Edit',
child: Container(
padding: const EdgeInsets.all(3),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(10 * 2),
color: Colors.white,
),
child: const Icon(
Icons.edit,
color: Colors.black,
size: 10 * 2,
),
),
),
),
),
),
)),
),
(rebuildStream, layer, interactions) => ReactiveWidget(
stream: rebuildStream,
builder: (_) => Positioned(
top: 0,
right: 0,
child: LayerInteractionButton(
rotation: -layer.rotation,
onTap: interactions.edit,
buttonRadius: 10,
cursor: SystemMouseCursors.click,
icon: Icons.clear,
tooltip: 'Remove',
color: Colors.black,
background: Colors.white,
),
),
),
(rebuildStream, layer, interactions) => ReactiveWidget(
stream: rebuildStream,
builder: (_) => Positioned(
bottom: 0,
left: 0,
child: LayerInteractionButton(
rotation: -layer.rotation,
onScaleRotateDown: interactions.scaleRotateDown,
onScaleRotateUp: interactions.scaleRotateUp,
buttonRadius: 10,
cursor: SystemMouseCursors.click,
icon: Icons.sync,
tooltip: 'Rotate and Scale',
color: Colors.black,
background: Colors.white,
),
),
),
],
),
),
),
final editor = editorKey.currentState!;
final sizeManager = editor.sizesManager;
print(sizeManager.decodedImageSize);Keep in mind that the editor needs a bit of time to decode the image and calculate all sizes. FYI: In version 10.0.0, the editor will get a major upgrade for layer selection, as it will then work with overlays. If you're already testing the prerelease |
Beta Was this translation helpful? Give feedback.
-
|
Your answer guided me well and far, thank you.
Edit: After more testing, this custom layer only appears after updating editor history, still unsure why though /// Prefill layers, called in `onAfterViewInit` callback.
/// The `bodySize` and `media.resolution` are used to calculate required layer scaling/offset.
/// I double checked its not the issue by disabling the calculation and setting the offset to (0,0)
/// The `media.layers` list children are all subtype of `Layer`.
void addInitialLayers(GeneratedMedia media) {
final bodySize = state.currentState!.sizesManager.bodySize;
final layers = media.layers
.map((layer) => layer.getLayer(bodySize, media.resolution))
.toList();
state.currentState!.stateManager.stateHistory[0].layers.addAll(layers);
state.currentState!.addHistory();
}class SvgLayer extends WidgetLayer {
SvgLayer({
required super.widget,
required this.url,
this.color,
super.offset,
super.rotation,
super.scale,
super.id,
super.flipX,
super.flipY,
super.interaction,
super.isDeleted,
super.meta,
super.boxConstraints,
}) : assert(widget is SvgPicture);
final String url;
final Color? color;
@override
SvgLayer copyWith({
Widget? widget,
String? url,
Color? color,
Offset? offset,
double? rotation,
double? scale,
String? id,
bool? flipX,
bool? flipY,
LayerInteraction? interaction,
WidgetLayerExportConfigs? exportConfigs,
}) {
return SvgLayer(
widget: widget ?? this.widget,
url: url ?? this.url,
color: color ?? this.color,
offset: offset ?? this.offset,
rotation: rotation ?? this.rotation,
scale: scale ?? this.scale,
id: id ?? this.id,
flipX: flipX ?? this.flipX,
flipY: flipY ?? this.flipY,
interaction: interaction ?? this.interaction,
);
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, and thanks for this great package!
I have multiple questions.
1. How can I open up SubEditor dialog for Layers other than TextLayer?
I want to be able to edit Widget layers, for example flipping or adding color filters to the layer.
Check the small images with the selection on Layers, Text layer has edit button, Widget layer doesn't.
2. How to customize the SubEditor widgets for any layer to add more custom options?
Check the image with the TextLayer SubEditor.
For example:
3. I have programmatically added TextLayers to the corners and center of the screen using offset, but for the top and bottom it is not aligned correctly with the top of the image, how to address this? Is there a way to know the dimensions of the image for use in the offset params? Will it be perfect for shorter or longer images in width/height?
Beta Was this translation helpful? Give feedback.
All reactions