Skip to content

Commit

Permalink
debug: viewer tile display flag
Browse files Browse the repository at this point in the history
  • Loading branch information
deckerst committed Jan 21, 2025
1 parent 0575a6c commit b282d0a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/model/settings/modules/debug.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:aves_model/aves_model.dart';

mixin DebugSettings on SettingsAccess {
bool get debugShowViewerTiles => getBool(SettingKeys.debugShowViewerTilesKey) ?? false;

set debugShowViewerTiles(bool newValue) => set(SettingKeys.debugShowViewerTilesKey, newValue);
}
3 changes: 2 additions & 1 deletion lib/model/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:aves/model/settings/enums/accessibility_animations.dart';
import 'package:aves/model/settings/enums/map_style.dart';
import 'package:aves/model/settings/modules/app.dart';
import 'package:aves/model/settings/modules/collection.dart';
import 'package:aves/model/settings/modules/debug.dart';
import 'package:aves/model/settings/modules/display.dart';
import 'package:aves/model/settings/modules/filter_grids.dart';
import 'package:aves/model/settings/modules/info.dart';
Expand Down Expand Up @@ -40,7 +41,7 @@ import 'package:latlong2/latlong.dart';

final Settings settings = Settings._private();

class Settings with ChangeNotifier, SettingsAccess, AppSettings, DisplaySettings, NavigationSettings, SearchSettings, CollectionSettings, FilterGridsSettings, PrivacySettings, ViewerSettings, VideoSettings, SubtitlesSettings, InfoSettings {
class Settings with ChangeNotifier, SettingsAccess, DebugSettings, AppSettings, DisplaySettings, NavigationSettings, SearchSettings, CollectionSettings, FilterGridsSettings, PrivacySettings, ViewerSettings, VideoSettings, SubtitlesSettings, InfoSettings {
final List<StreamSubscription> _subscriptions = [];
final EventChannel _platformSettingsChangeChannel = const OptionalEventChannel('deckers.thibault/aves/settings_change');
final StreamController<SettingsChangedEvent> _updateStreamController = StreamController.broadcast();
Expand Down
7 changes: 7 additions & 0 deletions lib/widgets/debug/general.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:aves/model/settings/settings.dart';
import 'package:aves/model/source/collection_source.dart';
import 'package:aves/services/analysis_service.dart';
import 'package:aves/widgets/common/identity/aves_expansion_tile.dart';
import 'package:aves/widgets/debug/overlay.dart';
import 'package:aves/widgets/settings/common/tiles.dart';
import 'package:aves/widgets/viewer/info/common.dart';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -61,6 +63,11 @@ class _DebugGeneralSectionState extends State<DebugGeneralSection> with Automati
},
title: const Text('Show tasks overlay'),
),
SettingsSwitchListTile(
selector: (context, s) => s.debugShowViewerTiles,
onChanged: (v) => settings.debugShowViewerTiles = v,
title: 'Show viewer tiles',
),
ElevatedButton(
onPressed: () => LeakTracking.collectLeaks().then((leaks) {
const config = LeakDiagnosticConfig(
Expand Down
22 changes: 22 additions & 0 deletions lib/widgets/viewer/visual/raster.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,28 @@ class _RegionTileState extends State<_RegionTile> {
);
}

if (settings.debugShowViewerTiles) {
final regionRect = widget.regionRect;
child = Stack(
children: [
Positioned.fill(child: child),
Text(
'\ntile=(${tileRect.left.round()}, ${tileRect.top.round()}) ${tileRect.width.round()} x ${tileRect.height.round()}'
'\nregion=(${regionRect.left.round()}, ${regionRect.top.round()}) ${regionRect.width.round()} x ${regionRect.height.round()}'
'\nsampleSize=${widget.sampleSize}',
style: const TextStyle(backgroundColor: Colors.black87),
),
Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: Colors.red, width: 1),
),
),
),
],
);
}

return Positioned.fromRect(
rect: tileRect,
child: child,
Expand Down
4 changes: 4 additions & 0 deletions plugins/aves_model/lib/src/settings/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SettingKeys {
topEntryIdsKey,
recentDestinationAlbumsKey,
recentTagsKey,
debugShowViewerTilesKey,
};

static const _widgetKeyPrefix = 'widget_';
Expand All @@ -29,6 +30,9 @@ class SettingKeys {
static const recentDestinationAlbumsKey = 'recent_destination_albums';
static const recentTagsKey = 'recent_tags';

// debug
static const debugShowViewerTilesKey = 'debug_show_viewer_tiles';

// display
static const displayRefreshRateModeKey = 'display_refresh_rate_mode';
static const themeBrightnessKey = 'theme_brightness';
Expand Down

0 comments on commit b282d0a

Please sign in to comment.