diff options
author | Tobias Christiansen <tobyase@serenityos.org> | 2021-08-31 21:02:38 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-04 03:29:09 +0200 |
commit | b3f53a0b5a6cb7019f02dd73883435cbb7e1cb1e (patch) | |
tree | 517ba79ac9b452456560bedfa8c682c823e06062 /Userland/Applications/PixelPaint | |
parent | e867e4b84bfc3c8074f848db85edb97806b9f6ed (diff) | |
download | serenity-b3f53a0b5a6cb7019f02dd73883435cbb7e1cb1e.zip |
PixelPaint: Save Guides when writing project to file
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r-- | Userland/Applications/PixelPaint/ImageEditor.cpp | 12 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/ImageEditor.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 8f0f7e2da7..441fe8262e 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -475,6 +476,17 @@ Result<void, String> ImageEditor::save_project_to_fd_and_close(int fd) const StringBuilder builder; JsonObjectSerializer json(builder); m_image->serialize_as_json(json); + auto json_guides = json.add_array("guides"); + for (const auto& guide : m_guides) { + auto json_guide = json_guides.add_object(); + json_guide.add("offset"sv, (double)guide.offset()); + if (guide.orientation() == Guide::Orientation::Vertical) + json_guide.add("orientation", "vertical"); + else if (guide.orientation() == Guide::Orientation::Horizontal) + json_guide.add("orientation", "horizontal"); + json_guide.finish(); + } + json_guides.finish(); json.finish(); auto file = Core::File::construct(); diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 04bb7d4c62..343e72e5e0 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ |