Image attachment tracking system, adjustable pins
This commit is contained in:
@@ -152,6 +152,7 @@
|
|||||||
// Add systems!
|
// Add systems!
|
||||||
(archive.addSystem nameSystem)
|
(archive.addSystem nameSystem)
|
||||||
(archive.addSystem (new WikipediaImageSystem))
|
(archive.addSystem (new WikipediaImageSystem))
|
||||||
|
(archive.addSystem (new ImageAttachmentSystem))
|
||||||
// Just for testing:
|
// Just for testing:
|
||||||
// (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files))
|
// (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files))
|
||||||
|
|
||||||
@@ -216,5 +217,19 @@
|
|||||||
(addFiles archive e files))
|
(addFiles archive e files))
|
||||||
entries)
|
entries)
|
||||||
|
|
||||||
|
(method adjustImagePins [:Array<Entry> entries increment]
|
||||||
|
(doFor e entries
|
||||||
|
(if (hasComponent e Images)
|
||||||
|
(withWritableComponents archive e [images Images]
|
||||||
|
(set images.pinnedImageIndex (max 0 (min images.imageFiles.length (+ increment images.pinnedImageIndex)))))
|
||||||
|
(ui.reportError "Entry $e has no Images component")))
|
||||||
|
entries)
|
||||||
|
|
||||||
|
(defCommand PinNextImage [entries (SelectedEntries 1 null)]
|
||||||
|
(adjustImagePins entries 1))
|
||||||
|
|
||||||
|
(defCommand PinPreviousImage [entries (SelectedEntries 1 null)]
|
||||||
|
(adjustImagePins entries -1))
|
||||||
|
|
||||||
(defCommand SelectByName [name (Text null)]
|
(defCommand SelectByName [name (Text null)]
|
||||||
(SelectEntries (nameSystem.getEntries name)) []))
|
(SelectEntries (nameSystem.getEntries name)) []))
|
||||||
|
|||||||
6
src/nat/components/Images.hx
Normal file
6
src/nat/components/Images.hx
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package nat.components;
|
||||||
|
|
||||||
|
typedef Images = {
|
||||||
|
imageFiles:Array<FileRef>,
|
||||||
|
pinnedImageIndex:Int
|
||||||
|
};
|
||||||
7
src/nat/systems/ImageAttachmentSystem.hx
Normal file
7
src/nat/systems/ImageAttachmentSystem.hx
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package nat.systems;
|
||||||
|
|
||||||
|
import kiss.Prelude;
|
||||||
|
import kiss.List;
|
||||||
|
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class ImageAttachmentSystem extends AttachmentSystem {}
|
||||||
12
src/nat/systems/ImageAttachmentSystem.kiss
Normal file
12
src/nat/systems/ImageAttachmentSystem.kiss
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
(load "../Lib.kiss")
|
||||||
|
|
||||||
|
(defNew []
|
||||||
|
(super
|
||||||
|
["jpg" "jpeg" "png"]
|
||||||
|
->[archive e imageFiles]
|
||||||
|
(unless (hasComponent e Images)
|
||||||
|
(withWritableEntry archive e
|
||||||
|
(addComponent archive e Images
|
||||||
|
(object
|
||||||
|
imageFiles imageFiles
|
||||||
|
pinnedImageIndex 0))))))
|
||||||
Reference in New Issue
Block a user