Support more commands without UI

- BackgroundFromLayer
- CelOpacity
- LayerFromBackground
- RemoveLayer
This commit is contained in:
David Capello 2018-09-06 14:18:59 -03:00
parent 2cac540d34
commit 26d510fffd
8 changed files with 46 additions and 20 deletions

View File

@ -187,10 +187,8 @@ if(ENABLE_UI)
commands/cmd_about.cpp
commands/cmd_add_color.cpp
commands/cmd_advanced_mode.cpp
commands/cmd_background_from_layer.cpp
commands/cmd_cancel.cpp
commands/cmd_canvas_size.cpp
commands/cmd_cel_opacity.cpp
commands/cmd_cel_properties.cpp
commands/cmd_change_brush.cpp
commands/cmd_change_color.cpp
@ -227,7 +225,6 @@ if(ENABLE_UI)
commands/cmd_invert_mask.cpp
commands/cmd_keyboard_shortcuts.cpp
commands/cmd_launch.cpp
commands/cmd_layer_from_background.cpp
commands/cmd_layer_lock.cpp
commands/cmd_layer_opacity.cpp
commands/cmd_layer_properties.cpp
@ -261,7 +258,6 @@ if(ENABLE_UI)
commands/cmd_refresh.cpp
commands/cmd_remove_frame.cpp
commands/cmd_remove_frame_tag.cpp
commands/cmd_remove_layer.cpp
commands/cmd_remove_slice.cpp
commands/cmd_repeat_last_export.cpp
commands/cmd_reselect_mask.cpp
@ -502,11 +498,15 @@ add_library(app-lib
color.cpp
color_picker.cpp
color_utils.cpp
commands/cmd_background_from_layer.cpp
commands/cmd_cel_opacity.cpp
commands/cmd_change_pixel_format.cpp
commands/cmd_crop.cpp
commands/cmd_layer_from_background.cpp
commands/cmd_load_palette.cpp
commands/cmd_new_layer.cpp
commands/cmd_open_file.cpp
commands/cmd_remove_layer.cpp
commands/cmd_save_file.cpp
commands/cmd_sprite_size.cpp
commands/cmd_undo.cpp

View File

@ -59,7 +59,10 @@ void BackgroundFromLayerCommand::onExecute(Context* context)
tx.commit();
}
update_screen_for_document(document);
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}
Command* CommandFactory::createBackgroundFromLayerCommand()

View File

@ -75,7 +75,13 @@ void CelOpacityCommand::onExecute(Context* context)
Tx tx(writer.context(), "Set Cel Opacity");
// TODO the range of selected cels should be in app::Site.
DocRange range = App::instance()->timeline()->range();
DocRange range;
#ifdef ENABLE_UI
if (context->isUIAvailable())
range = App::instance()->timeline()->range();
#endif
if (!range.enabled()) {
range.startRange(layer, cel->frame(), DocRange::kCels);
range.endRange(layer, cel->frame());
@ -94,7 +100,10 @@ void CelOpacityCommand::onExecute(Context* context)
tx.commit();
}
update_screen_for_document(writer.document());
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(writer.document());
#endif
}
std::string CelOpacityCommand::onGetFriendlyName() const

View File

@ -78,7 +78,8 @@ void CropSpriteCommand::onExecute(Context* context)
document->generateMaskBoundaries();
#ifdef ENABLE_UI
update_screen_for_document(document);
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}
@ -116,7 +117,8 @@ void AutocropSpriteCommand::onExecute(Context* context)
document->generateMaskBoundaries();
#ifdef ENABLE_UI
update_screen_for_document(document);
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}

View File

@ -56,7 +56,10 @@ void LayerFromBackgroundCommand::onExecute(Context* context)
document->getApi(tx).layerFromBackground(writer.layer());
tx.commit();
}
update_screen_for_document(document);
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}
Command* CommandFactory::createLayerFromBackgroundCommand()

View File

