MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / updateUsingEditor

Method updateUsingEditor

src/app/ui/preview_editor.cpp:329–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329void PreviewEditorWindow::updateUsingEditor(Editor* editor)
330{
331 if (!m_isEnabled || !editor) {
332 hideWindow();
333 m_relatedEditor = nullptr;
334 return;
335 }
336
337 if (!editor->isActive())
338 return;
339
340 m_relatedEditor = editor;
341
342 Document* document = editor->document();
343 Editor* miniEditor = (m_docView ? m_docView->editor(): nullptr);
344
345 if (!isVisible())
346 openWindow();
347
348 // Document preferences used to store the preferred zoom/scroll point
349 auto& docPref = Preferences::instance().document(document);
350 bool autoScroll = docPref.preview.autoScroll();
351
352 // Set the same location as in the given editor.
353 if (!miniEditor || miniEditor->document() != document) {
354 destroyDocView();
355
356 m_docView = new DocumentView(document, DocumentView::Preview, this);
357 addChild(m_docView);
358
359 miniEditor = m_docView->editor();
360 miniEditor->setZoom(render::Zoom::fromScale(docPref.preview.zoom()));
361 miniEditor->setLayer(editor->layer());
362 miniEditor->setFrame(editor->frame());
363 miniEditor->setState(EditorStatePtr(new NavigateState));
364 miniEditor->setAnimationSpeedMultiplier(m_aniSpeed);
365 miniEditor->addObserver(this);
366 layout();
367
368 if (!autoScroll)
369 miniEditor->setEditorScroll(docPref.preview.scroll());
370 }
371
372 m_centerButton->setSelected(autoScroll);
373 if (autoScroll) {
374 gfx::Point centerPoint = editor->getVisibleSpriteBounds().center();
375 miniEditor->centerInSpritePoint(centerPoint);
376
377 saveScrollPref();
378 }
379
380 if (!m_playButton->isPlaying()) {
381 miniEditor->stop();
382 miniEditor->setLayer(editor->layer());
383 miniEditor->setFrame(editor->frame());
384 }
385 else {
386 if (miniEditor->isPlaying()) {

Callers

nothing calls this directly

Calls 15

instanceFunction · 0.85
get_animation_tagFunction · 0.85
isActiveMethod · 0.80
autoScrollMethod · 0.80
setStateMethod · 0.80
setEditorScrollMethod · 0.80
setSelectedMethod · 0.80
centerMethod · 0.80
centerInSpritePointMethod · 0.80
playMethod · 0.80

Tested by

no test coverage detected