Skip to content

Commit

Permalink
Fix add dialog shows "No element" if there is only import search results
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Dec 13, 2024
1 parent d9f6b77 commit a55406a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
10 changes: 4 additions & 6 deletions app/lib/cubits/current_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
if (viewportSize != null) {
size *= resolution.multiplier;
}
final renderTransform = transform.improve(resolution, size / resolution.multiplier);
final renderTransform =
transform.improve(resolution, size / resolution.multiplier);
final viewChanged = cameraViewport.width != size.width.ceil() ||
cameraViewport.height != size.height.ceil() ||
cameraViewport.x != renderTransform.position.dx ||
Expand All @@ -545,7 +546,7 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
..addAll(renderers);
}
canvas.scale(ratio);

// Wait one frame
await Future.delayed(const Duration(milliseconds: 1));

Expand All @@ -563,7 +564,6 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
visibleElements: visibleElements,
)
: cameraViewport,
resolution: resolution,
renderBackground: false,
renderBaked: !reset,
renderBakedLayers: false,
Expand All @@ -574,7 +574,7 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
final imageWidth = (size.width * ratio).ceil();
final imageHeight = (size.height * ratio).ceil();

var newImage = await picture.toImage(imageWidth, imageHeight);
final newImage = await picture.toImage(imageWidth, imageHeight);

var currentRenderers = state.cameraViewport.unbakedElements;
if (reset) {
Expand Down Expand Up @@ -617,7 +617,6 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
info,
transform: renderTransform,
states: state.allRendererStates,
resolution: resolution,
cameraViewport: cameraViewport.unbake(
unbakedElements: visibleElements
.where((e) => belowLayers.contains(e.layer))
Expand All @@ -631,7 +630,6 @@ class CurrentIndexCubit extends Cubit<CurrentIndex> {
info,
transform: renderTransform,
states: state.allRendererStates,
resolution: resolution,
cameraViewport: cameraViewport.unbake(
unbakedElements: visibleElements
.where((e) => aboveLayers.contains(e.layer))
Expand Down
3 changes: 2 additions & 1 deletion app/lib/dialogs/import/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ class _AddDialogState extends State<AddDialog> {
if (tools.isEmpty &&
shapes.isEmpty &&
textures.isEmpty &&
actions.isEmpty)
actions.isEmpty &&
imports.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(
vertical: 64, horizontal: 16),
Expand Down
3 changes: 0 additions & 3 deletions app/lib/view_painter.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:math';

import 'package:butterfly/cubits/current_index.dart';
import 'package:butterfly/cubits/settings.dart';
import 'package:butterfly/helpers/rect.dart';
import 'package:butterfly/models/viewport.dart';
import 'package:butterfly/renderers/renderer.dart';
Expand Down Expand Up @@ -99,14 +98,12 @@ class ViewPainter extends CustomPainter {
final ColorScheme? colorScheme;
final Set<String> invisibleLayers;
final Map<String, RendererState> states;
final RenderResolution? resolution;

const ViewPainter(
this.document,
this.page,
this.info, {
this.currentArea,
this.resolution,
this.invisibleLayers = const {},
this.states = const {},
this.renderBackground = true,
Expand Down
1 change: 1 addition & 0 deletions metadata/en-US/changelogs/124.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Fix asset hash not correctly working with filenames
* Fix duplicated asset importing
* Fix aspect ratio label in area tool selection view
* Fix add dialog shows "No element" if there is only import search results
* Show git hash instead of version in web version
* Upgrade to flutter 3.27

Expand Down

0 comments on commit a55406a

Please sign in to comment.