mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
Presenter: Support multiple frames per slide
This commit is contained in:
parent
7c312980b0
commit
fcda397136
8 changed files with 84 additions and 37 deletions
|
@ -9,17 +9,18 @@
|
|||
#include "Presentation.h"
|
||||
#include <AK/JsonObject.h>
|
||||
|
||||
Slide::Slide(Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title)
|
||||
: m_slide_objects(move(slide_objects))
|
||||
Slide::Slide(unsigned frame_count, Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title)
|
||||
: m_frame_count(move(frame_count))
|
||||
, m_slide_objects(move(slide_objects))
|
||||
, m_title(move(title))
|
||||
{
|
||||
}
|
||||
|
||||
ErrorOr<Slide> Slide::parse_slide(JsonObject const& slide_json)
|
||||
ErrorOr<Slide> Slide::parse_slide(JsonObject const& slide_json, unsigned slide_index)
|
||||
{
|
||||
// FIXME: Use the text with the "title" role for a title, if there is no title given.
|
||||
auto title = slide_json.get_deprecated_string("title"sv).value_or("Untitled slide");
|
||||
|
||||
auto frame_count = slide_json.get_u32("frame_count"sv).value_or(1);
|
||||
auto maybe_slide_objects = slide_json.get_array("objects"sv);
|
||||
if (!maybe_slide_objects.has_value())
|
||||
return Error::from_string_view("Slide objects must be an array"sv);
|
||||
|
@ -31,11 +32,11 @@ ErrorOr<Slide> Slide::parse_slide(JsonObject const& slide_json)
|
|||
return Error::from_string_view("Slides must be objects"sv);
|
||||
auto const& slide_object_json = maybe_slide_object_json.as_object();
|
||||
|
||||
auto slide_object = TRY(SlideObject::parse_slide_object(slide_object_json));
|
||||
auto slide_object = TRY(SlideObject::parse_slide_object(slide_object_json, slide_index));
|
||||
slide_objects.append(move(slide_object));
|
||||
}
|
||||
|
||||
return Slide { move(slide_objects), title };
|
||||
return Slide { frame_count, move(slide_objects), title };
|
||||
}
|
||||
|
||||
ErrorOr<HTMLElement> Slide::render(Presentation const& presentation) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue