info: format XMP MWG Regions section
This commit is contained in:
parent
18a15d617f
commit
7252346444
2 changed files with 43 additions and 0 deletions
40
lib/widgets/viewer/info/metadata/xmp_ns/mwg.dart
Normal file
40
lib/widgets/viewer/info/metadata/xmp_ns/mwg.dart
Normal file
|
@ -0,0 +1,40 @@
|
|||
import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart';
|
||||
import 'package:aves/widgets/viewer/info/metadata/xmp_structs.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
// cf www.metadataworkinggroup.org/pdf/mwg_guidance.pdf (down, as of 2021/02/15)
|
||||
class XmpMgwRegionsNamespace extends XmpNamespace {
|
||||
static const ns = 'mwg-rs';
|
||||
|
||||
static final dimensionsPattern = RegExp(r'mwg-rs:Regions/mwg-rs:AppliedToDimensions/(.*)');
|
||||
static final regionListPattern = RegExp(r'mwg-rs:Regions/mwg-rs:RegionList\[(\d+)\]/(.*)');
|
||||
|
||||
final dimensions = <String, String>{};
|
||||
final regionList = <int, Map<String, String>>{};
|
||||
|
||||
XmpMgwRegionsNamespace() : super(ns);
|
||||
|
||||
@override
|
||||
String get displayTitle => 'Regions';
|
||||
|
||||
@override
|
||||
bool extractData(XmpProp prop) {
|
||||
final hasStructs = extractStruct(prop, dimensionsPattern, dimensions);
|
||||
final hasIndexedStructs = extractIndexedStruct(prop, regionListPattern, regionList);
|
||||
return hasStructs || hasIndexedStructs;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> buildFromExtractedData() => [
|
||||
if (dimensions.isNotEmpty)
|
||||
XmpStructCard(
|
||||
title: 'Applied To Dimensions',
|
||||
struct: dimensions,
|
||||
),
|
||||
if (regionList.isNotEmpty)
|
||||
XmpStructArrayCard(
|
||||
title: 'Region',
|
||||
structByIndex: regionList,
|
||||
),
|
||||
];
|
||||
}
|
|
@ -12,6 +12,7 @@ import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart';
|
|||
import 'package:aves/widgets/viewer/info/metadata/xmp_ns/exif.dart';
|
||||
import 'package:aves/widgets/viewer/info/metadata/xmp_ns/google.dart';
|
||||
import 'package:aves/widgets/viewer/info/metadata/xmp_ns/iptc.dart';
|
||||
import 'package:aves/widgets/viewer/info/metadata/xmp_ns/mwg.dart';
|
||||
import 'package:aves/widgets/viewer/info/metadata/xmp_ns/photoshop.dart';
|
||||
import 'package:aves/widgets/viewer/info/metadata/xmp_ns/tiff.dart';
|
||||
import 'package:aves/widgets/viewer/info/metadata/xmp_ns/xmp.dart';
|
||||
|
@ -60,6 +61,8 @@ class _XmpDirTileState extends State<XmpDirTile> with FeedbackMixin {
|
|||
return XmpGImageNamespace();
|
||||
case XmpIptcCoreNamespace.ns:
|
||||
return XmpIptcCoreNamespace();
|
||||
case XmpMgwRegionsNamespace.ns:
|
||||
return XmpMgwRegionsNamespace();
|
||||
case XmpMMNamespace.ns:
|
||||
return XmpMMNamespace();
|
||||
case XmpNoteNamespace.ns:
|
||||
|
|
Loading…
Reference in a new issue