Support NewFrame when ENABLE_UI is not defined

This commit is contained in:
David Capello 2018-10-31 17:36:22 -03:00
parent 2adfcf8829
commit 17496c8630
3 changed files with 21 additions and 8 deletions

View File

@ -242,7 +242,6 @@ if(ENABLE_UI)
commands/cmd_move_mask.cpp commands/cmd_move_mask.cpp
commands/cmd_new_brush.cpp commands/cmd_new_brush.cpp
commands/cmd_new_file.cpp commands/cmd_new_file.cpp
commands/cmd_new_frame.cpp
commands/cmd_new_frame_tag.cpp commands/cmd_new_frame_tag.cpp
commands/cmd_new_sprite_from_selection.cpp commands/cmd_new_sprite_from_selection.cpp
commands/cmd_onionskin.cpp commands/cmd_onionskin.cpp
@ -511,6 +510,7 @@ add_library(app-lib
commands/cmd_flatten_layers.cpp commands/cmd_flatten_layers.cpp
commands/cmd_layer_from_background.cpp commands/cmd_layer_from_background.cpp
commands/cmd_load_palette.cpp commands/cmd_load_palette.cpp
commands/cmd_new_frame.cpp
commands/cmd_new_layer.cpp commands/cmd_new_layer.cpp
commands/cmd_open_file.cpp commands/cmd_open_file.cpp
commands/cmd_remove_layer.cpp commands/cmd_remove_layer.cpp

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -111,9 +112,11 @@ void NewFrameCommand::onExecute(Context* context)
!site->selectedFrames().empty()) { !site->selectedFrames().empty()) {
std::map<CelData*, Cel*> relatedCels; std::map<CelData*, Cel*> relatedCels;
#if ENABLE_UI
auto timeline = App::instance()->timeline(); auto timeline = App::instance()->timeline();
timeline->prepareToMoveRange(); timeline->prepareToMoveRange();
DocRange range = timeline->range(); DocRange range = timeline->range();
#endif
SelectedLayers selLayers; SelectedLayers selLayers;
if (site->inFrames()) if (site->inFrames())
@ -161,19 +164,23 @@ void NewFrameCommand::onExecute(Context* context)
} }
} }
#ifdef ENABLE_UI // TODO the range should be part of the Site
range.displace(0, frameRange); range.displace(0, frameRange);
timeline->moveRange(range); timeline->moveRange(range);
#endif
} }
else { else {
api.copyCel( api.copyCel(
static_cast<LayerImage*>(writer.layer()), writer.frame(), static_cast<LayerImage*>(writer.layer()), writer.frame(),
static_cast<LayerImage*>(writer.layer()), writer.frame()+1); static_cast<LayerImage*>(writer.layer()), writer.frame()+1);
#ifdef ENABLE_UI // TODO the active frame should be part of the Site
// TODO should we use DocObserver? // TODO should we use DocObserver?
if (UIContext::instance() == context) { if (UIContext::instance() == context) {
if (DocView* view = UIContext::instance()->activeView()) if (DocView* view = UIContext::instance()->activeView())
view->editor()->setFrame(writer.frame()+1); view->editor()->setFrame(writer.frame()+1);
} }
#endif
} }
break; break;
} }
@ -181,14 +188,19 @@ void NewFrameCommand::onExecute(Context* context)
tx.commit(); tx.commit();
} }
update_screen_for_document(document);
StatusBar::instance() #ifdef ENABLE_UI
->showTip(1000, "New frame %d/%d", if (context->isUIAvailable()) {
(int)context->activeSite().frame()+1, update_screen_for_document(document);
(int)sprite->totalFrames());
App::instance()->mainWindow()->popTimeline(); StatusBar::instance()
->showTip(1000, "New frame %d/%d",
(int)context->activeSite().frame()+1,
(int)sprite->totalFrames());
App::instance()->mainWindow()->popTimeline();
}
#endif
} }
std::string NewFrameCommand::onGetFriendlyName() const std::string NewFrameCommand::onGetFriendlyName() const

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
@ -12,6 +13,7 @@ FOR_EACH_COMMAND(CropSprite)
FOR_EACH_COMMAND(FlattenLayers) FOR_EACH_COMMAND(FlattenLayers)
FOR_EACH_COMMAND(LayerFromBackground) FOR_EACH_COMMAND(LayerFromBackground)
FOR_EACH_COMMAND(LoadPalette) FOR_EACH_COMMAND(LoadPalette)
FOR_EACH_COMMAND(NewFrame)
FOR_EACH_COMMAND(NewLayer) FOR_EACH_COMMAND(NewLayer)
FOR_EACH_COMMAND(OpenFile) FOR_EACH_COMMAND(OpenFile)
FOR_EACH_COMMAND(Redo) FOR_EACH_COMMAND(Redo)
@ -95,7 +97,6 @@ FOR_EACH_COMMAND(MoveCel)
FOR_EACH_COMMAND(MoveMask) FOR_EACH_COMMAND(MoveMask)
FOR_EACH_COMMAND(NewBrush) FOR_EACH_COMMAND(NewBrush)
FOR_EACH_COMMAND(NewFile) FOR_EACH_COMMAND(NewFile)
FOR_EACH_COMMAND(NewFrame)
FOR_EACH_COMMAND(NewFrameTag) FOR_EACH_COMMAND(NewFrameTag)
FOR_EACH_COMMAND(NewSpriteFromSelection) FOR_EACH_COMMAND(NewSpriteFromSelection)
FOR_EACH_COMMAND(OpenBrowser) FOR_EACH_COMMAND(OpenBrowser)