Remove #if/endif ENABLE_UI conditional directives (fix #4619)

This was originated for #1279 (CLI-only Aseprite) which can be
achieved with LAF_BACKEND=none anyway.

In this way we simplify the development process, and checking for the
availability of the GUI can be done in run-time through App::isGui()
or Context::isUIAvailable().
This commit is contained in:
David Capello 2024-09-02 23:12:13 -03:00
parent c4526cf709
commit bf0a47545c
84 changed files with 169 additions and 756 deletions

View File

@ -95,10 +95,6 @@ add_definitions(-DLIBARCHIVE_STATIC)
add_library(app-lib ${generated_files})
# ENABLE_UI is always defined because there are still #ifdef/endif
# using it, but we should remove it.
target_compile_definitions(app-lib PUBLIC -DENABLE_UI)
# These specific-platform files should be in an external library
# (e.g. "base" or "os").
if(WIN32)

View File

@ -120,14 +120,8 @@ private:
class App::CoreModules {
public:
#ifdef ENABLE_UI
typedef app::UIContext ContextT;
#else
typedef app::Context ContextT;
#endif
ConfigModule m_configModule;
ContextT m_context;
app::UIContext m_context;
};
class App::LoadLanguage {
@ -148,11 +142,9 @@ public:
tools::ToolBox m_toolbox;
tools::ActiveToolManager m_activeToolManager;
Commands m_commands;
#ifdef ENABLE_UI
RecentFiles m_recent_files;
InputChain m_inputChain;
Clipboard m_clipboard;
#endif
#ifdef ENABLE_DATA_RECOVERY
// This is a raw pointer because we want to delete it explicitly.
// (e.g. if an exception occurs, the ~Modules() doesn't have to
@ -165,9 +157,7 @@ public:
: m_loggerModule(createLogInDesktop)
, m_loadLanguage(pref, m_extensions)
, m_activeToolManager(&m_toolbox)
#ifdef ENABLE_UI
, m_recent_files(pref.general.recentItems())
#endif
#ifdef ENABLE_DATA_RECOVERY
, m_recovery(nullptr)
#endif
@ -250,9 +240,7 @@ App::App(AppMod* mod)
, m_legacy(nullptr)
, m_isGui(false)
, m_isShell(false)
#ifdef ENABLE_UI
, m_backupIndicator(nullptr)
#endif
#ifdef ENABLE_SCRIPTING
, m_engine(new script::Engine)
#endif
@ -265,19 +253,15 @@ int App::initialize(const AppOptions& options)
{
os::System* system = os::instance();
#ifdef ENABLE_UI
m_isGui = options.startUI() && !options.previewCLI();
// Notify the scripting engine that we're going to enter to GUI
// mode, this is useful so we can mark the stdin file handle as
// closed so no script can hang the program if it tries to read from
// stdin when the GUI is running.
#ifdef ENABLE_SCRIPTING
#ifdef ENABLE_SCRIPTING
if (m_isGui)
m_engine->notifyRunningGui();
#endif
#else
m_isGui = false;
#endif
m_isShell = options.startShell();
@ -350,9 +334,7 @@ int App::initialize(const AppOptions& options)
// Load modules
m_modules = std::make_unique<Modules>(createLogInDesktop, pref);
m_legacy = std::make_unique<LegacyModules>(isGui() ? REQUIRE_INTERFACE: 0);
#ifdef ENABLE_UI
m_brushes = std::make_unique<AppBrushes>();
#endif
// Data recovery is enabled only in GUI mode
if (isGui() && pref.general.dataRecovery())
@ -365,7 +347,6 @@ int App::initialize(const AppOptions& options)
// palette from an old format palette to the new one, etc.
load_default_palette();
#ifdef ENABLE_UI
// Initialize GUI interface
if (isGui()) {
LOG("APP: GUI mode\n");
@ -416,7 +397,6 @@ int App::initialize(const AppOptions& options)
manager->updateAllDisplays(scale, gpu);
#endif
}
#endif // ENABLE_UI
#ifdef ENABLE_SCRIPTING
// Call the init() function from all plugins
@ -445,25 +425,30 @@ int App::initialize(const AppOptions& options)
namespace {
#ifdef ENABLE_UI
struct CloseMainWindow {
std::unique_ptr<MainWindow>& m_win;
CloseMainWindow(std::unique_ptr<MainWindow>& win) : m_win(win) { }
~CloseMainWindow() { m_win.reset(nullptr); }
};
#endif
struct CloseAllDocs {
// Deletes all docs.
struct DeleteAllDocs {
Context* m_ctx;
CloseAllDocs(Context* ctx) : m_ctx(ctx) { }
~CloseAllDocs() {
DeleteAllDocs(Context* ctx) : m_ctx(ctx) { }
~DeleteAllDocs() {
std::vector<Doc*> docs;
#ifdef ENABLE_UI
// Add all documents that were closed in the past, these docs
// are not part of any context and they are just temporarily in
// memory just in case the user wants to recover them.
for (Doc* doc : static_cast<UIContext*>(m_ctx)->getAndRemoveAllClosedDocs())
docs.push_back(doc);
#endif
// Add documents that are currently opened/in tabs/in the
// context.
for (Doc* doc : m_ctx->documents())
docs.push_back(doc);
for (Doc* doc : docs) {
// First we close the document. In this way we receive recent
// notifications related to the document as a app::Doc. If
@ -486,12 +471,9 @@ namespace {
void App::run()
{
#ifdef ENABLE_UI
CloseMainWindow closeMainWindow(m_mainWindow);
#endif
CloseAllDocs closeAllDocsAtExit(context());
DeleteAllDocs deleteAllDocsAtExit(context());
#ifdef ENABLE_UI
// Run the GUI
if (isGui()) {
auto manager = ui::Manager::getDefault();
@ -582,7 +564,6 @@ void App::run()
throw;
}
}
#endif // ENABLE_UI
#ifdef ENABLE_SCRIPTING
// Start shell to execute scripts.
@ -605,7 +586,6 @@ void App::run()
void App::close()
{
#ifdef ENABLE_UI
if (isGui()) {
ExitGui();
@ -616,7 +596,6 @@ void App::close()
// exceptions, and we are not in a destructor).
m_modules->deleteDataRecovery();
}
#endif
}
// Finishes the Aseprite application.
@ -645,7 +624,6 @@ App::~App()
// Fire App Exit signal.
App::instance()->Exit();
#ifdef ENABLE_UI
// Finalize modules, configuration and core.
Editor::destroyEditorSharedInternals();
@ -653,7 +631,6 @@ App::~App()
// Save brushes
m_brushes.reset();
#endif
m_legacy.reset();
m_modules.reset();
@ -667,11 +644,9 @@ App::~App()
m_coreModules.reset();
#ifdef ENABLE_UI
// Destroy the loaded gui.xml data.
KeyboardShortcuts::destroyInstance();
GuiXml::destroyInstance();
#endif
}
catch (const std::exception& e) {
LOG(ERROR, "APP: Error: %s\n", e.what());
@ -723,12 +698,8 @@ tools::ActiveToolManager* App::activeToolManager() const
RecentFiles* App::recentFiles() const
{
#ifdef ENABLE_UI
ASSERT(m_modules != NULL);
ASSERT(m_modules != nullptr);
return &m_modules->m_recent_files;
#else
return nullptr;
#endif
}
Workspace* App::workspace() const
@ -767,7 +738,6 @@ crash::DataRecovery* App::dataRecovery() const
return m_modules->recovery();
}
#ifdef ENABLE_UI
void App::showNotification(INotificationDelegate* del)
{
if (m_mainWindow)
@ -837,14 +807,14 @@ InputChain& App::inputChain()
{
return m_modules->m_inputChain;
}
#endif
// Updates palette and redraw the screen.
void app_refresh_screen()
{
#ifdef ENABLE_UI
Context* ctx = UIContext::instance();
ASSERT(ctx != NULL);
ASSERT(ctx != nullptr);
if (!ctx)
return;
Site site = ctx->activeSite();
if (Palette* pal = site.palette())
@ -853,8 +823,8 @@ void app_refresh_screen()
set_current_palette(nullptr, false);
// Invalidate the whole screen.
ui::Manager::getDefault()->invalidate();
#endif // ENABLE_UI
if (auto* man = ui::Manager::getDefault())
man->invalidate();
}
// TODO remove app_rebuild_documents_tabs() and replace it by
@ -862,12 +832,10 @@ void app_refresh_screen()
// document is modified).
void app_rebuild_documents_tabs()
{
#ifdef ENABLE_UI
if (App::instance()->isGui()) {
App::instance()->workspace()->updateTabs();
App::instance()->updateDisplayTitleBar();
if (auto* app = App::instance(); app->isGui()) {
app->workspace()->updateTabs();
app->updateDisplayTitleBar();
}
#endif // ENABLE_UI
}
PixelFormat app_get_current_pixel_format()
@ -883,21 +851,20 @@ PixelFormat app_get_current_pixel_format()
int app_get_color_to_clear_layer(Layer* layer)
{
ASSERT(layer != NULL);
ASSERT(layer != nullptr);
app::Color color;
// The `Background' is erased with the `Background Color'
if (layer->isBackground()) {
#ifdef ENABLE_UI
if (ColorBar::instance())
color = ColorBar::instance()->getBgColor();
if (auto* colorBar = ColorBar::instance())
color = colorBar->getBgColor();
else
#endif
color = app::Color::fromRgb(0, 0, 0); // TODO get background color color from doc::Settings
}
else // All transparent layers are cleared with the mask color
else { // All transparent layers are cleared with the mask color
color = app::Color::fromMask();
}
return color_utils::color_for_layer(color, layer);
}

View File

@ -9,10 +9,7 @@
#define APP_APP_H_INCLUDED
#pragma once
#ifdef ENABLE_UI
#include "app/app_brushes.h"
#endif
#include "base/paths.h"
#include "doc/pixel_format.h"
#include "obs/signal.h"
@ -101,7 +98,6 @@ namespace app {
Extensions& extensions() const;
crash::DataRecovery* dataRecovery() const;
#ifdef ENABLE_UI
AppBrushes& brushes() {
ASSERT(m_brushes.get());
return *m_brushes;
@ -112,7 +108,6 @@ namespace app {
void updateDisplayTitleBar();
InputChain& inputChain();
#endif
#ifdef ENABLE_SCRIPTING
script::Engine* scriptEngine() { return m_engine.get(); }
@ -147,10 +142,8 @@ namespace app {
#endif
std::unique_ptr<MainWindow> m_mainWindow;
base::paths m_files;
#ifdef ENABLE_UI
std::unique_ptr<AppBrushes> m_brushes;
std::unique_ptr<BackupIndicator> m_backupIndicator;
#endif // ENABLE_UI
#ifdef ENABLE_SCRIPTING
std::unique_ptr<script::Engine> m_engine;
#endif

View File

@ -11,13 +11,10 @@
#include "app/cmd_transaction.h"
#include "app/app.h"
#include "app/context.h"
#include "app/site.h"
#ifdef ENABLE_UI
#include "app/app.h"
#include "app/ui/timeline/timeline.h"
#endif
namespace app {
@ -45,10 +42,8 @@ CmdTransaction* CmdTransaction::moveToEmptyCopy()
void CmdTransaction::setNewDocRange(const DocRange& range)
{
#ifdef ENABLE_UI
if (m_ranges)
range.write(m_ranges->m_after);
#endif
}
void CmdTransaction::updateSpritePositionAfter()
@ -87,12 +82,10 @@ void CmdTransaction::onExecute()
{
// Save the current site and doc range
m_spritePositionBefore = calcSpritePosition();
#ifdef ENABLE_UI
if (isDocRangeEnabled()) {
m_ranges.reset(new Ranges);
calcDocRange().write(m_ranges->m_before);
}
#endif
// Execute the sequence of "cmds"
CmdSequence::onExecute();
@ -131,28 +124,23 @@ SpritePosition CmdTransaction::calcSpritePosition() const
bool CmdTransaction::isDocRangeEnabled() const
{
#ifdef ENABLE_UI
if (App::instance()) {
Timeline* timeline = App::instance()->timeline();
if (timeline && timeline->range().enabled())
return true;
}
#endif
return false;
}
DocRange CmdTransaction::calcDocRange() const
{
#ifdef ENABLE_UI
// TODO We cannot use Context::activeSite() because it losts
// important information about the DocRange() (type and
// flags).
if (App::instance()) {
Timeline* timeline = App::instance()->timeline();
if (timeline)
if (App* app = App::instance()) {
if (Timeline* timeline = app->timeline())
return timeline->range();
}
#endif
return DocRange();
}

View File

@ -39,11 +39,9 @@ os::ColorSpaceRef get_screen_color_space()
os::ColorSpaceRef get_current_color_space()
{
#ifdef ENABLE_UI
if (auto editor = Editor::activeEditor())
if (auto* editor = Editor::activeEditor())
return editor->document()->osColorSpace();
else
#endif
return get_screen_color_space();
}

View File

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

View File

@ -48,8 +48,6 @@ struct CanvasSizeParams : public NewParams {
Param<bool> trimOutside { this, false, "trimOutside" };
};
#ifdef ENABLE_UI
// Window used to show canvas parameters.
class CanvasSizeWindow : public app::gen::CanvasSize
, public SelectBoxDelegate
@ -285,8 +283,6 @@ private:
EditorStatePtr m_selectBoxState;
};
#endif // ENABLE_UI
class CanvasSizeCommand : public CommandWithNewParams<CanvasSizeParams> {
public:
CanvasSizeCommand();
@ -309,9 +305,7 @@ bool CanvasSizeCommand::onEnabled(Context* context)
void CanvasSizeCommand::onExecute(Context* context)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && context->isUIAvailable());
#endif
const ContextReader reader(context);
const Sprite* sprite(reader.sprite());
auto& params = this->params();
@ -326,7 +320,6 @@ void CanvasSizeCommand::onExecute(Context* context)
params.right(), params.bottom()));
}
#ifdef ENABLE_UI
if (ui) {
if (!params.trimOutside.isSet()) {
params.trimOutside(Preferences::instance().canvasSize.trimOutside());
@ -376,7 +369,6 @@ void CanvasSizeCommand::onExecute(Context* context)
params.right(), params.bottom()));
}
}
#endif
if (bounds.w < 1) bounds.w = 1;
if (bounds.h < 1) bounds.h = 1;
@ -390,10 +382,7 @@ void CanvasSizeCommand::onExecute(Context* context)
api.cropSprite(sprite, bounds, params.trimOutside());
tx.commit();
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(doc);
#endif
}
}

View File

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

View File

@ -166,8 +166,6 @@ private:
std::thread m_thread;
};
#ifdef ENABLE_UI
class ConversionItem : public ListItem {
public:
ConversionItem(const doc::PixelFormat pixelFormat)
@ -468,8 +466,6 @@ private:
bool m_imageJustCreated;
};
#endif // ENABLE_UI
} // anonymous namespace
class ChangePixelFormatCommand : public Command {
@ -628,7 +624,6 @@ void ChangePixelFormatCommand::onExecute(Context* context)
{
bool flatten = false;
#ifdef ENABLE_UI
if (context->isUIAvailable() && m_showDlg) {
ColorModeWindow window(Editor::activeEditor());
@ -650,7 +645,6 @@ void ChangePixelFormatCommand::onExecute(Context* context)
window.saveOptions();
}
#endif // ENABLE_UI
// No conversion needed
Doc* doc = context->activeDocument();

View File

@ -41,8 +41,6 @@ struct ColorQuantizationParams : public NewParams {
Param<RgbMapAlgorithm> algorithm { this, RgbMapAlgorithm::DEFAULT, "algorithm" };
};
#if ENABLE_UI
class PaletteFromSpriteWindow : public app::gen::PaletteFromSprite {
public:
PaletteFromSpriteWindow() {
@ -68,8 +66,6 @@ private:
RgbMapAlgorithmSelector m_algoSelector;
};
#endif
class ColorQuantizationCommand : public CommandWithNewParams<ColorQuantizationParams> {
public:
ColorQuantizationCommand();
@ -103,7 +99,6 @@ void ColorQuantizationCommand::onExecute(Context* ctx)
Site site = ctx->activeSite();
PalettePicks entries = site.selectedColors();
#ifdef ENABLE_UI
if (ui) {
PaletteFromSpriteWindow window;
{
@ -160,9 +155,7 @@ void ColorQuantizationCommand::onExecute(Context* ctx)
}
}
}
else
#endif // ENABLE_UI
{
else {
createPal = (!params().useRange());
}

View File

@ -77,10 +77,7 @@ void CropSpriteCommand::onExecute(Context* context)
tx.commit();
}
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}
class AutocropSpriteCommand : public Command {
@ -124,10 +121,7 @@ void AutocropSpriteCommand::onExecute(Context* context)
tx.commit();
}
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}
std::string AutocropSpriteCommand::onGetFriendlyName() const

View File

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

View File

@ -56,8 +56,6 @@ using namespace ui;
namespace {
#ifdef ENABLE_UI
enum Section {
kSectionLayout,
kSectionSprite,
@ -139,8 +137,6 @@ ConstraintType constraint_type_from_params(const ExportSpriteSheetParams& params
return kConstraintType_None;
}
#endif // ENABLE_UI
void destroy_doc(Context* ctx, Doc* doc)
{
try {
@ -304,8 +300,6 @@ std::unique_ptr<Doc> generate_sprite_sheet(
return newDocument;
}
#if ENABLE_UI
class ExportSpriteSheetWindow : public app::gen::ExportSpriteSheet {
public:
ExportSpriteSheetWindow(DocExporter& exporter,
@ -1230,8 +1224,6 @@ private:
std::unique_ptr<Doc> m_doc;
};
#endif // ENABLE_UI
} // anonymous namespace
ExportSpriteSheetCommand::ExportSpriteSheetCommand(const char* id)
@ -1250,14 +1242,6 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
auto& params = this->params();
DocExporter exporter;
#ifdef ENABLE_UI
// TODO if we use this line when !ENABLE_UI,
// Preferences::~Preferences() crashes on Linux when it wants to
// save the document preferences. It looks like
// Preferences::onRemoveDocument() is not called for some documents
// and when the Preferences::m_docs collection is iterated to save
// all DocumentPreferences, it accesses an invalid Doc* pointer (an
// already removed/deleted document).
Doc* document = site.document();
DocumentPreferences& docPref(Preferences::instance().document(document));
@ -1367,11 +1351,9 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
true, params.dataFilename()))
return; // Do not overwrite
}
#endif
exporter.setDocImageBuffer(std::make_shared<doc::ImageBuffer>());
std::unique_ptr<Doc> newDocument;
#ifdef ENABLE_UI
if (context->isUIAvailable()) {
ExportSpriteSheetJob job(exporter, site, params,
// Progress bar can be disabled with ui=false
@ -1401,9 +1383,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
newDocPref.pixelGrid = docPref.pixelGrid;
Preferences::instance().removeDocument(newDocument.get());
}
else
#endif
{
else {
base::task_token token;
newDocument = generate_sprite_sheet(
exporter, context, site, params, true, token);

View File

@ -51,12 +51,10 @@ bool FillCommand::onEnabled(Context* ctx)
ContextFlags::ActiveLayerIsImage)) {
return true;
}
#if ENABLE_UI
auto editor = Editor::activeEditor();
auto* editor = Editor::activeEditor();
if (editor && editor->isMovingPixels()) {
return true;
}
#endif
return false;
}

View File

@ -68,10 +68,8 @@ void FlattenLayersCommand::onExecute(Context* context)
range.selectLayer(layer);
}
else {
#ifdef ENABLE_UI
if (context->isUIAvailable())
range = App::instance()->timeline()->range();
#endif
// If the range is not selected or we have only one image layer
// selected, we'll flatten all layers.
@ -89,9 +87,7 @@ void FlattenLayersCommand::onExecute(Context* context)
tx.commit();
}
#ifdef ENABLE_UI
update_screen_for_document(writer.document());
#endif
}
std::string FlattenLayersCommand::onGetFriendlyName() const

View File

@ -73,7 +73,6 @@ void FlipCommand::onExecute(Context* ctx)
CelList cels;
if (m_flipMask) {
#ifdef ENABLE_UI
// If we want to flip the visible mask we can go to
// MovingPixelsState (even when the range is enabled, because now
// PixelsMovement support ranges).
@ -88,7 +87,6 @@ void FlipCommand::onExecute(Context* ctx)
return;
}
}
#endif
auto range = site.range();
if (range.enabled()) {
@ -101,12 +99,10 @@ void FlipCommand::onExecute(Context* ctx)
}
if (cels.empty()) {
#ifdef ENABLE_UI
if (ctx->isUIAvailable()) {
StatusBar::instance()->showTip(
1000, Strings::statusbar_tips_all_layers_are_locked());
}
#endif // ENABLE_UI
return;
}
}
@ -234,10 +230,7 @@ void FlipCommand::onExecute(Context* ctx)
tx.commit();
#ifdef ENABLE_UI
if (ctx->isUIAvailable())
update_screen_for_document(document);
#endif
}
std::string FlipCommand::onGetFriendlyName() const

View File

@ -416,7 +416,6 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
Doc* document;
auto& params = this->params();
#ifdef ENABLE_UI
if (context->isUIAvailable() && params.ui()) {
// TODO use params as input values for the ImportSpriteSheetWindow
@ -438,9 +437,9 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
docPref->importSpriteSheet.paddingBounds(params.padding());
docPref->importSpriteSheet.paddingEnabled(window.paddingEnabledValue());
}
else // We import the sprite sheet from the active document if there is no UI
#endif
{
// We import the sprite sheet from the active document if there is
// no UI.
else {
document = context->activeDocument();
if (!document)
return;
@ -558,10 +557,7 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
throw;
}
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}
Command* CommandFactory::createImportSpriteSheetCommand()

View File

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

View File

@ -61,7 +61,6 @@ void LoadPaletteCommand::onExecute(Context* context)
else if (!m_filename.empty()) {
filename = m_filename;
}
#ifdef ENABLE_UI
else if (context->isUIAvailable()) {
base::paths exts = get_readable_palette_extensions();
base::paths filenames;
@ -71,7 +70,6 @@ void LoadPaletteCommand::onExecute(Context* context)
filename = filenames.front();
}
}
#endif // ENABLE_UI
// Do nothing
if (filename.empty())

View File

@ -59,10 +59,7 @@ void MaskAllCommand::onExecute(Context* context)
docPref.show.selectionEdges(true);
}
#ifdef ENABLE_UI
if (context->isUIAvailable())
update_screen_for_document(document);
#endif
}
Command* CommandFactory::createMaskAllCommand()

View File

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

View File

@ -72,10 +72,7 @@ bool NewFileCommand::onEnabled(Context* ctx)
{
return
(!params().fromClipboard()
#ifdef ENABLE_UI
|| (ctx->clipboard()->format() == ClipboardFormat::Image)
#endif
);
|| (ctx->clipboard()->format() == ClipboardFormat::Image));
}
void NewFileCommand::onExecute(Context* ctx)
@ -85,13 +82,10 @@ void NewFileCommand::onExecute(Context* ctx)
doc::ColorMode colorMode = params().colorMode();
app::Color bgColor = app::Color::fromMask();
doc::PixelRatio pixelRatio(1, 1);
#ifdef ENABLE_UI
doc::ImageRef clipboardImage;
doc::Palette clipboardPalette(0, 256);
#endif
const int ncolors = get_default_palette()->size();
#ifdef ENABLE_UI
if (params().fromClipboard()) {
clipboardImage = ctx->clipboard()->getImage(&clipboardPalette);
if (!clipboardImage)
@ -205,7 +199,6 @@ void NewFileCommand::onExecute(Context* ctx)
width = w;
height = h;
}
#endif // ENABLE_UI
ASSERT(colorMode == ColorMode::RGB ||
colorMode == ColorMode::GRAYSCALE ||
@ -249,7 +242,6 @@ void NewFileCommand::onExecute(Context* ctx)
set_current_palette(&oldPal, false);
}
#ifdef ENABLE_UI
else if (clipboardImage) {
LayerImage* layerImage = static_cast<LayerImage*>(layer);
// layerImage->configureAsBackground();
@ -265,7 +257,6 @@ void NewFileCommand::onExecute(Context* ctx)
}
sprite->setPalette(&clipboardPalette, false);
}
#endif // ENABLE_UI
if (layer->isBackground())
layer->setName(Strings::commands_NewFile_BackgroundLayer());

