From dd208ebe5dfbd2dee7fb90bfad91e002af1c80fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=AF=D8=A7=D9=86=D8=AA=D9=8A=20=D8=A8=D8=A7=D9=88=D9=84?= =?UTF-8?q?=D8=A7?= <38820379+Liebranca@users.noreply.github.com> Date: Thu, 29 Aug 2024 10:45:52 -0300 Subject: [PATCH 1/6] Use right click action with shading ink (fix #4520) (#4615) --- src/app/tools/active_tool.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/tools/active_tool.cpp b/src/app/tools/active_tool.cpp index ea09997b3..d43a7f961 100644 --- a/src/app/tools/active_tool.cpp +++ b/src/app/tools/active_tool.cpp @@ -11,6 +11,7 @@ #include "app/tools/active_tool.h" +#include "app/app.h" #include "app/color.h" #include "app/pref/preferences.h" #include "app/tools/active_tool_observer.h" @@ -18,6 +19,7 @@ #include "app/tools/pointer.h" #include "app/tools/tool_box.h" #include "app/ui/color_bar.h" +#include "app/ui/context_bar.h" namespace app { namespace tools { @@ -236,7 +238,14 @@ 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 + return ((tool->getInk(0)->isPaint() && !shadingMode) || (tool->getInk(0)->isEffect())) && From 8323a555007e1db9670b098ce4b1b9c5f8b3d7ad Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Thu, 29 Aug 2024 09:57:17 -0300 Subject: [PATCH 2/6] Fix Cancel command do not work on scripting Before this fix, the 'Cancel' command did not work in the following specific situation: As soon as Aseprite was started and without hitting the 'Esc' key, the 'app.command.Cancel()' command did not perform any operation. It was discovered that the Cancel command is started only once per session and retains the 'm_type' throughout the session. Only a specific: app.command.Cancel {type = "all"} or app.command.Cancel {type = "noop"} could change the command type. --- src/app/commands/cmd_cancel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/commands/cmd_cancel.cpp b/src/app/commands/cmd_cancel.cpp index 8991a555e..794781243 100644 --- a/src/app/commands/cmd_cancel.cpp +++ b/src/app/commands/cmd_cancel.cpp @@ -1,4 +1,5 @@ // Aseprite +// Copyright (C) 2024 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -47,6 +48,8 @@ void CancelCommand::onLoadParams(const Params& params) std::string type = params.get("type"); if (type == "noop") m_type = NoOp; else if (type == "all") m_type = All; + // TODO: add specific types for selection/ranges during scripting. + else m_type = All; } void CancelCommand::onExecute(Context* context) From c554f07d284ab7607d770f04cbe3120d059096d4 Mon Sep 17 00:00:00 2001 From: Christian Kaiser Date: Thu, 29 Aug 2024 23:53:12 -0300 Subject: [PATCH 3/6] Adjust strings for clarity/correctness --- data/strings/en.ini | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/data/strings/en.ini b/data/strings/en.ini index 802d20c61..6cab1a729 100644 --- a/data/strings/en.ini +++ b/data/strings/en.ini @@ -48,7 +48,7 @@ cannot_move_bg_layer = The background layer cannot be moved nothing_to_move = Nothing to move recovery_task_using_sprite = Sprite is used by a backup/data recovery task non_transformable_reference_layer = Layer "{}" is reference, cannot be transformed -sprite_locked_somewhere = The sprite is locked in other editor +sprite_locked_somewhere = The sprite is locked in another editor not_enough_transform_memory = Not enough memory to transform the selection not_enough_rotsprite_memory = Not enough memory for RotSprite cannot_modify_readonly_sprite = Cannot modify a read-only sprite.\nUse "File > Save" menu for more information. @@ -62,8 +62,8 @@ deleting_tilemaps_will_delete_tilesets = Warning\n< Save As" menu option in that case.\n||&OK cannot_open_file = Problem< Save As" option to save the file with other name (you will lose information stored in the original file anyway) +message = This file was originally created with a newer version of Aseprite which contains information we cannot fully read.\n\nIt's marked as read-only to avoid losing that information when you try to save/overwrite it.\n\nTo solve this situation you can:\n- Update Aseprite to the latest version and try to load the file again (recommended), or\n- Use the "File > Save As" option to save the file with another name (you will lose information stored in the original file anyway) incompatibilities = Incompatibilities: update_link = Update Aseprite @@ -1291,7 +1291,7 @@ one_win = Confine the user interface to one native window.\ni.e. Menus, Preview, multi_win = Create one native window for each interface window.\ni.e. Menus, Preview, popups have their own window. theme_mode = Theme Mode: screen_scaling = Screen Scaling: -ui_scaling = UI Elements Scaling: +ui_scaling = UI Element Scaling: language = Language: download_translations = Download Translations gpu_acceleration = GPU acceleration [DEVMODE/INTERNAL TESTING ONLY] @@ -1300,7 +1300,7 @@ show_menu_bar = Show Aseprite menu bar show_aseprite_file_dialog = Show Aseprite file dialog show_home = Show Home tab when Aseprite is started expand_menu_bar_items_on_mouseover = Expand menu bar items on mouseover -expand_menu_bar_items_on_mouseover_tooltip = Check this option to get\nthis old menus behavior +expand_menu_bar_items_on_mouseover_tooltip = Check this option to get\nthis old menu behavior color_bar_entries_separator = Draw a separation between each palette entry recover_files = Recover Files auto_save_recovery_data = Automatically save recovery data every @@ -1325,7 +1325,7 @@ keep_edited_sprite_data_tooltip = With this option you can re-open edited docume 2_weeks = 2 Weeks 1_month = 1 Month show_full_path = Show full file name path -show_full_path_tooltip = Uncheck this option if you would prefer to hide\nfull path on UI (e.g. useful for live streaming) +show_full_path_tooltip = Uncheck this option if you would prefer to hide\nfull file paths on the UI (e.g. useful for live streaming) keep_closed_sprite_on_memory = Keep closed sprite on memory for keep_closed_sprite_on_memory_tooltip = When you close a sprite, it will be kept on memory just in case if you\nhave closed the sprite by mistake, so you can "undo" the close action\nusing "File > Open Recent > Reopen Closed File" menu option default_extension_for = Default extension for: @@ -1350,9 +1350,9 @@ show_scrollbars = Show scroll-bars in sprite editor show_scrollbars_tooltip = Show scroll-bars in all sprite editors auto_scroll = Auto-scroll on editor edges auto_fit = Auto-fit on screen when a sprite is opened -straight_line_preview = Preview straight line immediately on Pencil tool -straight_line_preview_tooltip = On Pencil tool you can draw straight lines\nusing Shift + Click, with this option checked\nyou will see the preview immediately when\nthe Shift key is pressed -discard_brush = Discard custom brush when eyedropper is used +straight_line_preview = Preview straight line immediately with the Pencil tool +straight_line_preview_tooltip = The Pencil tool can draw straight lines\nusing Shift + Click, with this option checked\nyou will see the preview immediately when\nthe Shift key is pressed +discard_brush = Discard custom brush whenever the eyedropper is used right_click = Right-click: right_click_paint_bgcolor = Paint with background color right_click_pick_fgcolor = Pick foreground color @@ -1439,23 +1439,23 @@ default_slice_color = Default Color: undo = Undo undo_show_tooltip = Show Undo Tooltip undo_size_limit = Undo Limit: -undo_size_limit_tooltip = Limit of memory to be used\nfor undo information per sprite.\nSpecified in megabytes +undo_size_limit_tooltip = Memory limit to be used\nfor undo information per sprite.\nSpecified in megabytes undo_mb = MB undo_goto_modified = Go to modified frame/layer -undo_goto_modified_tooltip = When it's enabled each time you undo/redo\nthe current frame & layer will be modified\nto focus the undid/redid change +undo_goto_modified_tooltip = When enabled, each time you undo/redo\nthe current frame & layer will be modified\nto focus the undone/redone change undo_allow_nonlinear_history = Allow non-linear history open_sequence_alert = Open a sequence of static files as an animation open_sequence_alert_ask = Ask open_sequence_alert_no = No open_sequence_alert_yes = Yes -file_format_doesnt_support_alert = Show warning when saving a file with unsupported features -export_animation_in_sequence_alert = Show warning when saving an animation as a sequence of static images -overwrite_files_on_export_alert = Show warning when overwriting files on "File > Export" -overwrite_files_on_export_sprite_sheet_alert = Show warning when overwriting files on Export Sprite Sheet -delete_tilemap_delete_unused_tileset_alert = Show warning when deleting a tilemap will delete its unused tileset +file_format_doesnt_support_alert = Show a warning when saving a file with unsupported features +export_animation_in_sequence_alert = Show a warning when saving an animation as a sequence of static images +overwrite_files_on_export_alert = Show a warning when overwriting files with "File > Export" +overwrite_files_on_export_sprite_sheet_alert = Show a warning when overwriting files with Export Sprite Sheet +delete_tilemap_delete_unused_tileset_alert = Show a warning when deleting a tilemap also deletes its unused tileset image_format_alerts = Show options when saving files: -advanced_mode_alert = Show alert when we enter to Advanced Mode -invalid_fg_bg_color_alert = Show alert when drawing with index out of palette bounds +advanced_mode_alert = Show an alert when entering Advanced Mode +invalid_fg_bg_color_alert = Show an alert when drawing with an index outside of palette bounds run_script_alert = Show alert when we try to run a script reset_alerts = Reset all alert dialogs color_management = Color Management @@ -1504,7 +1504,7 @@ native_clipboard = Use native clipboard native_file_dialog = Use native file dialog shaders_for_color_selectors = Use shaders for color selectors hue_with_sat_value = Apply Saturation/Value to Hue slider on Tint/Shade/Tone selector -cache_compressed_tilesets = Cache compressed tilesets for faster save (uses more memory) +cache_compressed_tilesets = Cache compressed tilesets for faster saving (uses more memory) windows_pointer = Windows Pointer options one_finger_as_mouse_movement = Interpret one finger as mouse movement one_finger_as_mouse_movement_tooltip = Interprets one finger as mouse movement and two fingers as pan/scroll.\nUncheck this to use the old behavior: one finger pans/scrolls @@ -1778,7 +1778,7 @@ current_layer = Current layer only behind_sprite = Behind sprite behind_sprite_toolip = Only for transparent layers.\nBackground is not included in this onion skin mode. in_front = In front of sprite -in_front_toolip = For all kind of layers (background and transparents) +in_front_toolip = For all kind of layers (background and transparent) [tools] rectangular_marquee = Rectangular Marquee Tool From fea3f5fceeab027ee3f5402272b94569c7a0daa9 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 30 Aug 2024 14:15:30 -0300 Subject: [PATCH 4/6] Fix English strings considering some comments from Weblate Comments: https://hosted.weblate.org/translate/aseprite/aseprite/en/?checksum=10ed5b5794156584#comments https://hosted.weblate.org/translate/aseprite/aseprite/en/?checksum=a866d26f91d1f329#comments https://hosted.weblate.org/translate/aseprite/aseprite/en/?checksum=df163b02578e8c01#comments https://hosted.weblate.org/translate/aseprite/aseprite/en/?checksum=b23f6bf0b6dcbce4#comments https://hosted.weblate.org/translate/aseprite/aseprite/en/?checksum=1b58980af2aa6bd0#comments --- data/strings/en.ini | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/strings/en.ini b/data/strings/en.ini index 6cab1a729..d9ece8cf2 100644 --- a/data/strings/en.ini +++ b/data/strings/en.ini @@ -820,7 +820,7 @@ title = Home new_file = New File... open_file = Open File... recover_files = Recover Files... -recover_files_tooltip = Recover files from crashed sessions or\nclosed sprite that were not saved in\nprevious sessions +recover_files_tooltip = Recover files from crashed sessions or\nclosed sprites that were not saved in\nprevious sessions share_crashdb = Share crash data with Aseprite developers share_crashdb_tooltip = Check to share crash data with Aseprite developers automatically,\nthis helps to find new bugs and improve the general stability\nof Aseprite for all users recent_files = Recent files: @@ -1161,7 +1161,7 @@ view_advanced_mode = &Advanced Mode view_full_screen_mode = &Full Screen Mode view_full_screen_preview = F&ull Screen Preview view_home = &Home -view_refresh = &Refresh && Reload Skin +view_refresh = &Refresh && Reload Theme help = &Help help_readme = Readme help_quick_reference = Quick &Reference @@ -1221,7 +1221,7 @@ grid_height = Grid Height: name = Name: default_name = Tileset base_index = Base Index: -base_tooltip = Visible aid to see the first tile with content from the tileset\nas index 1 (by default, one-based index) or other value\nE.g. you can use 0 here for zero-based indexing +base_tooltip = This number determines the numeric index of the first tile.\nDefaults to 1, but you can use 0 for zero-based indexing allowed_flips = Allowed Flips: allowed_flips_tooltip = Aseprite can reuse tiles matching automatically with their flipped\nversions (in X, Y, or Diagonal axes) in Auto/Stack modes @@ -1363,7 +1363,7 @@ right_click_lasso = Lasso right_click_select_layer_and_move = Select Layer and Move editor_selection = Selection auto_opaque = Adjust opaque/transparent mode automatically -auto_opaque_tooltip = Depending on the layer (background/transparent),\nthe pasted selection will be adjusted\nautomatically (opaque/transparent) +auto_opaque_tooltip = When we move the selection in the canvas, depending\non the active layer type (background/transparent),\nwe can adjust the selection mode to opaque/transparent\nrespectively keep_selection_after_clear = Keep selection after "Edit > Delete" command keep_selection_after_clear_tooltip = Check this if you want to keep the selection\nafter deleting it auto_show_selection_edges = Show selection edges automatically when the selection is modified @@ -1385,7 +1385,7 @@ rewind_on_stop = Rewind on Stop rewind_on_stop_tooltip = The "Stop" button should rewind the animation\nwhere it was started timeline_selection = Timeline Range Selection keep_timeline_selection = Keep selection -keep_timeline_selection_tooltip = Keep the selected range of layers/frames/cels\nwhen we edit the canvas / the timeline loses\nthe focus +keep_timeline_selection_tooltip = Keep the selected range of layers/frames/cels when\nwe edit the canvas/the timeline loses focus select_on_click = Select on Click select_on_click_tooltip = Enable the selected range of layers/frames/cels\nwhen we press the mouse button select_on_click_with_key = Select on Shift + Click From c4526cf709bd2ca38553f2ec891a69bdf9dc2d0a Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 2 Sep 2024 17:13:53 -0300 Subject: [PATCH 5/6] Remove ENABLE_UI option (#4619) Now we use the LAF_BACKEND=none/skia to detect if it's going to be the CLI/GUI version of the program. The ENABLE_UI flag is still defined at compile-time just to avoid removing all #ifdef/endif conditional directives right now. --- .github/workflows/build.yml | 3 - CMakeLists.txt | 10 +- src/CMakeLists.txt | 8 +- src/app/CMakeLists.txt | 478 ++++++++++++++++++------------------ 4 files changed, 244 insertions(+), 255 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bcfeae49a..3b44061c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,10 +62,8 @@ jobs: fi if [[ "${{ matrix.ui }}" == "gui" ]] ; then - export enable_ui=on export laf_backend=skia else - export enable_ui=off export laf_backend=none fi @@ -85,7 +83,6 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \ -DENABLE_TESTS=ON \ - -DENABLE_UI=$enable_ui \ -DENABLE_SCRIPTING=$enable_scripting \ -DENABLE_CCACHE=$enable_ccache \ -DLAF_BACKEND=$laf_backend \ diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d11de09..c634cecf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,6 @@ option(ENABLE_TRIAL_MODE "Compile the trial version" off) option(ENABLE_DRM "Compile the DRM-enabled version (e.g. for automatic updates)" off) option(ENABLE_STEAM "Compile with Steam library" off) option(ENABLE_DEVMODE "Compile vesion for developers" off) -option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on) option(ENABLE_I18N_STRINGS "Clone i18n strings repo (https://github.com/aseprite/strings) to bin/data/strings.git" off) option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off) option(ENABLE_CLANG_TIDY "Enable static analysis" off) @@ -98,12 +97,9 @@ if(REQUIRE_CURL AND NOT USE_SHARED_CURL) endif() endif() -if(NOT LAF_OS_BACKEND) - if(NOT ENABLE_UI) - set(LAF_OS_BACKEND "none") # Without UI, we use the none backend - else() - set(LAF_OS_BACKEND "skia") - endif() +# By default we'll try to use Skia back-end +if(NOT LAF_BACKEND) + set(LAF_BACKEND "skia") endif() if(ENABLE_DRM AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/drm/CMakeLists.txt) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index baa16672d..58e68673f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,7 @@ endif() if(MSVC) # As Skia is compiled with /GL flag (whole program optimization), # the linker prefer a /LTCG parameter to improve link times. - if(LAF_OS_BACKEND STREQUAL "skia") + if(LAF_BACKEND STREQUAL "skia") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG") endif() @@ -183,7 +183,7 @@ if(ENABLE_ASEPRITE_EXE) add_executable(${main_target} main/main.cpp ${main_resources}) - if(ENABLE_UI) + if(LAF_BACKEND STREQUAL "skia") if(WIN32) set_target_properties(${main_target} PROPERTIES WIN32_EXECUTABLE true) endif() @@ -192,9 +192,9 @@ if(ENABLE_ASEPRITE_EXE) target_link_libraries(${main_target} app-lib) add_dependencies(${main_target} copy_data) - if(LAF_OS_BACKEND_LINK_FLAGS) + if(LAF_BACKEND_LINK_FLAGS) set_target_properties(${main_target} PROPERTIES LINK_FLAGS - ${LAF_OS_BACKEND_LINK_FLAGS}) + ${LAF_BACKEND_LINK_FLAGS}) endif() install(TARGETS ${main_target} diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 7b0668b43..8d92b674e 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -95,6 +95,10 @@ 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) @@ -113,7 +117,7 @@ else() endif() # Data recovery -if(ENABLE_UI AND (NOT ENABLE_TRIAL_MODE OR ENABLE_DRM)) +if(NOT ENABLE_TRIAL_MODE OR ENABLE_DRM) set(ENABLE_DATA_RECOVERY on) else() set(ENABLE_DATA_RECOVERY off) @@ -170,14 +174,6 @@ if(ENABLE_SCRIPTING) target_link_libraries(app-lib lua lauxlib lualib) target_compile_definitions(app-lib PUBLIC -DENABLE_SCRIPTING) - if(ENABLE_UI) - target_sources(app-lib PRIVATE - commands/cmd_developer_console.cpp - commands/cmd_open_script_folder.cpp - commands/debugger.cpp - ui/devconsole_view.cpp) - endif() - if(ENABLE_WEBSOCKET) target_link_libraries(app-lib ixwebsocket) target_compile_definitions(app-lib PUBLIC -DENABLE_WEBSOCKET) @@ -186,11 +182,14 @@ if(ENABLE_SCRIPTING) endif() target_sources(app-lib PRIVATE + commands/cmd_developer_console.cpp + commands/cmd_open_script_folder.cpp commands/cmd_run_script.cpp + commands/debugger.cpp script/app_command_object.cpp script/app_fs_object.cpp - script/app_os_object.cpp script/app_object.cpp + script/app_os_object.cpp script/app_theme_object.cpp script/brush_class.cpp script/canvas_widget.cpp @@ -245,249 +244,23 @@ if(ENABLE_SCRIPTING) script/values.cpp script/version_class.cpp script/window_class.cpp - shell.cpp) -endif() - -# UI-only files -if(ENABLE_UI) - target_compile_definitions(app-lib PUBLIC -DENABLE_UI) - target_sources(app-lib PRIVATE - app_brushes.cpp - app_menus.cpp - closed_docs.cpp - commands/cmd_about.cpp - commands/cmd_advanced_mode.cpp - commands/cmd_cancel.cpp - commands/cmd_cel_properties.cpp - commands/cmd_change_brush.cpp - commands/cmd_change_color.cpp - commands/cmd_clear.cpp - commands/cmd_clear_cel.cpp - commands/cmd_clear_recent_files.cpp - commands/cmd_close_file.cpp - commands/cmd_contiguous_fill.cpp - commands/cmd_copy.cpp - commands/cmd_copy_cel.cpp - commands/cmd_copy_merged.cpp - commands/cmd_cut.cpp - commands/cmd_discard_brush.cpp - commands/cmd_duplicate_layer.cpp - commands/cmd_duplicate_sprite.cpp - commands/cmd_duplicate_view.cpp - commands/cmd_exit.cpp - commands/cmd_eyedropper.cpp - commands/cmd_fit_screen.cpp - commands/cmd_frame_properties.cpp - commands/cmd_frame_tag_properties.cpp - commands/cmd_fullscreen_mode.cpp - commands/cmd_fullscreen_preview.cpp - commands/cmd_goto_frame.cpp - commands/cmd_goto_layer.cpp - commands/cmd_goto_tab.cpp - commands/cmd_grid.cpp - commands/cmd_home.cpp - commands/cmd_invert_mask.cpp - commands/cmd_keyboard_shortcuts.cpp - commands/cmd_launch.cpp - commands/cmd_layer_lock.cpp - commands/cmd_layer_opacity.cpp - commands/cmd_layer_properties.cpp - commands/cmd_layer_visibility.cpp - commands/cmd_link_cels.cpp - commands/cmd_load_mask.cpp - commands/cmd_mask_by_color.cpp - commands/cmd_mask_content.cpp - commands/cmd_modify_selection.cpp - commands/cmd_move_cel.cpp - commands/cmd_move_mask.cpp - commands/cmd_new_brush.cpp - commands/cmd_new_frame_tag.cpp - commands/cmd_new_sprite_from_selection.cpp - commands/cmd_onionskin.cpp - commands/cmd_open_browser.cpp - commands/cmd_open_group.cpp - commands/cmd_open_in_folder.cpp - commands/cmd_open_with_app.cpp - commands/cmd_options.cpp - commands/cmd_palette_editor.cpp - commands/cmd_paste.cpp - commands/cmd_paste_text.cpp - commands/cmd_pixel_perfect_mode.cpp - commands/cmd_play_animation.cpp - commands/cmd_refresh.cpp - commands/cmd_enter_license.cpp - commands/cmd_remove_frame.cpp - commands/cmd_remove_frame_tag.cpp - commands/cmd_remove_slice.cpp - commands/cmd_reopen_closed_file.cpp - commands/cmd_repeat_last_export.cpp - commands/cmd_reselect_mask.cpp - commands/cmd_reverse_frames.cpp - commands/cmd_rotate.cpp - commands/cmd_save_mask.cpp - commands/cmd_save_palette.cpp - commands/cmd_select_palette.cpp - commands/cmd_scroll.cpp - commands/cmd_scroll_center.cpp - commands/cmd_select_tile.cpp - commands/cmd_set_color_selector.cpp - commands/cmd_set_ink_type.cpp - commands/cmd_set_loop_section.cpp - commands/cmd_set_palette.cpp - commands/cmd_set_palette_entry_size.cpp - commands/cmd_set_same_ink.cpp - commands/cmd_slice_properties.cpp - commands/cmd_sprite_properties.cpp - commands/cmd_swap_checkerboard_colors.cpp - commands/cmd_switch_colors.cpp - commands/cmd_symmetry_mode.cpp - commands/cmd_tiled_mode.cpp - commands/cmd_timeline.cpp - commands/cmd_toggle_preview.cpp - commands/cmd_toggle_tiles_mode.cpp - commands/cmd_toggle_timeline_thumbnails.cpp - commands/cmd_undo_history.cpp - commands/cmd_unlink_cel.cpp - commands/cmd_zoom.cpp - commands/filters/filter_preview.cpp - commands/filters/filter_target_buttons.cpp - commands/filters/filter_window.cpp - commands/screenshot.cpp - commands/set_playback_speed.cpp - commands/show_menu.cpp - commands/tileset_mode.cpp - commands/toggle_other_layers_opacity.cpp - commands/toggle_play_option.cpp - file_selector.cpp - modules/gfx.cpp - modules/gui.cpp - ui/alpha_entry.cpp - ui/alpha_slider.cpp - ui/app_menuitem.cpp - ui/backup_indicator.cpp - ui/browser_view.cpp - ui/brush_popup.cpp - ui/button_set.cpp - ui/color_bar.cpp - ui/color_button.cpp - ui/color_popup.cpp - ui/color_selector.cpp - ui/color_shades.cpp - ui/color_sliders.cpp - ui/color_spectrum.cpp - ui/color_tint_shade_tone.cpp - ui/color_wheel.cpp - ui/configure_timeline_popup.cpp - ui/context_bar.cpp - ui/dithering_selector.cpp - ui/doc_view.cpp - ui/drop_down_button.cpp - ui/dynamics_popup.cpp - ui/editor/brush_preview.cpp - ui/editor/delayed_mouse_move.cpp - ui/editor/dragging_value_state.cpp - ui/editor/drawing_state.cpp - ui/editor/editor.cpp - ui/editor/editor_observers.cpp - ui/editor/editor_render.cpp - ui/editor/editor_states_history.cpp - ui/editor/editor_view.cpp - ui/editor/moving_cel_state.cpp - ui/editor/moving_pixels_state.cpp - ui/editor/moving_selection_state.cpp - ui/editor/moving_slice_state.cpp - ui/editor/moving_symmetry_state.cpp - ui/editor/navigate_state.cpp - ui/editor/pivot_helpers.cpp - ui/editor/pixels_movement.cpp - ui/editor/play_state.cpp - ui/editor/scrolling_state.cpp - ui/editor/select_box_state.cpp - ui/editor/standby_state.cpp - ui/editor/state_with_wheel_behavior.cpp - ui/editor/transform_handles.cpp - ui/editor/zooming_state.cpp - ui/export_file_window.cpp - ui/expr_entry.cpp - ui/file_list.cpp - ui/file_list_view.cpp - ui/file_selector.cpp - ui/filename_field.cpp - ui/font_popup.cpp - ui/hex_color_entry.cpp - ui/home_view.cpp - ui/icon_button.cpp - ui/incompat_file_window.cpp - ui/input_chain.cpp - ui/keyboard_shortcuts.cpp - ui/main_menu_bar.cpp - ui/main_window.cpp - ui/mini_help_button.cpp - ui/notifications.cpp - ui/optional_alert.cpp - ui/palette_popup.cpp - ui/palette_view.cpp - ui/palettes_listbox.cpp - ui/popup_window_pin.cpp - ui/pref_widget.cpp - ui/preview_editor.cpp - ui/recent_listbox.cpp - ui/resources_listbox.cpp - ui/rgbmap_algorithm_selector.cpp - ui/sampling_selector.cpp - ui/search_entry.cpp - ui/select_accelerator.cpp - ui/selection_mode_field.cpp - ui/skin/font_data.cpp - ui/skin/skin_part.cpp - ui/skin/skin_property.cpp - ui/skin/skin_slider_property.cpp - ui/skin/skin_theme.cpp - ui/slice_window.cpp - ui/slider2.cpp - ui/status_bar.cpp - ui/tabs.cpp - ui/tag_window.cpp - ui/task_widget.cpp - ui/tile_button.cpp - ui/tileset_selector.cpp - ui/timeline/ani_controls.cpp - ui/timeline/timeline.cpp - ui/toolbar.cpp - ui/user_data_view.cpp - ui/workspace.cpp - ui/workspace_panel.cpp - ui/workspace_tabs.cpp - ui/zoom_entry.cpp - ui_context.cpp - widget_loader.cpp) - if(ENABLE_NEWS) - target_compile_definitions(app-lib PUBLIC -DENABLE_NEWS) - target_sources(app-lib PRIVATE - res/http_loader.cpp - ui/news_listbox.cpp) - endif() - if(ENABLE_DRM) - target_link_libraries(app-lib drm-lib) - target_compile_definitions(app-lib PUBLIC - -DENABLE_DRM - -DENABLE_SAVE) - target_sources(app-lib PRIVATE - ui/enter_license.cpp - ui/aseprite_update.cpp) - endif() + shell.cpp + ui/devconsole_view.cpp) endif() # Main app sources target_sources(app-lib PRIVATE active_site_handler.cpp app.cpp + app_brushes.cpp + app_menus.cpp check_update.cpp cli/app_options.cpp cli/cli_open_file.cpp cli/cli_processor.cpp cli/default_cli_delegate.cpp cli/preview_cli_delegate.cpp + closed_docs.cpp cmd.cpp cmd/add_cel.cpp cmd/add_frame.cpp @@ -589,33 +362,127 @@ target_sources(app-lib PRIVATE color_picker.cpp color_spaces.cpp color_utils.cpp + 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 commands/cmd_change_pixel_format.cpp + commands/cmd_clear.cpp + commands/cmd_clear_cel.cpp + commands/cmd_clear_recent_files.cpp + commands/cmd_close_file.cpp commands/cmd_color_quantization.cpp + commands/cmd_contiguous_fill.cpp + commands/cmd_copy.cpp + commands/cmd_copy_cel.cpp + commands/cmd_copy_merged.cpp commands/cmd_crop.cpp + commands/cmd_cut.cpp commands/cmd_deselect_mask.cpp + commands/cmd_discard_brush.cpp + commands/cmd_duplicate_layer.cpp + commands/cmd_duplicate_sprite.cpp + commands/cmd_duplicate_view.cpp + commands/cmd_enter_license.cpp + commands/cmd_exit.cpp commands/cmd_export_sprite_sheet.cpp + commands/cmd_eyedropper.cpp commands/cmd_fill_and_stroke.cpp + commands/cmd_fit_screen.cpp commands/cmd_flatten_layers.cpp commands/cmd_flip.cpp + commands/cmd_frame_properties.cpp + commands/cmd_frame_tag_properties.cpp + commands/cmd_fullscreen_mode.cpp + commands/cmd_fullscreen_preview.cpp + commands/cmd_goto_frame.cpp + commands/cmd_goto_layer.cpp + commands/cmd_goto_tab.cpp + commands/cmd_grid.cpp + commands/cmd_home.cpp commands/cmd_import_sprite_sheet.cpp + 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 + commands/cmd_layer_visibility.cpp + commands/cmd_link_cels.cpp + commands/cmd_load_mask.cpp commands/cmd_load_palette.cpp commands/cmd_mask_all.cpp + commands/cmd_mask_by_color.cpp + commands/cmd_mask_content.cpp commands/cmd_merge_down_layer.cpp + commands/cmd_modify_selection.cpp + commands/cmd_move_cel.cpp + commands/cmd_move_mask.cpp + commands/cmd_new_brush.cpp commands/cmd_new_file.cpp commands/cmd_new_frame.cpp + commands/cmd_new_frame_tag.cpp commands/cmd_new_layer.cpp + commands/cmd_new_sprite_from_selection.cpp + commands/cmd_onionskin.cpp + commands/cmd_open_browser.cpp commands/cmd_open_file.cpp + commands/cmd_open_group.cpp + commands/cmd_open_in_folder.cpp + commands/cmd_open_with_app.cpp + commands/cmd_options.cpp + commands/cmd_palette_editor.cpp commands/cmd_palette_size.cpp + commands/cmd_paste.cpp + commands/cmd_paste_text.cpp + commands/cmd_pixel_perfect_mode.cpp + commands/cmd_play_animation.cpp + 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_reopen_closed_file.cpp + commands/cmd_repeat_last_export.cpp + commands/cmd_reselect_mask.cpp + commands/cmd_reverse_frames.cpp + commands/cmd_rotate.cpp commands/cmd_save_file.cpp + commands/cmd_save_mask.cpp + commands/cmd_save_palette.cpp + commands/cmd_scroll.cpp + commands/cmd_scroll_center.cpp + commands/cmd_select_palette.cpp + commands/cmd_select_tile.cpp + commands/cmd_set_color_selector.cpp + commands/cmd_set_ink_type.cpp + commands/cmd_set_loop_section.cpp + commands/cmd_set_palette.cpp + commands/cmd_set_palette_entry_size.cpp + commands/cmd_set_same_ink.cpp commands/cmd_show.cpp + commands/cmd_slice_properties.cpp + commands/cmd_sprite_properties.cpp commands/cmd_sprite_size.cpp + commands/cmd_swap_checkerboard_colors.cpp + commands/cmd_switch_colors.cpp + commands/cmd_symmetry_mode.cpp + commands/cmd_tiled_mode.cpp + commands/cmd_timeline.cpp + commands/cmd_toggle_preview.cpp + commands/cmd_toggle_tiles_mode.cpp + commands/cmd_toggle_timeline_thumbnails.cpp commands/cmd_undo.cpp + commands/cmd_undo_history.cpp + commands/cmd_unlink_cel.cpp + commands/cmd_zoom.cpp commands/command.cpp commands/commands.cpp commands/convert_layer.cpp @@ -632,12 +499,21 @@ target_sources(app-lib PRIVATE commands/filters/color_curve_editor.cpp commands/filters/convolution_matrix_stock.cpp commands/filters/filter_manager_impl.cpp + commands/filters/filter_preview.cpp + commands/filters/filter_target_buttons.cpp + commands/filters/filter_window.cpp commands/filters/filter_worker.cpp commands/move_colors_command.cpp commands/move_thing.cpp commands/move_tiles_command.cpp commands/new_params.cpp commands/quick_command.cpp + commands/screenshot.cpp + commands/set_playback_speed.cpp + commands/show_menu.cpp + commands/tileset_mode.cpp + commands/toggle_other_layers_opacity.cpp + commands/toggle_play_option.cpp console.cpp context.cpp context_flags.cpp @@ -658,6 +534,7 @@ target_sources(app-lib PRIVATE file/file_op_config.cpp file/palette_file.cpp file/split_filename.cpp + file_selector.cpp file_system.cpp filename_formatter.cpp flatten.cpp @@ -672,6 +549,8 @@ target_sources(app-lib PRIVATE log.cpp loop_tag.cpp modules.cpp + modules/gfx.cpp + modules/gui.cpp modules/palettes.cpp pref/preferences.cpp recent_files.cpp @@ -700,8 +579,107 @@ target_sources(app-lib PRIVATE tools/velocity.cpp transaction.cpp transformation.cpp + ui/alpha_entry.cpp + ui/alpha_slider.cpp + ui/app_menuitem.cpp + ui/backup_indicator.cpp + ui/browser_view.cpp + ui/brush_popup.cpp + ui/button_set.cpp + ui/color_bar.cpp + ui/color_button.cpp + ui/color_popup.cpp + ui/color_selector.cpp + ui/color_shades.cpp + ui/color_sliders.cpp + ui/color_spectrum.cpp + ui/color_tint_shade_tone.cpp + ui/color_wheel.cpp + ui/configure_timeline_popup.cpp + ui/context_bar.cpp + ui/dithering_selector.cpp + ui/doc_view.cpp + ui/drop_down_button.cpp + ui/dynamics_popup.cpp + ui/editor/brush_preview.cpp + ui/editor/delayed_mouse_move.cpp + ui/editor/dragging_value_state.cpp + ui/editor/drawing_state.cpp + ui/editor/editor.cpp + ui/editor/editor_observers.cpp + ui/editor/editor_render.cpp + ui/editor/editor_states_history.cpp + ui/editor/editor_view.cpp + ui/editor/moving_cel_state.cpp + ui/editor/moving_pixels_state.cpp + ui/editor/moving_selection_state.cpp + ui/editor/moving_slice_state.cpp + ui/editor/moving_symmetry_state.cpp + ui/editor/navigate_state.cpp + ui/editor/pivot_helpers.cpp + ui/editor/pixels_movement.cpp + ui/editor/play_state.cpp + ui/editor/scrolling_state.cpp + ui/editor/select_box_state.cpp + ui/editor/standby_state.cpp + ui/editor/state_with_wheel_behavior.cpp ui/editor/tool_loop_impl.cpp + ui/editor/transform_handles.cpp + ui/editor/zooming_state.cpp + ui/export_file_window.cpp + ui/expr_entry.cpp + ui/file_list.cpp + ui/file_list_view.cpp + ui/file_selector.cpp + ui/filename_field.cpp + ui/font_popup.cpp + ui/hex_color_entry.cpp + ui/home_view.cpp + ui/icon_button.cpp + ui/incompat_file_window.cpp + ui/input_chain.cpp + ui/keyboard_shortcuts.cpp ui/layer_frame_comboboxes.cpp + ui/main_menu_bar.cpp + ui/main_window.cpp + ui/mini_help_button.cpp + ui/notifications.cpp + ui/optional_alert.cpp + ui/palette_popup.cpp + ui/palette_view.cpp + ui/palettes_listbox.cpp + ui/popup_window_pin.cpp + ui/pref_widget.cpp + ui/preview_editor.cpp + ui/recent_listbox.cpp + ui/resources_listbox.cpp + ui/rgbmap_algorithm_selector.cpp + ui/sampling_selector.cpp + ui/search_entry.cpp + ui/select_accelerator.cpp + ui/selection_mode_field.cpp + ui/skin/font_data.cpp + ui/skin/skin_part.cpp + ui/skin/skin_property.cpp + ui/skin/skin_slider_property.cpp + ui/skin/skin_theme.cpp + ui/slice_window.cpp + ui/slider2.cpp + ui/status_bar.cpp + ui/tabs.cpp + ui/tag_window.cpp + ui/task_widget.cpp + ui/tile_button.cpp + ui/tileset_selector.cpp + ui/timeline/ani_controls.cpp + ui/timeline/timeline.cpp + ui/toolbar.cpp + ui/user_data_view.cpp + ui/workspace.cpp + ui/workspace_panel.cpp + ui/workspace_tabs.cpp + ui/zoom_entry.cpp + ui_context.cpp util/autocrop.cpp util/buffer_region.cpp util/cel_ops.cpp @@ -725,6 +703,7 @@ target_sources(app-lib PRIVATE util/tile_flags_utils.cpp util/tileset_utils.cpp util/wrap_point.cpp + widget_loader.cpp xml_document.cpp xml_exception.cpp) @@ -732,6 +711,23 @@ if(TARGET generated_version) add_dependencies(app-lib generated_version) endif() +if(ENABLE_NEWS) + target_compile_definitions(app-lib PUBLIC -DENABLE_NEWS) + target_sources(app-lib PRIVATE + res/http_loader.cpp + ui/news_listbox.cpp) +endif() + +if(ENABLE_DRM) + target_link_libraries(app-lib drm-lib) + target_compile_definitions(app-lib PUBLIC + -DENABLE_DRM + -DENABLE_SAVE) + target_sources(app-lib PRIVATE + ui/enter_license.cpp + ui/aseprite_update.cpp) +endif() + target_link_libraries(app-lib laf-base cfg-lib From bf0a47545c9d749471c902e6d628be8013a8c55a Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 2 Sep 2024 23:12:13 -0300 Subject: [PATCH 6/6] 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(). --- src/app/CMakeLists.txt | 4 - src/app/app.cpp | 95 +++++--------- src/app/app.h | 7 -- src/app/cmd_transaction.cpp | 18 +-- src/app/color_spaces.cpp | 4 +- .../commands/cmd_background_from_layer.cpp | 5 +- src/app/commands/cmd_canvas_size.cpp | 13 +- src/app/commands/cmd_cel_opacity.cpp | 7 +- src/app/commands/cmd_change_pixel_format.cpp | 6 - src/app/commands/cmd_color_quantization.cpp | 9 +- src/app/commands/cmd_crop.cpp | 10 +- src/app/commands/cmd_deselect_mask.cpp | 5 +- src/app/commands/cmd_export_sprite_sheet.cpp | 22 +--- src/app/commands/cmd_fill_and_stroke.cpp | 4 +- src/app/commands/cmd_flatten_layers.cpp | 4 - src/app/commands/cmd_flip.cpp | 9 +- src/app/commands/cmd_import_sprite_sheet.cpp | 12 +- .../commands/cmd_layer_from_background.cpp | 5 +- src/app/commands/cmd_load_palette.cpp | 2 - src/app/commands/cmd_mask_all.cpp | 5 +- src/app/commands/cmd_merge_down_layer.cpp | 5 +- src/app/commands/cmd_new_file.cpp | 11 +- src/app/commands/cmd_new_frame.cpp | 8 -- src/app/commands/cmd_new_layer.cpp | 10 -- src/app/commands/cmd_open_file.cpp | 5 +- src/app/commands/cmd_palette_size.cpp | 2 - src/app/commands/cmd_remove_layer.cpp | 8 -- src/app/commands/cmd_run_script.cpp | 4 - src/app/commands/cmd_save_file.cpp | 8 -- src/app/commands/cmd_show.cpp | 2 - src/app/commands/cmd_sprite_size.cpp | 7 -- src/app/commands/cmd_undo.cpp | 11 +- src/app/commands/commands_list.h | 117 +++++++++--------- src/app/commands/convert_layer.cpp | 7 +- .../filters/cmd_brightness_contrast.cpp | 11 +- src/app/commands/filters/cmd_color_curve.cpp | 11 +- .../filters/cmd_convolution_matrix.cpp | 13 +- src/app/commands/filters/cmd_despeckle.cpp | 13 +- .../commands/filters/cmd_hue_saturation.cpp | 11 +- src/app/commands/filters/cmd_invert_color.cpp | 11 +- src/app/commands/filters/cmd_outline.cpp | 13 +- .../commands/filters/cmd_replace_color.cpp | 13 +- .../commands/filters/filter_manager_impl.cpp | 12 -- .../commands/filters/filter_manager_impl.h | 8 -- src/app/commands/filters/filter_worker.cpp | 23 +--- src/app/commands/move_colors_command.cpp | 4 - src/app/context.cpp | 5 - src/app/context_flags.cpp | 2 - src/app/extensions.cpp | 6 - src/app/file/css_format.cpp | 5 +- src/app/file/file.cpp | 24 +--- src/app/file/gif_format.cpp | 2 - src/app/file/jpeg_format.cpp | 2 - src/app/file/svg_format.cpp | 2 - src/app/file/tga_format.cpp | 2 - src/app/file/webp_format.cpp | 2 - src/app/modules.cpp | 2 - src/app/modules/gui.cpp | 4 + src/app/modules/palettes.cpp | 12 -- src/app/script/app_object.cpp | 22 +--- src/app/script/app_theme_object.cpp | 25 ++-- src/app/script/canvas_widget.cpp | 4 - src/app/script/dialog_class.cpp | 4 - src/app/script/editor_class.cpp | 4 - src/app/script/engine.cpp | 6 - src/app/script/engine.h | 4 - src/app/script/events_class.cpp | 4 - src/app/script/graphics_context.cpp | 4 - src/app/script/graphics_context.h | 4 - src/app/script/plugin_class.cpp | 12 +- src/app/script/range_class.cpp | 4 - src/app/script/security.cpp | 6 - src/app/script/tabs_widget.cpp | 4 - src/app/script/websocket_class.cpp | 2 - src/app/script/window_class.cpp | 4 - src/app/send_crash.cpp | 8 -- src/app/send_crash.h | 8 +- src/app/tools/active_tool.cpp | 23 ++-- src/app/transaction.cpp | 4 - src/app/ui/editor/tool_loop_impl.cpp | 60 +-------- src/app/ui/editor/tool_loop_impl.h | 4 - src/app/ui/timeline/timeline.h | 7 -- src/app/util/clipboard.cpp | 26 ++-- src/app/util/layer_utils.cpp | 8 +- 84 files changed, 169 insertions(+), 756 deletions(-) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 8d92b674e..44249ecb7 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -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) diff --git a/src/app/app.cpp b/src/app/app.cpp index 6899b516d..e0f480e3a 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -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 - if (m_isGui) - m_engine->notifyRunningGui(); - #endif -#else - m_isGui = false; +#ifdef ENABLE_SCRIPTING + if (m_isGui) + m_engine->notifyRunningGui(); #endif m_isShell = options.startShell(); @@ -350,9 +334,7 @@ int App::initialize(const AppOptions& options) // Load modules m_modules = std::make_unique(createLogInDesktop, pref); m_legacy = std::make_unique(isGui() ? REQUIRE_INTERFACE: 0); -#ifdef ENABLE_UI m_brushes = std::make_unique(); -#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& m_win; CloseMainWindow(std::unique_ptr& 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 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(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); } diff --git a/src/app/app.h b/src/app/app.h index b55c79dc0..96c3ea7a6 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -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 m_mainWindow; base::paths m_files; -#ifdef ENABLE_UI std::unique_ptr m_brushes; std::unique_ptr m_backupIndicator; -#endif // ENABLE_UI #ifdef ENABLE_SCRIPTING std::unique_ptr m_engine; #endif diff --git a/src/app/cmd_transaction.cpp b/src/app/cmd_transaction.cpp index 339d022e6..a6b59775c 100644 --- a/src/app/cmd_transaction.cpp +++ b/src/app/cmd_transaction.cpp @@ -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(); } diff --git a/src/app/color_spaces.cpp b/src/app/color_spaces.cpp index 532f79372..bf66c5cef 100644 --- a/src/app/color_spaces.cpp +++ b/src/app/color_spaces.cpp @@ -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(); } diff --git a/src/app/commands/cmd_background_from_layer.cpp b/src/app/commands/cmd_background_from_layer.cpp index 1cd36cbdd..35db18a61 100644 --- a/src/app/commands/cmd_background_from_layer.cpp +++ b/src/app/commands/cmd_background_from_layer.cpp @@ -60,10 +60,7 @@ void BackgroundFromLayerCommand::onExecute(Context* context) tx.commit(); } -#ifdef ENABLE_UI - if (context->isUIAvailable()) - update_screen_for_document(document); -#endif + update_screen_for_document(document); } Command* CommandFactory::createBackgroundFromLayerCommand() diff --git a/src/app/commands/cmd_canvas_size.cpp b/src/app/commands/cmd_canvas_size.cpp index ca17640ab..7de65ea2c 100644 --- a/src/app/commands/cmd_canvas_size.cpp +++ b/src/app/commands/cmd_canvas_size.cpp @@ -48,8 +48,6 @@ struct CanvasSizeParams : public NewParams { Param 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 { 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 + update_screen_for_document(doc); } } diff --git a/src/app/commands/cmd_cel_opacity.cpp b/src/app/commands/cmd_cel_opacity.cpp index 7389787a1..8eea2de8a 100644 --- a/src/app/commands/cmd_cel_opacity.cpp +++ b/src/app/commands/cmd_cel_opacity.cpp @@ -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 + update_screen_for_document(writer.document()); } std::string CelOpacityCommand::onGetFriendlyName() const diff --git a/src/app/commands/cmd_change_pixel_format.cpp b/src/app/commands/cmd_change_pixel_format.cpp index 500013497..341f6c4b4 100644 --- a/src/app/commands/cmd_change_pixel_format.cpp +++ b/src/app/commands/cmd_change_pixel_format.cpp @@ -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(); diff --git a/src/app/commands/cmd_color_quantization.cpp b/src/app/commands/cmd_color_quantization.cpp index 986f8b2a3..de1699ede 100644 --- a/src/app/commands/cmd_color_quantization.cpp +++ b/src/app/commands/cmd_color_quantization.cpp @@ -41,8 +41,6 @@ struct ColorQuantizationParams : public NewParams { Param 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 { 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()); } diff --git a/src/app/commands/cmd_crop.cpp b/src/app/commands/cmd_crop.cpp index 207bde55f..2fb457342 100644 --- a/src/app/commands/cmd_crop.cpp +++ b/src/app/commands/cmd_crop.cpp @@ -77,10 +77,7 @@ void CropSpriteCommand::onExecute(Context* context) tx.commit(); } -#ifdef ENABLE_UI - if (context->isUIAvailable()) - update_screen_for_document(document); -#endif + update_screen_for_document(document); } 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 + update_screen_for_document(document); } std::string AutocropSpriteCommand::onGetFriendlyName() const diff --git a/src/app/commands/cmd_deselect_mask.cpp b/src/app/commands/cmd_deselect_mask.cpp index 7dc7a7799..bd39bd7e3 100644 --- a/src/app/commands/cmd_deselect_mask.cpp +++ b/src/app/commands/cmd_deselect_mask.cpp @@ -49,10 +49,7 @@ void DeselectMaskCommand::onExecute(Context* context) tx.commit(); } -#ifdef ENABLE_UI - if (context->isUIAvailable()) - update_screen_for_document(document); -#endif + update_screen_for_document(document); } Command* CommandFactory::createDeselectMaskCommand() diff --git a/src/app/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp index 37f716718..62d6f3326 100644 --- a/src/app/commands/cmd_export_sprite_sheet.cpp +++ b/src/app/commands/cmd_export_sprite_sheet.cpp @@ -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 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 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()); std::unique_ptr 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); diff --git a/src/app/commands/cmd_fill_and_stroke.cpp b/src/app/commands/cmd_fill_and_stroke.cpp index ac17ae1c5..2e67f2dc7 100644 --- a/src/app/commands/cmd_fill_and_stroke.cpp +++ b/src/app/commands/cmd_fill_and_stroke.cpp @@ -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; } diff --git a/src/app/commands/cmd_flatten_layers.cpp b/src/app/commands/cmd_flatten_layers.cpp index b5c3439ec..59f11495d 100644 --- a/src/app/commands/cmd_flatten_layers.cpp +++ b/src/app/commands/cmd_flatten_layers.cpp @@ -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 diff --git a/src/app/commands/cmd_flip.cpp b/src/app/commands/cmd_flip.cpp index 14c58ea10..1c0561d97 100644 --- a/src/app/commands/cmd_flip.cpp +++ b/src/app/commands/cmd_flip.cpp @@ -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 + update_screen_for_document(document); } std::string FlipCommand::onGetFriendlyName() const diff --git a/src/app/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp index 955ea442e..d40a313bc 100644 --- a/src/app/commands/cmd_import_sprite_sheet.cpp +++ b/src/app/commands/cmd_import_sprite_sheet.cpp @@ -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 + update_screen_for_document(document); } Command* CommandFactory::createImportSpriteSheetCommand() diff --git a/src/app/commands/cmd_layer_from_background.cpp b/src/app/commands/cmd_layer_from_background.cpp index 7513acf30..c67218163 100644 --- a/src/app/commands/cmd_layer_from_background.cpp +++ b/src/app/commands/cmd_layer_from_background.cpp @@ -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 + update_screen_for_document(document); } Command* CommandFactory::createLayerFromBackgroundCommand() diff --git a/src/app/commands/cmd_load_palette.cpp b/src/app/commands/cmd_load_palette.cpp index d71ccc1c4..27daeb014 100644 --- a/src/app/commands/cmd_load_palette.cpp +++ b/src/app/commands/cmd_load_palette.cpp @@ -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()) diff --git a/src/app/commands/cmd_mask_all.cpp b/src/app/commands/cmd_mask_all.cpp index aa0936054..ec4aabb4d 100644 --- a/src/app/commands/cmd_mask_all.cpp +++ b/src/app/commands/cmd_mask_all.cpp @@ -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 + update_screen_for_document(document); } Command* CommandFactory::createMaskAllCommand() diff --git a/src/app/commands/cmd_merge_down_layer.cpp b/src/app/commands/cmd_merge_down_layer.cpp index b7d41aac7..05b5d7961 100644 --- a/src/app/commands/cmd_merge_down_layer.cpp +++ b/src/app/commands/cmd_merge_down_layer.cpp @@ -163,10 +163,7 @@ void MergeDownLayerCommand::onExecute(Context* context) tx.commit(); -#ifdef ENABLE_UI - if (context->isUIAvailable()) - update_screen_for_document(document); -#endif + update_screen_for_document(document); } Command* CommandFactory::createMergeDownLayerCommand() diff --git a/src/app/commands/cmd_new_file.cpp b/src/app/commands/cmd_new_file.cpp index e09391455..c357aa364 100644 --- a/src/app/commands/cmd_new_file.cpp +++ b/src/app/commands/cmd_new_file.cpp @@ -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(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()); diff --git a/src/app/commands/cmd_new_frame.cpp b/src/app/commands/cmd_new_frame.cpp index 2d1d9a2c2..e015b0445 100644 --- a/src/app/commands/cmd_new_frame.cpp +++ b/src/app/commands/cmd_new_frame.cpp @@ -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(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 diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp index b39e4cc44..520ea7b9d 100644 --- a/src/app/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -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 diff --git a/src/app/commands/cmd_open_file.cpp b/src/app/commands/cmd_open_file.cpp index 158352717..a6b68e73a 100644 --- a/src/app/commands/cmd_open_file.cpp +++ b/src/app/commands/cmd_open_file.cpp @@ -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); } diff --git a/src/app/commands/cmd_palette_size.cpp b/src/app/commands/cmd_palette_size.cpp index cee0302da..6464b3999 100644 --- a/src/app/commands/cmd_palette_size.cpp +++ b/src/app/commands/cmd_palette_size.cpp @@ -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; diff --git a/src/app/commands/cmd_remove_layer.cpp b/src/app/commands/cmd_remove_layer.cpp index 8a95637ba..e821860a0 100644 --- a/src/app/commands/cmd_remove_layer.cpp +++ b/src/app/commands/cmd_remove_layer.cpp @@ -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() diff --git a/src/app/commands/cmd_run_script.cpp b/src/app/commands/cmd_run_script.cpp index 4c7b1e1ec..c6fadc28e 100644 --- a/src/app/commands/cmd_run_script.cpp +++ b/src/app/commands/cmd_run_script.cpp @@ -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 diff --git a/src/app/commands/cmd_save_file.cpp b/src/app/commands/cmd_save_file.cpp index b54fe446d..3c7f33f21 100644 --- a/src/app/commands/cmd_save_file.cpp +++ b/src/app/commands/cmd_save_file.cpp @@ -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); diff --git a/src/app/commands/cmd_show.cpp b/src/app/commands/cmd_show.cpp index d2182c138..53e80152d 100644 --- a/src/app/commands/cmd_show.cpp +++ b/src/app/commands/cmd_show.cpp @@ -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 } }; diff --git a/src/app/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp index 3f82d6359..f5b778383 100644 --- a/src/app/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -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 { 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() diff --git a/src/app/commands/cmd_undo.cpp b/src/app/commands/cmd_undo.cpp index 0bf0f5a9b..8f36e6084 100644 --- a/src/app/commands/cmd_undo.cpp +++ b/src/app/commands/cmd_undo.cpp @@ -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); } diff --git a/src/app/commands/commands_list.h b/src/app/commands/commands_list.h index 4b732b903..583ff4446 100644 --- a/src/app/commands/commands_list.h +++ b/src/app/commands/commands_list.h @@ -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 diff --git a/src/app/commands/convert_layer.cpp b/src/app/commands/convert_layer.cpp index 738839fe2..e7fe1ee6f 100644 --- a/src/app/commands/convert_layer.cpp +++ b/src/app/commands/convert_layer.cpp @@ -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 + update_screen_for_document(document); } void ConvertLayerCommand::copyCels(Tx& tx, diff --git a/src/app/commands/filters/cmd_brightness_contrast.cpp b/src/app/commands/filters/cmd_brightness_contrast.cpp index be55a20da..8e11e886e 100644 --- a/src/app/commands/filters/cmd_brightness_contrast.cpp +++ b/src/app/commands/filters/cmd_brightness_contrast.cpp @@ -40,8 +40,6 @@ struct BrightnessContrastParams : public NewParams { Param 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 { 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); } } diff --git a/src/app/commands/filters/cmd_color_curve.cpp b/src/app/commands/filters/cmd_color_curve.cpp index 3377164c8..9b2a61186 100644 --- a/src/app/commands/filters/cmd_color_curve.cpp +++ b/src/app/commands/filters/cmd_color_curve.cpp @@ -33,8 +33,6 @@ struct ColorCurveParams : public NewParams { Param 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 { 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 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); } } diff --git a/src/app/commands/filters/cmd_convolution_matrix.cpp b/src/app/commands/filters/cmd_convolution_matrix.cpp index aaf671d18..72f27f0ec 100644 --- a/src/app/commands/filters/cmd_convolution_matrix.cpp +++ b/src/app/commands/filters/cmd_convolution_matrix.cpp @@ -51,8 +51,6 @@ struct ConvolutionMatrixParams : public NewParams { Param 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 { 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 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); } } diff --git a/src/app/commands/filters/cmd_despeckle.cpp b/src/app/commands/filters/cmd_despeckle.cpp index 6231bcda1..64f1a4636 100644 --- a/src/app/commands/filters/cmd_despeckle.cpp +++ b/src/app/commands/filters/cmd_despeckle.cpp @@ -46,8 +46,6 @@ struct DespeckleParams : public NewParams { Param 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 { 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); } } diff --git a/src/app/commands/filters/cmd_hue_saturation.cpp b/src/app/commands/filters/cmd_hue_saturation.cpp index c90059ba4..87e169da8 100644 --- a/src/app/commands/filters/cmd_hue_saturation.cpp +++ b/src/app/commands/filters/cmd_hue_saturation.cpp @@ -46,8 +46,6 @@ struct HueSaturationParams : public NewParams { Param 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 { 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); } } diff --git a/src/app/commands/filters/cmd_invert_color.cpp b/src/app/commands/filters/cmd_invert_color.cpp index 6632bf4f2..b6e12e7c3 100644 --- a/src/app/commands/filters/cmd_invert_color.cpp +++ b/src/app/commands/filters/cmd_invert_color.cpp @@ -36,8 +36,6 @@ struct InvertColorParams : public NewParams { Param 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 { 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); } } diff --git a/src/app/commands/filters/cmd_outline.cpp b/src/app/commands/filters/cmd_outline.cpp index 0edc95ec4..87c2924a1 100644 --- a/src/app/commands/filters/cmd_outline.cpp +++ b/src/app/commands/filters/cmd_outline.cpp @@ -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 { 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); } } diff --git a/src/app/commands/filters/cmd_replace_color.cpp b/src/app/commands/filters/cmd_replace_color.cpp index a852c1df6..8c1711481 100644 --- a/src/app/commands/filters/cmd_replace_color.cpp +++ b/src/app/commands/filters/cmd_replace_color.cpp @@ -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 { 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); } } diff --git a/src/app/commands/filters/filter_manager_impl.cpp b/src/app/commands/filters/filter_manager_impl.cpp index 2a93050f1..9a442f338 100644 --- a/src/app/commands/filters/filter_manager_impl.cpp +++ b/src/app/commands/filters/filter_manager_impl.cpp @@ -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(); diff --git a/src/app/commands/filters/filter_manager_impl.h b/src/app/commands/filters/filter_manager_impl.h index c19134bef..8bf467882 100644 --- a/src/app/commands/filters/filter_manager_impl.h +++ b/src/app/commands/filters/filter_manager_impl.h @@ -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 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 m_previewMask; diff --git a/src/app/commands/filters/filter_worker.cpp b/src/app/commands/filters/filter_worker.cpp index ab298d0cf..8dd176787 100644 --- a/src/app/commands/filters/filter_worker.cpp +++ b/src/app/commands/filters/filter_worker.cpp @@ -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 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. // diff --git a/src/app/commands/move_colors_command.cpp b/src/app/commands/move_colors_command.cpp index 4ca6b33b6..ddd2c101d 100644 --- a/src/app/commands/move_colors_command.cpp +++ b/src/app/commands/move_colors_command.cpp @@ -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(); } diff --git a/src/app/context.cpp b/src/app/context.cpp index 8d6024bdc..75f38b458 100644 --- a/src/app/context.cpp +++ b/src/app/context.cpp @@ -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) diff --git a/src/app/context_flags.cpp b/src/app/context_flags.cpp index d39e958c0..74a1c76c6 100644 --- a/src/app/context_flags.cpp +++ b/src/app/context_flags.cpp @@ -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 } } diff --git a/src/app/extensions.cpp b/src/app/extensions.cpp index e71527d2b..a9b4a6cd2 100644 --- a/src/app/extensions.cpp +++ b/src/app/extensions.cpp @@ -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 - } } diff --git a/src/app/file/css_format.cpp b/src/app/file/css_format.cpp index 40bf0da98..03d0ae301 100644 --- a/src/app/file/css_format.cpp +++ b/src/app/file/css_format.cpp @@ -254,8 +254,8 @@ FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp* fop) { auto opts = fop->formatOptionsOfDocument(); -#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; } diff --git a/src/app/file/file.cpp b/src/app/file/file.cpp index 1a8c4c46c..72e23fa8b 100644 --- a/src/app/file/file.cpp +++ b/src/app/file/file.cpp @@ -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()); } diff --git a/src/app/file/gif_format.cpp b/src/app/file/gif_format.cpp index 87044eb4e..ffa878ba9 100644 --- a/src/app/file/gif_format.cpp +++ b/src/app/file/gif_format.cpp @@ -1637,7 +1637,6 @@ bool GifFormat::onSave(FileOp* fop) FormatOptionsPtr GifFormat::onAskUserForFormatOptions(FileOp* fop) { auto opts = fop->formatOptionsOfDocument(); -#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(nullptr); } } -#endif // ENABLE_UI return opts; } diff --git a/src/app/file/jpeg_format.cpp b/src/app/file/jpeg_format.cpp index 7542994ba..bcd91c7b1 100644 --- a/src/app/file/jpeg_format.cpp +++ b/src/app/file/jpeg_format.cpp @@ -528,7 +528,6 @@ void JpegFormat::saveColorSpace(FileOp* fop, jpeg_compress_struct* cinfo, FormatOptionsPtr JpegFormat::onAskUserForFormatOptions(FileOp* fop) { auto opts = fop->formatOptionsOfDocument(); -#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(0); } } -#endif // ENABLE_UI return opts; } diff --git a/src/app/file/svg_format.cpp b/src/app/file/svg_format.cpp index 4df52964d..5c3f9b37e 100644 --- a/src/app/file/svg_format.cpp +++ b/src/app/file/svg_format.cpp @@ -170,7 +170,6 @@ bool SvgFormat::onSave(FileOp* fop) FormatOptionsPtr SvgFormat::onAskUserForFormatOptions(FileOp* fop) { auto opts = fop->formatOptionsOfDocument(); -#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(nullptr); } } -#endif return opts; } diff --git a/src/app/file/tga_format.cpp b/src/app/file/tga_format.cpp index 57087729e..3ff0c1b2b 100644 --- a/src/app/file/tga_format.cpp +++ b/src/app/file/tga_format.cpp @@ -334,7 +334,6 @@ FormatOptionsPtr TgaFormat::onAskUserForFormatOptions(FileOp* fop) { const bool origOpts = fop->hasFormatOptionsOfDocument(); auto opts = fop->formatOptionsOfDocument(); -#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(nullptr); } } -#endif // ENABLE_UI return opts; } diff --git a/src/app/file/webp_format.cpp b/src/app/file/webp_format.cpp index 0011920af..c5118a2d0 100644 --- a/src/app/file/webp_format.cpp +++ b/src/app/file/webp_format.cpp @@ -372,7 +372,6 @@ bool WebPFormat::onSave(FileOp* fop) FormatOptionsPtr WebPFormat::onAskUserForFormatOptions(FileOp* fop) { auto opts = fop->formatOptionsOfDocument(); -#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(nullptr); } } -#endif // ENABLE_UI return opts; } diff --git a/src/app/modules.cpp b/src/app/modules.cpp index 242f033ee..ca9dd1606 100644 --- a/src/app/modules.cpp +++ b/src/app/modules.cpp @@ -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); diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp index cdee60d55..296543c3f 100644 --- a/src/app/modules/gui.cpp +++ b/src/app/modules/gui.cpp @@ -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. diff --git a/src/app/modules/palettes.cpp b/src/app/modules/palettes.cpp index b3296eafb..aeae465c7 100644 --- a/src/app/modules/palettes.cpp +++ b/src/app/modules/palettes.cpp @@ -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; } diff --git a/src/app/script/app_object.cpp b/src/app/script/app_object.cpp index db6d6417f..26c514f6a 100644 --- a/src/app/script/app_object.cpp +++ b/src/app/script/app_object.cpp @@ -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; } diff --git a/src/app/script/app_theme_object.cpp b/src/app/script/app_theme_object.cpp index 14078b2ea..e5b7b594e 100644 --- a/src/app/script/app_theme_object.cpp +++ b/src/app/script/app_theme_object.cpp @@ -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(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); - push_obj(L, color_utils::color_from_ui(uiColor)); -#else - push_obj(L, app::Color::fromMask()); -#endif + if (auto* theme = skin::SkinTheme::instance()) { + const gfx::Color uiColor = theme->getColorById(id); + push_obj(L, color_utils::color_from_ui(uiColor)); + } + else { + push_obj(L, app::Color::fromMask()); + } return 1; } int Theme_styleMetrics(lua_State* L) { - [[maybe_unused]] auto theme = get_obj(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) diff --git a/src/app/script/canvas_widget.cpp b/src/app/script/canvas_widget.cpp index e6f1f1881..9bbe9cf4a 100644 --- a/src/app/script/canvas_widget.cpp +++ b/src/app/script/canvas_widget.cpp @@ -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 diff --git a/src/app/script/dialog_class.cpp b/src/app/script/dialog_class.cpp index 26ae0edf2..96fac9dfa 100644 --- a/src/app/script/dialog_class.cpp +++ b/src/app/script/dialog_class.cpp @@ -50,8 +50,6 @@ #include #include -#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 diff --git a/src/app/script/editor_class.cpp b/src/app/script/editor_class.cpp index 80cbf1016..8497e37b7 100644 --- a/src/app/script/editor_class.cpp +++ b/src/app/script/editor_class.cpp @@ -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 diff --git a/src/app/script/engine.cpp b/src/app/script/engine.cpp index 7c46fd1cb..c0b8887b9 100644 --- a/src/app/script/engine.cpp +++ b/src/app/script/engine.cpp @@ -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; } diff --git a/src/app/script/engine.h b/src/app/script/engine.h index 77281b2f5..46e3c9c0e 100644 --- a/src/app/script/engine.h +++ b/src/app/script/engine.h @@ -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 diff --git a/src/app/script/events_class.cpp b/src/app/script/events_class.cpp index 7fe5a8a16..2bfcc3bc3 100644 --- a/src/app/script/events_class.cpp +++ b/src/app/script/events_class.cpp @@ -571,8 +571,6 @@ void push_sprite_events(lua_State* L, Sprite* sprite) push_ptr(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(L, g_windowEvents.get()); } -#endif // ENABLE_UI - } // namespace script } // namespace app diff --git a/src/app/script/graphics_context.cpp b/src/app/script/graphics_context.cpp index 02c188849..32ddd9fb9 100644 --- a/src/app/script/graphics_context.cpp +++ b/src/app/script/graphics_context.cpp @@ -26,8 +26,6 @@ #include -#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 diff --git a/src/app/script/graphics_context.h b/src/app/script/graphics_context.h index a14a31686..aea3ed6fc 100644 --- a/src/app/script/graphics_context.h +++ b/src/app/script/graphics_context.h @@ -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 diff --git a/src/app/script/plugin_class.cpp b/src/app/script/plugin_class.cpp index 45f711cb1..dd36b8576 100644 --- a/src/app/script/plugin_class.cpp +++ b/src/app/script/plugin_class.cpp @@ -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(L, 1); + auto* plugin = get_obj(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; } diff --git a/src/app/script/range_class.cpp b/src/app/script/range_class.cpp index b1c2b9a58..38a438b49 100644 --- a/src/app/script/range_class.cpp +++ b/src/app/script/range_class.cpp @@ -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; diff --git a/src/app/script/security.cpp b/src/app/script/security.cpp index af4985c33..fe57310f1 100644 --- a/src/app/script/security.cpp +++ b/src/app/script/security.cpp @@ -67,8 +67,6 @@ static struct { { "package", "loadlib", secure_package_loadlib }, }; -#ifdef ENABLE_UI - // Map from .lua file name -> sha1 std::unordered_map 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; } diff --git a/src/app/script/tabs_widget.cpp b/src/app/script/tabs_widget.cpp index 38b145e9a..f8ff7a432 100644 --- a/src/app/script/tabs_widget.cpp +++ b/src/app/script/tabs_widget.cpp @@ -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 \ No newline at end of file diff --git a/src/app/script/websocket_class.cpp b/src/app/script/websocket_class.cpp index e0ff1a9ce..7548492b4 100644 --- a/src/app/script/websocket_class.cpp +++ b/src/app/script/websocket_class.cpp @@ -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(33, ui::Manager::getDefault()); g_timer->start(); } -#endif } g_connections.insert(ws); diff --git a/src/app/script/window_class.cpp b/src/app/script/window_class.cpp index 54cf59dea..4b4c333f8 100644 --- a/src/app/script/window_class.cpp +++ b/src/app/script/window_class.cpp @@ -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 diff --git a/src/app/send_crash.cpp b/src/app/send_crash.cpp index 0d15837e1..349390dcf 100644 --- a/src/app/send_crash.cpp +++ b/src/app/send_crash.cpp @@ -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 diff --git a/src/app/send_crash.h b/src/app/send_crash.h index c8b9ce3fc..a9616a7b4 100644 --- a/src/app/send_crash.h +++ b/src/app/send_crash.h @@ -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; diff --git a/src/app/tools/active_tool.cpp b/src/app/tools/active_tool.cpp index d43a7f961..021df9aca 100644 --- a/src/app/tools/active_tool.cpp +++ b/src/app/tools/active_tool.cpp @@ -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(); - color = (m_rightClick ? colorbar->getBgColor(): - colorbar->getFgColor()); -#endif + if (ColorBar* colorbar = ColorBar::instance()) { + color = (m_rightClick ? colorbar->getBgColor(): + colorbar->getFgColor()); + } 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) || diff --git a/src/app/transaction.cpp b/src/app/transaction.cpp index 21a7d1e10..1167fdf7f 100644 --- a/src/app/transaction.cpp +++ b/src/app/transaction.cpp @@ -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() diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp index a554b54a7..141024bef 100644 --- a/src/app/ui/editor/tool_loop_impl.cpp +++ b/src/app/ui/editor/tool_loop_impl.cpp @@ -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 diff --git a/src/app/ui/editor/tool_loop_impl.h b/src/app/ui/editor/tool_loop_impl.h index 14fd6d4b6..a1a22cfe9 100644 --- a/src/app/ui/editor/tool_loop_impl.h +++ b/src/app/ui/editor/tool_loop_impl.h @@ -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 diff --git a/src/app/ui/timeline/timeline.h b/src/app/ui/timeline/timeline.h index 4e815652f..53d58e229 100644 --- a/src/app/ui/timeline/timeline.h +++ b/src/app/ui/timeline/timeline.h @@ -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 diff --git a/src/app/util/clipboard.cpp b/src/app/util/clipboard.cpp index f6a4317f8..f8f18d0fc 100644 --- a/src/app/util/clipboard.cpp +++ b/src/app/util/clipboard.cpp @@ -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; diff --git a/src/app/util/layer_utils.cpp b/src/app/util/layer_utils.cpp index 8482bbbb9..003f65625 100644 --- a/src/app/util/layer_utils.cpp +++ b/src/app/util/layer_utils.cpp @@ -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; }