summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Christiansen <tobyase@serenityos.org>2021-09-03 18:50:33 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-04 03:29:09 +0200
commit65d52467f4d29a85ba65b5bd9bce982f38a1bf8e (patch)
tree70042145f104c51b0c8e171c65fe1623760c2824
parent508d56318931c0d6a3fd077ac2dc9f83bbfe612b (diff)
downloadserenity-65d52467f4d29a85ba65b5bd9bce982f38a1bf8e.zip
PixelPaint: Parse saved Guides from the ProjectLoader in main
This patch allows PixelPaint to recreate saved Guides from .pp files.
-rw-r--r--Userland/Applications/PixelPaint/main.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp
index 5f88543da9..1916e93aeb 100644
--- a/Userland/Applications/PixelPaint/main.cpp
+++ b/Userland/Applications/PixelPaint/main.cpp
@@ -765,6 +765,32 @@ int main(int argc, char** argv)
if (image->layer_count())
image_editor.set_active_layer(&image->layer(0));
+ if (!loader.is_raw_image()) {
+ loader.json_metadata().for_each([&](JsonValue const& value) {
+ if (!value.is_object())
+ return;
+ auto& json_object = value.as_object();
+ auto orientation_value = json_object.get("orientation"sv);
+ if (!orientation_value.is_string())
+ return;
+
+ auto offset_value = json_object.get("offset"sv);
+ if (!offset_value.is_number())
+ return;
+
+ auto orientation_string = orientation_value.as_string();
+ PixelPaint::Guide::Orientation orientation;
+ if (orientation_string == "horizontal"sv)
+ orientation = PixelPaint::Guide::Orientation::Horizontal;
+ else if (orientation_string == "vertical"sv)
+ orientation = PixelPaint::Guide::Orientation::Vertical;
+ else
+ return;
+
+ image_editor.add_guide(PixelPaint::Guide::construct(orientation, offset_value.to_number<float>()));
+ });
+ }
+
tab_widget.set_active_widget(&image_editor);
image_editor.set_focus(true);
return image_editor;