mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Add flag to compile CLI-only (fix #1279)
New cmake flag -DENABLE_UI=OFF can be used to turn off the GUI and compile a CLI-only version of Aseprite. Requested here too: https://community.aseprite.org/t/1351
This commit is contained in:
parent
c221685c44
commit
139c5aac49
@ -5,6 +5,11 @@ compiler:
|
|||||||
- clang
|
- clang
|
||||||
- gcc
|
- gcc
|
||||||
|
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- ENABLE_UI=OFF
|
||||||
|
- ENABLE_UI=ON
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
@ -14,7 +19,7 @@ before_install:
|
|||||||
before_script:
|
before_script:
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake .. -DENABLE_TESTS=ON
|
- cmake .. -DENABLE_TESTS=ON -DENABLE_UI=$ENABLE_UI
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- "make"
|
- "make"
|
||||||
|
@ -79,16 +79,26 @@ option(ENABLE_BENCHMARKS "Compile benchmarks" off)
|
|||||||
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
|
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
|
||||||
option(ENABLE_STEAM "Compile with Steam library" off)
|
option(ENABLE_STEAM "Compile with Steam library" off)
|
||||||
option(ENABLE_DEVMODE "Compile vesion for developers" off)
|
option(ENABLE_DEVMODE "Compile vesion for developers" off)
|
||||||
|
option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on)
|
||||||
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
|
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
|
||||||
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")
|
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")
|
||||||
|
|
||||||
if(APPLE)
|
if(NOT ENABLE_UI)
|
||||||
# On OS X Allegro isn't supported anymore
|
# Without UI, don't use back-ends
|
||||||
set(USE_ALLEG4_BACKEND off)
|
set(USE_ALLEG4_BACKEND off)
|
||||||
set(USE_SKIA_BACKEND on)
|
set(USE_SKIA_BACKEND off)
|
||||||
|
set(USE_NONE_BACKEND on)
|
||||||
else()
|
else()
|
||||||
option(USE_ALLEG4_BACKEND "Use Allegro 4 backend" on)
|
if(APPLE)
|
||||||
option(USE_SKIA_BACKEND "Use Skia backend" off)
|
# On OS X Allegro isn't supported anymore
|
||||||
|
set(USE_ALLEG4_BACKEND off)
|
||||||
|
set(USE_SKIA_BACKEND on)
|
||||||
|
set(USE_NONE_BACKEND off)
|
||||||
|
else()
|
||||||
|
option(USE_ALLEG4_BACKEND "Use Allegro 4 backend" on)
|
||||||
|
option(USE_SKIA_BACKEND "Use Skia backend" off)
|
||||||
|
set(USE_NONE_BACKEND off)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check valid gtk + libpng combination
|
# Check valid gtk + libpng combination
|
||||||
|
@ -53,28 +53,36 @@ if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Full-version or trial-mode?
|
# With static libcurl
|
||||||
|
|
||||||
if(NOT USE_SHARED_CURL AND CURL_STATICLIB)
|
if(NOT USE_SHARED_CURL AND CURL_STATICLIB)
|
||||||
add_definitions(-DCURL_STATICLIB)
|
add_definitions(-DCURL_STATICLIB)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Full-version or trial-mode?
|
# Special versions (full/trial, devmode, UI/CLI, etc.)
|
||||||
|
|
||||||
if(NOT ENABLE_TRIAL_MODE)
|
if(NOT ENABLE_TRIAL_MODE)
|
||||||
add_definitions(-DENABLE_SAVE -DENABLE_DATA_RECOVERY)
|
add_definitions(-DENABLE_SAVE)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DENABLE_TRIAL_MODE)
|
add_definitions(-DENABLE_TRIAL_MODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
######################################################################
|
|
||||||
# Special developer mode
|
|
||||||
|
|
||||||
if(ENABLE_DEVMODE)
|
if(ENABLE_DEVMODE)
|
||||||
add_definitions(-DENABLE_DEVMODE)
|
add_definitions(-DENABLE_DEVMODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_UI)
|
||||||
|
add_definitions(-DENABLE_UI)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_UI AND NOT ENABLE_TRIAL_MODE)
|
||||||
|
set(ENABLE_DATA_RECOVERY on)
|
||||||
|
add_definitions(-DENABLE_DATA_RECOVERY)
|
||||||
|
else()
|
||||||
|
set(ENABLE_DATA_RECOVERY off)
|
||||||
|
endif()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Aseprite Libraries (in preferred order to be built)
|
# Aseprite Libraries (in preferred order to be built)
|
||||||
|
|
||||||
@ -170,16 +178,23 @@ if(WIN32)
|
|||||||
main/settings.manifest)
|
main/settings.manifest)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(aseprite WIN32
|
add_executable(aseprite main/main.cpp ${win32_resources})
|
||||||
main/main.cpp
|
if(WIN32 AND ENABLE_UI)
|
||||||
${win32_resources})
|
set_target_properties(aseprite PROPERTIES WIN32_EXECUTABLE true)
|
||||||
|
endif()
|
||||||
target_link_libraries(aseprite app-lib ${PLATFORM_LIBS})
|
target_link_libraries(aseprite app-lib ${PLATFORM_LIBS})
|
||||||
add_dependencies(aseprite copy_data)
|
add_dependencies(aseprite copy_data)
|
||||||
|
|
||||||
if(MSVC AND USE_SKIA_BACKEND)
|
if(MSVC)
|
||||||
# Add support to expand filename wildcards in argc/argv
|
if(USE_SKIA_BACKEND)
|
||||||
set_target_properties(aseprite
|
# Linking with "wsetargv.obj" to add support to expand filename
|
||||||
PROPERTIES LINK_FLAGS "-LINK wsetargv.obj -ENTRY:\"wWinMainCRTStartup\"")
|
# wildcards in argc/argv.
|
||||||
|
set_target_properties(aseprite
|
||||||
|
PROPERTIES LINK_FLAGS "-LINK wsetargv.obj -ENTRY:\"wWinMainCRTStartup\"")
|
||||||
|
else()
|
||||||
|
set_target_properties(aseprite
|
||||||
|
PROPERTIES LINK_FLAGS "-LINK wsetargv.obj -ENTRY:\"wmainCRTStartup\"")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS aseprite
|
install(TARGETS aseprite
|
||||||
|
@ -114,7 +114,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(data_recovery_files)
|
set(data_recovery_files)
|
||||||
if(NOT ENABLE_TRIAL_MODE)
|
if(ENABLE_DATA_RECOVERY)
|
||||||
set(data_recovery_files
|
set(data_recovery_files
|
||||||
crash/backup_observer.cpp
|
crash/backup_observer.cpp
|
||||||
crash/data_recovery.cpp
|
crash/data_recovery.cpp
|
||||||
@ -140,8 +140,13 @@ endif()
|
|||||||
|
|
||||||
set(scripting_files)
|
set(scripting_files)
|
||||||
if(ENABLE_SCRIPTING)
|
if(ENABLE_SCRIPTING)
|
||||||
|
set(scripting_files_ui)
|
||||||
|
if(ENABLE_UI)
|
||||||
|
set(scripting_files_ui
|
||||||
|
commands/cmd_developer_console.cpp
|
||||||
|
ui/devconsole_view.cpp)
|
||||||
|
endif()
|
||||||
set(scripting_files
|
set(scripting_files
|
||||||
commands/cmd_developer_console.cpp
|
|
||||||
commands/cmd_run_script.cpp
|
commands/cmd_run_script.cpp
|
||||||
script/app_object.cpp
|
script/app_object.cpp
|
||||||
script/app_scripting.cpp
|
script/app_scripting.cpp
|
||||||
@ -156,18 +161,245 @@ if(ENABLE_SCRIPTING)
|
|||||||
script/sprite_class.cpp
|
script/sprite_class.cpp
|
||||||
script/sprite_wrap.cpp
|
script/sprite_wrap.cpp
|
||||||
shell.cpp
|
shell.cpp
|
||||||
ui/devconsole_view.cpp)
|
${scripting_files_ui})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ui_app_files)
|
||||||
|
if(ENABLE_UI)
|
||||||
|
set(ui_app_files
|
||||||
|
app_brushes.cpp
|
||||||
|
app_menus.cpp
|
||||||
|
app_render.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_properties.cpp
|
||||||
|
commands/cmd_change_brush.cpp
|
||||||
|
commands/cmd_change_color.cpp
|
||||||
|
commands/cmd_clear.cpp
|
||||||
|
commands/cmd_clear_cel.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_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_exit.cpp
|
||||||
|
commands/cmd_export_sprite_sheet.cpp
|
||||||
|
commands/cmd_eyedropper.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_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_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_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_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_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_show.cpp
|
||||||
|
commands/cmd_slice_properties.cpp
|
||||||
|
commands/cmd_sprite_properties.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_timeline_thumbnails.cpp
|
||||||
|
commands/cmd_undo_history.cpp
|
||||||
|
commands/cmd_unlink_cel.cpp
|
||||||
|
commands/cmd_zoom.cpp
|
||||||
|
commands/filters/cmd_brightness_contrast.cpp
|
||||||
|
commands/filters/cmd_color_curve.cpp
|
||||||
|
commands/filters/cmd_convolution_matrix.cpp
|
||||||
|
commands/filters/cmd_despeckle.cpp
|
||||||
|
commands/filters/cmd_hue_saturation.cpp
|
||||||
|
commands/filters/cmd_invert_color.cpp
|
||||||
|
commands/filters/cmd_replace_color.cpp
|
||||||
|
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
|
||||||
|
file_selector.cpp
|
||||||
|
gui_xml.cpp
|
||||||
|
modules/editors.cpp
|
||||||
|
modules/gfx.cpp
|
||||||
|
modules/gui.cpp
|
||||||
|
send_crash.cpp
|
||||||
|
tools/active_tool.cpp
|
||||||
|
tools/ink_type.cpp
|
||||||
|
tools/intertwine.cpp
|
||||||
|
tools/pick_ink.cpp
|
||||||
|
tools/point_shape.cpp
|
||||||
|
tools/stroke.cpp
|
||||||
|
tools/symmetries.cpp
|
||||||
|
tools/tool_box.cpp
|
||||||
|
tools/tool_loop_manager.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/document_view.cpp
|
||||||
|
ui/drop_down_button.cpp
|
||||||
|
ui/editor/brush_preview.cpp
|
||||||
|
ui/editor/drawing_state.cpp
|
||||||
|
ui/editor/editor.cpp
|
||||||
|
ui/editor/editor_observers.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/file_list.cpp
|
||||||
|
ui/file_list_view.cpp
|
||||||
|
ui/file_selector.cpp
|
||||||
|
ui/font_popup.cpp
|
||||||
|
ui/frame_tag_window.cpp
|
||||||
|
ui/hex_color_entry.cpp
|
||||||
|
ui/home_view.cpp
|
||||||
|
ui/icon_button.cpp
|
||||||
|
ui/input_chain.cpp
|
||||||
|
ui/keyboard_shortcuts.cpp
|
||||||
|
ui/main_menu_bar.cpp
|
||||||
|
ui/main_window.cpp
|
||||||
|
ui/news_listbox.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/preview_editor.cpp
|
||||||
|
ui/recent_listbox.cpp
|
||||||
|
ui/resources_listbox.cpp
|
||||||
|
ui/search_entry.cpp
|
||||||
|
ui/select_accelerator.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/timeline/ani_controls.cpp
|
||||||
|
ui/timeline/timeline.cpp
|
||||||
|
ui/toolbar.cpp
|
||||||
|
ui/user_data_popup.cpp
|
||||||
|
ui/workspace.cpp
|
||||||
|
ui/workspace_panel.cpp
|
||||||
|
ui/workspace_tabs.cpp
|
||||||
|
ui/zoom_entry.cpp
|
||||||
|
ui_context.cpp
|
||||||
|
util/clipboard.cpp
|
||||||
|
util/clipboard_native.cpp
|
||||||
|
widget_loader.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(app-lib
|
add_library(app-lib
|
||||||
app.cpp
|
app.cpp
|
||||||
app_brushes.cpp
|
|
||||||
app_menus.cpp
|
|
||||||
app_render.cpp
|
|
||||||
check_update.cpp
|
check_update.cpp
|
||||||
cli/app_options.cpp
|
cli/app_options.cpp
|
||||||
cli/cli_open_file.cpp
|
cli/cli_open_file.cpp
|
||||||
cli/cli_processor.cpp
|
cli/cli_processor.cpp
|
||||||
|
${file_formats}
|
||||||
cli/default_cli_delegate.cpp
|
cli/default_cli_delegate.cpp
|
||||||
cli/preview_cli_delegate.cpp
|
cli/preview_cli_delegate.cpp
|
||||||
cmd.cpp
|
cmd.cpp
|
||||||
@ -247,134 +479,15 @@ add_library(app-lib
|
|||||||
color.cpp
|
color.cpp
|
||||||
color_picker.cpp
|
color_picker.cpp
|
||||||
color_utils.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_properties.cpp
|
|
||||||
commands/cmd_change_brush.cpp
|
|
||||||
commands/cmd_change_color.cpp
|
|
||||||
commands/cmd_change_pixel_format.cpp
|
commands/cmd_change_pixel_format.cpp
|
||||||
commands/cmd_clear.cpp
|
|
||||||
commands/cmd_clear_cel.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_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_exit.cpp
|
|
||||||
commands/cmd_export_sprite_sheet.cpp
|
|
||||||
commands/cmd_eyedropper.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_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_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_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_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_file.cpp
|
||||||
commands/cmd_save_mask.cpp
|
|
||||||
commands/cmd_save_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_show.cpp
|
|
||||||
commands/cmd_slice_properties.cpp
|
|
||||||
commands/cmd_sprite_properties.cpp
|
|
||||||
commands/cmd_sprite_size.cpp
|
commands/cmd_sprite_size.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_timeline_thumbnails.cpp
|
|
||||||
commands/cmd_undo.cpp
|
commands/cmd_undo.cpp
|
||||||
commands/cmd_undo_history.cpp
|
|
||||||
commands/cmd_unlink_cel.cpp
|
|
||||||
commands/cmd_zoom.cpp
|
|
||||||
commands/command.cpp
|
commands/command.cpp
|
||||||
commands/commands.cpp
|
commands/commands.cpp
|
||||||
commands/filters/cmd_brightness_contrast.cpp
|
|
||||||
commands/filters/cmd_color_curve.cpp
|
|
||||||
commands/filters/cmd_convolution_matrix.cpp
|
|
||||||
commands/filters/cmd_despeckle.cpp
|
|
||||||
commands/filters/cmd_hue_saturation.cpp
|
|
||||||
commands/filters/cmd_invert_color.cpp
|
|
||||||
commands/filters/cmd_replace_color.cpp
|
|
||||||
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_thing.cpp
|
commands/move_thing.cpp
|
||||||
commands/quick_command.cpp
|
commands/quick_command.cpp
|
||||||
console.cpp
|
console.cpp
|
||||||
@ -394,13 +507,10 @@ add_library(app-lib
|
|||||||
file/file_formats_manager.cpp
|
file/file_formats_manager.cpp
|
||||||
file/palette_file.cpp
|
file/palette_file.cpp
|
||||||
file/split_filename.cpp
|
file/split_filename.cpp
|
||||||
${file_formats}
|
|
||||||
file_selector.cpp
|
|
||||||
file_system.cpp
|
file_system.cpp
|
||||||
filename_formatter.cpp
|
filename_formatter.cpp
|
||||||
flatten.cpp
|
flatten.cpp
|
||||||
font_path.cpp
|
font_path.cpp
|
||||||
gui_xml.cpp
|
|
||||||
i18n/strings.cpp
|
i18n/strings.cpp
|
||||||
i18n/xml_translator.cpp
|
i18n/xml_translator.cpp
|
||||||
ini_file.cpp
|
ini_file.cpp
|
||||||
@ -410,9 +520,6 @@ add_library(app-lib
|
|||||||
log.cpp
|
log.cpp
|
||||||
loop_tag.cpp
|
loop_tag.cpp
|
||||||
modules.cpp
|
modules.cpp
|
||||||
modules/editors.cpp
|
|
||||||
modules/gfx.cpp
|
|
||||||
modules/gui.cpp
|
|
||||||
modules/palettes.cpp
|
modules/palettes.cpp
|
||||||
pref/preferences.cpp
|
pref/preferences.cpp
|
||||||
project.cpp
|
project.cpp
|
||||||
@ -423,111 +530,15 @@ add_library(app-lib
|
|||||||
resource_finder.cpp
|
resource_finder.cpp
|
||||||
restore_visible_layers.cpp
|
restore_visible_layers.cpp
|
||||||
rw_lock.cpp
|
rw_lock.cpp
|
||||||
send_crash.cpp
|
|
||||||
shade.cpp
|
shade.cpp
|
||||||
snap_to_grid.cpp
|
snap_to_grid.cpp
|
||||||
sprite_job.cpp
|
sprite_job.cpp
|
||||||
thumbnail_generator.cpp
|
thumbnail_generator.cpp
|
||||||
thumbnails.cpp
|
thumbnails.cpp
|
||||||
tools/active_tool.cpp
|
|
||||||
tools/ink_type.cpp
|
|
||||||
tools/intertwine.cpp
|
|
||||||
tools/pick_ink.cpp
|
|
||||||
tools/point_shape.cpp
|
|
||||||
tools/stroke.cpp
|
|
||||||
tools/symmetries.cpp
|
|
||||||
tools/tool_box.cpp
|
|
||||||
tools/tool_loop_manager.cpp
|
|
||||||
transaction.cpp
|
transaction.cpp
|
||||||
transformation.cpp
|
transformation.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/document_view.cpp
|
|
||||||
ui/drop_down_button.cpp
|
|
||||||
ui/editor/brush_preview.cpp
|
|
||||||
ui/editor/drawing_state.cpp
|
|
||||||
ui/editor/editor.cpp
|
|
||||||
ui/editor/editor_observers.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/file_list.cpp
|
|
||||||
ui/file_list_view.cpp
|
|
||||||
ui/file_selector.cpp
|
|
||||||
ui/font_popup.cpp
|
|
||||||
ui/frame_tag_window.cpp
|
|
||||||
ui/hex_color_entry.cpp
|
|
||||||
ui/home_view.cpp
|
|
||||||
ui/icon_button.cpp
|
|
||||||
ui/input_chain.cpp
|
|
||||||
ui/keyboard_shortcuts.cpp
|
|
||||||
ui/layer_frame_comboboxes.cpp
|
ui/layer_frame_comboboxes.cpp
|
||||||
ui/main_menu_bar.cpp
|
|
||||||
ui/main_window.cpp
|
|
||||||
ui/news_listbox.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/preview_editor.cpp
|
|
||||||
ui/recent_listbox.cpp
|
|
||||||
ui/resources_listbox.cpp
|
|
||||||
ui/search_entry.cpp
|
|
||||||
ui/select_accelerator.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/timeline/ani_controls.cpp
|
|
||||||
ui/timeline/timeline.cpp
|
|
||||||
ui/toolbar.cpp
|
|
||||||
ui/user_data_popup.cpp
|
|
||||||
ui/workspace.cpp
|
|
||||||
ui/workspace_panel.cpp
|
|
||||||
ui/workspace_tabs.cpp
|
|
||||||
ui/zoom_entry.cpp
|
|
||||||
ui_context.cpp
|
|
||||||
util/autocrop.cpp
|
util/autocrop.cpp
|
||||||
util/clipboard.cpp
|
|
||||||
util/clipboard_native.cpp
|
|
||||||
util/create_cel_copy.cpp
|
util/create_cel_copy.cpp
|
||||||
util/expand_cel_canvas.cpp
|
util/expand_cel_canvas.cpp
|
||||||
util/filetoks.cpp
|
util/filetoks.cpp
|
||||||
@ -540,9 +551,9 @@ add_library(app-lib
|
|||||||
util/range_utils.cpp
|
util/range_utils.cpp
|
||||||
util/wrap_point.cpp
|
util/wrap_point.cpp
|
||||||
webserver.cpp
|
webserver.cpp
|
||||||
widget_loader.cpp
|
|
||||||
xml_document.cpp
|
xml_document.cpp
|
||||||
xml_exception.cpp
|
xml_exception.cpp
|
||||||
|
${ui_app_files}
|
||||||
${app_platform_files}
|
${app_platform_files}
|
||||||
${data_recovery_files}
|
${data_recovery_files}
|
||||||
${scripting_files}
|
${scripting_files}
|
||||||
|
@ -99,18 +99,28 @@ public:
|
|||||||
|
|
||||||
class App::Modules {
|
class App::Modules {
|
||||||
public:
|
public:
|
||||||
|
#ifdef ENABLE_UI
|
||||||
|
typedef app::UIContext ContextT;
|
||||||
|
#else
|
||||||
|
typedef app::Context ContextT;
|
||||||
|
#endif
|
||||||
|
|
||||||
LoggerModule m_loggerModule;
|
LoggerModule m_loggerModule;
|
||||||
FileSystemModule m_file_system_module;
|
FileSystemModule m_file_system_module;
|
||||||
Extensions m_extensions;
|
Extensions m_extensions;
|
||||||
// Load main language (after loading the extensions)
|
// Load main language (after loading the extensions)
|
||||||
LoadLanguage m_loadLanguage;
|
LoadLanguage m_loadLanguage;
|
||||||
|
#ifdef ENABLE_UI
|
||||||
tools::ToolBox m_toolbox;
|
tools::ToolBox m_toolbox;
|
||||||
tools::ActiveToolManager m_activeToolManager;
|
tools::ActiveToolManager m_activeToolManager;
|
||||||
|
#endif
|
||||||
Commands m_commands;
|
Commands m_commands;
|
||||||
UIContext m_ui_context;
|
ContextT m_context;
|
||||||
|
#ifdef ENABLE_UI
|
||||||
RecentFiles m_recent_files;
|
RecentFiles m_recent_files;
|
||||||
InputChain m_inputChain;
|
InputChain m_inputChain;
|
||||||
clipboard::ClipboardManager m_clipboardManager;
|
clipboard::ClipboardManager m_clipboardManager;
|
||||||
|
#endif
|
||||||
// This is a raw pointer because we want to delete this explicitly.
|
// This is a raw pointer because we want to delete this explicitly.
|
||||||
app::crash::DataRecovery* m_recovery;
|
app::crash::DataRecovery* m_recovery;
|
||||||
|
|
||||||
@ -118,8 +128,10 @@ public:
|
|||||||
Preferences& pref)
|
Preferences& pref)
|
||||||
: m_loggerModule(createLogInDesktop)
|
: m_loggerModule(createLogInDesktop)
|
||||||
, m_loadLanguage(pref, m_extensions)
|
, m_loadLanguage(pref, m_extensions)
|
||||||
|
#ifdef ENABLE_UI
|
||||||
, m_activeToolManager(&m_toolbox)
|
, m_activeToolManager(&m_toolbox)
|
||||||
, m_recent_files(pref.general.recentItems())
|
, m_recent_files(pref.general.recentItems())
|
||||||
|
#endif
|
||||||
, m_recovery(nullptr) {
|
, m_recovery(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +145,7 @@ public:
|
|||||||
|
|
||||||
void createDataRecovery() {
|
void createDataRecovery() {
|
||||||
#ifdef ENABLE_DATA_RECOVERY
|
#ifdef ENABLE_DATA_RECOVERY
|
||||||
m_recovery = new app::crash::DataRecovery(&m_ui_context);
|
m_recovery = new app::crash::DataRecovery(&m_context);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +166,9 @@ App::App()
|
|||||||
, m_legacy(NULL)
|
, m_legacy(NULL)
|
||||||
, m_isGui(false)
|
, m_isGui(false)
|
||||||
, m_isShell(false)
|
, m_isShell(false)
|
||||||
|
#ifdef ENABLE_UI
|
||||||
, m_backupIndicator(nullptr)
|
, m_backupIndicator(nullptr)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
ASSERT(m_instance == NULL);
|
ASSERT(m_instance == NULL);
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
@ -167,7 +181,11 @@ void App::initialize(const AppOptions& options)
|
|||||||
she::instance()->useWintabAPI(false);
|
she::instance()->useWintabAPI(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
m_isGui = options.startUI() && !options.previewCLI();
|
m_isGui = options.startUI() && !options.previewCLI();
|
||||||
|
#else
|
||||||
|
m_isGui = false;
|
||||||
|
#endif
|
||||||
m_isShell = options.startShell();
|
m_isShell = options.startShell();
|
||||||
m_coreModules = new CoreModules;
|
m_coreModules = new CoreModules;
|
||||||
if (m_isGui)
|
if (m_isGui)
|
||||||
@ -190,7 +208,9 @@ void App::initialize(const AppOptions& options)
|
|||||||
// Load modules
|
// Load modules
|
||||||
m_modules = new Modules(createLogInDesktop, preferences());
|
m_modules = new Modules(createLogInDesktop, preferences());
|
||||||
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
||||||
|
#ifdef ENABLE_UI
|
||||||
m_brushes.reset(new AppBrushes);
|
m_brushes.reset(new AppBrushes);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Data recovery is enabled only in GUI mode
|
// Data recovery is enabled only in GUI mode
|
||||||
if (isGui() && preferences().general.dataRecovery())
|
if (isGui() && preferences().general.dataRecovery())
|
||||||
@ -203,6 +223,7 @@ void App::initialize(const AppOptions& options)
|
|||||||
// palette from an old format palette to the new one, etc.
|
// palette from an old format palette to the new one, etc.
|
||||||
load_default_palette();
|
load_default_palette();
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// Initialize GUI interface
|
// Initialize GUI interface
|
||||||
if (isGui()) {
|
if (isGui()) {
|
||||||
LOG("APP: GUI mode\n");
|
LOG("APP: GUI mode\n");
|
||||||
@ -230,6 +251,7 @@ void App::initialize(const AppOptions& options)
|
|||||||
// Redraw the whole screen.
|
// Redraw the whole screen.
|
||||||
ui::Manager::getDefault()->invalidate();
|
ui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
// Process options
|
// Process options
|
||||||
LOG("APP: Processing options...\n");
|
LOG("APP: Processing options...\n");
|
||||||
@ -241,7 +263,7 @@ void App::initialize(const AppOptions& options)
|
|||||||
delegate.reset(new DefaultCliDelegate);
|
delegate.reset(new DefaultCliDelegate);
|
||||||
|
|
||||||
CliProcessor cli(delegate.get(), options);
|
CliProcessor cli(delegate.get(), options);
|
||||||
cli.process();
|
cli.process(&m_modules->m_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
she::instance()->finishLaunching();
|
she::instance()->finishLaunching();
|
||||||
@ -249,6 +271,7 @@ void App::initialize(const AppOptions& options)
|
|||||||
|
|
||||||
void App::run()
|
void App::run()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// Run the GUI
|
// Run the GUI
|
||||||
if (isGui()) {
|
if (isGui()) {
|
||||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||||
@ -310,6 +333,7 @@ void App::run()
|
|||||||
// Run the GUI main message loop
|
// Run the GUI main message loop
|
||||||
ui::Manager::getDefault()->run();
|
ui::Manager::getDefault()->run();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
#ifdef ENABLE_SCRIPTING
|
#ifdef ENABLE_SCRIPTING
|
||||||
// Start shell to execute scripts.
|
// Start shell to execute scripts.
|
||||||
@ -320,10 +344,10 @@ void App::run()
|
|||||||
Shell shell;
|
Shell shell;
|
||||||
shell.run(engine);
|
shell.run(engine);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // ENABLE_SCRIPTING
|
||||||
|
|
||||||
// Destroy all documents in the UIContext.
|
// Destroy all documents in the UIContext.
|
||||||
const doc::Documents& docs = m_modules->m_ui_context.documents();
|
const doc::Documents& docs = m_modules->m_context.documents();
|
||||||
while (!docs.empty()) {
|
while (!docs.empty()) {
|
||||||
doc::Document* doc = docs.back();
|
doc::Document* doc = docs.back();
|
||||||
|
|
||||||
@ -342,10 +366,12 @@ void App::run()
|
|||||||
delete doc;
|
delete doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
if (isGui()) {
|
if (isGui()) {
|
||||||
// Destroy the window.
|
// Destroy the window.
|
||||||
m_mainWindow.reset(NULL);
|
m_mainWindow.reset(NULL);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Delete backups (this is a normal shutdown, we are not handling
|
// Delete backups (this is a normal shutdown, we are not handling
|
||||||
// exceptions, and we are not in a destructor).
|
// exceptions, and we are not in a destructor).
|
||||||
@ -365,24 +391,28 @@ App::~App()
|
|||||||
// Fire App Exit signal.
|
// Fire App Exit signal.
|
||||||
App::instance()->Exit();
|
App::instance()->Exit();
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// Finalize modules, configuration and core.
|
// Finalize modules, configuration and core.
|
||||||
Editor::destroyEditorSharedInternals();
|
Editor::destroyEditorSharedInternals();
|
||||||
|
|
||||||
// Save brushes
|
|
||||||
m_brushes.reset(nullptr);
|
|
||||||
|
|
||||||
if (m_backupIndicator) {
|
if (m_backupIndicator) {
|
||||||
delete m_backupIndicator;
|
delete m_backupIndicator;
|
||||||
m_backupIndicator = nullptr;
|
m_backupIndicator = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save brushes
|
||||||
|
m_brushes.reset(nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
delete m_legacy;
|
delete m_legacy;
|
||||||
delete m_modules;
|
delete m_modules;
|
||||||
delete m_coreModules;
|
delete m_coreModules;
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// Destroy the loaded gui.xml data.
|
// Destroy the loaded gui.xml data.
|
||||||
delete KeyboardShortcuts::instance();
|
delete KeyboardShortcuts::instance();
|
||||||
delete GuiXml::instance();
|
delete GuiXml::instance();
|
||||||
|
#endif
|
||||||
|
|
||||||
m_instance = NULL;
|
m_instance = NULL;
|
||||||
}
|
}
|
||||||
@ -399,6 +429,11 @@ App::~App()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context* App::context()
|
||||||
|
{
|
||||||
|
return &m_modules->m_context;
|
||||||
|
}
|
||||||
|
|
||||||
bool App::isPortable()
|
bool App::isPortable()
|
||||||
{
|
{
|
||||||
static bool* is_portable = NULL;
|
static bool* is_portable = NULL;
|
||||||
@ -415,23 +450,39 @@ bool App::isPortable()
|
|||||||
tools::ToolBox* App::toolBox() const
|
tools::ToolBox* App::toolBox() const
|
||||||
{
|
{
|
||||||
ASSERT(m_modules != NULL);
|
ASSERT(m_modules != NULL);
|
||||||
|
#ifdef ENABLE_UI
|
||||||
return &m_modules->m_toolbox;
|
return &m_modules->m_toolbox;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
tools::Tool* App::activeTool() const
|
tools::Tool* App::activeTool() const
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
return m_modules->m_activeToolManager.activeTool();
|
return m_modules->m_activeToolManager.activeTool();
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
tools::ActiveToolManager* App::activeToolManager() const
|
tools::ActiveToolManager* App::activeToolManager() const
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
return &m_modules->m_activeToolManager;
|
return &m_modules->m_activeToolManager;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RecentFiles* App::recentFiles() const
|
RecentFiles* App::recentFiles() const
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
ASSERT(m_modules != NULL);
|
ASSERT(m_modules != NULL);
|
||||||
return &m_modules->m_recent_files;
|
return &m_modules->m_recent_files;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Workspace* App::workspace() const
|
Workspace* App::workspace() const
|
||||||
@ -473,6 +524,7 @@ crash::DataRecovery* App::dataRecovery() const
|
|||||||
return m_modules->recovery();
|
return m_modules->recovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
void App::showNotification(INotificationDelegate* del)
|
void App::showNotification(INotificationDelegate* del)
|
||||||
{
|
{
|
||||||
m_mainWindow->showNotification(del);
|
m_mainWindow->showNotification(del);
|
||||||
@ -512,10 +564,12 @@ InputChain& App::inputChain()
|
|||||||
{
|
{
|
||||||
return m_modules->m_inputChain;
|
return m_modules->m_inputChain;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Updates palette and redraw the screen.
|
// Updates palette and redraw the screen.
|
||||||
void app_refresh_screen()
|
void app_refresh_screen()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
Context* context = UIContext::instance();
|
Context* context = UIContext::instance();
|
||||||
ASSERT(context != NULL);
|
ASSERT(context != NULL);
|
||||||
|
|
||||||
@ -528,6 +582,7 @@ void app_refresh_screen()
|
|||||||
|
|
||||||
// Invalidate the whole screen.
|
// Invalidate the whole screen.
|
||||||
ui::Manager::getDefault()->invalidate();
|
ui::Manager::getDefault()->invalidate();
|
||||||
|
#endif // ENABLE_UI
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove app_rebuild_documents_tabs() and replace it by
|
// TODO remove app_rebuild_documents_tabs() and replace it by
|
||||||
@ -535,14 +590,17 @@ void app_refresh_screen()
|
|||||||
// document is modified).
|
// document is modified).
|
||||||
void app_rebuild_documents_tabs()
|
void app_rebuild_documents_tabs()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
if (App::instance()->isGui()) {
|
if (App::instance()->isGui()) {
|
||||||
App::instance()->workspace()->updateTabs();
|
App::instance()->workspace()->updateTabs();
|
||||||
App::instance()->updateDisplayTitleBar();
|
App::instance()->updateDisplayTitleBar();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelFormat app_get_current_pixel_format()
|
PixelFormat app_get_current_pixel_format()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
Context* context = UIContext::instance();
|
Context* context = UIContext::instance();
|
||||||
ASSERT(context != NULL);
|
ASSERT(context != NULL);
|
||||||
|
|
||||||
@ -551,12 +609,17 @@ PixelFormat app_get_current_pixel_format()
|
|||||||
return document->sprite()->pixelFormat();
|
return document->sprite()->pixelFormat();
|
||||||
else
|
else
|
||||||
return IMAGE_RGB;
|
return IMAGE_RGB;
|
||||||
|
#else // ENABLE_UI
|
||||||
|
return IMAGE_RGB;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_default_statusbar_message()
|
void app_default_statusbar_message()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_UI
|
||||||
StatusBar::instance()
|
StatusBar::instance()
|
||||||
->setStatusText(250, "%s %s | %s", PACKAGE, VERSION, COPYRIGHT);
|
->setStatusText(250, "%s %s | %s", PACKAGE, VERSION, COPYRIGHT);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int app_get_color_to_clear_layer(Layer* layer)
|
int app_get_color_to_clear_layer(Layer* layer)
|
||||||
@ -567,9 +630,11 @@ int app_get_color_to_clear_layer(Layer* layer)
|
|||||||
|
|
||||||
// The `Background' is erased with the `Background Color'
|
// The `Background' is erased with the `Background Color'
|
||||||
if (layer->isBackground()) {
|
if (layer->isBackground()) {
|
||||||
|
#ifdef ENABLE_UI
|
||||||
if (ColorBar::instance())
|
if (ColorBar::instance())
|
||||||
color = ColorBar::instance()->getBgColor();
|
color = ColorBar::instance()->getBgColor();
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
color = app::Color::fromRgb(0, 0, 0); // TODO get background color color from doc::Settings
|
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
|
||||||
@ -578,4 +643,18 @@ int app_get_color_to_clear_layer(Layer* layer)
|
|||||||
return color_utils::color_for_layer(color, layer);
|
return color_utils::color_for_layer(color, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string memory_dump_filename()
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
static const char* kDefaultCrashName = PACKAGE "-crash-" VERSION ".dmp";
|
||||||
|
|
||||||
|
app::ResourceFinder rf;
|
||||||
|
rf.includeUserDir(kDefaultCrashName);
|
||||||
|
return rf.getFirstOrCreateDefault();
|
||||||
|
|
||||||
|
#else
|
||||||
|
return "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -8,7 +8,10 @@
|
|||||||
#define APP_APP_H_INCLUDED
|
#define APP_APP_H_INCLUDED
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
#include "app/app_brushes.h"
|
#include "app/app_brushes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "base/mutex.h"
|
#include "base/mutex.h"
|
||||||
#include "base/paths.h"
|
#include "base/paths.h"
|
||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
@ -30,6 +33,7 @@ namespace app {
|
|||||||
|
|
||||||
class AppOptions;
|
class AppOptions;
|
||||||
class BackupIndicator;
|
class BackupIndicator;
|
||||||
|
class Context;
|
||||||
class ContextBar;
|
class ContextBar;
|
||||||
class Document;
|
class Document;
|
||||||
class Extensions;
|
class Extensions;
|
||||||
@ -62,6 +66,8 @@ namespace app {
|
|||||||
|
|
||||||
static App* instance() { return m_instance; }
|
static App* instance() { return m_instance; }
|
||||||
|
|
||||||
|
Context* context();
|
||||||
|
|
||||||
// Returns true if Aseprite is running with GUI available.
|
// Returns true if Aseprite is running with GUI available.
|
||||||
bool isGui() const { return m_isGui; }
|
bool isGui() const { return m_isGui; }
|
||||||
|
|
||||||
@ -86,6 +92,7 @@ namespace app {
|
|||||||
Extensions& extensions() const;
|
Extensions& extensions() const;
|
||||||
crash::DataRecovery* dataRecovery() const;
|
crash::DataRecovery* dataRecovery() const;
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
AppBrushes& brushes() {
|
AppBrushes& brushes() {
|
||||||
ASSERT(m_brushes.get());
|
ASSERT(m_brushes.get());
|
||||||
return *m_brushes;
|
return *m_brushes;
|
||||||
@ -97,6 +104,7 @@ namespace app {
|
|||||||
void updateDisplayTitleBar();
|
void updateDisplayTitleBar();
|
||||||
|
|
||||||
InputChain& inputChain();
|
InputChain& inputChain();
|
||||||
|
#endif
|
||||||
|
|
||||||
// App Signals
|
// App Signals
|
||||||
obs::signal<void()> Exit;
|
obs::signal<void()> Exit;
|
||||||
@ -117,9 +125,11 @@ namespace app {
|
|||||||
bool m_isShell;
|
bool m_isShell;
|
||||||
base::UniquePtr<MainWindow> m_mainWindow;
|
base::UniquePtr<MainWindow> m_mainWindow;
|
||||||
base::paths m_files;
|
base::paths m_files;
|
||||||
|
#ifdef ENABLE_UI
|
||||||
base::UniquePtr<AppBrushes> m_brushes;
|
base::UniquePtr<AppBrushes> m_brushes;
|
||||||
BackupIndicator* m_backupIndicator;
|
BackupIndicator* m_backupIndicator;
|
||||||
base::mutex m_backupIndicatorMutex;
|
base::mutex m_backupIndicatorMutex;
|
||||||
|
#endif // ENABLE_UI
|
||||||
};
|
};
|
||||||
|
|
||||||
void app_refresh_screen();
|
void app_refresh_screen();
|
||||||
@ -127,6 +137,7 @@ namespace app {
|
|||||||
PixelFormat app_get_current_pixel_format();
|
PixelFormat app_get_current_pixel_format();
|
||||||
void app_default_statusbar_message();
|
void app_default_statusbar_message();
|
||||||
int app_get_color_to_clear_layer(doc::Layer* layer);
|
int app_get_color_to_clear_layer(doc::Layer* layer);
|
||||||
|
std::string memory_dump_filename();
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2016 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -13,6 +13,7 @@
|
|||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class AppOptions;
|
class AppOptions;
|
||||||
|
class Context;
|
||||||
class DocumentExporter;
|
class DocumentExporter;
|
||||||
struct CliOpenFile;
|
struct CliOpenFile;
|
||||||
|
|
||||||
@ -26,9 +27,9 @@ namespace app {
|
|||||||
virtual void batchMode() { }
|
virtual void batchMode() { }
|
||||||
virtual void beforeOpenFile(const CliOpenFile& cof) { }
|
virtual void beforeOpenFile(const CliOpenFile& cof) { }
|
||||||
virtual void afterOpenFile(const CliOpenFile& cof) { }
|
virtual void afterOpenFile(const CliOpenFile& cof) { }
|
||||||
virtual void saveFile(const CliOpenFile& cof) { }
|
virtual void saveFile(Context* ctx, const CliOpenFile& cof) { }
|
||||||
virtual void loadPalette(const CliOpenFile& cof, const std::string& filename) { }
|
virtual void loadPalette(Context* ctx, const CliOpenFile& cof, const std::string& filename) { }
|
||||||
virtual void exportFiles(DocumentExporter& exporter) { }
|
virtual void exportFiles(Context* ctx, DocumentExporter& exporter) { }
|
||||||
virtual void execScript(const std::string& filename) { }
|
virtual void execScript(const std::string& filename) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -113,7 +113,7 @@ void filter_layers(const LayerList& layers,
|
|||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
CliProcessor::CliProcessor(CliDelegate* delegate,
|
CliProcessor::CliProcessor(CliDelegate* delegate,
|
||||||
const AppOptions& options)
|
const AppOptions& options)
|
||||||
: m_delegate(delegate)
|
: m_delegate(delegate)
|
||||||
, m_options(options)
|
, m_options(options)
|
||||||
, m_exporter(nullptr)
|
, m_exporter(nullptr)
|
||||||
@ -122,7 +122,7 @@ CliProcessor::CliProcessor(CliDelegate* delegate,
|
|||||||
m_exporter.reset(new DocumentExporter);
|
m_exporter.reset(new DocumentExporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CliProcessor::process()
|
void CliProcessor::process(Context* ctx)
|
||||||
{
|
{
|
||||||
// --help
|
// --help
|
||||||
if (m_options.showHelp()) {
|
if (m_options.showHelp()) {
|
||||||
@ -135,7 +135,6 @@ void CliProcessor::process()
|
|||||||
// Process other options and file names
|
// Process other options and file names
|
||||||
else if (!m_options.values().empty()) {
|
else if (!m_options.values().empty()) {
|
||||||
Console console;
|
Console console;
|
||||||
UIContext* ctx = UIContext::instance();
|
|
||||||
CliOpenFile cof;
|
CliOpenFile cof;
|
||||||
SpriteSheetType sheetType = SpriteSheetType::None;
|
SpriteSheetType sheetType = SpriteSheetType::None;
|
||||||
app::Document* lastDoc = nullptr;
|
app::Document* lastDoc = nullptr;
|
||||||
@ -316,7 +315,7 @@ void CliProcessor::process()
|
|||||||
|
|
||||||
cof.document = lastDoc;
|
cof.document = lastDoc;
|
||||||
cof.filename = fn;
|
cof.filename = fn;
|
||||||
saveFile(cof);
|
saveFile(ctx, cof);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
console.printf("A document is needed before --save-as argument\n");
|
console.printf("A document is needed before --save-as argument\n");
|
||||||
@ -327,7 +326,7 @@ void CliProcessor::process()
|
|||||||
ASSERT(cof.document == lastDoc);
|
ASSERT(cof.document == lastDoc);
|
||||||
|
|
||||||
std::string filename = value.value();
|
std::string filename = value.value();
|
||||||
m_delegate->loadPalette(cof, filename);
|
m_delegate->loadPalette(ctx, cof, filename);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.printf("You need to load a document to change its palette with --palette\n");
|
console.printf("You need to load a document to change its palette with --palette\n");
|
||||||
@ -462,7 +461,7 @@ void CliProcessor::process()
|
|||||||
else {
|
else {
|
||||||
cof.document = nullptr;
|
cof.document = nullptr;
|
||||||
cof.filename = base::normalize_path(value.value());
|
cof.filename = base::normalize_path(value.value());
|
||||||
if (openFile(cof))
|
if (openFile(ctx, cof))
|
||||||
lastDoc = cof.document;
|
lastDoc = cof.document;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,7 +470,7 @@ void CliProcessor::process()
|
|||||||
if (sheetType != SpriteSheetType::None)
|
if (sheetType != SpriteSheetType::None)
|
||||||
m_exporter->setSpriteSheetType(sheetType);
|
m_exporter->setSpriteSheetType(sheetType);
|
||||||
|
|
||||||
m_delegate->exportFiles(*m_exporter.get());
|
m_delegate->exportFiles(ctx, *m_exporter.get());
|
||||||
m_exporter.reset(nullptr);
|
m_exporter.reset(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,11 +487,10 @@ void CliProcessor::process()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CliProcessor::openFile(CliOpenFile& cof)
|
bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
|
||||||
{
|
{
|
||||||
m_delegate->beforeOpenFile(cof);
|
m_delegate->beforeOpenFile(cof);
|
||||||
|
|
||||||
Context* ctx = UIContext::instance();
|
|
||||||
app::Document* oldDoc = ctx->activeDocument();
|
app::Document* oldDoc = ctx->activeDocument();
|
||||||
Command* openCommand = Commands::instance()->byId(CommandId::OpenFile());
|
Command* openCommand = Commands::instance()->byId(CommandId::OpenFile());
|
||||||
Params params;
|
Params params;
|
||||||
@ -576,9 +574,8 @@ bool CliProcessor::openFile(CliOpenFile& cof)
|
|||||||
return (doc ? true: false);
|
return (doc ? true: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CliProcessor::saveFile(const CliOpenFile& cof)
|
void CliProcessor::saveFile(Context* ctx, const CliOpenFile& cof)
|
||||||
{
|
{
|
||||||
UIContext* ctx = UIContext::instance();
|
|
||||||
ctx->setActiveDocument(cof.document);
|
ctx->setActiveDocument(cof.document);
|
||||||
|
|
||||||
Command* trimCommand = Commands::instance()->byId(CommandId::AutocropSprite());
|
Command* trimCommand = Commands::instance()->byId(CommandId::AutocropSprite());
|
||||||
@ -727,7 +724,7 @@ void CliProcessor::saveFile(const CliOpenFile& cof)
|
|||||||
itemCof.filenameFormat = filename_formatter(filenameFormat, fnInfo, false);
|
itemCof.filenameFormat = filename_formatter(filenameFormat, fnInfo, false);
|
||||||
|
|
||||||
// Call delegate
|
// Call delegate
|
||||||
m_delegate->saveFile(itemCof);
|
m_delegate->saveFile(ctx, itemCof);
|
||||||
|
|
||||||
if (cof.trim) {
|
if (cof.trim) {
|
||||||
ctx->executeCommand(undoCommand);
|
ctx->executeCommand(undoCommand);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2016 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -18,17 +18,18 @@
|
|||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
class AppOptions;
|
class AppOptions;
|
||||||
|
class Context;
|
||||||
class DocumentExporter;
|
class DocumentExporter;
|
||||||
|
|
||||||
class CliProcessor {
|
class CliProcessor {
|
||||||
public:
|
public:
|
||||||
CliProcessor(CliDelegate* delegate,
|
CliProcessor(CliDelegate* delegate,
|
||||||
const AppOptions& options);
|
const AppOptions& options);
|
||||||
void process();
|
void process(Context* ctx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool openFile(CliOpenFile& cof);
|
bool openFile(Context* ctx, CliOpenFile& cof);
|
||||||
void saveFile(const CliOpenFile& cof);
|
void saveFile(Context* ctx, const CliOpenFile& cof);
|
||||||
|
|
||||||
CliDelegate* m_delegate;
|
CliDelegate* m_delegate;
|
||||||
const AppOptions& m_options;
|
const AppOptions& m_options;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2016 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -31,8 +31,8 @@ public:
|
|||||||
void batchMode() override { m_batchMode = true; }
|
void batchMode() override { m_batchMode = true; }
|
||||||
void beforeOpenFile(const CliOpenFile& cof) override { }
|
void beforeOpenFile(const CliOpenFile& cof) override { }
|
||||||
void afterOpenFile(const CliOpenFile& cof) override { }
|
void afterOpenFile(const CliOpenFile& cof) override { }
|
||||||
void saveFile(const CliOpenFile& cof) override { }
|
void saveFile(Context* ctx, const CliOpenFile& cof) override { }
|
||||||
void exportFiles(DocumentExporter& exporter) override { }
|
void exportFiles(Context* ctx, DocumentExporter& exporter) override { }
|
||||||
void execScript(const std::string& filename) override { }
|
void execScript(const std::string& filename) override { }
|
||||||
|
|
||||||
bool helpWasShown() const { return m_helpWasShown; }
|
bool helpWasShown() const { return m_helpWasShown; }
|
||||||
@ -64,7 +64,7 @@ TEST(Cli, None)
|
|||||||
{
|
{
|
||||||
CliTestDelegate d;
|
CliTestDelegate d;
|
||||||
CliProcessor p(&d, args({ }));
|
CliProcessor p(&d, args({ }));
|
||||||
p.process();
|
p.process(nullptr);
|
||||||
EXPECT_TRUE(!d.helpWasShown());
|
EXPECT_TRUE(!d.helpWasShown());
|
||||||
EXPECT_TRUE(!d.versionWasShown());
|
EXPECT_TRUE(!d.versionWasShown());
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ TEST(Cli, Help)
|
|||||||
{
|
{
|
||||||
CliTestDelegate d;
|
CliTestDelegate d;
|
||||||
CliProcessor p(&d, args({ "--help" }));
|
CliProcessor p(&d, args({ "--help" }));
|
||||||
p.process();
|
p.process(nullptr);
|
||||||
EXPECT_TRUE(d.helpWasShown());
|
EXPECT_TRUE(d.helpWasShown());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +81,6 @@ TEST(Cli, Version)
|
|||||||
{
|
{
|
||||||
CliTestDelegate d;
|
CliTestDelegate d;
|
||||||
CliProcessor p(&d, args({ "--version" }));
|
CliProcessor p(&d, args({ "--version" }));
|
||||||
p.process();
|
p.process(nullptr);
|
||||||
EXPECT_TRUE(d.versionWasShown());
|
EXPECT_TRUE(d.versionWasShown());
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2016-2017 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -73,9 +73,8 @@ void DefaultCliDelegate::afterOpenFile(const CliOpenFile& cof)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultCliDelegate::saveFile(const CliOpenFile& cof)
|
void DefaultCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
|
||||||
{
|
{
|
||||||
Context* ctx = UIContext::instance();
|
|
||||||
Command* saveAsCommand = Commands::instance()->byId(CommandId::SaveFileCopyAs());
|
Command* saveAsCommand = Commands::instance()->byId(CommandId::SaveFileCopyAs());
|
||||||
Params params;
|
Params params;
|
||||||
params.set("filename", cof.filename.c_str());
|
params.set("filename", cof.filename.c_str());
|
||||||
@ -95,12 +94,12 @@ void DefaultCliDelegate::saveFile(const CliOpenFile& cof)
|
|||||||
ctx->executeCommand(saveAsCommand, params);
|
ctx->executeCommand(saveAsCommand, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultCliDelegate::loadPalette(const CliOpenFile& cof,
|
void DefaultCliDelegate::loadPalette(Context* ctx,
|
||||||
|
const CliOpenFile& cof,
|
||||||
const std::string& filename)
|
const std::string& filename)
|
||||||
{
|
{
|
||||||
base::UniquePtr<doc::Palette> palette(load_palette(filename.c_str()));
|
base::UniquePtr<doc::Palette> palette(load_palette(filename.c_str()));
|
||||||
if (palette) {
|
if (palette) {
|
||||||
Context* ctx = UIContext::instance();
|
|
||||||
Command* loadPalCommand = Commands::instance()->byId(CommandId::LoadPalette());
|
Command* loadPalCommand = Commands::instance()->byId(CommandId::LoadPalette());
|
||||||
Params params;
|
Params params;
|
||||||
params.set("filename", filename.c_str());
|
params.set("filename", filename.c_str());
|
||||||
@ -113,11 +112,11 @@ void DefaultCliDelegate::loadPalette(const CliOpenFile& cof,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultCliDelegate::exportFiles(DocumentExporter& exporter)
|
void DefaultCliDelegate::exportFiles(Context* ctx, DocumentExporter& exporter)
|
||||||
{
|
{
|
||||||
LOG("APP: Exporting sheet...\n");
|
LOG("APP: Exporting sheet...\n");
|
||||||
|
|
||||||
base::UniquePtr<app::Document> spriteSheet(exporter.exportSheet());
|
base::UniquePtr<app::Document> spriteSheet(exporter.exportSheet(ctx));
|
||||||
|
|
||||||
// Sprite sheet isn't used, we just delete it.
|
// Sprite sheet isn't used, we just delete it.
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2016 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -17,9 +17,9 @@ namespace app {
|
|||||||
void showHelp(const AppOptions& programOptions) override;
|
void showHelp(const AppOptions& programOptions) override;
|
||||||
void showVersion() override;
|
void showVersion() override;
|
||||||
void afterOpenFile(const CliOpenFile& cof) override;
|
void afterOpenFile(const CliOpenFile& cof) override;
|
||||||
void saveFile(const CliOpenFile& cof) override;
|
void saveFile(Context* ctx, const CliOpenFile& cof) override;
|
||||||
void loadPalette(const CliOpenFile& cof, const std::string& filename) override;
|
void loadPalette(Context* ctx, const CliOpenFile& cof, const std::string& filename) override;
|
||||||
void exportFiles(DocumentExporter& exporter) override;
|
void exportFiles(Context* ctx, DocumentExporter& exporter) override;
|
||||||
void execScript(const std::string& filename) override;
|
void execScript(const std::string& filename) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
#include "app/cli/preview_cli_delegate.h"
|
#include "app/cli/preview_cli_delegate.h"
|
||||||
|
|
||||||
#include "app/cli/cli_open_file.h"
|
#include "app/cli/cli_open_file.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/document.h"
|
#include "app/document.h"
|
||||||
#include "app/document_exporter.h"
|
#include "app/document_exporter.h"
|
||||||
#include "app/file/file.h"
|
#include "app/file/file.h"
|
||||||
#include "app/ui_context.h"
|
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
#include "base/unique_ptr.h"
|
#include "base/unique_ptr.h"
|
||||||
#include "doc/sprite.h"
|
#include "doc/sprite.h"
|
||||||
@ -78,7 +78,7 @@ void PreviewCliDelegate::afterOpenFile(const CliOpenFile& cof)
|
|||||||
showLayersFilter(cof);
|
showLayersFilter(cof);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewCliDelegate::saveFile(const CliOpenFile& cof)
|
void PreviewCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
|
||||||
{
|
{
|
||||||
ASSERT(cof.document);
|
ASSERT(cof.document);
|
||||||
ASSERT(cof.document->sprite());
|
ASSERT(cof.document->sprite());
|
||||||
@ -133,7 +133,7 @@ void PreviewCliDelegate::saveFile(const CliOpenFile& cof)
|
|||||||
|
|
||||||
base::UniquePtr<FileOp> fop(
|
base::UniquePtr<FileOp> fop(
|
||||||
FileOp::createSaveDocumentOperation(
|
FileOp::createSaveDocumentOperation(
|
||||||
UIContext::instance(),
|
ctx,
|
||||||
cof.roi(),
|
cof.roi(),
|
||||||
cof.filename,
|
cof.filename,
|
||||||
cof.filenameFormat));
|
cof.filenameFormat));
|
||||||
@ -152,7 +152,8 @@ void PreviewCliDelegate::saveFile(const CliOpenFile& cof)
|
|||||||
std::cout << " - No output\n";
|
std::cout << " - No output\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewCliDelegate::loadPalette(const CliOpenFile& cof,
|
void PreviewCliDelegate::loadPalette(Context* ctx,
|
||||||
|
const CliOpenFile& cof,
|
||||||
const std::string& filename)
|
const std::string& filename)
|
||||||
{
|
{
|
||||||
ASSERT(cof.document);
|
ASSERT(cof.document);
|
||||||
@ -163,7 +164,7 @@ void PreviewCliDelegate::loadPalette(const CliOpenFile& cof,
|
|||||||
<< " - Palette: '" << filename << "'\n";
|
<< " - Palette: '" << filename << "'\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreviewCliDelegate::exportFiles(DocumentExporter& exporter)
|
void PreviewCliDelegate::exportFiles(Context* ctx, DocumentExporter& exporter)
|
||||||
{
|
{
|
||||||
std::string type = "None";
|
std::string type = "None";
|
||||||
switch (exporter.spriteSheetType()) {
|
switch (exporter.spriteSheetType()) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2016 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -21,10 +21,11 @@ namespace app {
|
|||||||
void batchMode() override;
|
void batchMode() override;
|
||||||
void beforeOpenFile(const CliOpenFile& cof) override;
|
void beforeOpenFile(const CliOpenFile& cof) override;
|
||||||
void afterOpenFile(const CliOpenFile& cof) override;
|
void afterOpenFile(const CliOpenFile& cof) override;
|
||||||
void saveFile(const CliOpenFile& cof) override;
|
void saveFile(Context* ctx, const CliOpenFile& cof) override;
|
||||||
void loadPalette(const CliOpenFile& cof,
|
void loadPalette(Context* ctx,
|
||||||
|
const CliOpenFile& cof,
|
||||||
const std::string& filename) override;
|
const std::string& filename) override;
|
||||||
void exportFiles(DocumentExporter& exporter) override;
|
void exportFiles(Context* ctx, DocumentExporter& exporter) override;
|
||||||
void execScript(const std::string& filename) override;
|
void execScript(const std::string& filename) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -438,6 +438,7 @@ void ChangePixelFormatCommand::onExecute(Context* context)
|
|||||||
{
|
{
|
||||||
bool flatten = false;
|
bool flatten = false;
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
if (m_useUI) {
|
if (m_useUI) {
|
||||||
ColorModeWindow window(current_editor);
|
ColorModeWindow window(current_editor);
|
||||||
|
|
||||||
@ -456,6 +457,7 @@ void ChangePixelFormatCommand::onExecute(Context* context)
|
|||||||
m_ditheringMatrix = window.ditheringMatrix();
|
m_ditheringMatrix = window.ditheringMatrix();
|
||||||
flatten = window.flattenEnabled();
|
flatten = window.flattenEnabled();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
// No conversion needed
|
// No conversion needed
|
||||||
if (context->activeDocument()->sprite()->pixelFormat() == m_format)
|
if (context->activeDocument()->sprite()->pixelFormat() == m_format)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -76,7 +76,10 @@ void CropSpriteCommand::onExecute(Context* context)
|
|||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
document->generateMaskBoundaries();
|
document->generateMaskBoundaries();
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
update_screen_for_document(document);
|
update_screen_for_document(document);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutocropSpriteCommand : public Command {
|
class AutocropSpriteCommand : public Command {
|
||||||
@ -111,7 +114,10 @@ void AutocropSpriteCommand::onExecute(Context* context)
|
|||||||
transaction.commit();
|
transaction.commit();
|
||||||
}
|
}
|
||||||
document->generateMaskBoundaries();
|
document->generateMaskBoundaries();
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
update_screen_for_document(document);
|
update_screen_for_document(document);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandFactory::createCropSpriteCommand()
|
Command* CommandFactory::createCropSpriteCommand()
|
||||||
|
@ -777,7 +777,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
|
|||||||
(!selLayers.empty() ? &selLayers: nullptr),
|
(!selLayers.empty() ? &selLayers: nullptr),
|
||||||
(!selFrames.empty() ? &selFrames: nullptr));
|
(!selFrames.empty() ? &selFrames: nullptr));
|
||||||
|
|
||||||
base::UniquePtr<Document> newDocument(exporter.exportSheet());
|
base::UniquePtr<Document> newDocument(exporter.exportSheet(context));
|
||||||
if (!newDocument)
|
if (!newDocument)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ void LoadPaletteCommand::onExecute(Context* context)
|
|||||||
else if (!m_filename.empty()) {
|
else if (!m_filename.empty()) {
|
||||||
filename = m_filename;
|
filename = m_filename;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_UI
|
||||||
else {
|
else {
|
||||||
base::paths exts = get_readable_palette_extensions();
|
base::paths exts = get_readable_palette_extensions();
|
||||||
base::paths filenames;
|
base::paths filenames;
|
||||||
@ -72,6 +73,7 @@ void LoadPaletteCommand::onExecute(Context* context)
|
|||||||
filename = filenames.front();
|
filename = filenames.front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
// Do nothing
|
// Do nothing
|
||||||
if (filename.empty())
|
if (filename.empty())
|
||||||
|
@ -107,6 +107,7 @@ void OpenFileCommand::onExecute(Context* context)
|
|||||||
base::paths filenames;
|
base::paths filenames;
|
||||||
|
|
||||||
// interactive
|
// interactive
|
||||||
|
#ifdef ENABLE_UI
|
||||||
if (context->isUIAvailable() && m_filename.empty()) {
|
if (context->isUIAvailable() && m_filename.empty()) {
|
||||||
base::paths exts = get_readable_extensions();
|
base::paths exts = get_readable_extensions();
|
||||||
|
|
||||||
@ -122,7 +123,9 @@ void OpenFileCommand::onExecute(Context* context)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!m_filename.empty()) {
|
else
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
if (!m_filename.empty()) {
|
||||||
filenames.push_back(m_filename);
|
filenames.push_back(m_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
#include "app/recent_files.h"
|
#include "app/recent_files.h"
|
||||||
#include "app/resource_finder.h"
|
#include "app/resource_finder.h"
|
||||||
#include "app/send_crash.h"
|
|
||||||
#include "app/ui/color_button.h"
|
#include "app/ui/color_button.h"
|
||||||
#include "app/ui/separator_in_view.h"
|
#include "app/ui/separator_in_view.h"
|
||||||
#include "app/ui/skin/skin_theme.h"
|
#include "app/ui/skin/skin_theme.h"
|
||||||
|
@ -133,6 +133,7 @@ std::string SaveFileBaseCommand::saveAsDialog(
|
|||||||
base::paths exts = get_writable_extensions();
|
base::paths exts = get_writable_extensions();
|
||||||
filename = initialFilename;
|
filename = initialFilename;
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
again:;
|
again:;
|
||||||
base::paths newfilename;
|
base::paths newfilename;
|
||||||
if (!app::show_file_selector(
|
if (!app::show_file_selector(
|
||||||
@ -148,6 +149,7 @@ std::string SaveFileBaseCommand::saveAsDialog(
|
|||||||
ui::Alert::show(Strings::alerts_cannot_file_overwrite_on_export());
|
ui::Alert::show(Strings::alerts_cannot_file_overwrite_on_export());
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveInBackground) {
|
if (saveInBackground) {
|
||||||
@ -210,9 +212,11 @@ void SaveFileBaseCommand::saveDocumentInBackground(
|
|||||||
document->setFilename(filename);
|
document->setFilename(filename);
|
||||||
document->incrementVersion();
|
document->incrementVersion();
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_UI
|
||||||
StatusBar::instance()
|
StatusBar::instance()
|
||||||
->setStatusText(2000, "File <%s> saved.",
|
->setStatusText(2000, "File <%s> saved.",
|
||||||
base::get_file_name(filename).c_str());
|
base::get_file_name(filename).c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +308,7 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
|
|||||||
doc::AniDir aniDirValue = convert_string_to_anidir(m_aniDir);
|
doc::AniDir aniDirValue = convert_string_to_anidir(m_aniDir);
|
||||||
bool isForTwitter = false;
|
bool isForTwitter = false;
|
||||||
|
|
||||||
|
#if ENABLE_UI
|
||||||
if (context->isUIAvailable()) {
|
if (context->isUIAvailable()) {
|
||||||
ExportFileWindow win(doc);
|
ExportFileWindow win(doc);
|
||||||
bool askOverwrite = true;
|
bool askOverwrite = true;
|
||||||
@ -350,6 +355,7 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
|
|||||||
aniDirValue = win.aniDirValue();
|
aniDirValue = win.aniDirValue();
|
||||||
isForTwitter = win.isForTwitter();
|
isForTwitter = win.isForTwitter();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Pixel ratio
|
// Pixel ratio
|
||||||
if (applyPixelRatio) {
|
if (applyPixelRatio) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -332,6 +332,7 @@ void SpriteSizeCommand::onExecute(Context* context)
|
|||||||
int new_height = (m_height ? m_height: int(sprite->height()*m_scaleY));
|
int new_height = (m_height ? m_height: int(sprite->height()*m_scaleY));
|
||||||
ResizeMethod resize_method = m_resizeMethod;
|
ResizeMethod resize_method = m_resizeMethod;
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
if (m_useUI && context->isUIAvailable()) {
|
if (m_useUI && context->isUIAvailable()) {
|
||||||
SpriteSizeWindow window(context, new_width, new_height);
|
SpriteSizeWindow window(context, new_width, new_height);
|
||||||
window.remapWindow();
|
window.remapWindow();
|
||||||
@ -351,6 +352,7 @@ void SpriteSizeCommand::onExecute(Context* context)
|
|||||||
|
|
||||||
set_config_int("SpriteSize", "Method", resize_method);
|
set_config_int("SpriteSize", "Method", resize_method);
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
{
|
{
|
||||||
SpriteSizeJob job(reader, new_width, new_height, resize_method);
|
SpriteSizeJob job(reader, new_width, new_height, resize_method);
|
||||||
@ -358,7 +360,9 @@ void SpriteSizeCommand::onExecute(Context* context)
|
|||||||
job.waitJob();
|
job.waitJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
update_screen_for_document(reader.document());
|
update_screen_for_document(reader.document());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandFactory::createSpriteSizeCommand()
|
Command* CommandFactory::createSpriteSizeCommand()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -63,11 +63,11 @@ void UndoCommand::onExecute(Context* context)
|
|||||||
ContextWriter writer(context);
|
ContextWriter writer(context);
|
||||||
Document* document(writer.document());
|
Document* document(writer.document());
|
||||||
DocumentUndo* undo = document->undoHistory();
|
DocumentUndo* undo = document->undoHistory();
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
Sprite* sprite = document->sprite();
|
Sprite* sprite = document->sprite();
|
||||||
SpritePosition spritePosition;
|
SpritePosition spritePosition;
|
||||||
const bool gotoModified =
|
const bool gotoModified = Preferences::instance().undo.gotoModified();
|
||||||
Preferences::instance().undo.gotoModified();
|
|
||||||
|
|
||||||
if (gotoModified) {
|
if (gotoModified) {
|
||||||
SpritePosition currentPosition(writer.site()->layer(),
|
SpritePosition currentPosition(writer.site()->layer(),
|
||||||
writer.site()->frame());
|
writer.site()->frame());
|
||||||
@ -100,6 +100,7 @@ void UndoCommand::onExecute(Context* context)
|
|||||||
(m_type == Undo ?
|
(m_type == Undo ?
|
||||||
undo->nextUndoLabel().c_str():
|
undo->nextUndoLabel().c_str():
|
||||||
undo->nextRedoLabel().c_str()));
|
undo->nextRedoLabel().c_str()));
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
// Effectively undo/redo.
|
// Effectively undo/redo.
|
||||||
if (m_type == Undo)
|
if (m_type == Undo)
|
||||||
@ -107,6 +108,7 @@ void UndoCommand::onExecute(Context* context)
|
|||||||
else
|
else
|
||||||
undo->redo();
|
undo->redo();
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// After redo/undo, we retry to change the current SpritePosition
|
// After redo/undo, we retry to change the current SpritePosition
|
||||||
// (because new frames/layers could be added, positions that we
|
// (because new frames/layers could be added, positions that we
|
||||||
// weren't able to reach before the undo).
|
// weren't able to reach before the undo).
|
||||||
@ -122,11 +124,14 @@ void UndoCommand::onExecute(Context* context)
|
|||||||
current_editor->setFrame(spritePosition.frame());
|
current_editor->setFrame(spritePosition.frame());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
document->generateMaskBoundaries();
|
document->generateMaskBoundaries();
|
||||||
document->setExtraCel(ExtraCelRef(nullptr));
|
document->setExtraCel(ExtraCelRef(nullptr));
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
update_screen_for_document(document);
|
update_screen_for_document(document);
|
||||||
|
#endif
|
||||||
set_current_palette(writer.palette(), false);
|
set_current_palette(writer.palette(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,25 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
|
|
||||||
|
FOR_EACH_COMMAND(AutocropSprite)
|
||||||
|
FOR_EACH_COMMAND(ChangePixelFormat)
|
||||||
|
FOR_EACH_COMMAND(CropSprite)
|
||||||
|
FOR_EACH_COMMAND(LoadPalette)
|
||||||
|
FOR_EACH_COMMAND(OpenFile)
|
||||||
|
FOR_EACH_COMMAND(Redo)
|
||||||
|
FOR_EACH_COMMAND(SaveFile)
|
||||||
|
FOR_EACH_COMMAND(SaveFileAs)
|
||||||
|
FOR_EACH_COMMAND(SaveFileCopyAs)
|
||||||
|
FOR_EACH_COMMAND(SpriteSize)
|
||||||
|
FOR_EACH_COMMAND(Undo)
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
FOR_EACH_COMMAND(About)
|
FOR_EACH_COMMAND(About)
|
||||||
FOR_EACH_COMMAND(AddColor)
|
FOR_EACH_COMMAND(AddColor)
|
||||||
FOR_EACH_COMMAND(AdvancedMode)
|
FOR_EACH_COMMAND(AdvancedMode)
|
||||||
FOR_EACH_COMMAND(AutocropSprite)
|
|
||||||
FOR_EACH_COMMAND(BackgroundFromLayer)
|
FOR_EACH_COMMAND(BackgroundFromLayer)
|
||||||
FOR_EACH_COMMAND(BrightnessContrast)
|
FOR_EACH_COMMAND(BrightnessContrast)
|
||||||
FOR_EACH_COMMAND(Cancel)
|
FOR_EACH_COMMAND(Cancel)
|
||||||
@ -15,7 +27,6 @@ FOR_EACH_COMMAND(CanvasSize)
|
|||||||
FOR_EACH_COMMAND(CelProperties)
|
FOR_EACH_COMMAND(CelProperties)
|
||||||
FOR_EACH_COMMAND(ChangeBrush)
|
FOR_EACH_COMMAND(ChangeBrush)
|
||||||
FOR_EACH_COMMAND(ChangeColor)
|
FOR_EACH_COMMAND(ChangeColor)
|
||||||
FOR_EACH_COMMAND(ChangePixelFormat)
|
|
||||||
FOR_EACH_COMMAND(Clear)
|
FOR_EACH_COMMAND(Clear)
|
||||||
FOR_EACH_COMMAND(ClearCel)
|
FOR_EACH_COMMAND(ClearCel)
|
||||||
FOR_EACH_COMMAND(CloseAllFiles)
|
FOR_EACH_COMMAND(CloseAllFiles)
|
||||||
@ -27,7 +38,6 @@ FOR_EACH_COMMAND(ConvolutionMatrix)
|
|||||||
FOR_EACH_COMMAND(Copy)
|
FOR_EACH_COMMAND(Copy)
|
||||||
FOR_EACH_COMMAND(CopyCel)
|
FOR_EACH_COMMAND(CopyCel)
|
||||||
FOR_EACH_COMMAND(CopyMerged)
|
FOR_EACH_COMMAND(CopyMerged)
|
||||||
FOR_EACH_COMMAND(CropSprite)
|
|
||||||
FOR_EACH_COMMAND(Cut)
|
FOR_EACH_COMMAND(Cut)
|
||||||
FOR_EACH_COMMAND(DeselectMask)
|
FOR_EACH_COMMAND(DeselectMask)
|
||||||
FOR_EACH_COMMAND(Despeckle)
|
FOR_EACH_COMMAND(Despeckle)
|
||||||
@ -70,7 +80,6 @@ FOR_EACH_COMMAND(LayerProperties)
|
|||||||
FOR_EACH_COMMAND(LayerVisibility)
|
FOR_EACH_COMMAND(LayerVisibility)
|
||||||
FOR_EACH_COMMAND(LinkCels)
|
FOR_EACH_COMMAND(LinkCels)
|
||||||
FOR_EACH_COMMAND(LoadMask)
|
FOR_EACH_COMMAND(LoadMask)
|
||||||
FOR_EACH_COMMAND(LoadPalette)
|
|
||||||
FOR_EACH_COMMAND(MaskAll)
|
FOR_EACH_COMMAND(MaskAll)
|
||||||
FOR_EACH_COMMAND(MaskByColor)
|
FOR_EACH_COMMAND(MaskByColor)
|
||||||
FOR_EACH_COMMAND(MaskContent)
|
FOR_EACH_COMMAND(MaskContent)
|
||||||
@ -85,7 +94,6 @@ FOR_EACH_COMMAND(NewFrameTag)
|
|||||||
FOR_EACH_COMMAND(NewLayer)
|
FOR_EACH_COMMAND(NewLayer)
|
||||||
FOR_EACH_COMMAND(NewSpriteFromSelection)
|
FOR_EACH_COMMAND(NewSpriteFromSelection)
|
||||||
FOR_EACH_COMMAND(OpenBrowser)
|
FOR_EACH_COMMAND(OpenBrowser)
|
||||||
FOR_EACH_COMMAND(OpenFile)
|
|
||||||
FOR_EACH_COMMAND(OpenGroup)
|
FOR_EACH_COMMAND(OpenGroup)
|
||||||
FOR_EACH_COMMAND(OpenInFolder)
|
FOR_EACH_COMMAND(OpenInFolder)
|
||||||
FOR_EACH_COMMAND(OpenWithApp)
|
FOR_EACH_COMMAND(OpenWithApp)
|
||||||
@ -96,7 +104,6 @@ FOR_EACH_COMMAND(Paste)
|
|||||||
FOR_EACH_COMMAND(PasteText)
|
FOR_EACH_COMMAND(PasteText)
|
||||||
FOR_EACH_COMMAND(PixelPerfectMode)
|
FOR_EACH_COMMAND(PixelPerfectMode)
|
||||||
FOR_EACH_COMMAND(PlayAnimation)
|
FOR_EACH_COMMAND(PlayAnimation)
|
||||||
FOR_EACH_COMMAND(Redo)
|
|
||||||
FOR_EACH_COMMAND(Refresh)
|
FOR_EACH_COMMAND(Refresh)
|
||||||
FOR_EACH_COMMAND(RemoveFrame)
|
FOR_EACH_COMMAND(RemoveFrame)
|
||||||
FOR_EACH_COMMAND(RemoveFrameTag)
|
FOR_EACH_COMMAND(RemoveFrameTag)
|
||||||
@ -107,9 +114,6 @@ FOR_EACH_COMMAND(ReplaceColor)
|
|||||||
FOR_EACH_COMMAND(ReselectMask)
|
FOR_EACH_COMMAND(ReselectMask)
|
||||||
FOR_EACH_COMMAND(ReverseFrames)
|
FOR_EACH_COMMAND(ReverseFrames)
|
||||||
FOR_EACH_COMMAND(Rotate)
|
FOR_EACH_COMMAND(Rotate)
|
||||||
FOR_EACH_COMMAND(SaveFile)
|
|
||||||
FOR_EACH_COMMAND(SaveFileAs)
|
|
||||||
FOR_EACH_COMMAND(SaveFileCopyAs)
|
|
||||||
FOR_EACH_COMMAND(SaveMask)
|
FOR_EACH_COMMAND(SaveMask)
|
||||||
FOR_EACH_COMMAND(SavePalette)
|
FOR_EACH_COMMAND(SavePalette)
|
||||||
FOR_EACH_COMMAND(Scroll)
|
FOR_EACH_COMMAND(Scroll)
|
||||||
@ -134,19 +138,20 @@ FOR_EACH_COMMAND(ShowSlices)
|
|||||||
FOR_EACH_COMMAND(SliceProperties)
|
FOR_EACH_COMMAND(SliceProperties)
|
||||||
FOR_EACH_COMMAND(SnapToGrid)
|
FOR_EACH_COMMAND(SnapToGrid)
|
||||||
FOR_EACH_COMMAND(SpriteProperties)
|
FOR_EACH_COMMAND(SpriteProperties)
|
||||||
FOR_EACH_COMMAND(SpriteSize)
|
|
||||||
FOR_EACH_COMMAND(SwitchColors)
|
FOR_EACH_COMMAND(SwitchColors)
|
||||||
FOR_EACH_COMMAND(SymmetryMode)
|
FOR_EACH_COMMAND(SymmetryMode)
|
||||||
FOR_EACH_COMMAND(TiledMode)
|
FOR_EACH_COMMAND(TiledMode)
|
||||||
FOR_EACH_COMMAND(Timeline)
|
FOR_EACH_COMMAND(Timeline)
|
||||||
FOR_EACH_COMMAND(TogglePreview)
|
FOR_EACH_COMMAND(TogglePreview)
|
||||||
FOR_EACH_COMMAND(ToggleTimelineThumbnails)
|
FOR_EACH_COMMAND(ToggleTimelineThumbnails)
|
||||||
FOR_EACH_COMMAND(Undo)
|
|
||||||
FOR_EACH_COMMAND(UndoHistory)
|
FOR_EACH_COMMAND(UndoHistory)
|
||||||
FOR_EACH_COMMAND(UnlinkCel)
|
FOR_EACH_COMMAND(UnlinkCel)
|
||||||
FOR_EACH_COMMAND(Zoom)
|
FOR_EACH_COMMAND(Zoom)
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
#ifdef ENABLE_SCRIPTING
|
#ifdef ENABLE_SCRIPTING
|
||||||
FOR_EACH_COMMAND(DeveloperConsole)
|
#ifdef ENABLE_UI
|
||||||
|
FOR_EACH_COMMAND(DeveloperConsole)
|
||||||
|
#endif
|
||||||
FOR_EACH_COMMAND(RunScript)
|
FOR_EACH_COMMAND(RunScript)
|
||||||
#endif
|
#endif // ENABLE_SCRIPTING
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -15,6 +15,7 @@
|
|||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/console.h"
|
#include "app/console.h"
|
||||||
#include "app/document.h"
|
#include "app/document.h"
|
||||||
|
#include "doc/site.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -22,6 +23,7 @@
|
|||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
Context::Context()
|
Context::Context()
|
||||||
|
: m_lastSelectedDoc(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +34,11 @@ void Context::sendDocumentToTop(doc::Document* document)
|
|||||||
documents().move(document, 0);
|
documents().move(document, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Context::setActiveDocument(doc::Document* document)
|
||||||
|
{
|
||||||
|
onSetActiveDocument(document);
|
||||||
|
}
|
||||||
|
|
||||||
app::Document* Context::activeDocument() const
|
app::Document* Context::activeDocument() const
|
||||||
{
|
{
|
||||||
return static_cast<app::Document*>(doc::Context::activeDocument());
|
return static_cast<app::Document*>(doc::Context::activeDocument());
|
||||||
@ -59,6 +66,8 @@ void Context::executeCommand(Command* command, const Params& params)
|
|||||||
Console console;
|
Console console;
|
||||||
|
|
||||||
ASSERT(command != NULL);
|
ASSERT(command != NULL);
|
||||||
|
if (command == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
LOG(VERBOSE) << "CTXT: Executing command " << command->id() << "\n";
|
LOG(VERBOSE) << "CTXT: Executing command " << command->id() << "\n";
|
||||||
try {
|
try {
|
||||||
@ -118,4 +127,31 @@ void Context::onCreateDocument(doc::CreateDocumentArgs* args)
|
|||||||
args->setDocument(new app::Document(NULL));
|
args->setDocument(new app::Document(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Context::onAddDocument(doc::Document* doc)
|
||||||
|
{
|
||||||
|
m_lastSelectedDoc = static_cast<app::Document*>(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context::onRemoveDocument(doc::Document* doc)
|
||||||
|
{
|
||||||
|
if (doc == m_lastSelectedDoc)
|
||||||
|
m_lastSelectedDoc = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context::onGetActiveSite(doc::Site* site) const
|
||||||
|
{
|
||||||
|
// Default/dummy site (maybe for batch/command line mode)
|
||||||
|
if (Document* doc = m_lastSelectedDoc) {
|
||||||
|
site->document(doc);
|
||||||
|
site->sprite(doc->sprite());
|
||||||
|
site->layer(doc->sprite()->root()->firstLayer());
|
||||||
|
site->frame(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Context::onSetActiveDocument(doc::Document* doc)
|
||||||
|
{
|
||||||
|
m_lastSelectedDoc = static_cast<app::Document*>(doc);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -20,6 +20,7 @@
|
|||||||
namespace app {
|
namespace app {
|
||||||
class Command;
|
class Command;
|
||||||
class Document;
|
class Document;
|
||||||
|
class DocumentView;
|
||||||
|
|
||||||
class CommandPreconditionException : public base::Exception {
|
class CommandPreconditionException : public base::Exception {
|
||||||
public:
|
public:
|
||||||
@ -61,21 +62,33 @@ namespace app {
|
|||||||
|
|
||||||
void sendDocumentToTop(doc::Document* document);
|
void sendDocumentToTop(doc::Document* document);
|
||||||
|
|
||||||
|
void setActiveDocument(doc::Document* document);
|
||||||
app::Document* activeDocument() const;
|
app::Document* activeDocument() const;
|
||||||
bool hasModifiedDocuments() const;
|
bool hasModifiedDocuments() const;
|
||||||
|
|
||||||
void executeCommand(const char* commandName);
|
void executeCommand(const char* commandName);
|
||||||
virtual void executeCommand(Command* command, const Params& params = Params());
|
virtual void executeCommand(Command* command, const Params& params = Params());
|
||||||
|
|
||||||
|
virtual DocumentView* getFirstDocumentView(doc::Document* document) const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
obs::signal<void (CommandExecutionEvent&)> BeforeCommandExecution;
|
obs::signal<void (CommandExecutionEvent&)> BeforeCommandExecution;
|
||||||
obs::signal<void (CommandExecutionEvent&)> AfterCommandExecution;
|
obs::signal<void (CommandExecutionEvent&)> AfterCommandExecution;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onCreateDocument(doc::CreateDocumentArgs* args) override;
|
void onCreateDocument(doc::CreateDocumentArgs* args) override;
|
||||||
|
void onAddDocument(doc::Document* doc) override;
|
||||||
|
void onRemoveDocument(doc::Document* doc) override;
|
||||||
|
void onGetActiveSite(doc::Site* site) const override;
|
||||||
|
virtual void onSetActiveDocument(doc::Document* doc);
|
||||||
|
|
||||||
|
Document* lastSelectedDoc() { return m_lastSelectedDoc; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Last updated flags.
|
// Last updated flags.
|
||||||
ContextFlags m_flags;
|
ContextFlags m_flags;
|
||||||
|
Document* m_lastSelectedDoc;
|
||||||
|
|
||||||
DISABLE_COPYING(Context);
|
DISABLE_COPYING(Context);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -50,6 +50,7 @@ void ContextFlags::update(Context* context)
|
|||||||
document->unlock();
|
document->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// TODO this is a hack, try to find a better design to handle this
|
// TODO this is a hack, try to find a better design to handle this
|
||||||
// "moving pixels" state.
|
// "moving pixels" state.
|
||||||
if (current_editor &&
|
if (current_editor &&
|
||||||
@ -63,6 +64,7 @@ void ContextFlags::update(Context* context)
|
|||||||
|
|
||||||
updateFlagsFromSite(current_editor->getSite());
|
updateFlagsFromSite(current_editor->getSite());
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
#include "app/cmd/set_pixel_format.h"
|
#include "app/cmd/set_pixel_format.h"
|
||||||
#include "app/console.h"
|
#include "app/console.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/document.h"
|
#include "app/document.h"
|
||||||
#include "app/file/file.h"
|
#include "app/file/file.h"
|
||||||
#include "app/filename_formatter.h"
|
#include "app/filename_formatter.h"
|
||||||
#include "app/restore_visible_layers.h"
|
#include "app/restore_visible_layers.h"
|
||||||
#include "app/ui_context.h"
|
|
||||||
#include "base/convert_to.h"
|
#include "base/convert_to.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
#include "base/fstream_path.h"
|
#include "base/fstream_path.h"
|
||||||
@ -409,14 +409,14 @@ DocumentExporter::DocumentExporter()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Document* DocumentExporter::exportSheet()
|
Document* DocumentExporter::exportSheet(Context* ctx)
|
||||||
{
|
{
|
||||||
// We output the metadata to std::cout if the user didn't specify a file.
|
// We output the metadata to std::cout if the user didn't specify a file.
|
||||||
std::ofstream fos;
|
std::ofstream fos;
|
||||||
std::streambuf* osbuf = nullptr;
|
std::streambuf* osbuf = nullptr;
|
||||||
if (m_dataFilename.empty()) {
|
if (m_dataFilename.empty()) {
|
||||||
// Redirect to stdout if we are running in batch mode
|
// Redirect to stdout if we are running in batch mode
|
||||||
if (!UIContext::instance()->isUIAvailable())
|
if (!ctx->isUIAvailable())
|
||||||
osbuf = std::cout.rdbuf();
|
osbuf = std::cout.rdbuf();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -446,7 +446,7 @@ Document* DocumentExporter::exportSheet()
|
|||||||
Image* textureImage = texture->root()->firstLayer()
|
Image* textureImage = texture->root()->firstLayer()
|
||||||
->cel(frame_t(0))->image();
|
->cel(frame_t(0))->image();
|
||||||
|
|
||||||
renderTexture(samples, textureImage);
|
renderTexture(ctx, samples, textureImage);
|
||||||
|
|
||||||
// Save the metadata.
|
// Save the metadata.
|
||||||
if (osbuf)
|
if (osbuf)
|
||||||
@ -455,7 +455,7 @@ Document* DocumentExporter::exportSheet()
|
|||||||
// Save the image files.
|
// Save the image files.
|
||||||
if (!m_textureFilename.empty()) {
|
if (!m_textureFilename.empty()) {
|
||||||
textureDocument->setFilename(m_textureFilename.c_str());
|
textureDocument->setFilename(m_textureFilename.c_str());
|
||||||
int ret = save_document(UIContext::instance(), textureDocument.get());
|
int ret = save_document(ctx, textureDocument.get());
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
textureDocument->markAsSaved();
|
textureDocument->markAsSaved();
|
||||||
}
|
}
|
||||||
@ -693,7 +693,7 @@ Document* DocumentExporter::createEmptyTexture(const Samples& samples) const
|
|||||||
return document.release();
|
return document.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentExporter::renderTexture(const Samples& samples, Image* textureImage) const
|
void DocumentExporter::renderTexture(Context* ctx, const Samples& samples, Image* textureImage) const
|
||||||
{
|
{
|
||||||
textureImage->clear(0);
|
textureImage->clear(0);
|
||||||
|
|
||||||
@ -711,7 +711,7 @@ void DocumentExporter::renderTexture(const Samples& samples, Image* textureImage
|
|||||||
render::DitheringAlgorithm::None,
|
render::DitheringAlgorithm::None,
|
||||||
render::DitheringMatrix(),
|
render::DitheringMatrix(),
|
||||||
nullptr) // TODO add a delegate to show progress
|
nullptr) // TODO add a delegate to show progress
|
||||||
.execute(UIContext::instance());
|
.execute(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSample(sample, textureImage,
|
renderSample(sample, textureImage,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -29,6 +29,7 @@ namespace doc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
class Context;
|
||||||
class Document;
|
class Document;
|
||||||
|
|
||||||
class DocumentExporter {
|
class DocumentExporter {
|
||||||
@ -79,7 +80,7 @@ namespace app {
|
|||||||
m_documents.push_back(Item(document, tag, selLayers, selFrames));
|
m_documents.push_back(Item(document, tag, selLayers, selFrames));
|
||||||
}
|
}
|
||||||
|
|
||||||
Document* exportSheet();
|
Document* exportSheet(Context* ctx);
|
||||||
gfx::Size calculateSheetSize();
|
gfx::Size calculateSheetSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -93,7 +94,7 @@ namespace app {
|
|||||||
void layoutSamples(Samples& samples);
|
void layoutSamples(Samples& samples);
|
||||||
gfx::Size calculateSheetSize(const Samples& samples) const;
|
gfx::Size calculateSheetSize(const Samples& samples) const;
|
||||||
Document* createEmptyTexture(const Samples& samples) const;
|
Document* createEmptyTexture(const Samples& samples) const;
|
||||||
void renderTexture(const Samples& samples, doc::Image* textureImage) const;
|
void renderTexture(Context* ctx, const Samples& samples, doc::Image* textureImage) const;
|
||||||
void createDataFile(const Samples& samples, std::ostream& os, doc::Image* textureImage);
|
void createDataFile(const Samples& samples, std::ostream& os, doc::Image* textureImage);
|
||||||
void renderSample(const Sample& sample, doc::Image* dst, int x, int y) const;
|
void renderSample(const Sample& sample, doc::Image* dst, int x, int y) const;
|
||||||
|
|
||||||
|
@ -228,6 +228,7 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context, const std::string&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// TODO add a better dialog to edit file-names
|
// TODO add a better dialog to edit file-names
|
||||||
if ((flags & FILE_LOAD_SEQUENCE_ASK) &&
|
if ((flags & FILE_LOAD_SEQUENCE_ASK) &&
|
||||||
context &&
|
context &&
|
||||||
@ -287,6 +288,7 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context, const std::string&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -440,6 +442,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
|||||||
|
|
||||||
// Show the confirmation alert
|
// Show the confirmation alert
|
||||||
if (!warnings.empty()) {
|
if (!warnings.empty()) {
|
||||||
|
#ifdef ENABLE_UI
|
||||||
// Interative
|
// Interative
|
||||||
if (context && context->isUIAvailable()) {
|
if (context && context->isUIAvailable()) {
|
||||||
int ret = OptionalAlert::show(
|
int ret = OptionalAlert::show(
|
||||||
@ -457,7 +460,9 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
// No interactive & fatal error?
|
// No interactive & fatal error?
|
||||||
else if (fatal) {
|
else
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
if (fatal) {
|
||||||
fop->setError(warnings.c_str());
|
fop->setError(warnings.c_str());
|
||||||
return fop.release();
|
return fop.release();
|
||||||
}
|
}
|
||||||
@ -500,6 +505,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
|||||||
++outputFrame;
|
++outputFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
if (context && context->isUIAvailable() &&
|
if (context && context->isUIAvailable() &&
|
||||||
fop->m_seq.filename_list.size() > 1 &&
|
fop->m_seq.filename_list.size() > 1 &&
|
||||||
OptionalAlert::show(
|
OptionalAlert::show(
|
||||||
@ -512,6 +518,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
|||||||
base::get_file_name(fop->m_seq.filename_list[1]))) != 1) {
|
base::get_file_name(fop->m_seq.filename_list[1]))) != 1) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fop->m_filename = filename;
|
fop->m_filename = filename;
|
||||||
|
@ -1406,45 +1406,44 @@ base::SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop)
|
|||||||
if (!gif_options)
|
if (!gif_options)
|
||||||
gif_options.reset(new GifOptions);
|
gif_options.reset(new GifOptions);
|
||||||
|
|
||||||
// Non-interactive mode
|
#ifdef ENABLE_UI
|
||||||
if (!fop->context() ||
|
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||||
!fop->context()->isUIAvailable())
|
try {
|
||||||
return gif_options;
|
auto& pref = Preferences::instance();
|
||||||
|
|
||||||
try {
|
|
||||||
auto& pref = Preferences::instance();
|
|
||||||
|
|
||||||
if (pref.isSet(pref.gif.interlaced))
|
|
||||||
gif_options->setInterlaced(pref.gif.interlaced());
|
|
||||||
if (pref.isSet(pref.gif.loop))
|
|
||||||
gif_options->setLoop(pref.gif.loop());
|
|
||||||
|
|
||||||
if (pref.gif.showAlert()) {
|
|
||||||
app::gen::GifOptions win;
|
|
||||||
win.interlaced()->setSelected(gif_options->interlaced());
|
|
||||||
win.loop()->setSelected(gif_options->loop());
|
|
||||||
|
|
||||||
win.openWindowInForeground();
|
|
||||||
|
|
||||||
if (win.closer() == win.ok()) {
|
|
||||||
pref.gif.interlaced(win.interlaced()->isSelected());
|
|
||||||
pref.gif.loop(win.loop()->isSelected());
|
|
||||||
pref.gif.showAlert(!win.dontShow()->isSelected());
|
|
||||||
|
|
||||||
|
if (pref.isSet(pref.gif.interlaced))
|
||||||
gif_options->setInterlaced(pref.gif.interlaced());
|
gif_options->setInterlaced(pref.gif.interlaced());
|
||||||
|
if (pref.isSet(pref.gif.loop))
|
||||||
gif_options->setLoop(pref.gif.loop());
|
gif_options->setLoop(pref.gif.loop());
|
||||||
}
|
|
||||||
else {
|
if (pref.gif.showAlert()) {
|
||||||
gif_options.reset(nullptr);
|
app::gen::GifOptions win;
|
||||||
|
win.interlaced()->setSelected(gif_options->interlaced());
|
||||||
|
win.loop()->setSelected(gif_options->loop());
|
||||||
|
|
||||||
|
win.openWindowInForeground();
|
||||||
|
|
||||||
|
if (win.closer() == win.ok()) {
|
||||||
|
pref.gif.interlaced(win.interlaced()->isSelected());
|
||||||
|
pref.gif.loop(win.loop()->isSelected());
|
||||||
|
pref.gif.showAlert(!win.dontShow()->isSelected());
|
||||||
|
|
||||||
|
gif_options->setInterlaced(pref.gif.interlaced());
|
||||||
|
gif_options->setLoop(pref.gif.loop());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gif_options.reset(nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
Console::showException(e);
|
||||||
|
return base::SharedPtr<GifOptions>(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
return gif_options;
|
return gif_options;
|
||||||
}
|
|
||||||
catch (std::exception& e) {
|
|
||||||
Console::showException(e);
|
|
||||||
return base::SharedPtr<GifOptions>(nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -372,39 +372,38 @@ base::SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)
|
|||||||
if (!jpeg_options)
|
if (!jpeg_options)
|
||||||
jpeg_options.reset(new JpegOptions);
|
jpeg_options.reset(new JpegOptions);
|
||||||
|
|
||||||
// Non-interactive mode
|
#ifdef ENABLE_UI
|
||||||
if (!fop->context() ||
|
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||||
!fop->context()->isUIAvailable())
|
try {
|
||||||
return jpeg_options;
|
auto& pref = Preferences::instance();
|
||||||
|
|
||||||
try {
|
|
||||||
auto& pref = Preferences::instance();
|
|
||||||
|
|
||||||
if (pref.isSet(pref.jpeg.quality))
|
|
||||||
jpeg_options->quality = pref.jpeg.quality();
|
|
||||||
|
|
||||||
if (pref.jpeg.showAlert()) {
|
|
||||||
app::gen::JpegOptions win;
|
|
||||||
win.quality()->setValue(int(jpeg_options->quality * 10.0f));
|
|
||||||
win.openWindowInForeground();
|
|
||||||
|
|
||||||
if (win.closer() == win.ok()) {
|
|
||||||
pref.jpeg.quality(float(win.quality()->getValue()) / 10.0f);
|
|
||||||
pref.jpeg.showAlert(!win.dontShow()->isSelected());
|
|
||||||
|
|
||||||
|
if (pref.isSet(pref.jpeg.quality))
|
||||||
jpeg_options->quality = pref.jpeg.quality();
|
jpeg_options->quality = pref.jpeg.quality();
|
||||||
}
|
|
||||||
else {
|
if (pref.jpeg.showAlert()) {
|
||||||
jpeg_options.reset(nullptr);
|
app::gen::JpegOptions win;
|
||||||
|
win.quality()->setValue(int(jpeg_options->quality * 10.0f));
|
||||||
|
win.openWindowInForeground();
|
||||||
|
|
||||||
|
if (win.closer() == win.ok()) {
|
||||||
|
pref.jpeg.quality(float(win.quality()->getValue()) / 10.0f);
|
||||||
|
pref.jpeg.showAlert(!win.dontShow()->isSelected());
|
||||||
|
|
||||||
|
jpeg_options->quality = pref.jpeg.quality();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
jpeg_options.reset(nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
Console::showException(e);
|
||||||
|
return base::SharedPtr<JpegOptions>(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
return jpeg_options;
|
return jpeg_options;
|
||||||
}
|
|
||||||
catch (std::exception& e) {
|
|
||||||
Console::showException(e);
|
|
||||||
return base::SharedPtr<JpegOptions>(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -374,95 +374,94 @@ base::SharedPtr<FormatOptions> WebPFormat::onGetFormatOptions(FileOp* fop)
|
|||||||
if (!opts)
|
if (!opts)
|
||||||
opts.reset(new WebPOptions);
|
opts.reset(new WebPOptions);
|
||||||
|
|
||||||
// Non-interactive mode
|
#ifdef ENABLE_UI
|
||||||
if (!fop->context() ||
|
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||||
!fop->context()->isUIAvailable())
|
try {
|
||||||
return opts;
|
auto& pref = Preferences::instance();
|
||||||
|
|
||||||
try {
|
|
||||||
auto& pref = Preferences::instance();
|
|
||||||
|
|
||||||
if (pref.isSet(pref.webp.loop))
|
|
||||||
opts->setLoop(pref.webp.loop());
|
|
||||||
|
|
||||||
if (pref.isSet(pref.webp.type))
|
|
||||||
opts->setType(WebPOptions::Type(pref.webp.type()));
|
|
||||||
|
|
||||||
switch (opts->type()) {
|
|
||||||
case WebPOptions::Lossless:
|
|
||||||
if (pref.isSet(pref.webp.compression)) opts->setCompression(pref.webp.compression());
|
|
||||||
if (pref.isSet(pref.webp.imageHint)) opts->setImageHint(WebPImageHint(pref.webp.imageHint()));
|
|
||||||
break;
|
|
||||||
case WebPOptions::Lossy:
|
|
||||||
if (pref.isSet(pref.webp.quality)) opts->setQuality(pref.webp.quality());
|
|
||||||
if (pref.isSet(pref.webp.imagePreset)) opts->setImagePreset(WebPPreset(pref.webp.imagePreset()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pref.webp.showAlert()) {
|
|
||||||
app::gen::WebpOptions win;
|
|
||||||
|
|
||||||
auto updatePanels = [&win, &opts]{
|
|
||||||
int o = base::convert_to<int>(win.type()->getValue());
|
|
||||||
opts->setType(WebPOptions::Type(o));
|
|
||||||
win.losslessOptions()->setVisible(o == int(WebPOptions::Lossless));
|
|
||||||
win.lossyOptions()->setVisible(o == int(WebPOptions::Lossy));
|
|
||||||
|
|
||||||
auto rc = win.bounds();
|
|
||||||
win.setBounds(
|
|
||||||
gfx::Rect(rc.origin(),
|
|
||||||
win.sizeHint()));
|
|
||||||
|
|
||||||
auto manager = win.manager();
|
|
||||||
if (manager)
|
|
||||||
manager->invalidateRect(rc); // TODO this should be automatic
|
|
||||||
// when a window bounds is modified
|
|
||||||
};
|
|
||||||
|
|
||||||
win.loop()->setSelected(opts->loop());
|
|
||||||
win.type()->setSelectedItemIndex(int(opts->type()));
|
|
||||||
win.compression()->setValue(opts->compression());
|
|
||||||
win.imageHint()->setSelectedItemIndex(opts->imageHint());
|
|
||||||
win.quality()->setValue(static_cast<int>(opts->quality()));
|
|
||||||
win.imagePreset()->setSelectedItemIndex(opts->imagePreset());
|
|
||||||
|
|
||||||
updatePanels();
|
|
||||||
win.type()->Change.connect(base::Bind<void>(updatePanels));
|
|
||||||
|
|
||||||
win.openWindowInForeground();
|
|
||||||
|
|
||||||
if (win.closer() == win.ok()) {
|
|
||||||
pref.webp.loop(win.loop()->isSelected());
|
|
||||||
pref.webp.type(base::convert_to<int>(win.type()->getValue()));
|
|
||||||
pref.webp.compression(win.compression()->getValue());
|
|
||||||
pref.webp.imageHint(base::convert_to<int>(win.imageHint()->getValue()));
|
|
||||||
pref.webp.quality(win.quality()->getValue());
|
|
||||||
pref.webp.imagePreset(base::convert_to<int>(win.imagePreset()->getValue()));
|
|
||||||
|
|
||||||
|
if (pref.isSet(pref.webp.loop))
|
||||||
opts->setLoop(pref.webp.loop());
|
opts->setLoop(pref.webp.loop());
|
||||||
|
|
||||||
|
if (pref.isSet(pref.webp.type))
|
||||||
opts->setType(WebPOptions::Type(pref.webp.type()));
|
opts->setType(WebPOptions::Type(pref.webp.type()));
|
||||||
switch (opts->type()) {
|
|
||||||
case WebPOptions::Lossless:
|
switch (opts->type()) {
|
||||||
opts->setCompression(pref.webp.compression());
|
case WebPOptions::Lossless:
|
||||||
opts->setImageHint(WebPImageHint(pref.webp.imageHint()));
|
if (pref.isSet(pref.webp.compression)) opts->setCompression(pref.webp.compression());
|
||||||
break;
|
if (pref.isSet(pref.webp.imageHint)) opts->setImageHint(WebPImageHint(pref.webp.imageHint()));
|
||||||
case WebPOptions::Lossy:
|
break;
|
||||||
opts->setQuality(pref.webp.quality());
|
case WebPOptions::Lossy:
|
||||||
opts->setImagePreset(WebPPreset(pref.webp.imagePreset()));
|
if (pref.isSet(pref.webp.quality)) opts->setQuality(pref.webp.quality());
|
||||||
break;
|
if (pref.isSet(pref.webp.imagePreset)) opts->setImagePreset(WebPPreset(pref.webp.imagePreset()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pref.webp.showAlert()) {
|
||||||
|
app::gen::WebpOptions win;
|
||||||
|
|
||||||
|
auto updatePanels = [&win, &opts]{
|
||||||
|
int o = base::convert_to<int>(win.type()->getValue());
|
||||||
|
opts->setType(WebPOptions::Type(o));
|
||||||
|
win.losslessOptions()->setVisible(o == int(WebPOptions::Lossless));
|
||||||
|
win.lossyOptions()->setVisible(o == int(WebPOptions::Lossy));
|
||||||
|
|
||||||
|
auto rc = win.bounds();
|
||||||
|
win.setBounds(
|
||||||
|
gfx::Rect(rc.origin(),
|
||||||
|
win.sizeHint()));
|
||||||
|
|
||||||
|
auto manager = win.manager();
|
||||||
|
if (manager)
|
||||||
|
manager->invalidateRect(rc); // TODO this should be automatic
|
||||||
|
// when a window bounds is modified
|
||||||
|
};
|
||||||
|
|
||||||
|
win.loop()->setSelected(opts->loop());
|
||||||
|
win.type()->setSelectedItemIndex(int(opts->type()));
|
||||||
|
win.compression()->setValue(opts->compression());
|
||||||
|
win.imageHint()->setSelectedItemIndex(opts->imageHint());
|
||||||
|
win.quality()->setValue(static_cast<int>(opts->quality()));
|
||||||
|
win.imagePreset()->setSelectedItemIndex(opts->imagePreset());
|
||||||
|
|
||||||
|
updatePanels();
|
||||||
|
win.type()->Change.connect(base::Bind<void>(updatePanels));
|
||||||
|
|
||||||
|
win.openWindowInForeground();
|
||||||
|
|
||||||
|
if (win.closer() == win.ok()) {
|
||||||
|
pref.webp.loop(win.loop()->isSelected());
|
||||||
|
pref.webp.type(base::convert_to<int>(win.type()->getValue()));
|
||||||
|
pref.webp.compression(win.compression()->getValue());
|
||||||
|
pref.webp.imageHint(base::convert_to<int>(win.imageHint()->getValue()));
|
||||||
|
pref.webp.quality(win.quality()->getValue());
|
||||||
|
pref.webp.imagePreset(base::convert_to<int>(win.imagePreset()->getValue()));
|
||||||
|
|
||||||
|
opts->setLoop(pref.webp.loop());
|
||||||
|
opts->setType(WebPOptions::Type(pref.webp.type()));
|
||||||
|
switch (opts->type()) {
|
||||||
|
case WebPOptions::Lossless:
|
||||||
|
opts->setCompression(pref.webp.compression());
|
||||||
|
opts->setImageHint(WebPImageHint(pref.webp.imageHint()));
|
||||||
|
break;
|
||||||
|
case WebPOptions::Lossy:
|
||||||
|
opts->setQuality(pref.webp.quality());
|
||||||
|
opts->setImagePreset(WebPPreset(pref.webp.imagePreset()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
opts.reset(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
opts.reset(nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
Console::showException(e);
|
||||||
|
return base::SharedPtr<WebPOptions>(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // ENABLE_UI
|
||||||
|
|
||||||
return opts;
|
return opts;
|
||||||
}
|
|
||||||
catch (const std::exception& e) {
|
|
||||||
Console::showException(e);
|
|
||||||
return base::SharedPtr<WebPOptions>(nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -32,7 +32,9 @@ static Module module[] =
|
|||||||
// first ones.
|
// first ones.
|
||||||
|
|
||||||
DEF_MODULE(palette, 0),
|
DEF_MODULE(palette, 0),
|
||||||
|
#ifdef ENABLE_UI
|
||||||
DEF_MODULE(gui, REQUIRE_INTERFACE),
|
DEF_MODULE(gui, REQUIRE_INTERFACE),
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static int modules = sizeof(module) / sizeof(Module);
|
static int modules = sizeof(module) / sizeof(Module);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2015-2017 David Capello
|
// Copyright (C) 2015-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -8,12 +8,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "app/document.h"
|
#include "app/app.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/commands/params.h"
|
#include "app/commands/params.h"
|
||||||
|
#include "app/document.h"
|
||||||
#include "app/script/app_scripting.h"
|
#include "app/script/app_scripting.h"
|
||||||
#include "app/script/sprite_wrap.h"
|
#include "app/script/sprite_wrap.h"
|
||||||
#include "app/ui_context.h"
|
|
||||||
#include "script/engine.h"
|
#include "script/engine.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -27,15 +28,16 @@ void App_open(script::ContextHandle handle)
|
|||||||
script::Context ctx(handle);
|
script::Context ctx(handle);
|
||||||
const char* filename = ctx.requireString(1);
|
const char* filename = ctx.requireString(1);
|
||||||
|
|
||||||
app::Document* oldDoc = UIContext::instance()->activeDocument();
|
app::Context* appCtx = App::instance()->context();
|
||||||
|
app::Document* oldDoc = appCtx->activeDocument();
|
||||||
|
|
||||||
Command* openCommand =
|
Command* openCommand =
|
||||||
Commands::instance()->byId(CommandId::OpenFile());
|
Commands::instance()->byId(CommandId::OpenFile());
|
||||||
Params params;
|
Params params;
|
||||||
params.set("filename", filename);
|
params.set("filename", filename);
|
||||||
UIContext::instance()->executeCommand(openCommand, params);
|
appCtx->executeCommand(openCommand, params);
|
||||||
|
|
||||||
app::Document* newDoc = UIContext::instance()->activeDocument();
|
app::Document* newDoc = appCtx->activeDocument();
|
||||||
if (newDoc != oldDoc)
|
if (newDoc != oldDoc)
|
||||||
ctx.newObject("Sprite", unwrap_engine(ctx)->wrapSprite(newDoc), nullptr);
|
ctx.newObject("Sprite", unwrap_engine(ctx)->wrapSprite(newDoc), nullptr);
|
||||||
else
|
else
|
||||||
@ -45,7 +47,7 @@ void App_open(script::ContextHandle handle)
|
|||||||
void App_exit(script::ContextHandle handle)
|
void App_exit(script::ContextHandle handle)
|
||||||
{
|
{
|
||||||
script::Context ctx(handle);
|
script::Context ctx(handle);
|
||||||
UIContext* appCtx = UIContext::instance();
|
app::Context* appCtx = App::instance()->context();
|
||||||
if (appCtx && appCtx->isUIAvailable()) {
|
if (appCtx && appCtx->isUIAvailable()) {
|
||||||
Command* exitCommand =
|
Command* exitCommand =
|
||||||
Commands::instance()->byId(CommandId::Exit());
|
Commands::instance()->byId(CommandId::Exit());
|
||||||
@ -57,7 +59,8 @@ void App_exit(script::ContextHandle handle)
|
|||||||
void App_get_activeSprite(script::ContextHandle handle)
|
void App_get_activeSprite(script::ContextHandle handle)
|
||||||
{
|
{
|
||||||
script::Context ctx(handle);
|
script::Context ctx(handle);
|
||||||
app::Document* doc = UIContext::instance()->activeDocument();
|
app::Context* appCtx = App::instance()->context();
|
||||||
|
app::Document* doc = appCtx->activeDocument();
|
||||||
if (doc)
|
if (doc)
|
||||||
ctx.newObject("Sprite", unwrap_engine(ctx)->wrapSprite(doc), nullptr);
|
ctx.newObject("Sprite", unwrap_engine(ctx)->wrapSprite(doc), nullptr);
|
||||||
else
|
else
|
||||||
@ -67,7 +70,8 @@ void App_get_activeSprite(script::ContextHandle handle)
|
|||||||
void App_get_activeImage(script::ContextHandle handle)
|
void App_get_activeImage(script::ContextHandle handle)
|
||||||
{
|
{
|
||||||
script::Context ctx(handle);
|
script::Context ctx(handle);
|
||||||
app::Document* doc = UIContext::instance()->activeDocument();
|
app::Context* appCtx = App::instance()->context();
|
||||||
|
app::Document* doc = appCtx->activeDocument();
|
||||||
if (doc) {
|
if (doc) {
|
||||||
SpriteWrap* sprWrap = unwrap_engine(ctx)->wrapSprite(doc);
|
SpriteWrap* sprWrap = unwrap_engine(ctx)->wrapSprite(doc);
|
||||||
ASSERT(sprWrap);
|
ASSERT(sprWrap);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2015-2017 David Capello
|
// Copyright (C) 2015-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -8,9 +8,11 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
#include "app/cmd/set_sprite_size.h"
|
#include "app/cmd/set_sprite_size.h"
|
||||||
#include "app/commands/commands.h"
|
#include "app/commands/commands.h"
|
||||||
#include "app/commands/params.h"
|
#include "app/commands/params.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/document.h"
|
#include "app/document.h"
|
||||||
#include "app/document_api.h"
|
#include "app/document_api.h"
|
||||||
#include "app/file/palette_file.h"
|
#include "app/file/palette_file.h"
|
||||||
@ -18,7 +20,6 @@
|
|||||||
#include "app/script/sprite_wrap.h"
|
#include "app/script/sprite_wrap.h"
|
||||||
#include "app/transaction.h"
|
#include "app/transaction.h"
|
||||||
#include "app/ui/document_view.h"
|
#include "app/ui/document_view.h"
|
||||||
#include "app/ui_context.h"
|
|
||||||
#include "doc/mask.h"
|
#include "doc/mask.h"
|
||||||
#include "doc/palette.h"
|
#include "doc/palette.h"
|
||||||
#include "doc/site.h"
|
#include "doc/site.h"
|
||||||
@ -43,7 +44,8 @@ void Sprite_new(script::ContextHandle handle)
|
|||||||
base::UniquePtr<Document> doc(new Document(sprite));
|
base::UniquePtr<Document> doc(new Document(sprite));
|
||||||
sprite.release();
|
sprite.release();
|
||||||
|
|
||||||
doc->setContext(UIContext::instance());
|
app::Context* appCtx = App::instance()->context();
|
||||||
|
doc->setContext(appCtx);
|
||||||
|
|
||||||
ctx.newObject(kTag, unwrap_engine(ctx)->wrapSprite(doc.release()), nullptr);
|
ctx.newObject(kTag, unwrap_engine(ctx)->wrapSprite(doc.release()), nullptr);
|
||||||
}
|
}
|
||||||
@ -105,11 +107,11 @@ void Sprite_save(script::ContextHandle handle)
|
|||||||
wrap->commit();
|
wrap->commit();
|
||||||
|
|
||||||
auto doc = wrap->document();
|
auto doc = wrap->document();
|
||||||
auto uiCtx = UIContext::instance();
|
app::Context* appCtx = App::instance()->context();
|
||||||
uiCtx->setActiveDocument(doc);
|
appCtx->setActiveDocument(doc);
|
||||||
Command* saveCommand =
|
Command* saveCommand =
|
||||||
Commands::instance()->byId(CommandId::SaveFile());
|
Commands::instance()->byId(CommandId::SaveFile());
|
||||||
uiCtx->executeCommand(saveCommand);
|
appCtx->executeCommand(saveCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.pushUndefined();
|
ctx.pushUndefined();
|
||||||
@ -125,15 +127,15 @@ void Sprite_saveAs(script::ContextHandle handle)
|
|||||||
wrap->commit();
|
wrap->commit();
|
||||||
|
|
||||||
auto doc = wrap->document();
|
auto doc = wrap->document();
|
||||||
auto uiCtx = UIContext::instance();
|
app::Context* appCtx = App::instance()->context();
|
||||||
uiCtx->setActiveDocument(doc);
|
appCtx->setActiveDocument(doc);
|
||||||
|
|
||||||
Command* saveCommand =
|
Command* saveCommand =
|
||||||
Commands::instance()->byId(CommandId::SaveFile());
|
Commands::instance()->byId(CommandId::SaveFile());
|
||||||
|
|
||||||
Params params;
|
Params params;
|
||||||
doc->setFilename(fn);
|
doc->setFilename(fn);
|
||||||
uiCtx->executeCommand(saveCommand, params);
|
appCtx->executeCommand(saveCommand, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.pushUndefined();
|
ctx.pushUndefined();
|
||||||
@ -149,15 +151,15 @@ void Sprite_saveCopyAs(script::ContextHandle handle)
|
|||||||
wrap->commit();
|
wrap->commit();
|
||||||
|
|
||||||
auto doc = wrap->document();
|
auto doc = wrap->document();
|
||||||
auto uiCtx = UIContext::instance();
|
app::Context* appCtx = App::instance()->context();
|
||||||
uiCtx->setActiveDocument(doc);
|
appCtx->setActiveDocument(doc);
|
||||||
|
|
||||||
Command* saveCommand =
|
Command* saveCommand =
|
||||||
Commands::instance()->byId(CommandId::SaveFileCopyAs());
|
Commands::instance()->byId(CommandId::SaveFileCopyAs());
|
||||||
|
|
||||||
Params params;
|
Params params;
|
||||||
params.set("filename", fn);
|
params.set("filename", fn);
|
||||||
uiCtx->executeCommand(saveCommand, params);
|
appCtx->executeCommand(saveCommand, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.pushUndefined();
|
ctx.pushUndefined();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2016 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -10,13 +10,14 @@
|
|||||||
|
|
||||||
#include "app/script/sprite_wrap.h"
|
#include "app/script/sprite_wrap.h"
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
#include "app/cmd/set_sprite_size.h"
|
#include "app/cmd/set_sprite_size.h"
|
||||||
|
#include "app/context.h"
|
||||||
#include "app/document.h"
|
#include "app/document.h"
|
||||||
#include "app/document_api.h"
|
#include "app/document_api.h"
|
||||||
#include "app/script/image_wrap.h"
|
#include "app/script/image_wrap.h"
|
||||||
#include "app/transaction.h"
|
#include "app/transaction.h"
|
||||||
#include "app/ui/document_view.h"
|
#include "app/ui/document_view.h"
|
||||||
#include "app/ui_context.h"
|
|
||||||
#include "doc/site.h"
|
#include "doc/site.h"
|
||||||
#include "doc/sprite.h"
|
#include "doc/sprite.h"
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ namespace app {
|
|||||||
|
|
||||||
SpriteWrap::SpriteWrap(app::Document* doc)
|
SpriteWrap::SpriteWrap(app::Document* doc)
|
||||||
: m_doc(doc)
|
: m_doc(doc)
|
||||||
, m_view(UIContext::instance()->getFirstDocumentView(m_doc))
|
, m_view(App::instance()->context()->getFirstDocumentView(m_doc))
|
||||||
, m_transaction(nullptr)
|
, m_transaction(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -41,7 +42,7 @@ SpriteWrap::~SpriteWrap()
|
|||||||
Transaction& SpriteWrap::transaction()
|
Transaction& SpriteWrap::transaction()
|
||||||
{
|
{
|
||||||
if (!m_transaction) {
|
if (!m_transaction) {
|
||||||
m_transaction = new Transaction(UIContext::instance(),
|
m_transaction = new Transaction(App::instance()->context(),
|
||||||
"Script Execution",
|
"Script Execution",
|
||||||
ModifyDocument);
|
ModifyDocument);
|
||||||
}
|
}
|
||||||
@ -78,14 +79,18 @@ doc::Sprite* SpriteWrap::sprite()
|
|||||||
ImageWrap* SpriteWrap::activeImage()
|
ImageWrap* SpriteWrap::activeImage()
|
||||||
{
|
{
|
||||||
if (!m_view) {
|
if (!m_view) {
|
||||||
m_view = UIContext::instance()->getFirstDocumentView(m_doc);
|
m_view = App::instance()->context()->getFirstDocumentView(m_doc);
|
||||||
if (!m_view)
|
if (!m_view)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_UI
|
||||||
doc::Site site;
|
doc::Site site;
|
||||||
m_view->getSite(&site);
|
m_view->getSite(&site);
|
||||||
return wrapImage(site.image());
|
return wrapImage(site.image());
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageWrap* SpriteWrap::wrapImage(doc::Image* img)
|
ImageWrap* SpriteWrap::wrapImage(doc::Image* img)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -22,23 +22,6 @@
|
|||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
static const char* kDefaultCrashName = PACKAGE "-crash-" VERSION ".dmp";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string memory_dump_filename()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
app::ResourceFinder rf;
|
|
||||||
rf.includeUserDir(kDefaultCrashName);
|
|
||||||
return rf.getFirstOrCreateDefault();
|
|
||||||
|
|
||||||
#else
|
|
||||||
return "";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendCrash::search()
|
void SendCrash::search()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -28,8 +28,6 @@ namespace app {
|
|||||||
std::string m_dumpFilename;
|
std::string m_dumpFilename;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string memory_dump_filename();
|
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
||||||
#endif // APP_SEND_CRASH_H_INCLUDED
|
#endif // APP_SEND_CRASH_H_INCLUDED
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -32,8 +32,7 @@ namespace app {
|
|||||||
UIContext* UIContext::m_instance = nullptr;
|
UIContext* UIContext::m_instance = nullptr;
|
||||||
|
|
||||||
UIContext::UIContext()
|
UIContext::UIContext()
|
||||||
: m_lastSelectedDoc(nullptr)
|
: m_lastSelectedView(nullptr)
|
||||||
, m_lastSelectedView(nullptr)
|
|
||||||
{
|
{
|
||||||
documents().add_observer(&Preferences::instance());
|
documents().add_observer(&Preferences::instance());
|
||||||
|
|
||||||
@ -121,10 +120,10 @@ void UIContext::setActiveView(DocumentView* docView)
|
|||||||
notifyActiveSiteChanged();
|
notifyActiveSiteChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIContext::setActiveDocument(Document* document)
|
void UIContext::onSetActiveDocument(doc::Document* document)
|
||||||
{
|
{
|
||||||
bool notify = (m_lastSelectedDoc != document);
|
bool notify = (lastSelectedDoc() != document);
|
||||||
m_lastSelectedDoc = document;
|
app::Context::onSetActiveDocument(document);
|
||||||
|
|
||||||
DocumentView* docView = getFirstDocumentView(document);
|
DocumentView* docView = getFirstDocumentView(document);
|
||||||
if (docView) { // The view can be null if we are in --batch mode
|
if (docView) { // The view can be null if we are in --batch mode
|
||||||
@ -180,7 +179,7 @@ Editor* UIContext::activeEditor()
|
|||||||
|
|
||||||
void UIContext::onAddDocument(doc::Document* doc)
|
void UIContext::onAddDocument(doc::Document* doc)
|
||||||
{
|
{
|
||||||
m_lastSelectedDoc = static_cast<app::Document*>(doc);
|
app::Context::onAddDocument(doc);
|
||||||
|
|
||||||
// We don't create views in batch mode.
|
// We don't create views in batch mode.
|
||||||
if (!App::instance()->isGui())
|
if (!App::instance()->isGui())
|
||||||
@ -188,7 +187,7 @@ void UIContext::onAddDocument(doc::Document* doc)
|
|||||||
|
|
||||||
// Add a new view for this document
|
// Add a new view for this document
|
||||||
DocumentView* view = new DocumentView(
|
DocumentView* view = new DocumentView(
|
||||||
m_lastSelectedDoc,
|
lastSelectedDoc(),
|
||||||
DocumentView::Normal,
|
DocumentView::Normal,
|
||||||
App::instance()->mainWindow()->getPreviewEditor());
|
App::instance()->mainWindow()->getPreviewEditor());
|
||||||
|
|
||||||
@ -201,8 +200,7 @@ void UIContext::onAddDocument(doc::Document* doc)
|
|||||||
|
|
||||||
void UIContext::onRemoveDocument(doc::Document* doc)
|
void UIContext::onRemoveDocument(doc::Document* doc)
|
||||||
{
|
{
|
||||||
if (doc == m_lastSelectedDoc)
|
app::Context::onRemoveDocument(doc);
|
||||||
m_lastSelectedDoc = nullptr;
|
|
||||||
|
|
||||||
// We don't destroy views in batch mode.
|
// We don't destroy views in batch mode.
|
||||||
if (isUIAvailable()) {
|
if (isUIAvailable()) {
|
||||||
@ -246,14 +244,8 @@ void UIContext::onGetActiveSite(Site* site) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Default/dummy site (maybe for batch/command line mode)
|
|
||||||
else if (!isUIAvailable()) {
|
else if (!isUIAvailable()) {
|
||||||
if (Document* doc = m_lastSelectedDoc) {
|
return app::Context::onGetActiveSite(site);
|
||||||
site->document(doc);
|
|
||||||
site->sprite(doc->sprite());
|
|
||||||
site->layer(doc->sprite()->root()->firstLayer());
|
|
||||||
site->frame(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2015, 2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -28,9 +28,8 @@ namespace app {
|
|||||||
|
|
||||||
DocumentView* activeView() const;
|
DocumentView* activeView() const;
|
||||||
void setActiveView(DocumentView* documentView);
|
void setActiveView(DocumentView* documentView);
|
||||||
void setActiveDocument(Document* document);
|
|
||||||
|
|
||||||
DocumentView* getFirstDocumentView(doc::Document* document) const;
|
DocumentView* getFirstDocumentView(doc::Document* document) const override;
|
||||||
DocumentViews getAllDocumentViews(doc::Document* document) const;
|
DocumentViews getAllDocumentViews(doc::Document* document) const;
|
||||||
|
|
||||||
// Returns the current editor. It can be null.
|
// Returns the current editor. It can be null.
|
||||||
@ -44,9 +43,9 @@ namespace app {
|
|||||||
void onAddDocument(doc::Document* doc) override;
|
void onAddDocument(doc::Document* doc) override;
|
||||||
void onRemoveDocument(doc::Document* doc) override;
|
void onRemoveDocument(doc::Document* doc) override;
|
||||||
void onGetActiveSite(doc::Site* site) const override;
|
void onGetActiveSite(doc::Site* site) const override;
|
||||||
|
void onSetActiveDocument(doc::Document* doc) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Document* m_lastSelectedDoc;
|
|
||||||
DocumentView* m_lastSelectedView;
|
DocumentView* m_lastSelectedView;
|
||||||
static UIContext* m_instance;
|
static UIContext* m_instance;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
# SHE
|
# SHE
|
||||||
# Copyright (C) 2012-2017 David Capello
|
# Copyright (C) 2012-2018 David Capello
|
||||||
|
|
||||||
|
# TODO the following variables should be available through options
|
||||||
|
# in this file instead of the main Aseprite CMakeLists.txt:
|
||||||
|
# - USE_ALLEG4_BACKEND
|
||||||
|
# - USE_NONE_BACKEND
|
||||||
|
# - USE_SKIA_BACKEND
|
||||||
|
# - WITH_GTK_FILE_DIALOG_SUPPORT
|
||||||
|
|
||||||
set(SHE_SOURCES
|
set(SHE_SOURCES
|
||||||
common/freetype_font.cpp
|
common/freetype_font.cpp
|
||||||
@ -138,6 +145,14 @@ if(USE_SKIA_BACKEND)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# None backend
|
||||||
|
|
||||||
|
if(USE_NONE_BACKEND)
|
||||||
|
list(APPEND SHE_SOURCES
|
||||||
|
none/she.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
76
src/she/none/she.cpp
Normal file
76
src/she/none/she.cpp
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
// SHE library
|
||||||
|
// Copyright (C) 2018 David Capello
|
||||||
|
//
|
||||||
|
// This file is released under the terms of the MIT license.
|
||||||
|
// Read LICENSE.txt for more information.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "base/memory.h"
|
||||||
|
#include "she/she.h"
|
||||||
|
|
||||||
|
namespace she {
|
||||||
|
|
||||||
|
class NoneSystem : public System {
|
||||||
|
public:
|
||||||
|
void dispose() override { delete this; }
|
||||||
|
void activateApp() override { }
|
||||||
|
void finishLaunching() override { }
|
||||||
|
Capabilities capabilities() const override { return (Capabilities)0; }
|
||||||
|
void useWintabAPI(bool enable) override { }
|
||||||
|
Logger* logger() override { return nullptr; }
|
||||||
|
Menus* menus() override { return nullptr; }
|
||||||
|
NativeDialogs* nativeDialogs() override { return nullptr; }
|
||||||
|
EventQueue* eventQueue() override { return nullptr; }
|
||||||
|
bool gpuAcceleration() const override { return false; }
|
||||||
|
void setGpuAcceleration(bool state) override { }
|
||||||
|
gfx::Size defaultNewDisplaySize() override { return gfx::Size(0, 0); }
|
||||||
|
Display* defaultDisplay() override { return nullptr; }
|
||||||
|
Display* createDisplay(int width, int height, int scale) override { return nullptr; }
|
||||||
|
Surface* createSurface(int width, int height) override { return nullptr; }
|
||||||
|
Surface* createRgbaSurface(int width, int height) override { return nullptr; }
|
||||||
|
Surface* loadSurface(const char* filename) override { return nullptr; }
|
||||||
|
Surface* loadRgbaSurface(const char* filename) override { return nullptr; }
|
||||||
|
Font* loadSpriteSheetFont(const char* filename, int scale) override { return nullptr; }
|
||||||
|
Font* loadTrueTypeFont(const char* filename, int height) override { return nullptr; }
|
||||||
|
bool isKeyPressed(KeyScancode scancode) override { return false; }
|
||||||
|
KeyModifiers keyModifiers() override { return kKeyNoneModifier; }
|
||||||
|
int getUnicodeFromScancode(KeyScancode scancode) override { return 0; }
|
||||||
|
void clearKeyboardBuffer() override { }
|
||||||
|
void setTranslateDeadKeys(bool state) override { }
|
||||||
|
};
|
||||||
|
|
||||||
|
System* create_system_impl() {
|
||||||
|
return new NoneSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void error_message(const char* msg)
|
||||||
|
{
|
||||||
|
fputs(msg, stderr);
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace she
|
||||||
|
|
||||||
|
extern int app_main(int argc, char* argv[]);
|
||||||
|
|
||||||
|
#if _WIN32
|
||||||
|
int wmain(int argc, wchar_t* wargv[], wchar_t* envp[]) {
|
||||||
|
char** argv;
|
||||||
|
if (wargv && argc > 0) {
|
||||||
|
argv = new char*[argc];
|
||||||
|
for (int i=0; i<argc; ++i)
|
||||||
|
argv[i] = base_strdup(base::to_utf8(std::wstring(wargv[i])).c_str());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
argv = new char*[1];
|
||||||
|
argv[0] = base_strdup("");
|
||||||
|
argc = 1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
#endif
|
||||||
|
return app_main(argc, argv);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user