View File

@ -93,12 +93,10 @@ void NewFrameCommand::onExecute(Context* context)
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
#if ENABLE_UI
// Show the tooltip feedback only if we are not inside a transaction
// (e.g. we can be already in a transaction if we are running in a
// Lua script app.transaction()).
const bool showTooltip = (document->transaction() == nullptr);
#endif
{
Tx tx(writer, friendlyName());
@ -127,11 +125,9 @@ void NewFrameCommand::onExecute(Context* context)
if (site->inTimeline() &&
!site->selectedLayers().empty() &&
!site->selectedFrames().empty()) {
#if ENABLE_UI
auto timeline = App::instance()->timeline();
timeline->prepareToMoveRange();
DocRange range = timeline->range();
#endif
SelectedLayers selLayers;
if (site->inFrames())
@ -156,10 +152,8 @@ void NewFrameCommand::onExecute(Context* context)
}
}
#ifdef ENABLE_UI // TODO the range should be part of the Site
range.displace(0, frameRange);
timeline->moveRange(range);
#endif
}
else if (auto layer = static_cast<LayerImage*>(writer.layer())) {
api.copyCel(
@ -175,7 +169,6 @@ void NewFrameCommand::onExecute(Context* context)
tx.commit();
}
#ifdef ENABLE_UI
if (context->isUIAvailable() && showTooltip) {
update_screen_for_document(document);
@ -186,7 +179,6 @@ void NewFrameCommand::onExecute(Context* context)
App::instance()->mainWindow()->popTimeline();
}
#endif
}
std::string NewFrameCommand::onGetFriendlyName() const

View File

@ -128,11 +128,9 @@ bool NewLayerCommand::onEnabled(Context* ctx)
ContextFlags::HasActiveSprite))
return false;
#ifdef ENABLE_UI
if (params().fromClipboard() &&
ctx->clipboard()->format() != ClipboardFormat::Image)
return false;
#endif
if ((params().viaCut() ||
params().viaCopy()) &&
@ -160,12 +158,10 @@ void NewLayerCommand::onExecute(Context* context)
Sprite* sprite(reader.sprite());
std::string name;
#if ENABLE_UI
// Show the tooltip feedback only if we are not inside a transaction
// (e.g. we can be already in a transaction if we are running in a
// Lua script app.transaction()).
const bool showTooltip = (document->transaction() == nullptr);
#endif
Doc* pasteDoc = nullptr;
Scoped destroyPasteDoc(
@ -220,7 +216,6 @@ void NewLayerCommand::onExecute(Context* context)
tilesetInfo.baseIndex = 1;
tilesetInfo.matchFlags = 0; // TODO default flags?
#ifdef ENABLE_UI
// If params specify to ask the user about the name...
if (params().ask() && context->isUIAvailable()) {
auto& pref = Preferences::instance();
@ -254,7 +249,6 @@ void NewLayerCommand::onExecute(Context* context)
tilesetSelector->saveAdvancedPreferences();
}
}
#endif
LayerGroup* parent = sprite->root();
Layer* activeLayer = reader.layer();
@ -423,7 +417,6 @@ void NewLayerCommand::onExecute(Context* context)
}
}
}
#ifdef ENABLE_UI
// Paste new layer from clipboard
else if (params().fromClipboard() && layer->isImage()) {
context->clipboard()->paste(context, false);
@ -435,7 +428,6 @@ void NewLayerCommand::onExecute(Context* context)
}
}
}
#endif // ENABLE_UI
// Paste new layer from selection
else if ((params().viaCut() || params().viaCopy())
&& document->isMaskVisible()) {
@ -494,7 +486,6 @@ void NewLayerCommand::onExecute(Context* context)
tx.commit();
}
#ifdef ENABLE_UI
if (context->isUIAvailable() && showTooltip) {
update_screen_for_document(document);
@ -505,7 +496,6 @@ void NewLayerCommand::onExecute(Context* context)
App::instance()->mainWindow()->popTimeline();
}
#endif
}
std::string NewLayerCommand::onGetFriendlyName() const

View File

@ -120,7 +120,6 @@ void OpenFileCommand::onExecute(Context* context)
base::paths filenames;
// interactive
#ifdef ENABLE_UI
if (context->isUIAvailable() && m_filename.empty()) {
base::paths exts = get_readable_extensions();
@ -142,9 +141,7 @@ void OpenFileCommand::onExecute(Context* context)
if (filenames.size() > 1)
m_repeatCheckbox = true;
}
else
#endif // ENABLE_UI
if (!m_filename.empty()) {
else if (!m_filename.empty()) {
filenames.push_back(m_filename);
}

View File

@ -60,7 +60,6 @@ void PaletteSizeCommand::onExecute(Context* context)
Palette palette(*reader.palette());
int ncolors = (m_size != 0 ? m_size: palette.size());
#ifdef ENABLE_UI
if (m_size == 0 && context->isUIAvailable()) {
app::gen::PaletteSize window;
window.colors()->setTextf("%d", ncolors);
@ -70,7 +69,6 @@ void PaletteSizeCommand::onExecute(Context* context)
ncolors = window.colors()->textInt();
}
#endif
if (ncolors == palette.size())
return;

View File

@ -38,11 +38,9 @@ static bool deleting_all_layers(Context* ctx, Sprite* sprite, int topLevelLayers
{
const bool deletingAll = (topLevelLayersToDelete == sprite->root()->layersCount());
#ifdef ENABLE_UI
if (ctx->isUIAvailable() && deletingAll) {
ui::Alert::show(Strings::alerts_cannot_delete_all_layers());
}
#endif
return deletingAll;
}
@ -77,7 +75,6 @@ static bool continue_deleting_unused_tilesets(
}
}
#ifdef ENABLE_UI
// Just continue if UI is not available.
if (!ctx->isUIAvailable())
return true;
@ -94,9 +91,6 @@ static bool continue_deleting_unused_tilesets(
return tsiToDelete.empty() ||
app::OptionalAlert::show(
Preferences::instance().tilemap.showDeleteUnusedTilesetAlert, 1, message) == 1;
#else
return true;
#endif
}
class RemoveLayerCommand : public Command {
@ -199,7 +193,6 @@ void RemoveLayerCommand::onExecute(Context* context)
tx.commit();
}
#ifdef ENABLE_UI
if (context->isUIAvailable()) {
update_screen_for_document(document);
@ -213,7 +206,6 @@ void RemoveLayerCommand::onExecute(Context* context)
1000, Strings::remove_layer_layers_removed());
}
}
#endif
}
Command* CommandFactory::createRemoveLayerCommand()

View File

@ -65,7 +65,6 @@ void RunScriptCommand::onLoadParams(const Params& params)
void RunScriptCommand::onExecute(Context* context)
{
#if ENABLE_UI
if (context->isUIAvailable()) {
int ret = OptionalAlert::show(
Preferences::instance().scripts.showRunScriptAlert,
@ -74,16 +73,13 @@ void RunScriptCommand::onExecute(Context* context)
if (ret != 1)
return;
}
#endif // ENABLE_UI
App::instance()
->scriptEngine()
->evalUserFile(m_filename, m_params);
#if ENABLE_UI
if (context->isUIAvailable())
ui::Manager::getDefault()->invalidate();
#endif
}
std::string RunScriptCommand::onGetFriendlyName() const

View File

@ -136,7 +136,6 @@ std::string SaveFileBaseCommand::saveAsDialog(
base::paths exts = get_writable_extensions();
filename = initialFilename;
#ifdef ENABLE_UI
if (context->isUIAvailable()) {
again:;
base::paths newfilename;
@ -156,7 +155,6 @@ std::string SaveFileBaseCommand::saveAsDialog(
goto again;
}
}
#endif // ENABLE_UI
}
if (filename.empty())
@ -200,7 +198,6 @@ void SaveFileBaseCommand::saveDocumentInBackground(
const ResizeOnTheFly resizeOnTheFly,
const gfx::PointF& scale)
{
#ifdef ENABLE_UI
// If the document is read only, we cannot save it directly (we have
// to use File > Save As)
if (document->isReadOnly() &&
@ -209,7 +206,6 @@ void SaveFileBaseCommand::saveDocumentInBackground(
window.show();
return;
}
#endif // ENABLE_UI
gfx::Rect bounds;
if (params().bounds.isSet()) {
@ -265,12 +261,10 @@ void SaveFileBaseCommand::saveDocumentInBackground(
document->incrementVersion();
}
#ifdef ENABLE_UI
if (context->isUIAvailable() && params().ui()) {
StatusBar::instance()->setStatusText(
2000, Strings::save_file_saved(base::get_file_name(filename)));
}
#endif
}
}
@ -371,7 +365,6 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
bool isPlaySubtags = params().playSubtags();
bool isForTwitter = false;
#if ENABLE_UI
if (params().ui() && context->isUIAvailable()) {
ExportFileWindow win(doc);
bool askOverwrite = true;
@ -447,7 +440,6 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
isForTwitter = win.isForTwitter();
isPlaySubtags = win.isPlaySubtags();
}
#endif
gfx::PointF scaleXY(scale, scale);

View File

@ -141,12 +141,10 @@ protected:
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
docPref.show.brushPreview(!docPref.show.brushPreview());
#if ENABLE_UI
// TODO we shouldn't need this, but it happens to be that the
// Preview editor isn't being updated correctly when we change the
// brush preview state.
update_screen_for_document(ctx->activeDocument());
#endif
}
};

View File

@ -253,8 +253,6 @@ protected:
};
#ifdef ENABLE_UI
class SpriteSizeWindow : public app::gen::SpriteSize {
public:
SpriteSizeWindow(Context* ctx, const SpriteSizeParams& params) : m_ctx(ctx) {
@ -350,7 +348,6 @@ private:
Context* m_ctx;
};
#endif // ENABLE_UI
class SpriteSizeCommand : public CommandWithNewParams<SpriteSizeParams> {
public:
@ -437,7 +434,6 @@ void SpriteSizeCommand::onExecute(Context* context)
int new_height = params.height();
ResizeMethod resize_method = params.method();
#ifdef ENABLE_UI
if (ui) {
SpriteSizeWindow window(context, params);
window.remapWindow();
@ -458,7 +454,6 @@ void SpriteSizeCommand::onExecute(Context* context)
set_config_int("SpriteSize", "Method", resize_method);
set_config_bool("SpriteSize", "LockRatio", window.lockRatio()->isSelected());
}
#endif // ENABLE_UI
new_width = std::clamp(new_width, 1, DOC_SPRITE_MAX_WIDTH);
new_height = std::clamp(new_height, 1, DOC_SPRITE_MAX_HEIGHT);
@ -469,9 +464,7 @@ void SpriteSizeCommand::onExecute(Context* context)
job.waitJob();
}
#ifdef ENABLE_UI
update_screen_for_document(doc);
#endif
}
Command* CommandFactory::createSpriteSizeCommand()

View File

@ -19,15 +19,12 @@
#include "app/pref/preferences.h"
#include "app/ui/editor/editor.h"
#include "app/ui/status_bar.h"
#include "app/ui/timeline/timeline.h"
#include "base/thread.h"
#include "doc/sprite.h"
#include "ui/manager.h"
#include "ui/system.h"
#ifdef ENABLE_UI
#include "app/ui/timeline/timeline.h"
#endif
namespace app {
class UndoCommand : public Command {
@ -67,7 +64,6 @@ void UndoCommand::onExecute(Context* context)
Doc* document(writer.document());
DocUndo* undo = document->undoHistory();
#ifdef ENABLE_UI
auto editor = Editor::activeEditor();
Sprite* sprite = document->sprite();
SpritePosition spritePosition;
@ -120,7 +116,6 @@ void UndoCommand::onExecute(Context* context)
else
statusbar->setStatusText(0, msg);
}
#endif // ENABLE_UI
// Effectively undo/redo.
if (m_type == Undo)
@ -128,7 +123,6 @@ void UndoCommand::onExecute(Context* context)
else
undo->redo();
#ifdef ENABLE_UI
// After redo/undo, we retry to change the current SpritePosition
// (because new frames/layers could be added, positions that we
// weren't able to reach before the undo).
@ -157,14 +151,11 @@ void UndoCommand::onExecute(Context* context)
timeline->setRange(docRange);
}
}
#endif // ENABLE_UI
document->generateMaskBoundaries();
document->setExtraCel(ExtraCelRef(nullptr));
#ifdef ENABLE_UI
update_screen_for_document(document);
#endif
set_current_palette(writer.palette(), false);
}

View File

@ -5,86 +5,51 @@
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
FOR_EACH_COMMAND(About)
FOR_EACH_COMMAND(AddColor)
FOR_EACH_COMMAND(AdvancedMode)
FOR_EACH_COMMAND(AutocropSprite)
FOR_EACH_COMMAND(BackgroundFromLayer)
FOR_EACH_COMMAND(BrightnessContrast)
FOR_EACH_COMMAND(Cancel)
FOR_EACH_COMMAND(CanvasSize)
FOR_EACH_COMMAND(CelOpacity)
FOR_EACH_COMMAND(ChangePixelFormat)
FOR_EACH_COMMAND(ColorCurve)
FOR_EACH_COMMAND(ColorQuantization)
FOR_EACH_COMMAND(ConvertLayer)
FOR_EACH_COMMAND(ConvolutionMatrix)
FOR_EACH_COMMAND(CopyColors)
FOR_EACH_COMMAND(CopyPath)
FOR_EACH_COMMAND(CopyTiles)
FOR_EACH_COMMAND(CropSprite)
FOR_EACH_COMMAND(DeselectMask)
FOR_EACH_COMMAND(Despeckle)
FOR_EACH_COMMAND(ExportSpriteSheet)
FOR_EACH_COMMAND(ExportTileset)
FOR_EACH_COMMAND(Fill)
FOR_EACH_COMMAND(FlattenLayers)
FOR_EACH_COMMAND(Flip)
FOR_EACH_COMMAND(HueSaturation)
FOR_EACH_COMMAND(ImportSpriteSheet)
FOR_EACH_COMMAND(InvertColor)
FOR_EACH_COMMAND(LayerFromBackground)
FOR_EACH_COMMAND(LoadPalette)
FOR_EACH_COMMAND(MaskAll)
FOR_EACH_COMMAND(MergeDownLayer)
FOR_EACH_COMMAND(MoveColors)
FOR_EACH_COMMAND(MoveTiles)
FOR_EACH_COMMAND(NewFile)
FOR_EACH_COMMAND(NewFrame)
FOR_EACH_COMMAND(NewLayer)
FOR_EACH_COMMAND(OpenFile)
FOR_EACH_COMMAND(Outline)
FOR_EACH_COMMAND(PaletteSize)
FOR_EACH_COMMAND(Redo)
FOR_EACH_COMMAND(RemoveLayer)
FOR_EACH_COMMAND(ReplaceColor)
FOR_EACH_COMMAND(SaveFile)
FOR_EACH_COMMAND(SaveFileAs)
FOR_EACH_COMMAND(SaveFileCopyAs)
FOR_EACH_COMMAND(ShowAutoGuides)
FOR_EACH_COMMAND(ShowBrushPreview)
FOR_EACH_COMMAND(ShowExtras)
FOR_EACH_COMMAND(ShowGrid)
FOR_EACH_COMMAND(ShowLayerEdges)
FOR_EACH_COMMAND(ShowPixelGrid)
FOR_EACH_COMMAND(ShowSelectionEdges)
FOR_EACH_COMMAND(ShowSlices)
FOR_EACH_COMMAND(ShowTileNumbers)
FOR_EACH_COMMAND(SpriteSize)
FOR_EACH_COMMAND(Stroke)
FOR_EACH_COMMAND(Undo)
#ifdef ENABLE_UI
FOR_EACH_COMMAND(About)
FOR_EACH_COMMAND(AdvancedMode)
FOR_EACH_COMMAND(Cancel)
FOR_EACH_COMMAND(CelProperties)
FOR_EACH_COMMAND(ChangeBrush)
FOR_EACH_COMMAND(ChangeColor)
FOR_EACH_COMMAND(ChangePixelFormat)
FOR_EACH_COMMAND(Clear)
FOR_EACH_COMMAND(ClearCel)
FOR_EACH_COMMAND(ClearRecentFiles)
FOR_EACH_COMMAND(CloseAllFiles)
FOR_EACH_COMMAND(CloseFile)
FOR_EACH_COMMAND(ColorCurve)
FOR_EACH_COMMAND(ColorQuantization)
FOR_EACH_COMMAND(ContiguousFill)
FOR_EACH_COMMAND(ConvertLayer)
FOR_EACH_COMMAND(ConvolutionMatrix)
FOR_EACH_COMMAND(Copy)
FOR_EACH_COMMAND(CopyCel)
FOR_EACH_COMMAND(CopyColors)
FOR_EACH_COMMAND(CopyMerged)
FOR_EACH_COMMAND(CopyPath)
FOR_EACH_COMMAND(CopyTiles)
FOR_EACH_COMMAND(CropSprite)
FOR_EACH_COMMAND(Cut)
FOR_EACH_COMMAND(DeselectMask)
FOR_EACH_COMMAND(Despeckle)
FOR_EACH_COMMAND(DiscardBrush)
FOR_EACH_COMMAND(DuplicateLayer)
FOR_EACH_COMMAND(DuplicateSprite)
FOR_EACH_COMMAND(DuplicateView)
FOR_EACH_COMMAND(Exit)
FOR_EACH_COMMAND(ExportSpriteSheet)
FOR_EACH_COMMAND(ExportTileset)
FOR_EACH_COMMAND(Eyedropper)
FOR_EACH_COMMAND(Fill)
FOR_EACH_COMMAND(FitScreen)
FOR_EACH_COMMAND(FlattenLayers)
FOR_EACH_COMMAND(Flip)
FOR_EACH_COMMAND(FrameProperties)
FOR_EACH_COMMAND(FrameTagProperties)
FOR_EACH_COMMAND(FullscreenMode)
@ -104,50 +69,71 @@ FOR_EACH_COMMAND(GotoPreviousLayer)
FOR_EACH_COMMAND(GotoPreviousTab)
FOR_EACH_COMMAND(GridSettings)
FOR_EACH_COMMAND(Home)
FOR_EACH_COMMAND(HueSaturation)
FOR_EACH_COMMAND(ImportSpriteSheet)
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)
FOR_EACH_COMMAND(LayerVisibility)
FOR_EACH_COMMAND(LinkCels)
FOR_EACH_COMMAND(LoadMask)
FOR_EACH_COMMAND(LoadPalette)
FOR_EACH_COMMAND(MaskAll)
FOR_EACH_COMMAND(MaskByColor)
FOR_EACH_COMMAND(MaskContent)
FOR_EACH_COMMAND(MergeDownLayer)
FOR_EACH_COMMAND(ModifySelection)
FOR_EACH_COMMAND(MoveCel)
FOR_EACH_COMMAND(MoveColors)
FOR_EACH_COMMAND(MoveMask)
FOR_EACH_COMMAND(MoveTiles)
FOR_EACH_COMMAND(NewBrush)
FOR_EACH_COMMAND(NewFile)
FOR_EACH_COMMAND(NewFrame)
FOR_EACH_COMMAND(NewFrameTag)
FOR_EACH_COMMAND(NewLayer)
FOR_EACH_COMMAND(NewSpriteFromSelection)
FOR_EACH_COMMAND(OpenBrowser)
FOR_EACH_COMMAND(OpenFile)
FOR_EACH_COMMAND(OpenGroup)
FOR_EACH_COMMAND(OpenInFolder)
FOR_EACH_COMMAND(OpenWithApp)
FOR_EACH_COMMAND(Options)
FOR_EACH_COMMAND(Outline)
FOR_EACH_COMMAND(PaletteEditor)
FOR_EACH_COMMAND(PaletteSize)
FOR_EACH_COMMAND(Paste)
FOR_EACH_COMMAND(PasteText)
FOR_EACH_COMMAND(PixelPerfectMode)
FOR_EACH_COMMAND(PlayAnimation)
FOR_EACH_COMMAND(PlayPreviewAnimation)
FOR_EACH_COMMAND(Redo)
FOR_EACH_COMMAND(Refresh)
FOR_EACH_COMMAND(Register)
FOR_EACH_COMMAND(RemoveFrame)
FOR_EACH_COMMAND(RemoveFrameTag)
FOR_EACH_COMMAND(RemoveLayer)
FOR_EACH_COMMAND(RemoveSlice)
FOR_EACH_COMMAND(ReopenClosedFile)
FOR_EACH_COMMAND(RepeatLastExport)
FOR_EACH_COMMAND(ReplaceColor)
FOR_EACH_COMMAND(ReselectMask)
FOR_EACH_COMMAND(ReverseFrames)
FOR_EACH_COMMAND(Rotate)
FOR_EACH_COMMAND(SaveFile)
FOR_EACH_COMMAND(SaveFileAs)
FOR_EACH_COMMAND(SaveFileCopyAs)
FOR_EACH_COMMAND(SaveMask)
FOR_EACH_COMMAND(SavePalette)
FOR_EACH_COMMAND(SelectPaletteColors)
FOR_EACH_COMMAND(Screenshot)
FOR_EACH_COMMAND(Scroll)
FOR_EACH_COMMAND(ScrollCenter)
FOR_EACH_COMMAND(SelectPaletteColors)
FOR_EACH_COMMAND(SelectTile)
FOR_EACH_COMMAND(SelectionAsGrid)
FOR_EACH_COMMAND(SetColorSelector)
@ -157,11 +143,22 @@ FOR_EACH_COMMAND(SetPalette)
FOR_EACH_COMMAND(SetPaletteEntrySize)
FOR_EACH_COMMAND(SetPlaybackSpeed)
FOR_EACH_COMMAND(SetSameInk)
FOR_EACH_COMMAND(ShowAutoGuides)
FOR_EACH_COMMAND(ShowBrushPreview)
FOR_EACH_COMMAND(ShowExtras)
FOR_EACH_COMMAND(ShowGrid)
FOR_EACH_COMMAND(ShowLayerEdges)
FOR_EACH_COMMAND(ShowMenu)
FOR_EACH_COMMAND(ShowOnionSkin)
FOR_EACH_COMMAND(ShowPixelGrid)
FOR_EACH_COMMAND(ShowSelectionEdges)
FOR_EACH_COMMAND(ShowSlices)
FOR_EACH_COMMAND(ShowTileNumbers)
FOR_EACH_COMMAND(SliceProperties)
FOR_EACH_COMMAND(SnapToGrid)
FOR_EACH_COMMAND(SpriteProperties)
FOR_EACH_COMMAND(SpriteSize)
FOR_EACH_COMMAND(Stroke)
FOR_EACH_COMMAND(SwapCheckerboardColors)
FOR_EACH_COMMAND(SwitchColors)
FOR_EACH_COMMAND(SymmetryMode)
@ -176,16 +173,14 @@ FOR_EACH_COMMAND(TogglePreview)
FOR_EACH_COMMAND(ToggleRewindOnStop)
FOR_EACH_COMMAND(ToggleTilesMode)
FOR_EACH_COMMAND(ToggleTimelineThumbnails)
FOR_EACH_COMMAND(Undo)
FOR_EACH_COMMAND(UndoHistory)
FOR_EACH_COMMAND(UnlinkCel)
FOR_EACH_COMMAND(Zoom)
#endif // ENABLE_UI
#ifdef ENABLE_SCRIPTING
#ifdef ENABLE_UI
FOR_EACH_COMMAND(Debugger)
FOR_EACH_COMMAND(DeveloperConsole)
FOR_EACH_COMMAND(OpenScriptFolder)
#endif
FOR_EACH_COMMAND(Debugger)
FOR_EACH_COMMAND(DeveloperConsole)
FOR_EACH_COMMAND(OpenScriptFolder)
FOR_EACH_COMMAND(RunScript)
#endif // ENABLE_SCRIPTING

View File

@ -146,7 +146,6 @@ void ConvertLayerCommand::onExecute(Context* ctx)
Grid grid0 = site.grid();
grid0.origin(gfx::Point(0, 0));
#if ENABLE_UI
if (params().to() == ConvertLayerParam::Tilemap &&
ctx->isUIAvailable() &&
params().ui() &&
@ -175,7 +174,6 @@ void ConvertLayerCommand::onExecute(Context* ctx)
baseIndex = tilesetInfo.baseIndex;
matchFlags = tilesetInfo.matchFlags;
}
#endif
ContextWriter writer(ctx);
Doc* document(writer.document());
@ -261,10 +259,7 @@ void ConvertLayerCommand::onExecute(Context* ctx)
tx.commit();
}
#ifdef ENABLE_UI
if (ctx->isUIAvailable())
update_screen_for_document(document);
#endif
}
void ConvertLayerCommand::copyCels(Tx& tx,

View File

@ -40,8 +40,6 @@ struct BrightnessContrastParams : public NewParams {
Param<double> contrast { this, 0.0, "contrast" };
};
#ifdef ENABLE_UI
static const char* ConfigSection = "BrightnessContrast";
class BrightnessContrastWindow : public FilterWindow {
@ -81,8 +79,6 @@ private:
BrightnessContrastFilter& m_filter;
};
#endif // ENABLE_UI
class BrightnessContrastCommand : public CommandWithNewParams<BrightnessContrastParams> {
public:
BrightnessContrastCommand();
@ -105,9 +101,7 @@ bool BrightnessContrastCommand::onEnabled(Context* context)
void BrightnessContrastCommand::onExecute(Context* context)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && context->isUIAvailable());
#endif
BrightnessContrastFilter filter;
FilterManagerImpl filterMgr(context, &filter);
@ -121,14 +115,11 @@ void BrightnessContrastCommand::onExecute(Context* context)
if (params().brightness.isSet()) filter.setBrightness(params().brightness() / 100.0);
if (params().contrast.isSet()) filter.setContrast(params().contrast() / 100.0);
#ifdef ENABLE_UI
if (ui) {
BrightnessContrastWindow window(filter, filterMgr);
window.doModal();
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -33,8 +33,6 @@ struct ColorCurveParams : public NewParams {
Param<filters::ColorCurve> curve { this, filters::ColorCurve(), "curve" };
};
#ifdef ENABLE_UI
class ColorCurveWindow : public FilterWindow {
public:
ColorCurveWindow(ColorCurveFilter& filter, FilterManagerImpl& filterMgr)
@ -72,8 +70,6 @@ private:
ColorCurveEditor m_editor;
};
#endif // ENABLE_UI
class ColorCurveCommand : public CommandWithNewParams<ColorCurveParams> {
public:
ColorCurveCommand();
@ -99,7 +95,6 @@ void ColorCurveCommand::onExecute(Context* context)
const bool ui = (params().ui() && context->isUIAvailable());
ColorCurveFilter filter;
#ifdef ENABLE_UI
// Default curve
if (ui) {
static std::unique_ptr<ColorCurve> the_curve;
@ -110,7 +105,6 @@ void ColorCurveCommand::onExecute(Context* context)
}
filter.setCurve(*the_curve.get());
}
#endif
FilterManagerImpl filterMgr(context, &filter);
@ -129,16 +123,13 @@ void ColorCurveCommand::onExecute(Context* context)
filter.setCurve(curve);
}
#ifdef ENABLE_UI
if (ui) {
ColorCurveWindow window(filter, filterMgr);
if (window.doModal()) {
// TODO save the curve?
}
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -51,8 +51,6 @@ struct ConvolutionMatrixParams : public NewParams {
Param<std::string> fromResource { this, std::string(), "fromResource" };
};
#ifdef ENABLE_UI
static const char* ConfigSection = "ConvolutionMatrix";
class ConvolutionMatrixWindow : public FilterWindow {
@ -153,8 +151,6 @@ private:
Button* m_reloadButton;
};
#endif // ENABLE_UI
class ConvolutionMatrixCommand : public CommandWithNewParams<ConvolutionMatrixParams> {
public:
ConvolutionMatrixCommand();
@ -177,15 +173,12 @@ bool ConvolutionMatrixCommand::onEnabled(Context* context)
void ConvolutionMatrixCommand::onExecute(Context* context)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && context->isUIAvailable());
#endif
static ConvolutionMatrixStock stock; // Load stock
ConvolutionMatrixFilter filter; // Create the filter and setup initial settings
std::shared_ptr<ConvolutionMatrix> matrix;
#ifdef ENABLE_UI
if (ui) {
// Get last used (selected) matrix
matrix = stock.getByName(get_config_string(ConfigSection, "Selected", ""));
@ -194,7 +187,6 @@ void ConvolutionMatrixCommand::onExecute(Context* context)
.document(context->activeDocument());
filter.setTiledMode(docPref.tiled.mode());
}
#endif // ENABLE_UI
if (params().tiledMode.isSet()) filter.setTiledMode(params().tiledMode());
if (params().fromResource.isSet()) matrix = stock.getByName(params().fromResource().c_str());
@ -202,7 +194,6 @@ void ConvolutionMatrixCommand::onExecute(Context* context)
FilterManagerImpl filterMgr(context, &filter);
#ifdef ENABLE_UI
if (ui) {
ConvolutionMatrixWindow window(filter, filterMgr, stock);
if (window.doModal()) {
@ -210,9 +201,7 @@ void ConvolutionMatrixCommand::onExecute(Context* context)
set_config_string(ConfigSection, "Selected", filter.getMatrix()->getName());
}
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -46,8 +46,6 @@ struct DespeckleParams : public NewParams {
Param<filters::TiledMode> tiledMode { this, filters::TiledMode::NONE, "tiledMode" };
};
#ifdef ENABLE_UI
static const char* ConfigSection = "Despeckle";
class DespeckleWindow : public FilterWindow {
@ -100,8 +98,6 @@ private:
ExprEntry* m_heightEntry;
};
#endif // ENABLE_UI
class DespeckleCommand : public CommandWithNewParams<DespeckleParams> {
public:
DespeckleCommand();
@ -124,9 +120,7 @@ bool DespeckleCommand::onEnabled(Context* context)
void DespeckleCommand::onExecute(Context* context)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && context->isUIAvailable());
#endif
MedianFilter filter;
filter.setSize(3, 3); // Default size
@ -137,7 +131,6 @@ void DespeckleCommand::onExecute(Context* context)
TARGET_BLUE_CHANNEL |
TARGET_GRAY_CHANNEL);
#ifdef ENABLE_UI
if (ui) {
DocumentPreferences& docPref = Preferences::instance()
.document(context->activeDocument());
@ -145,14 +138,12 @@ void DespeckleCommand::onExecute(Context* context)
filter.setSize(get_config_int(ConfigSection, "Width", 3),
get_config_int(ConfigSection, "Height", 3));
}
#endif
if (params().width.isSet()) filter.setSize(params().width(), filter.getHeight());
if (params().height.isSet()) filter.setSize(filter.getWidth(), params().height());
if (params().channels.isSet()) filterMgr.setTarget(params().channels());
if (params().tiledMode.isSet()) filter.setTiledMode(params().tiledMode());
#ifdef ENABLE_UI
if (ui) {
DespeckleWindow window(filter, filterMgr);
if (window.doModal()) {
@ -160,9 +151,7 @@ void DespeckleCommand::onExecute(Context* context)
set_config_int(ConfigSection, "Height", filter.getHeight());
}
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -46,8 +46,6 @@ struct HueSaturationParams : public NewParams {
Param<double> alpha { this, 0.0, "alpha" };
};
#ifdef ENABLE_UI
static const char* ConfigSection = "HueSaturation";
class HueSaturationWindow : public FilterWindow {
@ -139,8 +137,6 @@ private:
ColorSliders m_sliders;
};
#endif // ENABLE_UI
class HueSaturationCommand : public CommandWithNewParams<HueSaturationParams> {
public:
HueSaturationCommand();
@ -163,9 +159,7 @@ bool HueSaturationCommand::onEnabled(Context* ctx)
void HueSaturationCommand::onExecute(Context* ctx)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && ctx->isUIAvailable());
#endif
HueSaturationFilter filter;
FilterManagerImpl filterMgr(ctx, &filter);
@ -184,14 +178,11 @@ void HueSaturationCommand::onExecute(Context* ctx)
if (params().channels.isSet()) channels = params().channels();
filterMgr.setTarget(channels);
#ifdef ENABLE_UI
if (ui) {
HueSaturationWindow window(filter, filterMgr);
window.doModal();
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -36,8 +36,6 @@ struct InvertColorParams : public NewParams {
Param<filters::Target> channels { this, 0, "channels" };
};
#ifdef ENABLE_UI
static const char* ConfigSection = "InvertColor";
class InvertColorWindow : public FilterWindow {
@ -49,8 +47,6 @@ public:
}
};
#endif // ENABLE_UI
class InvertColorCommand : public CommandWithNewParams<InvertColorParams> {
public:
InvertColorCommand();
@ -73,9 +69,7 @@ bool InvertColorCommand::onEnabled(Context* context)
void InvertColorCommand::onExecute(Context* context)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && context->isUIAvailable());
#endif
InvertColorFilter filter;
FilterManagerImpl filterMgr(context, &filter);
@ -86,14 +80,11 @@ void InvertColorCommand::onExecute(Context* context)
if (params().channels.isSet()) filterMgr.setTarget(params().channels());
#ifdef ENABLE_UI
if (ui) {
InvertColorWindow window(filterMgr);
window.doModal();
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -76,8 +76,6 @@ private:
app::Color m_bgColor;
};
#ifdef ENABLE_UI
static const char* ConfigSection = "Outline";
class OutlineWindow : public FilterWindow {
@ -187,8 +185,6 @@ private:
gen::Outline m_panel;
};
#endif // ENABLE_UI
class OutlineCommand : public CommandWithNewParams<OutlineParams> {
public:
OutlineCommand();
@ -211,9 +207,7 @@ bool OutlineCommand::onEnabled(Context* context)
void OutlineCommand::onExecute(Context* context)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && context->isUIAvailable());
#endif
Site site = context->activeSite();
@ -227,7 +221,6 @@ void OutlineCommand::onExecute(Context* context)
filter.bgColor(app::Color::fromMask());
}
#ifdef ENABLE_UI
if (ui) {
filter.place((OutlineFilter::Place)get_config_int(ConfigSection, "Place", int(OutlineFilter::Place::Outside)));
filter.matrix((OutlineFilter::Matrix)get_config_int(ConfigSection, "Matrix", int(OutlineFilter::Matrix::Circle)));
@ -237,7 +230,6 @@ void OutlineCommand::onExecute(Context* context)
.document(site.document());
filter.tiledMode(docPref.tiled.mode());
}
#endif // ENABLE_UI
if (params().place.isSet()) filter.place(params().place());
if (params().matrix.isSet()) filter.matrix(params().matrix());
@ -257,7 +249,6 @@ void OutlineCommand::onExecute(Context* context)
if (params().channels.isSet()) filterMgr.setTarget(params().channels());
#ifdef ENABLE_UI
if (ui) {
OutlineWindow window(filter, filterMgr);
if (window.doModal()) {
@ -265,9 +256,7 @@ void OutlineCommand::onExecute(Context* context)
set_config_int(ConfigSection, "Matrix", int(filter.matrix()));
}
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -72,8 +72,6 @@ private:
app::Color m_to;
};
#ifdef ENABLE_UI
static const char* ConfigSection = "ReplaceColor";
class ReplaceColorWindow : public FilterWindow {
@ -146,8 +144,6 @@ private:
ui::Slider* m_toleranceSlider;
};
#endif // ENABLE_UI
class ReplaceColorCommand : public CommandWithNewParams<ReplaceColorParams> {
public:
ReplaceColorCommand();
@ -170,9 +166,7 @@ bool ReplaceColorCommand::onEnabled(Context* context)
void ReplaceColorCommand::onExecute(Context* context)
{
#ifdef ENABLE_UI
const bool ui = (params().ui() && context->isUIAvailable());
#endif
Site site = context->activeSite();
ReplaceColorFilterWrapper filter(site.layer());
@ -188,25 +182,20 @@ void ReplaceColorCommand::onExecute(Context* context)
filter.setFrom(Preferences::instance().colorBar.fgColor());
filter.setTo(Preferences::instance().colorBar.bgColor());
#ifdef ENABLE_UI
if (ui)
filter.setTolerance(get_config_int(ConfigSection, "Tolerance", 0));
#endif // ENABLE_UI
if (params().from.isSet()) filter.setFrom(params().from());
if (params().to.isSet()) filter.setTo(params().to());
if (params().tolerance.isSet()) filter.setTolerance(params().tolerance());
if (params().channels.isSet()) filterMgr.setTarget(params().channels());
#ifdef ENABLE_UI
if (ui) {
ReplaceColorWindow window(filter, filterMgr);
if (window.doModal())
set_config_int(ConfigSection, "Tolerance", filter.getTolerance());
}
else
#endif // ENABLE_UI
{
else {
start_filter_worker(&filterMgr);
}
}

View File

@ -126,8 +126,6 @@ void FilterManagerImpl::begin()
updateBounds(m_mask);
}
#ifdef ENABLE_UI
void FilterManagerImpl::beginForPreview()
{
Doc* document = m_site.document();
@ -166,8 +164,6 @@ void FilterManagerImpl::beginForPreview()
}
}
#endif // ENABLE_UI
void FilterManagerImpl::end()
{
m_maskBits.unlock();
@ -372,8 +368,6 @@ void FilterManagerImpl::commitTransaction()
m_writer.reset();
}
#ifdef ENABLE_UI
void FilterManagerImpl::flush()
{
int h = m_row - m_nextRowToFlush;
@ -424,8 +418,6 @@ void FilterManagerImpl::disablePreview()
}
}
#endif // ENABLE_UI
const void* FilterManagerImpl::getSourceAddress()
{
return m_src->getPixelAddress(m_bounds.x, m_bounds.y+m_row);
@ -537,16 +529,12 @@ void FilterManagerImpl::applyToPaletteIfNeeded()
m_filter->applyToPalette(this);
}
#ifdef ENABLE_UI
void FilterManagerImpl::redrawColorPalette()
{
set_current_palette(getNewPalette(), false);
ColorBar::instance()->invalidate();
}
#endif // ENABLE_UI
bool FilterManagerImpl::isMaskActive() const
{
return m_site.document()->isMaskVisible();

View File

@ -83,9 +83,7 @@ namespace app {
void setCelsTarget(CelsTarget celsTarget);
void begin();
#ifdef ENABLE_UI
void beginForPreview();
#endif
void end();
bool applyStep();
void applyToTarget();
@ -101,11 +99,9 @@ namespace app {
doc::Image* destinationImage() const { return m_dst.get(); }
gfx::Point position() const { return gfx::Point(0, 0); }
#ifdef ENABLE_UI
// Updates the current editor to show the progress of the preview.
void flush();
void disablePreview();
#endif
void setTaskToken(base::task_token& token);
// FilterManager implementation
@ -141,9 +137,7 @@ namespace app {
void restoreSpritePalette();
void applyToPaletteIfNeeded();
#ifdef ENABLE_UI
void redrawColorPalette();
#endif
ContextReader m_reader;
std::unique_ptr<ContextWriter> m_writer;
@ -153,9 +147,7 @@ namespace app {
doc::ImageRef m_src;
doc::ImageRef m_dst;
int m_row;
#ifdef ENABLE_UI
int m_nextRowToFlush;
#endif
gfx::Rect m_bounds;
doc::Mask* m_mask;
std::unique_ptr<doc::Mask> m_previewMask;

View File

@ -32,8 +32,6 @@ namespace app {
using namespace base;
using namespace ui;
#ifdef ENABLE_UI
namespace {
const int kMonitoringPeriod = 100;
@ -71,8 +69,6 @@ private:
} // anonymous namespace
#endif // ENABLE_UI
// Applies filters in two threads: a background worker thread to
// modify the sprite, and the main thread to monitoring the progress
// (and given to the user the possibility to cancel the process).
@ -90,9 +86,7 @@ public:
private:
void applyFilterInBackground();
#ifdef ENABLE_UI
void onMonitoringTick();
#endif
FilterManagerImpl* m_filterMgr; // Effect to be applied.
std::mutex m_mutex; // Mutex to access to 'pos', 'done' and 'cancelled' fields in different threads.
@ -101,9 +95,7 @@ private:
bool m_cancelled; // Was the effect cancelled by the user?
bool m_abort; // An exception was thrown
std::string m_error;
#ifdef ENABLE_UI
std::unique_ptr<FilterWorkerAlert> m_alert;
#endif
};
FilterWorker::FilterWorker(FilterManagerImpl* filterMgr)
@ -116,18 +108,14 @@ FilterWorker::FilterWorker(FilterManagerImpl* filterMgr)
m_cancelled = false;
m_abort = false;
#ifdef ENABLE_UI
if (Manager::getDefault())
m_alert.reset(new FilterWorkerAlert([this]{ onMonitoringTick(); }));
#endif
}
FilterWorker::~FilterWorker()
{
#ifdef ENABLE_UI
if (m_alert)
m_alert->close();
#endif
}
void FilterWorker::run()
@ -135,7 +123,6 @@ void FilterWorker::run()
// Initialize writting transaction
m_filterMgr->initTransaction();
#ifdef ENABLE_UI
std::thread thread;
// Open the alert window in foreground (this is modal, locks the main thread)
if (m_alert) {
@ -143,9 +130,7 @@ void FilterWorker::run()
thread = std::thread([this]{ applyFilterInBackground(); });
m_alert->openAndWait();
}
else
#endif // ENABLE_UI
{
else {
// Without UI? Apply filter from the main thread
applyFilterInBackground();
}
@ -158,7 +143,6 @@ void FilterWorker::run()
m_cancelled = true;
}
#ifdef ENABLE_UI
// Wait the `effect_bg' thread
if (thread.joinable())
thread.join();
@ -171,7 +155,6 @@ void FilterWorker::run()
StatusBar::instance()->showTip(2500,
Strings::statusbar_tips_filter_no_unlocked_layer());
}
#endif // ENABLE_UI
}
// Called by FilterManagerImpl to informate the progress of the filter.
@ -218,8 +201,6 @@ void FilterWorker::applyFilterInBackground()
}
}
#ifdef ENABLE_UI
// Called by the GUI monitor (a timer in the gui module that is called
// every 100 milliseconds).
void FilterWorker::onMonitoringTick()
@ -234,8 +215,6 @@ void FilterWorker::onMonitoringTick()
}
}
#endif
// Applies the filter in a background thread meanwhile a progress bar
// is shown to the user.
//

View File

@ -59,13 +59,11 @@ protected:
const int beforeIndex = params().before();
int currentEntry = picks.firstPick();
#ifdef ENABLE_UI
if (ctx->isUIAvailable()) {
auto& fgColor = Preferences::instance().colorBar.fgColor;
if (fgColor().getType() == app::Color::IndexType)
currentEntry = fgColor().getIndex();
}
#endif
doc::Palette palette(*writer.palette());
doc::Palette newPalette(palette);
@ -79,13 +77,11 @@ protected:
ctx->setSelectedColors(picks);
#ifdef ENABLE_UI
if (ctx->isUIAvailable()) {
auto& fgColor = Preferences::instance().colorBar.fgColor;
if (fgColor().getType() == app::Color::IndexType)
fgColor(Color::fromIndex(currentEntry));
}
#endif
tx.commit();
}

View File

@ -62,12 +62,7 @@ Preferences& Context::preferences() const
Clipboard* Context::clipboard() const
{
#ifdef ENABLE_UI
return Clipboard::instance();
#else
// TODO support clipboard when !ENABLE_UI
throw std::runtime_error("Clipboard not supported");
#endif
}
void Context::sendDocumentToTop(Doc* document)

View File

@ -51,7 +51,6 @@ void ContextFlags::update(Context* context)
document->unlock(res);
}
#ifdef ENABLE_UI
// TODO this is a hack, try to find a better design to handle this
// "moving pixels" state.
auto editor = Editor::activeEditor();
@ -66,7 +65,6 @@ void ContextFlags::update(Context* context)
updateFlagsFromSite(editor->getSite());
}
#endif // ENABLE_UI
}
}

View File

@ -743,10 +743,8 @@ void Extension::exitScripts()
auto cmd = cmds->byId(item.id.c_str());
ASSERT(cmd);
if (cmd) {
#ifdef ENABLE_UI
// TODO use a signal
AppMenus::instance()->removeMenuItemFromGroup(cmd);
#endif // ENABLE_UI
cmds->remove(cmd);
@ -757,8 +755,6 @@ void Extension::exitScripts()
break;
}
#ifdef ENABLE_UI
case PluginItem::MenuSeparator:
ASSERT(item.widget);
ASSERT(item.widget->parent());
@ -776,8 +772,6 @@ void Extension::exitScripts()
AppMenus::instance()->removeMenuGroup(item.id);
break;
#endif // ENABLE_UI
}
}

View File

@ -254,8 +254,8 @@ FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp* fop)
{
auto opts = fop->formatOptionsOfDocument<CssOptions>();
#ifdef ENABLE_UI
if (fop->context() && fop->context()->isUIAvailable()) {
if (fop->context() &&
fop->context()->isUIAvailable()) {
try {
auto &pref = Preferences::instance();
@ -296,7 +296,6 @@ FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp* fop)
}
}
#endif
return opts;
}

View File

@ -433,7 +433,6 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context,
}
}
#ifdef ENABLE_UI
// TODO add a better dialog to edit file-names
if ((flags & FILE_LOAD_SEQUENCE_ASK) &&
context &&
@ -514,7 +513,6 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context,
}
}
}
#endif // ENABLE_UI
}
}
else {
@ -695,7 +693,6 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
// Show the confirmation alert
if (!warnings.empty()) {
#ifdef ENABLE_UI
// Interative
if (context && context->isUIAvailable()) {
int ret;
@ -724,9 +721,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
return nullptr;
}
// No interactive & fatal error?
else
#endif // ENABLE_UI
if (fatal) {
else if (fatal) {
// Return nullptr as the operation cannot be done because a
// fatal error/conversion was found, e.g. the format doesn't
// support the color mode of the sprite.
@ -777,7 +772,6 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
++outputFrame;
}
#ifdef ENABLE_UI
if (context && context->isUIAvailable() &&
fop->m_seq.filename_list.size() > 1 &&
OptionalAlert::show(
@ -789,7 +783,6 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
base::get_file_name(fop->m_seq.filename_list[1]))) != 1) {
return nullptr;
}
#endif // ENABLE_UI
}
else
fop->m_filename = filename;
@ -1192,7 +1185,6 @@ void FileOp::postLoad()
if (this->hasEmbeddedColorProfile()) {
behavior = m_config.filesWithProfile;
if (behavior == app::gen::ColorProfileBehavior::ASK) {
#ifdef ENABLE_UI
if (m_context && m_context->isUIAvailable()) {
app::gen::AskForColorProfile window;
window.spriteWithoutProfile()->setVisible(false);
@ -1207,9 +1199,7 @@ void FileOp::postLoad()
else
behavior = app::gen::ColorProfileBehavior::DISABLE;
}
else
#endif // ENABLE_UI
{
else {
behavior = app::gen::ColorProfileBehavior::EMBEDDED;
}
}
@ -1218,7 +1208,6 @@ void FileOp::postLoad()
else {
behavior = m_config.missingProfile;
if (behavior == app::gen::ColorProfileBehavior::ASK) {
#ifdef ENABLE_UI
if (m_context && m_context->isUIAvailable()) {
app::gen::AskForColorProfile window;
window.spriteWithProfile()->setVisible(false);
@ -1232,9 +1221,7 @@ void FileOp::postLoad()
behavior = app::gen::ColorProfileBehavior::DISABLE;
}
}
else
#endif // ENABLE_UI
{
else {
behavior = app::gen::ColorProfileBehavior::ASSIGN;
}
}
@ -1283,14 +1270,11 @@ void FileOp::postLoad()
// disk state.
m_document->impossibleToBackToSavedState();
#ifdef ENABLE_UI
if (m_context && m_context->isUIAvailable()) {
IncompatFileWindow window;
window.show(m_incompatibilityError);
}
else
#endif // ENABLE_UI
{
else {
setError(m_incompatibilityError.c_str());
}

View File

@ -1637,7 +1637,6 @@ bool GifFormat::onSave(FileOp* fop)
FormatOptionsPtr GifFormat::onAskUserForFormatOptions(FileOp* fop)
{
auto opts = fop->formatOptionsOfDocument<GifOptions>();
#ifdef ENABLE_UI
if (fop->context() && fop->context()->isUIAvailable()) {
try {
auto& pref = Preferences::instance();
@ -1688,7 +1687,6 @@ FormatOptionsPtr GifFormat::onAskUserForFormatOptions(FileOp* fop)
return std::shared_ptr<GifOptions>(nullptr);
}
}
#endif // ENABLE_UI
return opts;
}

View File

@ -528,7 +528,6 @@ void JpegFormat::saveColorSpace(FileOp* fop, jpeg_compress_struct* cinfo,
FormatOptionsPtr JpegFormat::onAskUserForFormatOptions(FileOp* fop)
{
auto opts = fop->formatOptionsOfDocument<JpegOptions>();
#ifdef ENABLE_UI
if (fop->context() && fop->context()->isUIAvailable()) {
try {
auto& pref = Preferences::instance();
@ -557,7 +556,6 @@ FormatOptionsPtr JpegFormat::onAskUserForFormatOptions(FileOp* fop)
return std::shared_ptr<JpegOptions>(0);
}
}
#endif // ENABLE_UI
return opts;
}

View File

@ -170,7 +170,6 @@ bool SvgFormat::onSave(FileOp* fop)
FormatOptionsPtr SvgFormat::onAskUserForFormatOptions(FileOp* fop)
{
auto opts = fop->formatOptionsOfDocument<SvgOptions>();
#ifdef ENABLE_UI
if (fop->context() && fop->context()->isUIAvailable()) {
try {
auto& pref = Preferences::instance();
@ -199,7 +198,6 @@ FormatOptionsPtr SvgFormat::onAskUserForFormatOptions(FileOp* fop)
return std::shared_ptr<SvgOptions>(nullptr);
}
}
#endif
return opts;
}

View File

@ -334,7 +334,6 @@ FormatOptionsPtr TgaFormat::onAskUserForFormatOptions(FileOp* fop)
{
const bool origOpts = fop->hasFormatOptionsOfDocument();
auto opts = fop->formatOptionsOfDocument<TgaOptions>();
#ifdef ENABLE_UI
if (fop->context() && fop->context()->isUIAvailable()) {
try {
auto& pref = Preferences::instance();
@ -398,7 +397,6 @@ FormatOptionsPtr TgaFormat::onAskUserForFormatOptions(FileOp* fop)
return std::shared_ptr<TgaOptions>(nullptr);
}
}
#endif // ENABLE_UI
return opts;
}

View File

@ -372,7 +372,6 @@ bool WebPFormat::onSave(FileOp* fop)
FormatOptionsPtr WebPFormat::onAskUserForFormatOptions(FileOp* fop)
{
auto opts = fop->formatOptionsOfDocument<WebPOptions>();
#ifdef ENABLE_UI
if (fop->context() && fop->context()->isUIAvailable()) {
try {
auto& pref = Preferences::instance();
@ -457,7 +456,6 @@ FormatOptionsPtr WebPFormat::onAskUserForFormatOptions(FileOp* fop)
return std::shared_ptr<WebPOptions>(nullptr);
}
}
#endif // ENABLE_UI
return opts;
}

View File

@ -32,9 +32,7 @@ static Module module[] =
// first ones.
DEF_MODULE(palette, 0),
#ifdef ENABLE_UI
DEF_MODULE(gui, REQUIRE_INTERFACE),
#endif
};
static int modules = sizeof(module) / sizeof(Module);

View File

@ -382,6 +382,10 @@ static void save_gui_config()
void update_screen_for_document(const Doc* document)
{
auto* ctx = UIContext::instance();
if (!ctx || !ctx->isUIAvailable())
return;
// Without document.
if (!document) {
// Well, change to the default palette.

View File

@ -122,20 +122,8 @@ void load_default_palette()
set_current_palette(nullptr, true);
}
// TODO This palette isn't synced with the current sprite palette when
// ENABLE_UI=0 and we are running scripts, we should remove this
// function and use the active Site palette.
Palette* get_current_palette()
{
#if !ENABLE_UI
if (auto* app = App::instance()) {
if (auto* ctx = app->context()) {
Site site = ctx->activeSite();
if (site.sprite())
return site.palette();
}
}
#endif
return ase_current_palette;
}

View File

@ -200,7 +200,6 @@ int App_redo(lua_State* L)
int App_alert(lua_State* L)
{
#ifdef ENABLE_UI
app::Context* ctx = App::instance()->context();
if (!ctx || !ctx->isUIAvailable())
return 0; // No UI to show the alert
@ -261,17 +260,14 @@ int App_alert(lua_State* L)
lua_pushinteger(L, alert->show());
return 1;
}
#endif
return 0;
}
int App_refresh(lua_State* L)
{
#ifdef ENABLE_UI
app::Context* ctx = App::instance()->context();
if (ctx && ctx->isUIAvailable())
app_refresh_screen();
#endif
return 0;
}
@ -382,14 +378,12 @@ int App_useTool(lua_State* L)
params.brush = get_brush_from_arg(L, -1);
else {
// Default brush is the active brush in the context bar
#ifdef ENABLE_UI
if (App::instance()->isGui() &&
App::instance()->contextBar()) {
params.brush = App::instance()
->contextBar()->activeBrush(params.tool,
params.ink);
}
#endif
}
lua_pop(L, 1);
if (!params.brush) {
@ -526,13 +520,11 @@ int App_get_uiScale(lua_State* L)
int App_get_editor(lua_State* L)
{
#ifdef ENABLE_UI
auto ctx = UIContext::instance();
if (Editor* editor = ctx->activeEditor()) {
push_editor(L, editor);
return 1;
}
#endif
return 0;
}
@ -598,13 +590,10 @@ int App_get_tag(lua_State* L)
app::Context* ctx = App::instance()->context();
Site site = ctx->activeSite();
if (site.sprite()) {
#ifdef ENABLE_UI
if (App::instance()->timeline()) {
tag = App::instance()->timeline()->getTagByFrame(site.frame(), false);
}
else
#endif
{
else {
tag = get_animation_tag(site.sprite(), site.frame());
}
}
@ -692,14 +681,12 @@ int App_get_tool(lua_State* L)
int App_get_brush(lua_State* L)
{
#if ENABLE_UI
App* app = App::instance();
if (app->isGui()) {
doc::BrushRef brush = app->contextBar()->activeBrush();
push_brush(L, brush);
return 1;
}
#endif
push_brush(L, doc::BrushRef(new doc::Brush()));
return 1;
}
@ -716,14 +703,11 @@ int App_get_defaultPalette(lua_State* L)
int App_get_window(lua_State* L)
{
#if ENABLE_UI
App* app = App::instance();
if (app && app->mainWindow()) {
push_ptr(L, (ui::Window*)app->mainWindow());
}
else
#endif
{
else {
lua_pushnil(L);
}
return 1;
@ -784,13 +768,11 @@ int App_set_tool(lua_State* L)
int App_set_brush(lua_State* L)
{
#if ENABLE_UI
if (auto brush = get_brush_from_arg(L, 2)) {
App* app = App::instance();
if (app->isGui())
app->contextBar()->setActiveBrush(brush);
}
#endif
return 0;
}

View File

@ -60,7 +60,6 @@ struct ThemeDimension {
struct ThemeColor { };
#ifdef ENABLE_UI
void push_border_as_table(lua_State* L, const gfx::Border& border)
{
lua_newtable(L);
@ -73,23 +72,17 @@ void push_border_as_table(lua_State* L, const gfx::Border& border)
}
lua_setfield(L, -2, "border");
}
#endif
int ThemeDimension_index(lua_State* L)
{
[[maybe_unused]]
auto themeDimension = get_obj<ThemeDimension>(L, 1);
const char* id = lua_tostring(L, 2);
if (!id)
return luaL_error(L, "id in app.theme.dimension.id must be a string");
#ifdef ENABLE_UI
const int value = themeDimension->getById(id);
lua_pushinteger(L, value);
#else
lua_pushinteger(L, 0);
#endif
return 1;
}
@ -99,31 +92,27 @@ int ThemeColor_index(lua_State* L)
if (!id)
return luaL_error(L, "id in app.theme.color.id must be a string");
#ifdef ENABLE_UI
const gfx::Color uiColor = skin::SkinTheme::instance()->getColorById(id);
if (auto* theme = skin::SkinTheme::instance()) {
const gfx::Color uiColor = theme->getColorById(id);
push_obj<app::Color>(L, color_utils::color_from_ui(uiColor));
#else
}
else {
push_obj<app::Color>(L, app::Color::fromMask());
#endif
}
return 1;
}
int Theme_styleMetrics(lua_State* L)
{
[[maybe_unused]]
auto theme = get_obj<Theme>(L, 1);
const char* id = lua_tostring(L, 2);
if (!id)
return 0;
#ifdef ENABLE_UI
gfx::Border border = theme->styleMetrics(id);
push_border_as_table(L, border);
return 1;
#else // ENABLE_UI
return 0;
#endif
}
int Theme_get_dimension(lua_State* L)

View File

@ -15,8 +15,6 @@
#include "ui/size_hint_event.h"
#include "ui/system.h"
#ifdef ENABLE_UI
namespace app {
namespace script {
@ -218,5 +216,3 @@ void Canvas::onPaint(ui::PaintEvent& ev)
} // namespace script
} // namespace app
#endif // ENABLE_UI

View File

@ -50,8 +50,6 @@
#include <string>
#include <vector>
#ifdef ENABLE_UI
#define TRACE_DIALOG(...) // TRACEARGS(__VA_ARGS__)
namespace app {
@ -1909,5 +1907,3 @@ void close_all_dialogs()
} // namespace script
} // namespace app
#endif // ENABLE_UI

View File

@ -17,8 +17,6 @@
#include "app/ui/editor/select_box_state.h"
#include "ui/display.h"
#ifdef ENABLE_UI
namespace app {
namespace script {
@ -348,5 +346,3 @@ void push_editor(lua_State* L, Editor* editor)
} // namespace script
} // namespace app
#endif // ENABLE_UI

View File

@ -182,12 +182,10 @@ void register_cel_class(lua_State* L);
void register_cels_class(lua_State* L);
void register_color_class(lua_State* L);
void register_color_space_class(lua_State* L);
#ifdef ENABLE_UI
void register_dialog_class(lua_State* L);
void register_editor_class(lua_State* L);
void register_graphics_context_class(lua_State* L);
void register_window_class(lua_State* L);
#endif
void register_events_class(lua_State* L);
void register_frame_class(lua_State* L);
void register_frames_class(lua_State* L);
@ -484,12 +482,10 @@ Engine::Engine()
register_cels_class(L);
register_color_class(L);
register_color_space_class(L);
#ifdef ENABLE_UI
register_dialog_class(L);
register_editor_class(L);
register_graphics_context_class(L);
register_window_class(L);
#endif
register_events_class(L);
register_frame_class(L);
register_frames_class(L);
@ -539,9 +535,7 @@ Engine::~Engine()
void Engine::destroy()
{
#ifdef ENABLE_UI
close_all_dialogs();
#endif
lua_close(L);
L = nullptr;
}

View File

@ -185,9 +185,7 @@ namespace app {
void push_tilesets(lua_State* L, doc::Tilesets* tilesets);
void push_tool(lua_State* L, app::tools::Tool* tool);
void push_version(lua_State* L, const base::Version& ver);
#ifdef ENABLE_UI
void push_window_events(lua_State* L, ui::Window* window);
#endif
gfx::Point convert_args_into_point(lua_State* L, int index);
gfx::Rect convert_args_into_rect(lua_State* L, int index);
@ -214,10 +212,8 @@ namespace app {
int load_sprite_from_file(lua_State* L, const char* filename,
const LoadSpriteFromFileParam param);
#ifdef ENABLE_UI
// close all opened Dialogs before closing the UI
void close_all_dialogs();
#endif
} // namespace script
} // namespace app

View File

@ -571,8 +571,6 @@ void push_sprite_events(lua_State* L, Sprite* sprite)
push_ptr<Events>(L, spriteEvents);
}
#ifdef ENABLE_UI
void push_window_events(lua_State* L, ui::Window* window)
{
if (!g_windowEvents) {
@ -585,7 +583,5 @@ void push_window_events(lua_State* L, ui::Window* window)
push_ptr<Events>(L, g_windowEvents.get());
}
#endif // ENABLE_UI
} // namespace script
} // namespace app

View File

@ -26,8 +26,6 @@
#include <algorithm>
#ifdef ENABLE_UI
namespace app {
namespace script {
@ -549,5 +547,3 @@ void register_graphics_context_class(lua_State* L)
} // namespace script
} // namespace app
#endif // ENABLE_UI

View File

@ -8,8 +8,6 @@
#define APP_SCRIPT_GRAPHICS_CONTEXT_H_INCLUDED
#pragma once
#ifdef ENABLE_UI
#include "doc/palette.h"
#include "gfx/path.h"
#include "os/font.h"
@ -150,5 +148,3 @@ private:
} // namespace app
#endif
#endif

View File

@ -110,10 +110,8 @@ void deleteCommandIfExistent(Extension* ext, const std::string& id)
void deleteMenuGroupIfExistent(Extension* ext, const std::string& id)
{
#ifdef ENABLE_UI
if (auto appMenus = AppMenus::instance())
if (auto* appMenus = AppMenus::instance())
appMenus->removeMenuGroup(id);
#endif
ext->removeMenuGroup(id);
}
@ -172,7 +170,6 @@ int Plugin_newCommand(lua_State* L)
Commands::instance()->add(cmd);
plugin->ext->addCommand(id);
#ifdef ENABLE_UI
// Add a new menu option if the "group" is defined
if (!group.empty() &&
App::instance()->isGui()) { // On CLI menus do not make sense
@ -181,7 +178,6 @@ int Plugin_newCommand(lua_State* L)
appMenus->addMenuItemIntoGroup(group, std::move(menuItem));
}
}
#endif // ENABLE_UI
}
else {
lua_pop(L, 1);
@ -247,7 +243,6 @@ int Plugin_newMenuGroup(lua_State* L)
plugin->ext->addMenuGroup(id);
#ifdef ENABLE_UI
// Add a new menu option if the "group" is defined
if (!group.empty() &&
App::instance()->isGui()) { // On CLI menus do not make sense
@ -258,7 +253,6 @@ int Plugin_newMenuGroup(lua_State* L)
appMenus->addMenuItemIntoGroup(group, std::move(menuItem));
}
}
#endif // ENABLE_UI
}
return 0;
}
@ -288,7 +282,7 @@ int Plugin_deleteMenuGroup(lua_State* L)
int Plugin_newMenuSeparator(lua_State* L)
{
auto plugin = get_obj<Plugin>(L, 1);
auto* plugin = get_obj<Plugin>(L, 1);
if (lua_istable(L, 2)) {
std::string group;
@ -298,7 +292,6 @@ int Plugin_newMenuSeparator(lua_State* L)
}
lua_pop(L, 1);
#ifdef ENABLE_UI
// Add a new separator if the "group" is defined
if (!group.empty() &&
App::instance()->isGui()) { // On CLI menus do not make sense
@ -308,7 +301,6 @@ int Plugin_newMenuSeparator(lua_State* L)
appMenus->addMenuItemIntoGroup(group, std::move(menuItem));
}
}
#endif // ENABLE_UI
}
return 0;
}

View File

@ -188,12 +188,10 @@ int Range_clear(lua_State* L)
doc::PalettePicks picks;
ctx->setSelectedColors(picks);
#ifdef ENABLE_UI
// Empty selected slices in the current editor
// TODO add a new function to Context class for this
if (auto editor = Editor::activeEditor())
editor->clearSlicesSelection();
#endif
obj->updateFromSite(ctx->activeSite());
return 0;
@ -397,7 +395,6 @@ int Range_set_slices(lua_State* L)
app::Context* ctx = App::instance()->context();
// TODO we should add support to CLI scripts
#ifdef ENABLE_UI
if (auto editor = Editor::activeEditor()) {
editor->clearSlicesSelection();
const int len = luaL_len(L, 2);
@ -407,7 +404,6 @@ int Range_set_slices(lua_State* L)
lua_pop(L, 1);
}
}
#endif
obj->updateFromSite(ctx->activeSite());
return 0;

View File

@ -67,8 +67,6 @@ static struct {
{ "package", "loadlib", secure_package_loadlib },
};
#ifdef ENABLE_UI
// Map from .lua file name -> sha1
std::unordered_map<std::string, std::string> g_keys;
@ -100,8 +98,6 @@ std::string get_script_filename(lua_State* L)
return script;
}
#endif // ENABLE_UI
int unsupported(lua_State* L)
{
// debug.getinfo(1, "n").name
@ -242,7 +238,6 @@ bool ask_access(lua_State* L,
const FileAccessMode mode,
const ResourceType resourceType)
{
#ifdef ENABLE_UI
// Ask for permission to open the file
if (App::instance()->context()->isUIAvailable()) {
std::string script = get_script_filename(L);
@ -334,7 +329,6 @@ bool ask_access(lua_State* L,
if (!allow)
return false;
}
#endif
return true;
}

View File

@ -9,8 +9,6 @@
#define TAB_CONTENT_ID(tabid) (tabid + "_content")
#ifdef ENABLE_UI
using namespace ui;
namespace app {
@ -191,5 +189,3 @@ void Tab::onClick()
} // namespace script
} // namespace app
#endif // ENABLE_UI

View File

@ -194,12 +194,10 @@ int WebSocket_connect(lua_State* L)
ws->start();
if (g_connections.empty()) {
#ifdef ENABLE_UI
if (App::instance()->isGui()) {
g_timer = std::make_unique<ui::Timer>(33, ui::Manager::getDefault());
g_timer->start();
}
#endif
}
g_connections.insert(ws);

View File

@ -12,8 +12,6 @@
#include "app/script/luacpp.h"
#include "ui/window.h"
#ifdef ENABLE_UI
namespace app {
namespace script {
@ -64,5 +62,3 @@ void register_window_class(lua_State* L)
} // namespace script
} // namespace app
#endif // ENABLE_UI

View File

@ -62,9 +62,7 @@ void SendCrash::search()
base::is_file(m_dumpFilename)) {
auto app = App::instance();
app->memoryDumpFilename(m_dumpFilename);
#ifdef ENABLE_UI
app->showNotification(this);
#endif
}
#elif defined(__APPLE__)
@ -98,9 +96,7 @@ void SendCrash::search()
m_dumpFilename = fn;
if (auto app = App::instance()) {
app->memoryDumpFilename(fn);
#ifdef ENABLE_UI
app->showNotification(this);
#endif
}
});
}
@ -111,8 +107,6 @@ void SendCrash::search()
#endif
}
#ifdef ENABLE_UI
std::string SendCrash::notificationText()
{
return "Report last crash";
@ -172,6 +166,4 @@ void SendCrash::onClickDevFilename()
base::launcher::open_file(m_dumpFilename);
}
#endif // ENABLE_UI
} // namespace app

View File

@ -18,11 +18,7 @@ namespace app {
#if !ENABLE_SENTRY
class SendCrash
#ifdef ENABLE_UI
: public INotificationDelegate
#endif
{
class SendCrash : public INotificationDelegate {
public:
static std::string DefaultMemoryDumpFilename();
@ -30,7 +26,6 @@ namespace app {
void search();
#ifdef ENABLE_UI
public: // INotificationDelegate impl
virtual std::string notificationText() override;
virtual void notificationClick() override;
@ -38,7 +33,6 @@ namespace app {
private:
void onClickFilename();
void onClickDevFilename();
#endif // ENABLE_UI
private:
Task m_task;

View File

@ -81,11 +81,10 @@ Ink* ActiveToolManager::activeInk() const
if (ink->isPaint() && !ink->isEffect()) {
const tools::InkType inkType = Preferences::instance().tool(tool).ink();
app::Color color;
#ifdef ENABLE_UI
ColorBar* colorbar = ColorBar::instance();
if (ColorBar* colorbar = ColorBar::instance()) {
color = (m_rightClick ? colorbar->getBgColor():
colorbar->getFgColor());
#endif
}
ink = adjustToolInkDependingOnSelectedInkType(ink, inkType, color);
}
@ -238,13 +237,15 @@ void ActiveToolManager::setSelectedTool(Tool* tool)
// static
bool ActiveToolManager::isToolAffectedByRightClickMode(Tool* tool)
{
#if ENABLE_UI
bool shadingMode = ((Preferences::instance().tool(tool).ink() == InkType::SHADING) &&
(App::instance()->contextBar()->getShade().size() >= 2));
#else
bool shadingMode = (Preferences::instance().tool(tool).ink() == InkType::SHADING);
#endif
if (shadingMode) {
if (auto* contextBar = App::instance()->contextBar()) {
// Shading ink is only enabled if we have a shade of two or more
// colors selected, in other case we disable it so a right-click
// can be used for its configured action.
shadingMode = (contextBar->getShade().size() >= 2);
}
}
return
((tool->getInk(0)->isPaint() && !shadingMode) ||

View File

@ -95,9 +95,7 @@ void Transaction::commit()
TX_TRACE("TX: Commit <%s>\n", m_cmds->label().c_str());
m_cmds->updateSpritePositionAfter();
#ifdef ENABLE_UI
const SpritePosition sprPos = m_cmds->spritePositionAfterExecute();
#endif
m_undo->add(m_cmds);
m_cmds = nullptr;
@ -108,7 +106,6 @@ void Transaction::commit()
m_doc->generateMaskBoundaries();
}
#ifdef ENABLE_UI
if (int(m_changes) & int(Changes::kColorChange)) {
ASSERT(m_doc);
ASSERT(m_doc->sprite());
@ -123,7 +120,6 @@ void Transaction::commit()
if (m_ctx->isUIAvailable())
ui::Manager::getDefault()->invalidate();
}
#endif
}
void Transaction::rollbackAndStartAgain()

View File

@ -68,8 +68,6 @@ namespace app {
using namespace ui;
#ifdef ENABLE_UI
static void fill_toolloop_params_from_tool_preferences(ToolLoopParams& params)
{
ToolPreferences& toolPref =
@ -82,8 +80,6 @@ static void fill_toolloop_params_from_tool_preferences(ToolLoopParams& params)
params.freehandAlgorithm = toolPref.freehandAlgorithm();
}
#endif // ENABLE_UI
//////////////////////////////////////////////////////////////////////
// Common properties between drawing/preview ToolLoop impl
@ -162,9 +158,7 @@ public:
, m_isSelectingTiles(false)
, m_grid(grid)
, m_gridBounds(grid.origin(), grid.tileSize())
#ifdef ENABLE_UI
, m_mainTilePos(editor ? -editor->mainTilePosition(): gfx::Point(0, 0))
#endif
, m_button(params.button)
, m_ink(params.ink->clone())
, m_controller(params.controller)
@ -236,13 +230,12 @@ public:
site.tilemapMode(TilemapMode::Pixels);
}
#ifdef ENABLE_UI // TODO add dynamics support when UI is not enabled
if (m_controller->isFreehand() &&
!m_pointShape->isFloodFill() &&
// TODO add dynamics support when UI is not enabled
App::instance()->contextBar()) {
m_dynamics = App::instance()->contextBar()->getDynamics();
}
#endif
if (m_tracePolicy == tools::TracePolicy::Accumulate) {
tools::ToolBox* toolbox = App::instance()->toolBox();
@ -287,18 +280,15 @@ public:
m_opacity = 255;
}
#ifdef ENABLE_UI // TODO add support when UI is not enabled
if (params.inkType == tools::InkType::SHADING) {
// TODO add shading support when UI is not enabled
m_shade = App::instance()->contextBar()->getShade();
m_shadingRemap.reset(
App::instance()->contextBar()->createShadeRemap(
m_button == tools::ToolLoop::Left));
}
#endif
#ifdef ENABLE_UI
updateAllVisibleRegion();
#endif
}
~ToolLoopBase() {
@ -391,33 +381,27 @@ public:
doc::Remap* getShadingRemap() override { return m_shadingRemap.get(); }
void limitDirtyAreaToViewport(gfx::Region& rgn) override {
#ifdef ENABLE_UI
rgn &= m_allVisibleRgn;
#endif // ENABLE_UI
}
void updateDirtyArea(const gfx::Region& dirtyArea) override {
if (!m_editor)
return;
#ifdef ENABLE_UI
// This is necessary here so the "on sprite crosshair" is hidden,
// we update screen pixels with the new sprite, and then we show
// the crosshair saving the updated pixels. It fixes problems with
// filled shape tools when we release the button, or paint-bucket
// when we press the button.
HideBrushPreview hide(m_editor->brushPreview());
#endif
m_document->notifySpritePixelsModified(
m_sprite, dirtyArea, m_frame);
}
void updateStatusBar(const char* text) override {
#ifdef ENABLE_UI
if (auto statusBar = StatusBar::instance())
statusBar->setStatusText(0, text);
#endif
}
gfx::Point statusBarPositionOffset() override {
@ -425,27 +409,18 @@ public:
}
render::DitheringMatrix getDitheringMatrix() override {
#ifdef ENABLE_UI // TODO add support when UI is not enabled
// TODO add support when UI is not enabled
return App::instance()->contextBar()->ditheringMatrix();
#else
return render::DitheringMatrix();
#endif
}
render::DitheringAlgorithmBase* getDitheringAlgorithm() override {
#ifdef ENABLE_UI // TODO add support when UI is not enabled
// TODO add support when UI is not enabled
return App::instance()->contextBar()->ditheringAlgorithm();
#else
return nullptr;
#endif
}
render::GradientType getGradientType() override {
#ifdef ENABLE_UI // TODO add support when UI is not enabled
// TODO add support when UI is not enabled
return App::instance()->contextBar()->gradientType();
#else
return render::GradientType::Linear;
#endif
}
tools::DynamicsOptions getDynamics() override {
@ -458,7 +433,6 @@ public:
return m_tiledModeHelper;
}
#ifdef ENABLE_UI
protected:
void updateAllVisibleRegion() {
m_allVisibleRgn.clear();
@ -473,7 +447,6 @@ protected:
}
}
}
#endif // ENABLE_UI
};
@ -611,17 +584,13 @@ public:
m_mask->bounds().y-m_celOrigin.y):
gfx::Point(0, 0));
#ifdef ENABLE_UI
if (m_editor)
m_editor->add_observer(this);
#endif
}
~ToolLoopImpl() {
#ifdef ENABLE_UI
if (m_editor)
m_editor->remove_observer(this);
#endif
// getSrcImage() is a virtual member function but ToolLoopImpl is
// marked as final to avoid not calling a derived version from
@ -683,12 +652,8 @@ public:
rollback();
}
#ifdef ENABLE_UI
if (redraw)
update_screen_for_document(m_document);
#else
(void)redraw; // To avoid warning about unused variable
#endif
}
void rollback() override {
@ -700,9 +665,7 @@ public:
catch (const LockedDocException& ex) {
Console::showException(ex);
}
#ifdef ENABLE_UI
update_screen_for_document(m_document);
#endif
}
const Cel* getCel() override { return m_expandCelCanvas->getCel(); }
@ -742,7 +705,7 @@ public:
int getSpraySpeed() override { return m_spraySpeed; }
void onSliceRect(const gfx::Rect& bounds) override {
#ifdef ENABLE_UI // TODO add support for slice tool from batch scripts without UI?
// TODO add support for slice tool from batch scripts without UI?
if (m_editor && getMouseButton() == ToolLoop::Left) {
// Try to select slices, but if it returns false, it means that
// there are no slices in the box to be selected, so we show a
@ -766,7 +729,6 @@ public:
return;
}
}
#endif
// Cancel the operation (do not create a new transaction for this
// no-op, e.g. just change the set of selected slices).
@ -775,7 +737,6 @@ public:
private:
#ifdef ENABLE_UI
// EditorObserver impl
void onScrollChanged(Editor* editor) override { updateAllVisibleRegion(); }
void onZoomChanged(Editor* editor) override { updateAllVisibleRegion(); }
@ -790,15 +751,12 @@ private:
return fmt::format("{} {}", prefix, max+1);
}
#endif // ENABLE_UI
};
//////////////////////////////////////////////////////////////////////
// For user UI painting
#ifdef ENABLE_UI
// TODO add inks for tilemaps
static void adjust_ink_for_tilemaps(const Site& site,
ToolLoopParams& params)
@ -943,8 +901,6 @@ tools::ToolLoop* create_tool_loop(
}
}
#endif // ENABLE_UI
//////////////////////////////////////////////////////////////////////
// For scripting
@ -983,8 +939,6 @@ tools::ToolLoop* create_tool_loop_for_script(
//////////////////////////////////////////////////////////////////////
// For UI preview
#ifdef ENABLE_UI
class PreviewToolLoopImpl final : public ToolLoopBase {
Image* m_image;
@ -1112,8 +1066,6 @@ tools::ToolLoop* create_tool_loop_preview(
}
}
#endif // ENABLE_UI
//////////////////////////////////////////////////////////////////////
} // namespace app

View File

@ -54,8 +54,6 @@ namespace app {
//////////////////////////////////////////////////////////////////////
// For UI
#ifdef ENABLE_UI
tools::ToolLoop* create_tool_loop(
Editor* editor,
Context* context,
@ -69,8 +67,6 @@ namespace app {
doc::Image* image,
const gfx::Point& celOrigin);
#endif // ENABLE_UI
//////////////////////////////////////////////////////////////////////
// For scripting

View File

@ -482,7 +482,6 @@ namespace app {
} m_resizeTagData;
};
#ifdef ENABLE_UI
class LockTimelineRange {
public:
LockTimelineRange(Timeline* timeline)
@ -497,12 +496,6 @@ namespace app {
private:
Timeline* m_timeline;
};
#else // !ENABLE_UI
class LockTimelineRange {
public:
LockTimelineRange(Timeline* timeline) { }
};
#endif
} // namespace app

View File

@ -58,15 +58,11 @@ namespace {
}
void observeUIContext() {
#ifdef ENABLE_UI
UIContext::instance()->documents().add_observer(this);
#endif
}
void unobserveUIContext() {
#ifdef ENABLE_UI
UIContext::instance()->documents().remove_observer(this);
#endif
}
bool valid() const {
@ -379,9 +375,7 @@ void Clipboard::cut(ContextWriter& writer)
tx.commit();
}
writer.document()->generateMaskBoundaries();
#ifdef ENABLE_UI
update_screen_for_document(writer.document());
#endif
}
}
@ -412,11 +406,13 @@ void Clipboard::copyRange(const ContextReader& reader, const DocRange& range)
clearContent();
m_data->range.setRange(writer.document(), range);
#ifdef ENABLE_UI
// TODO Replace this with a signal, because here the timeline
// depends on the clipboard and the clipboard on the timeline.
App::instance()->timeline()->activateClipboardRange();
#endif
if (App* app = App::instance()) {
if (Timeline* timeline = app->timeline()) {
timeline->activateClipboardRange();
}
}
}
void Clipboard::copyImage(const Image* image,
@ -478,9 +474,7 @@ void Clipboard::paste(Context* ctx,
if (!dstSpr)
return;
#ifdef ENABLE_UI
Editor* editor = Editor::activeEditor();
#endif
bool updateDstDoc = false;
switch (format()) {
@ -516,7 +510,6 @@ void Clipboard::paste(Context* ctx,
0));
}
#ifdef ENABLE_UI
if (editor && interactive) {
// TODO we don't support pasting in multiple cels at the
// moment, so we clear the range here (same as in
@ -527,9 +520,7 @@ void Clipboard::paste(Context* ctx,
editor->pasteImage(src_image.get(),
m_data->mask.get());
}
else
#endif
{
else {
// Non-interactive version (just copy the image to the cel)
Layer* dstLayer = site.layer();
ASSERT(dstLayer);
@ -565,7 +556,6 @@ void Clipboard::paste(Context* ctx,
}
case ClipboardFormat::Tilemap: {
#ifdef ENABLE_UI
if (editor && interactive) {
// TODO match both tilesets?
// TODO add post-command parameters (issue #2324)
@ -574,9 +564,7 @@ void Clipboard::paste(Context* ctx,
editor->pasteImage(m_data->tilemap.get(),
m_data->mask.get());
}
else
#endif
{
else {
// TODO non-interactive version (for scripts)
}
break;

View File

@ -48,27 +48,21 @@ bool layer_is_locked(Editor* editor)
if (!layer)
return false;
#ifdef ENABLE_UI
auto statusBar = StatusBar::instance();
#endif
auto* statusBar = StatusBar::instance();
if (!layer->isVisibleHierarchy()) {
#ifdef ENABLE_UI
if (statusBar) {
statusBar->showTip(
1000, Strings::statusbar_tips_layer_x_is_hidden(layer->name()));
}
#endif
return true;
}
if (!layer->isEditableHierarchy()) {
#ifdef ENABLE_UI
if (statusBar) {
statusBar->showTip(
1000, Strings::statusbar_tips_layer_locked(layer->name()));
}
#endif
return true;
}