@ -151,6 +151,7 @@ void NewLayerCommand::onExecute(Context* context)
return;
}
#ifdef ENABLE_UI
// If params specify to ask the user about the name...
if (m_ask) {
// We open the window to ask the name
@ -163,6 +164,7 @@ void NewLayerCommand::onExecute(Context* context)
name = window.name()->text();
}
#endif
LayerGroup* parent = sprite->root();
Layer* activeLayer = writer.layer();
@ -320,6 +322,7 @@ void NewLayerCommand::onExecute(Context* context)
tx.commit();
}
#ifdef ENABLE_UI
if (context->isUIAvailable()) {
update_screen_for_document(document);
@ -331,6 +334,7 @@ void NewLayerCommand::onExecute(Context* context)
App::instance()->mainWindow()->popTimeline();
}
#endif
}
std::string NewLayerCommand::onGetFriendlyName() const

View File

@ -89,13 +89,18 @@ void RemoveLayerCommand::onExecute(Context* context)
tx.commit();
}
update_screen_for_document(document);
StatusBar::instance()->invalidate();
if (!layerName.empty())
StatusBar::instance()->showTip(1000, "Layer '%s' removed", layerName.c_str());
else
StatusBar::instance()->showTip(1000, "Layers removed");
#ifdef ENABLE_UI
if (context->isUIAvailable()) {
update_screen_for_document(document);
StatusBar::instance()->invalidate();
if (!layerName.empty())
StatusBar::instance()->showTip(1000, "Layer '%s' removed", layerName.c_str());
else
StatusBar::instance()->showTip(1000, "Layers removed");
}
#endif
}
Command* CommandFactory::createRemoveLayerCommand()

View File

@ -5,12 +5,16 @@
// the End-User License Agreement for Aseprite.
FOR_EACH_COMMAND(AutocropSprite)
FOR_EACH_COMMAND(BackgroundFromLayer)
FOR_EACH_COMMAND(CelOpacity)
FOR_EACH_COMMAND(ChangePixelFormat)
FOR_EACH_COMMAND(CropSprite)
FOR_EACH_COMMAND(LayerFromBackground)
FOR_EACH_COMMAND(LoadPalette)
FOR_EACH_COMMAND(NewLayer)
FOR_EACH_COMMAND(OpenFile)
FOR_EACH_COMMAND(Redo)
FOR_EACH_COMMAND(RemoveLayer)
FOR_EACH_COMMAND(SaveFile)
FOR_EACH_COMMAND(SaveFileAs)
FOR_EACH_COMMAND(SaveFileCopyAs)
@ -21,11 +25,9 @@ FOR_EACH_COMMAND(Undo)
FOR_EACH_COMMAND(About)
FOR_EACH_COMMAND(AddColor)
FOR_EACH_COMMAND(AdvancedMode)
FOR_EACH_COMMAND(BackgroundFromLayer)
FOR_EACH_COMMAND(BrightnessContrast)
FOR_EACH_COMMAND(Cancel)
FOR_EACH_COMMAND(CanvasSize)
FOR_EACH_COMMAND(CelOpacity)
FOR_EACH_COMMAND(CelProperties)
FOR_EACH_COMMAND(ChangeBrush)
FOR_EACH_COMMAND(ChangeColor)
@ -76,7 +78,6 @@ FOR_EACH_COMMAND(InvertColor)
FOR_EACH_COMMAND(InvertMask)
FOR_EACH_COMMAND(KeyboardShortcuts)
FOR_EACH_COMMAND(Launch)
FOR_EACH_COMMAND(LayerFromBackground)
FOR_EACH_COMMAND(LayerLock)
FOR_EACH_COMMAND(LayerOpacity)
FOR_EACH_COMMAND(LayerProperties)
@ -110,7 +111,6 @@ FOR_EACH_COMMAND(PlayPreviewAnimation)
FOR_EACH_COMMAND(Refresh)
FOR_EACH_COMMAND(RemoveFrame)
FOR_EACH_COMMAND(RemoveFrameTag)
FOR_EACH_COMMAND(RemoveLayer)
FOR_EACH_COMMAND(RemoveSlice)
FOR_EACH_COMMAND(RepeatLastExport)
FOR_EACH_COMMAND(ReplaceColor)