mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +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
|
||||
- gcc
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- ENABLE_UI=OFF
|
||||
- ENABLE_UI=ON
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
- sudo apt-get update -qq
|
||||
@ -14,7 +19,7 @@ before_install:
|
||||
before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DENABLE_TESTS=ON
|
||||
- cmake .. -DENABLE_TESTS=ON -DENABLE_UI=$ENABLE_UI
|
||||
|
||||
script:
|
||||
- "make"
|
||||
|
@ -79,16 +79,26 @@ option(ENABLE_BENCHMARKS "Compile benchmarks" off)
|
||||
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
|
||||
option(ENABLE_STEAM "Compile with Steam library" off)
|
||||
option(ENABLE_DEVMODE "Compile vesion for developers" off)
|
||||
option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on)
|
||||
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
|
||||
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")
|
||||
|
||||
if(APPLE)
|
||||
# On OS X Allegro isn't supported anymore
|
||||
if(NOT ENABLE_UI)
|
||||
# Without UI, don't use back-ends
|
||||
set(USE_ALLEG4_BACKEND off)
|
||||
set(USE_SKIA_BACKEND on)
|
||||
set(USE_SKIA_BACKEND off)
|
||||
set(USE_NONE_BACKEND on)
|
||||
else()
|
||||
option(USE_ALLEG4_BACKEND "Use Allegro 4 backend" on)
|
||||
option(USE_SKIA_BACKEND "Use Skia backend" off)
|
||||
if(APPLE)
|
||||
# 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()
|
||||
|
||||
# Check valid gtk + libpng combination
|
||||
|
@ -53,28 +53,36 @@ if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# Full-version or trial-mode?
|
||||
# With static libcurl
|
||||
|
||||
if(NOT USE_SHARED_CURL AND CURL_STATICLIB)
|
||||
add_definitions(-DCURL_STATICLIB)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# Full-version or trial-mode?
|
||||
# Special versions (full/trial, devmode, UI/CLI, etc.)
|
||||
|
||||
if(NOT ENABLE_TRIAL_MODE)
|
||||
add_definitions(-DENABLE_SAVE -DENABLE_DATA_RECOVERY)
|
||||
add_definitions(-DENABLE_SAVE)
|
||||
else()
|
||||
add_definitions(-DENABLE_TRIAL_MODE)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# Special developer mode
|
||||
|
||||
if(ENABLE_DEVMODE)
|
||||
add_definitions(-DENABLE_DEVMODE)
|
||||
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)
|
||||
|
||||
@ -170,16 +178,23 @@ if(WIN32)
|
||||
main/settings.manifest)
|
||||
endif()
|
||||
|
||||
add_executable(aseprite WIN32
|
||||
main/main.cpp
|
||||
${win32_resources})
|
||||
add_executable(aseprite main/main.cpp ${win32_resources})
|
||||
if(WIN32 AND ENABLE_UI)
|
||||
set_target_properties(aseprite PROPERTIES WIN32_EXECUTABLE true)
|
||||
endif()
|
||||
target_link_libraries(aseprite app-lib ${PLATFORM_LIBS})
|
||||
add_dependencies(aseprite copy_data)
|
||||
|
||||
if(MSVC AND USE_SKIA_BACKEND)
|
||||
# Add support to expand filename wildcards in argc/argv
|
||||
set_target_properties(aseprite
|
||||
PROPERTIES LINK_FLAGS "-LINK wsetargv.obj -ENTRY:\"wWinMainCRTStartup\"")
|
||||
if(MSVC)
|
||||
if(USE_SKIA_BACKEND)
|
||||
# Linking with "wsetargv.obj" to add support to expand filename
|
||||
# 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()
|
||||
|
||||
install(TARGETS aseprite
|
||||
|
@ -114,7 +114,7 @@ else()
|
||||
endif()
|
||||
|
||||
set(data_recovery_files)
|
||||
if(NOT ENABLE_TRIAL_MODE)
|
||||
if(ENABLE_DATA_RECOVERY)
|
||||
set(data_recovery_files
|
||||
crash/backup_observer.cpp
|
||||
crash/data_recovery.cpp
|
||||
@ -140,8 +140,13 @@ endif()
|
||||
|
||||
set(scripting_files)
|
||||
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
|
||||
commands/cmd_developer_console.cpp
|
||||
commands/cmd_run_script.cpp
|
||||
script/app_object.cpp
|
||||
script/app_scripting.cpp
|
||||
@ -156,18 +161,245 @@ if(ENABLE_SCRIPTING)
|
||||
script/sprite_class.cpp
|
||||
script/sprite_wrap.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()
|
||||
|
||||
add_library(app-lib
|
||||
app.cpp
|
||||
app_brushes.cpp
|
||||
app_menus.cpp
|
||||
app_render.cpp
|
||||
check_update.cpp
|
||||
cli/app_options.cpp
|
||||
cli/cli_open_file.cpp
|
||||
cli/cli_processor.cpp
|
||||
${file_formats}
|
||||
cli/default_cli_delegate.cpp
|
||||
cli/preview_cli_delegate.cpp
|
||||
cmd.cpp
|
||||
@ -247,134 +479,15 @@ add_library(app-lib
|
||||
color.cpp
|
||||
color_picker.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_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_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_mask_all.cpp
|
||||
commands/cmd_mask_by_color.cpp
|
||||
commands/cmd_mask_content.cpp
|
||||
commands/cmd_merge_down_layer.cpp
|
||||
commands/cmd_modify_selection.cpp
|
||||
commands/cmd_move_cel.cpp
|
||||
commands/cmd_move_mask.cpp
|
||||
commands/cmd_new_brush.cpp
|
||||
commands/cmd_new_file.cpp
|
||||
commands/cmd_new_frame.cpp
|
||||
commands/cmd_new_frame_tag.cpp
|
||||
commands/cmd_new_layer.cpp
|
||||
commands/cmd_new_sprite_from_selection.cpp
|
||||
commands/cmd_onionskin.cpp
|
||||
commands/cmd_open_browser.cpp
|
||||
commands/cmd_open_file.cpp
|
||||
commands/cmd_open_group.cpp
|
||||
commands/cmd_open_in_folder.cpp
|
||||
commands/cmd_open_with_app.cpp
|
||||
commands/cmd_options.cpp
|
||||
commands/cmd_palette_editor.cpp
|
||||
commands/cmd_palette_size.cpp
|
||||
commands/cmd_paste.cpp
|
||||
commands/cmd_paste_text.cpp
|
||||
commands/cmd_pixel_perfect_mode.cpp
|
||||
commands/cmd_play_animation.cpp
|
||||
commands/cmd_refresh.cpp
|
||||
commands/cmd_remove_frame.cpp
|
||||
commands/cmd_remove_frame_tag.cpp
|
||||
commands/cmd_remove_layer.cpp
|
||||
commands/cmd_remove_slice.cpp
|
||||
commands/cmd_repeat_last_export.cpp
|
||||
commands/cmd_reselect_mask.cpp
|
||||
commands/cmd_reverse_frames.cpp
|
||||
commands/cmd_rotate.cpp
|
||||
commands/cmd_save_file.cpp
|
||||
commands/cmd_save_mask.cpp
|
||||
commands/cmd_save_palette.cpp
|
||||
commands/cmd_scroll.cpp
|
||||
commands/cmd_scroll_center.cpp
|
||||
commands/cmd_select_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_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_history.cpp
|
||||
commands/cmd_unlink_cel.cpp
|
||||
commands/cmd_zoom.cpp
|
||||
commands/command.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/quick_command.cpp
|
||||
console.cpp
|
||||
@ -394,13 +507,10 @@ add_library(app-lib
|
||||
file/file_formats_manager.cpp
|
||||
file/palette_file.cpp
|
||||
file/split_filename.cpp
|
||||
${file_formats}
|
||||
file_selector.cpp
|
||||
file_system.cpp
|
||||
filename_formatter.cpp
|
||||
flatten.cpp
|
||||
font_path.cpp
|
||||
gui_xml.cpp
|
||||
i18n/strings.cpp
|
||||
i18n/xml_translator.cpp
|
||||
ini_file.cpp
|
||||
@ -410,9 +520,6 @@ add_library(app-lib
|
||||
log.cpp
|
||||
loop_tag.cpp
|
||||
modules.cpp
|
||||
modules/editors.cpp
|
||||
modules/gfx.cpp
|
||||
modules/gui.cpp
|
||||
modules/palettes.cpp
|
||||
pref/preferences.cpp
|
||||
project.cpp
|
||||
@ -423,111 +530,15 @@ add_library(app-lib
|
||||
resource_finder.cpp
|
||||
restore_visible_layers.cpp
|
||||
rw_lock.cpp
|
||||
send_crash.cpp
|
||||
shade.cpp
|
||||
snap_to_grid.cpp
|
||||
sprite_job.cpp
|
||||
thumbnail_generator.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
|
||||
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/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/clipboard.cpp
|
||||
util/clipboard_native.cpp
|
||||
util/create_cel_copy.cpp
|
||||
util/expand_cel_canvas.cpp
|
||||
util/filetoks.cpp
|
||||
@ -540,9 +551,9 @@ add_library(app-lib
|
||||
util/range_utils.cpp
|
||||
util/wrap_point.cpp
|
||||
webserver.cpp
|
||||
widget_loader.cpp
|
||||
xml_document.cpp
|
||||
xml_exception.cpp
|
||||
${ui_app_files}
|
||||
${app_platform_files}
|
||||
${data_recovery_files}
|
||||
${scripting_files}
|
||||
|
@ -99,18 +99,28 @@ public:
|
||||
|
||||
class App::Modules {
|
||||
public:
|
||||
#ifdef ENABLE_UI
|
||||
typedef app::UIContext ContextT;
|
||||
#else
|
||||
typedef app::Context ContextT;
|
||||
#endif
|
||||
|
||||
LoggerModule m_loggerModule;
|
||||
FileSystemModule m_file_system_module;
|
||||
Extensions m_extensions;
|
||||
// Load main language (after loading the extensions)
|
||||
LoadLanguage m_loadLanguage;
|
||||
#ifdef ENABLE_UI
|
||||
tools::ToolBox m_toolbox;
|
||||
tools::ActiveToolManager m_activeToolManager;
|
||||
#endif
|
||||
Commands m_commands;
|
||||
UIContext m_ui_context;
|
||||
ContextT m_context;
|
||||
#ifdef ENABLE_UI
|
||||
RecentFiles m_recent_files;
|
||||
InputChain m_inputChain;
|
||||
clipboard::ClipboardManager m_clipboardManager;
|
||||
#endif
|
||||
// This is a raw pointer because we want to delete this explicitly.
|
||||
app::crash::DataRecovery* m_recovery;
|
||||
|
||||
@ -118,8 +128,10 @@ public:
|
||||
Preferences& pref)
|
||||
: m_loggerModule(createLogInDesktop)
|
||||
, m_loadLanguage(pref, m_extensions)
|
||||
#ifdef ENABLE_UI
|
||||
, m_activeToolManager(&m_toolbox)
|
||||
, m_recent_files(pref.general.recentItems())
|
||||
#endif
|
||||
, m_recovery(nullptr) {
|
||||
}
|
||||
|
||||
@ -133,7 +145,7 @@ public:
|
||||
|
||||
void createDataRecovery() {
|
||||
#ifdef ENABLE_DATA_RECOVERY
|
||||
m_recovery = new app::crash::DataRecovery(&m_ui_context);
|
||||
m_recovery = new app::crash::DataRecovery(&m_context);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -154,7 +166,9 @@ App::App()
|
||||
, m_legacy(NULL)
|
||||
, m_isGui(false)
|
||||
, m_isShell(false)
|
||||
#ifdef ENABLE_UI
|
||||
, m_backupIndicator(nullptr)
|
||||
#endif
|
||||
{
|
||||
ASSERT(m_instance == NULL);
|
||||
m_instance = this;
|
||||
@ -167,7 +181,11 @@ void App::initialize(const AppOptions& options)
|
||||
she::instance()->useWintabAPI(false);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
m_isGui = options.startUI() && !options.previewCLI();
|
||||
#else
|
||||
m_isGui = false;
|
||||
#endif
|
||||
m_isShell = options.startShell();
|
||||
m_coreModules = new CoreModules;
|
||||
if (m_isGui)
|
||||
@ -190,7 +208,9 @@ void App::initialize(const AppOptions& options)
|
||||
// Load modules
|
||||
m_modules = new Modules(createLogInDesktop, preferences());
|
||||
m_legacy = new LegacyModules(isGui() ? REQUIRE_INTERFACE: 0);
|
||||
#ifdef ENABLE_UI
|
||||
m_brushes.reset(new AppBrushes);
|
||||
#endif
|
||||
|
||||
// Data recovery is enabled only in GUI mode
|
||||
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.
|
||||
load_default_palette();
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
// Initialize GUI interface
|
||||
if (isGui()) {
|
||||
LOG("APP: GUI mode\n");
|
||||
@ -230,6 +251,7 @@ void App::initialize(const AppOptions& options)
|
||||
// Redraw the whole screen.
|
||||
ui::Manager::getDefault()->invalidate();
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
||||
// Process options
|
||||
LOG("APP: Processing options...\n");
|
||||
@ -241,7 +263,7 @@ void App::initialize(const AppOptions& options)
|
||||
delegate.reset(new DefaultCliDelegate);
|
||||
|
||||
CliProcessor cli(delegate.get(), options);
|
||||
cli.process();
|
||||
cli.process(&m_modules->m_context);
|
||||
}
|
||||
|
||||
she::instance()->finishLaunching();
|
||||
@ -249,6 +271,7 @@ void App::initialize(const AppOptions& options)
|
||||
|
||||
void App::run()
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
// Run the GUI
|
||||
if (isGui()) {
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
@ -310,6 +333,7 @@ void App::run()
|
||||
// Run the GUI main message loop
|
||||
ui::Manager::getDefault()->run();
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
// Start shell to execute scripts.
|
||||
@ -320,10 +344,10 @@ void App::run()
|
||||
Shell shell;
|
||||
shell.run(engine);
|
||||
}
|
||||
#endif
|
||||
#endif // ENABLE_SCRIPTING
|
||||
|
||||
// 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()) {
|
||||
doc::Document* doc = docs.back();
|
||||
|
||||
@ -342,10 +366,12 @@ void App::run()
|
||||
delete doc;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
if (isGui()) {
|
||||
// Destroy the window.
|
||||
m_mainWindow.reset(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Delete backups (this is a normal shutdown, we are not handling
|
||||
// exceptions, and we are not in a destructor).
|
||||
@ -365,24 +391,28 @@ App::~App()
|
||||
// Fire App Exit signal.
|
||||
App::instance()->Exit();
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
// Finalize modules, configuration and core.
|
||||
Editor::destroyEditorSharedInternals();
|
||||
|
||||
// Save brushes
|
||||
m_brushes.reset(nullptr);
|
||||
|
||||
if (m_backupIndicator) {
|
||||
delete m_backupIndicator;
|
||||
m_backupIndicator = nullptr;
|
||||
}
|
||||
|
||||
// Save brushes
|
||||
m_brushes.reset(nullptr);
|
||||
#endif
|
||||
|
||||
delete m_legacy;
|
||||
delete m_modules;
|
||||
delete m_coreModules;
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
// Destroy the loaded gui.xml data.
|
||||
delete KeyboardShortcuts::instance();
|
||||
delete GuiXml::instance();
|
||||
#endif
|
||||
|
||||
m_instance = NULL;
|
||||
}
|
||||
@ -399,6 +429,11 @@ App::~App()
|
||||
}
|
||||
}
|
||||
|
||||
Context* App::context()
|
||||
{
|
||||
return &m_modules->m_context;
|
||||
}
|
||||
|
||||
bool App::isPortable()
|
||||
{
|
||||
static bool* is_portable = NULL;
|
||||
@ -415,23 +450,39 @@ bool App::isPortable()
|
||||
tools::ToolBox* App::toolBox() const
|
||||
{
|
||||
ASSERT(m_modules != NULL);
|
||||
#ifdef ENABLE_UI
|
||||
return &m_modules->m_toolbox;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
tools::Tool* App::activeTool() const
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
return m_modules->m_activeToolManager.activeTool();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
tools::ActiveToolManager* App::activeToolManager() const
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
return &m_modules->m_activeToolManager;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
RecentFiles* App::recentFiles() const
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
ASSERT(m_modules != NULL);
|
||||
return &m_modules->m_recent_files;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
Workspace* App::workspace() const
|
||||
@ -473,6 +524,7 @@ crash::DataRecovery* App::dataRecovery() const
|
||||
return m_modules->recovery();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
void App::showNotification(INotificationDelegate* del)
|
||||
{
|
||||
m_mainWindow->showNotification(del);
|
||||
@ -512,10 +564,12 @@ InputChain& App::inputChain()
|
||||
{
|
||||
return m_modules->m_inputChain;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Updates palette and redraw the screen.
|
||||
void app_refresh_screen()
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
Context* context = UIContext::instance();
|
||||
ASSERT(context != NULL);
|
||||
|
||||
@ -528,6 +582,7 @@ void app_refresh_screen()
|
||||
|
||||
// Invalidate the whole screen.
|
||||
ui::Manager::getDefault()->invalidate();
|
||||
#endif // ENABLE_UI
|
||||
}
|
||||
|
||||
// TODO remove app_rebuild_documents_tabs() and replace it by
|
||||
@ -535,14 +590,17 @@ void app_refresh_screen()
|
||||
// document is modified).
|
||||
void app_rebuild_documents_tabs()
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
if (App::instance()->isGui()) {
|
||||
App::instance()->workspace()->updateTabs();
|
||||
App::instance()->updateDisplayTitleBar();
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
}
|
||||
|
||||
PixelFormat app_get_current_pixel_format()
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
Context* context = UIContext::instance();
|
||||
ASSERT(context != NULL);
|
||||
|
||||
@ -551,12 +609,17 @@ PixelFormat app_get_current_pixel_format()
|
||||
return document->sprite()->pixelFormat();
|
||||
else
|
||||
return IMAGE_RGB;
|
||||
#else // ENABLE_UI
|
||||
return IMAGE_RGB;
|
||||
#endif
|
||||
}
|
||||
|
||||
void app_default_statusbar_message()
|
||||
{
|
||||
#ifdef ENABLE_UI
|
||||
StatusBar::instance()
|
||||
->setStatusText(250, "%s %s | %s", PACKAGE, VERSION, COPYRIGHT);
|
||||
#endif
|
||||
}
|
||||
|
||||
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'
|
||||
if (layer->isBackground()) {
|
||||
#ifdef ENABLE_UI
|
||||
if (ColorBar::instance())
|
||||
color = ColorBar::instance()->getBgColor();
|
||||
else
|
||||
#endif
|
||||
color = app::Color::fromRgb(0, 0, 0); // TODO get background color color from doc::Settings
|
||||
}
|
||||
else // All transparent layers are cleared with the mask color
|
||||
@ -578,4 +643,18 @@ int app_get_color_to_clear_layer(Layer* 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
|
||||
|
@ -8,7 +8,10 @@
|
||||
#define APP_APP_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
#include "app/app_brushes.h"
|
||||
#endif
|
||||
|
||||
#include "base/mutex.h"
|
||||
#include "base/paths.h"
|
||||
#include "base/unique_ptr.h"
|
||||
@ -30,6 +33,7 @@ namespace app {
|
||||
|
||||
class AppOptions;
|
||||
class BackupIndicator;
|
||||
class Context;
|
||||
class ContextBar;
|
||||
class Document;
|
||||
class Extensions;
|
||||
@ -62,6 +66,8 @@ namespace app {
|
||||
|
||||
static App* instance() { return m_instance; }
|
||||
|
||||
Context* context();
|
||||
|
||||
// Returns true if Aseprite is running with GUI available.
|
||||
bool isGui() const { return m_isGui; }
|
||||
|
||||
@ -86,6 +92,7 @@ namespace app {
|
||||
Extensions& extensions() const;
|
||||
crash::DataRecovery* dataRecovery() const;
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
AppBrushes& brushes() {
|
||||
ASSERT(m_brushes.get());
|
||||
return *m_brushes;
|
||||
@ -97,6 +104,7 @@ namespace app {
|
||||
void updateDisplayTitleBar();
|
||||
|
||||
InputChain& inputChain();
|
||||
#endif
|
||||
|
||||
// App Signals
|
||||
obs::signal<void()> Exit;
|
||||
@ -117,9 +125,11 @@ namespace app {
|
||||
bool m_isShell;
|
||||
base::UniquePtr<MainWindow> m_mainWindow;
|
||||
base::paths m_files;
|
||||
#ifdef ENABLE_UI
|
||||
base::UniquePtr<AppBrushes> m_brushes;
|
||||
BackupIndicator* m_backupIndicator;
|
||||
base::mutex m_backupIndicatorMutex;
|
||||
#endif // ENABLE_UI
|
||||
};
|
||||
|
||||
void app_refresh_screen();
|
||||
@ -127,6 +137,7 @@ namespace app {
|
||||
PixelFormat app_get_current_pixel_format();
|
||||
void app_default_statusbar_message();
|
||||
int app_get_color_to_clear_layer(doc::Layer* layer);
|
||||
std::string memory_dump_filename();
|
||||
|
||||
} // namespace app
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -13,6 +13,7 @@
|
||||
namespace app {
|
||||
|
||||
class AppOptions;
|
||||
class Context;
|
||||
class DocumentExporter;
|
||||
struct CliOpenFile;
|
||||
|
||||
@ -26,9 +27,9 @@ namespace app {
|
||||
virtual void batchMode() { }
|
||||
virtual void beforeOpenFile(const CliOpenFile& cof) { }
|
||||
virtual void afterOpenFile(const CliOpenFile& cof) { }
|
||||
virtual void saveFile(const CliOpenFile& cof) { }
|
||||
virtual void loadPalette(const CliOpenFile& cof, const std::string& filename) { }
|
||||
virtual void exportFiles(DocumentExporter& exporter) { }
|
||||
virtual void saveFile(Context* ctx, const CliOpenFile& cof) { }
|
||||
virtual void loadPalette(Context* ctx, const CliOpenFile& cof, const std::string& filename) { }
|
||||
virtual void exportFiles(Context* ctx, DocumentExporter& exporter) { }
|
||||
virtual void execScript(const std::string& filename) { }
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -113,7 +113,7 @@ void filter_layers(const LayerList& layers,
|
||||
} // anonymous namespace
|
||||
|
||||
CliProcessor::CliProcessor(CliDelegate* delegate,
|
||||
const AppOptions& options)
|
||||
const AppOptions& options)
|
||||
: m_delegate(delegate)
|
||||
, m_options(options)
|
||||
, m_exporter(nullptr)
|
||||
@ -122,7 +122,7 @@ CliProcessor::CliProcessor(CliDelegate* delegate,
|
||||
m_exporter.reset(new DocumentExporter);
|
||||
}
|
||||
|
||||
void CliProcessor::process()
|
||||
void CliProcessor::process(Context* ctx)
|
||||
{
|
||||
// --help
|
||||
if (m_options.showHelp()) {
|
||||
@ -135,7 +135,6 @@ void CliProcessor::process()
|
||||
// Process other options and file names
|
||||
else if (!m_options.values().empty()) {
|
||||
Console console;
|
||||
UIContext* ctx = UIContext::instance();
|
||||
CliOpenFile cof;
|
||||
SpriteSheetType sheetType = SpriteSheetType::None;
|
||||
app::Document* lastDoc = nullptr;
|
||||
@ -316,7 +315,7 @@ void CliProcessor::process()
|
||||
|
||||
cof.document = lastDoc;
|
||||
cof.filename = fn;
|
||||
saveFile(cof);
|
||||
saveFile(ctx, cof);
|
||||
}
|
||||
else
|
||||
console.printf("A document is needed before --save-as argument\n");
|
||||
@ -327,7 +326,7 @@ void CliProcessor::process()
|
||||
ASSERT(cof.document == lastDoc);
|
||||
|
||||
std::string filename = value.value();
|
||||
m_delegate->loadPalette(cof, filename);
|
||||
m_delegate->loadPalette(ctx, cof, filename);
|
||||
}
|
||||
else {
|
||||
console.printf("You need to load a document to change its palette with --palette\n");
|
||||
@ -462,7 +461,7 @@ void CliProcessor::process()
|
||||
else {
|
||||
cof.document = nullptr;
|
||||
cof.filename = base::normalize_path(value.value());
|
||||
if (openFile(cof))
|
||||
if (openFile(ctx, cof))
|
||||
lastDoc = cof.document;
|
||||
}
|
||||
}
|
||||
@ -471,7 +470,7 @@ void CliProcessor::process()
|
||||
if (sheetType != SpriteSheetType::None)
|
||||
m_exporter->setSpriteSheetType(sheetType);
|
||||
|
||||
m_delegate->exportFiles(*m_exporter.get());
|
||||
m_delegate->exportFiles(ctx, *m_exporter.get());
|
||||
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);
|
||||
|
||||
Context* ctx = UIContext::instance();
|
||||
app::Document* oldDoc = ctx->activeDocument();
|
||||
Command* openCommand = Commands::instance()->byId(CommandId::OpenFile());
|
||||
Params params;
|
||||
@ -576,9 +574,8 @@ bool CliProcessor::openFile(CliOpenFile& cof)
|
||||
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);
|
||||
|
||||
Command* trimCommand = Commands::instance()->byId(CommandId::AutocropSprite());
|
||||
@ -727,7 +724,7 @@ void CliProcessor::saveFile(const CliOpenFile& cof)
|
||||
itemCof.filenameFormat = filename_formatter(filenameFormat, fnInfo, false);
|
||||
|
||||
// Call delegate
|
||||
m_delegate->saveFile(itemCof);
|
||||
m_delegate->saveFile(ctx, itemCof);
|
||||
|
||||
if (cof.trim) {
|
||||
ctx->executeCommand(undoCommand);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -18,17 +18,18 @@
|
||||
namespace app {
|
||||
|
||||
class AppOptions;
|
||||
class Context;
|
||||
class DocumentExporter;
|
||||
|
||||
class CliProcessor {
|
||||
public:
|
||||
CliProcessor(CliDelegate* delegate,
|
||||
const AppOptions& options);
|
||||
void process();
|
||||
void process(Context* ctx);
|
||||
|
||||
private:
|
||||
bool openFile(CliOpenFile& cof);
|
||||
void saveFile(const CliOpenFile& cof);
|
||||
bool openFile(Context* ctx, CliOpenFile& cof);
|
||||
void saveFile(Context* ctx, const CliOpenFile& cof);
|
||||
|
||||
CliDelegate* m_delegate;
|
||||
const AppOptions& m_options;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -31,8 +31,8 @@ public:
|
||||
void batchMode() override { m_batchMode = true; }
|
||||
void beforeOpenFile(const CliOpenFile& cof) override { }
|
||||
void afterOpenFile(const CliOpenFile& cof) override { }
|
||||
void saveFile(const CliOpenFile& cof) override { }
|
||||
void exportFiles(DocumentExporter& exporter) override { }
|
||||
void saveFile(Context* ctx, const CliOpenFile& cof) override { }
|
||||
void exportFiles(Context* ctx, DocumentExporter& exporter) override { }
|
||||
void execScript(const std::string& filename) override { }
|
||||
|
||||
bool helpWasShown() const { return m_helpWasShown; }
|
||||
@ -64,7 +64,7 @@ TEST(Cli, None)
|
||||
{
|
||||
CliTestDelegate d;
|
||||
CliProcessor p(&d, args({ }));
|
||||
p.process();
|
||||
p.process(nullptr);
|
||||
EXPECT_TRUE(!d.helpWasShown());
|
||||
EXPECT_TRUE(!d.versionWasShown());
|
||||
}
|
||||
@ -73,7 +73,7 @@ TEST(Cli, Help)
|
||||
{
|
||||
CliTestDelegate d;
|
||||
CliProcessor p(&d, args({ "--help" }));
|
||||
p.process();
|
||||
p.process(nullptr);
|
||||
EXPECT_TRUE(d.helpWasShown());
|
||||
}
|
||||
|
||||
@ -81,6 +81,6 @@ TEST(Cli, Version)
|
||||
{
|
||||
CliTestDelegate d;
|
||||
CliProcessor p(&d, args({ "--version" }));
|
||||
p.process();
|
||||
p.process(nullptr);
|
||||
EXPECT_TRUE(d.versionWasShown());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016-2017 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// 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());
|
||||
Params params;
|
||||
params.set("filename", cof.filename.c_str());
|
||||
@ -95,12 +94,12 @@ void DefaultCliDelegate::saveFile(const CliOpenFile& cof)
|
||||
ctx->executeCommand(saveAsCommand, params);
|
||||
}
|
||||
|
||||
void DefaultCliDelegate::loadPalette(const CliOpenFile& cof,
|
||||
void DefaultCliDelegate::loadPalette(Context* ctx,
|
||||
const CliOpenFile& cof,
|
||||
const std::string& filename)
|
||||
{
|
||||
base::UniquePtr<doc::Palette> palette(load_palette(filename.c_str()));
|
||||
if (palette) {
|
||||
Context* ctx = UIContext::instance();
|
||||
Command* loadPalCommand = Commands::instance()->byId(CommandId::LoadPalette());
|
||||
Params params;
|
||||
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");
|
||||
|
||||
base::UniquePtr<app::Document> spriteSheet(exporter.exportSheet());
|
||||
base::UniquePtr<app::Document> spriteSheet(exporter.exportSheet(ctx));
|
||||
|
||||
// Sprite sheet isn't used, we just delete it.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -17,9 +17,9 @@ namespace app {
|
||||
void showHelp(const AppOptions& programOptions) override;
|
||||
void showVersion() override;
|
||||
void afterOpenFile(const CliOpenFile& cof) override;
|
||||
void saveFile(const CliOpenFile& cof) override;
|
||||
void loadPalette(const CliOpenFile& cof, const std::string& filename) override;
|
||||
void exportFiles(DocumentExporter& exporter) override;
|
||||
void saveFile(Context* ctx, const CliOpenFile& cof) override;
|
||||
void loadPalette(Context* ctx, const CliOpenFile& cof, const std::string& filename) override;
|
||||
void exportFiles(Context* ctx, DocumentExporter& exporter) override;
|
||||
void execScript(const std::string& filename) override;
|
||||
};
|
||||
|
||||
|
@ -11,10 +11,10 @@
|
||||
#include "app/cli/preview_cli_delegate.h"
|
||||
|
||||
#include "app/cli/cli_open_file.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_exporter.h"
|
||||
#include "app/file/file.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/fs.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/sprite.h"
|
||||
@ -78,7 +78,7 @@ void PreviewCliDelegate::afterOpenFile(const CliOpenFile& cof)
|
||||
showLayersFilter(cof);
|
||||
}
|
||||
|
||||
void PreviewCliDelegate::saveFile(const CliOpenFile& cof)
|
||||
void PreviewCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
|
||||
{
|
||||
ASSERT(cof.document);
|
||||
ASSERT(cof.document->sprite());
|
||||
@ -133,7 +133,7 @@ void PreviewCliDelegate::saveFile(const CliOpenFile& cof)
|
||||
|
||||
base::UniquePtr<FileOp> fop(
|
||||
FileOp::createSaveDocumentOperation(
|
||||
UIContext::instance(),
|
||||
ctx,
|
||||
cof.roi(),
|
||||
cof.filename,
|
||||
cof.filenameFormat));
|
||||
@ -152,7 +152,8 @@ void PreviewCliDelegate::saveFile(const CliOpenFile& cof)
|
||||
std::cout << " - No output\n";
|
||||
}
|
||||
|
||||
void PreviewCliDelegate::loadPalette(const CliOpenFile& cof,
|
||||
void PreviewCliDelegate::loadPalette(Context* ctx,
|
||||
const CliOpenFile& cof,
|
||||
const std::string& filename)
|
||||
{
|
||||
ASSERT(cof.document);
|
||||
@ -163,7 +164,7 @@ void PreviewCliDelegate::loadPalette(const CliOpenFile& cof,
|
||||
<< " - Palette: '" << filename << "'\n";
|
||||
}
|
||||
|
||||
void PreviewCliDelegate::exportFiles(DocumentExporter& exporter)
|
||||
void PreviewCliDelegate::exportFiles(Context* ctx, DocumentExporter& exporter)
|
||||
{
|
||||
std::string type = "None";
|
||||
switch (exporter.spriteSheetType()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -21,10 +21,11 @@ namespace app {
|
||||
void batchMode() override;
|
||||
void beforeOpenFile(const CliOpenFile& cof) override;
|
||||
void afterOpenFile(const CliOpenFile& cof) override;
|
||||
void saveFile(const CliOpenFile& cof) override;
|
||||
void loadPalette(const CliOpenFile& cof,
|
||||
void saveFile(Context* ctx, const CliOpenFile& cof) 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;
|
||||
|
||||
private:
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -438,6 +438,7 @@ void ChangePixelFormatCommand::onExecute(Context* context)
|
||||
{
|
||||
bool flatten = false;
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
if (m_useUI) {
|
||||
ColorModeWindow window(current_editor);
|
||||
|
||||
@ -456,6 +457,7 @@ void ChangePixelFormatCommand::onExecute(Context* context)
|
||||
m_ditheringMatrix = window.ditheringMatrix();
|
||||
flatten = window.flattenEnabled();
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
||||
// No conversion needed
|
||||
if (context->activeDocument()->sprite()->pixelFormat() == m_format)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -76,7 +76,10 @@ void CropSpriteCommand::onExecute(Context* context)
|
||||
transaction.commit();
|
||||
}
|
||||
document->generateMaskBoundaries();
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
update_screen_for_document(document);
|
||||
#endif
|
||||
}
|
||||
|
||||
class AutocropSpriteCommand : public Command {
|
||||
@ -111,7 +114,10 @@ void AutocropSpriteCommand::onExecute(Context* context)
|
||||
transaction.commit();
|
||||
}
|
||||
document->generateMaskBoundaries();
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
update_screen_for_document(document);
|
||||
#endif
|
||||
}
|
||||
|
||||
Command* CommandFactory::createCropSpriteCommand()
|
||||
|
@ -777,7 +777,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
|
||||
(!selLayers.empty() ? &selLayers: nullptr),
|
||||
(!selFrames.empty() ? &selFrames: nullptr));
|
||||
|
||||
base::UniquePtr<Document> newDocument(exporter.exportSheet());
|
||||
base::UniquePtr<Document> newDocument(exporter.exportSheet(context));
|
||||
if (!newDocument)
|
||||
return;
|
||||
|
||||
|
@ -63,6 +63,7 @@ void LoadPaletteCommand::onExecute(Context* context)
|
||||
else if (!m_filename.empty()) {
|
||||
filename = m_filename;
|
||||
}
|
||||
#ifdef ENABLE_UI
|
||||
else {
|
||||
base::paths exts = get_readable_palette_extensions();
|
||||
base::paths filenames;
|
||||
@ -72,6 +73,7 @@ void LoadPaletteCommand::onExecute(Context* context)
|
||||
filename = filenames.front();
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
||||
// Do nothing
|
||||
if (filename.empty())
|
||||
|
@ -107,6 +107,7 @@ void OpenFileCommand::onExecute(Context* context)
|
||||
base::paths filenames;
|
||||
|
||||
// interactive
|
||||
#ifdef ENABLE_UI
|
||||
if (context->isUIAvailable() && m_filename.empty()) {
|
||||
base::paths exts = get_readable_extensions();
|
||||
|
||||
@ -122,7 +123,9 @@ void OpenFileCommand::onExecute(Context* context)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!m_filename.empty()) {
|
||||
else
|
||||
#endif // ENABLE_UI
|
||||
if (!m_filename.empty()) {
|
||||
filenames.push_back(m_filename);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/recent_files.h"
|
||||
#include "app/resource_finder.h"
|
||||
#include "app/send_crash.h"
|
||||
#include "app/ui/color_button.h"
|
||||
#include "app/ui/separator_in_view.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
|
@ -133,6 +133,7 @@ std::string SaveFileBaseCommand::saveAsDialog(
|
||||
base::paths exts = get_writable_extensions();
|
||||
filename = initialFilename;
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
again:;
|
||||
base::paths newfilename;
|
||||
if (!app::show_file_selector(
|
||||
@ -148,6 +149,7 @@ std::string SaveFileBaseCommand::saveAsDialog(
|
||||
ui::Alert::show(Strings::alerts_cannot_file_overwrite_on_export());
|
||||
goto again;
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
}
|
||||
|
||||
if (saveInBackground) {
|
||||
@ -210,9 +212,11 @@ void SaveFileBaseCommand::saveDocumentInBackground(
|
||||
document->setFilename(filename);
|
||||
document->incrementVersion();
|
||||
}
|
||||
#ifdef ENABLE_UI
|
||||
StatusBar::instance()
|
||||
->setStatusText(2000, "File <%s> saved.",
|
||||
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);
|
||||
bool isForTwitter = false;
|
||||
|
||||
#if ENABLE_UI
|
||||
if (context->isUIAvailable()) {
|
||||
ExportFileWindow win(doc);
|
||||
bool askOverwrite = true;
|
||||
@ -350,6 +355,7 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
|
||||
aniDirValue = win.aniDirValue();
|
||||
isForTwitter = win.isForTwitter();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Pixel ratio
|
||||
if (applyPixelRatio) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// 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));
|
||||
ResizeMethod resize_method = m_resizeMethod;
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
if (m_useUI && context->isUIAvailable()) {
|
||||
SpriteSizeWindow window(context, new_width, new_height);
|
||||
window.remapWindow();
|
||||
@ -351,6 +352,7 @@ void SpriteSizeCommand::onExecute(Context* context)
|
||||
|
||||
set_config_int("SpriteSize", "Method", resize_method);
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
||||
{
|
||||
SpriteSizeJob job(reader, new_width, new_height, resize_method);
|
||||
@ -358,7 +360,9 @@ void SpriteSizeCommand::onExecute(Context* context)
|
||||
job.waitJob();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
update_screen_for_document(reader.document());
|
||||
#endif
|
||||
}
|
||||
|
||||
Command* CommandFactory::createSpriteSizeCommand()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -63,11 +63,11 @@ void UndoCommand::onExecute(Context* context)
|
||||
ContextWriter writer(context);
|
||||
Document* document(writer.document());
|
||||
DocumentUndo* undo = document->undoHistory();
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
Sprite* sprite = document->sprite();
|
||||
SpritePosition spritePosition;
|
||||
const bool gotoModified =
|
||||
Preferences::instance().undo.gotoModified();
|
||||
|
||||
const bool gotoModified = Preferences::instance().undo.gotoModified();
|
||||
if (gotoModified) {
|
||||
SpritePosition currentPosition(writer.site()->layer(),
|
||||
writer.site()->frame());
|
||||
@ -100,6 +100,7 @@ void UndoCommand::onExecute(Context* context)
|
||||
(m_type == Undo ?
|
||||
undo->nextUndoLabel().c_str():
|
||||
undo->nextRedoLabel().c_str()));
|
||||
#endif // ENABLE_UI
|
||||
|
||||
// Effectively undo/redo.
|
||||
if (m_type == Undo)
|
||||
@ -107,6 +108,7 @@ void UndoCommand::onExecute(Context* context)
|
||||
else
|
||||
undo->redo();
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
// After redo/undo, we retry to change the current SpritePosition
|
||||
// (because new frames/layers could be added, positions that we
|
||||
// weren't able to reach before the undo).
|
||||
@ -122,11 +124,14 @@ void UndoCommand::onExecute(Context* context)
|
||||
current_editor->setFrame(spritePosition.frame());
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
|
||||
document->generateMaskBoundaries();
|
||||
document->setExtraCel(ExtraCelRef(nullptr));
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
update_screen_for_document(document);
|
||||
#endif
|
||||
set_current_palette(writer.palette(), false);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,25 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// 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(AddColor)
|
||||
FOR_EACH_COMMAND(AdvancedMode)
|
||||
FOR_EACH_COMMAND(AutocropSprite)
|
||||
FOR_EACH_COMMAND(BackgroundFromLayer)
|
||||
FOR_EACH_COMMAND(BrightnessContrast)
|
||||
FOR_EACH_COMMAND(Cancel)
|
||||
@ -15,7 +27,6 @@ FOR_EACH_COMMAND(CanvasSize)
|
||||
FOR_EACH_COMMAND(CelProperties)
|
||||
FOR_EACH_COMMAND(ChangeBrush)
|
||||
FOR_EACH_COMMAND(ChangeColor)
|
||||
FOR_EACH_COMMAND(ChangePixelFormat)
|
||||
FOR_EACH_COMMAND(Clear)
|
||||
FOR_EACH_COMMAND(ClearCel)
|
||||
FOR_EACH_COMMAND(CloseAllFiles)
|
||||
@ -27,7 +38,6 @@ FOR_EACH_COMMAND(ConvolutionMatrix)
|
||||
FOR_EACH_COMMAND(Copy)
|
||||
FOR_EACH_COMMAND(CopyCel)
|
||||
FOR_EACH_COMMAND(CopyMerged)
|
||||
FOR_EACH_COMMAND(CropSprite)
|
||||
FOR_EACH_COMMAND(Cut)
|
||||
FOR_EACH_COMMAND(DeselectMask)
|
||||
FOR_EACH_COMMAND(Despeckle)
|
||||
@ -70,7 +80,6 @@ FOR_EACH_COMMAND(LayerProperties)
|
||||
FOR_EACH_COMMAND(LayerVisibility)
|
||||
FOR_EACH_COMMAND(LinkCels)
|
||||
FOR_EACH_COMMAND(LoadMask)
|
||||
FOR_EACH_COMMAND(LoadPalette)
|
||||
FOR_EACH_COMMAND(MaskAll)
|
||||
FOR_EACH_COMMAND(MaskByColor)
|
||||
FOR_EACH_COMMAND(MaskContent)
|
||||
@ -85,7 +94,6 @@ FOR_EACH_COMMAND(NewFrameTag)
|
||||
FOR_EACH_COMMAND(NewLayer)
|
||||
FOR_EACH_COMMAND(NewSpriteFromSelection)
|
||||
FOR_EACH_COMMAND(OpenBrowser)
|
||||
FOR_EACH_COMMAND(OpenFile)
|
||||
FOR_EACH_COMMAND(OpenGroup)
|
||||
FOR_EACH_COMMAND(OpenInFolder)
|
||||
FOR_EACH_COMMAND(OpenWithApp)
|
||||
@ -96,7 +104,6 @@ FOR_EACH_COMMAND(Paste)
|
||||
FOR_EACH_COMMAND(PasteText)
|
||||
FOR_EACH_COMMAND(PixelPerfectMode)
|
||||
FOR_EACH_COMMAND(PlayAnimation)
|
||||
FOR_EACH_COMMAND(Redo)
|
||||
FOR_EACH_COMMAND(Refresh)
|
||||
FOR_EACH_COMMAND(RemoveFrame)
|
||||
FOR_EACH_COMMAND(RemoveFrameTag)
|
||||
@ -107,9 +114,6 @@ FOR_EACH_COMMAND(ReplaceColor)
|
||||
FOR_EACH_COMMAND(ReselectMask)
|
||||
FOR_EACH_COMMAND(ReverseFrames)
|
||||
FOR_EACH_COMMAND(Rotate)
|
||||
FOR_EACH_COMMAND(SaveFile)
|
||||
FOR_EACH_COMMAND(SaveFileAs)
|
||||
FOR_EACH_COMMAND(SaveFileCopyAs)
|
||||
FOR_EACH_COMMAND(SaveMask)
|
||||
FOR_EACH_COMMAND(SavePalette)
|
||||
FOR_EACH_COMMAND(Scroll)
|
||||
@ -134,19 +138,20 @@ FOR_EACH_COMMAND(ShowSlices)
|
||||
FOR_EACH_COMMAND(SliceProperties)
|
||||
FOR_EACH_COMMAND(SnapToGrid)
|
||||
FOR_EACH_COMMAND(SpriteProperties)
|
||||
FOR_EACH_COMMAND(SpriteSize)
|
||||
FOR_EACH_COMMAND(SwitchColors)
|
||||
FOR_EACH_COMMAND(SymmetryMode)
|
||||
FOR_EACH_COMMAND(TiledMode)
|
||||
FOR_EACH_COMMAND(Timeline)
|
||||
FOR_EACH_COMMAND(TogglePreview)
|
||||
FOR_EACH_COMMAND(ToggleTimelineThumbnails)
|
||||
FOR_EACH_COMMAND(Undo)
|
||||
FOR_EACH_COMMAND(UndoHistory)
|
||||
FOR_EACH_COMMAND(UnlinkCel)
|
||||
FOR_EACH_COMMAND(Zoom)
|
||||
#endif // ENABLE_UI
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
FOR_EACH_COMMAND(DeveloperConsole)
|
||||
#ifdef ENABLE_UI
|
||||
FOR_EACH_COMMAND(DeveloperConsole)
|
||||
#endif
|
||||
FOR_EACH_COMMAND(RunScript)
|
||||
#endif
|
||||
#endif // ENABLE_SCRIPTING
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -15,6 +15,7 @@
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/console.h"
|
||||
#include "app/document.h"
|
||||
#include "doc/site.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
@ -22,6 +23,7 @@
|
||||
namespace app {
|
||||
|
||||
Context::Context()
|
||||
: m_lastSelectedDoc(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -32,6 +34,11 @@ void Context::sendDocumentToTop(doc::Document* document)
|
||||
documents().move(document, 0);
|
||||
}
|
||||
|
||||
void Context::setActiveDocument(doc::Document* document)
|
||||
{
|
||||
onSetActiveDocument(document);
|
||||
}
|
||||
|
||||
app::Document* Context::activeDocument() const
|
||||
{
|
||||
return static_cast<app::Document*>(doc::Context::activeDocument());
|
||||
@ -59,6 +66,8 @@ void Context::executeCommand(Command* command, const Params& params)
|
||||
Console console;
|
||||
|
||||
ASSERT(command != NULL);
|
||||
if (command == NULL)
|
||||
return;
|
||||
|
||||
LOG(VERBOSE) << "CTXT: Executing command " << command->id() << "\n";
|
||||
try {
|
||||
@ -118,4 +127,31 @@ void Context::onCreateDocument(doc::CreateDocumentArgs* args)
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -20,6 +20,7 @@
|
||||
namespace app {
|
||||
class Command;
|
||||
class Document;
|
||||
class DocumentView;
|
||||
|
||||
class CommandPreconditionException : public base::Exception {
|
||||
public:
|
||||
@ -61,21 +62,33 @@ namespace app {
|
||||
|
||||
void sendDocumentToTop(doc::Document* document);
|
||||
|
||||
void setActiveDocument(doc::Document* document);
|
||||
app::Document* activeDocument() const;
|
||||
bool hasModifiedDocuments() const;
|
||||
|
||||
void executeCommand(const char* commandName);
|
||||
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&)> AfterCommandExecution;
|
||||
|
||||
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:
|
||||
// Last updated flags.
|
||||
ContextFlags m_flags;
|
||||
Document* m_lastSelectedDoc;
|
||||
|
||||
DISABLE_COPYING(Context);
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -50,6 +50,7 @@ void ContextFlags::update(Context* context)
|
||||
document->unlock();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
// TODO this is a hack, try to find a better design to handle this
|
||||
// "moving pixels" state.
|
||||
if (current_editor &&
|
||||
@ -63,6 +64,7 @@ void ContextFlags::update(Context* context)
|
||||
|
||||
updateFlagsFromSite(current_editor->getSite());
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,11 @@
|
||||
|
||||
#include "app/cmd/set_pixel_format.h"
|
||||
#include "app/console.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/file/file.h"
|
||||
#include "app/filename_formatter.h"
|
||||
#include "app/restore_visible_layers.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/convert_to.h"
|
||||
#include "base/fs.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.
|
||||
std::ofstream fos;
|
||||
std::streambuf* osbuf = nullptr;
|
||||
if (m_dataFilename.empty()) {
|
||||
// Redirect to stdout if we are running in batch mode
|
||||
if (!UIContext::instance()->isUIAvailable())
|
||||
if (!ctx->isUIAvailable())
|
||||
osbuf = std::cout.rdbuf();
|
||||
}
|
||||
else {
|
||||
@ -446,7 +446,7 @@ Document* DocumentExporter::exportSheet()
|
||||
Image* textureImage = texture->root()->firstLayer()
|
||||
->cel(frame_t(0))->image();
|
||||
|
||||
renderTexture(samples, textureImage);
|
||||
renderTexture(ctx, samples, textureImage);
|
||||
|
||||
// Save the metadata.
|
||||
if (osbuf)
|
||||
@ -455,7 +455,7 @@ Document* DocumentExporter::exportSheet()
|
||||
// Save the image files.
|
||||
if (!m_textureFilename.empty()) {
|
||||
textureDocument->setFilename(m_textureFilename.c_str());
|
||||
int ret = save_document(UIContext::instance(), textureDocument.get());
|
||||
int ret = save_document(ctx, textureDocument.get());
|
||||
if (ret == 0)
|
||||
textureDocument->markAsSaved();
|
||||
}
|
||||
@ -693,7 +693,7 @@ Document* DocumentExporter::createEmptyTexture(const Samples& samples) const
|
||||
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);
|
||||
|
||||
@ -711,7 +711,7 @@ void DocumentExporter::renderTexture(const Samples& samples, Image* textureImage
|
||||
render::DitheringAlgorithm::None,
|
||||
render::DitheringMatrix(),
|
||||
nullptr) // TODO add a delegate to show progress
|
||||
.execute(UIContext::instance());
|
||||
.execute(ctx);
|
||||
}
|
||||
|
||||
renderSample(sample, textureImage,
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -29,6 +29,7 @@ namespace doc {
|
||||
}
|
||||
|
||||
namespace app {
|
||||
class Context;
|
||||
class Document;
|
||||
|
||||
class DocumentExporter {
|
||||
@ -79,7 +80,7 @@ namespace app {
|
||||
m_documents.push_back(Item(document, tag, selLayers, selFrames));
|
||||
}
|
||||
|
||||
Document* exportSheet();
|
||||
Document* exportSheet(Context* ctx);
|
||||
gfx::Size calculateSheetSize();
|
||||
|
||||
private:
|
||||
@ -93,7 +94,7 @@ namespace app {
|
||||
void layoutSamples(Samples& samples);
|
||||
gfx::Size calculateSheetSize(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 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
|
||||
if ((flags & FILE_LOAD_SEQUENCE_ASK) &&
|
||||
context &&
|
||||
@ -287,6 +288,7 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context, const std::string&
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -440,6 +442,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
||||
|
||||
// Show the confirmation alert
|
||||
if (!warnings.empty()) {
|
||||
#ifdef ENABLE_UI
|
||||
// Interative
|
||||
if (context && context->isUIAvailable()) {
|
||||
int ret = OptionalAlert::show(
|
||||
@ -457,7 +460,9 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
||||
return nullptr;
|
||||
}
|
||||
// No interactive & fatal error?
|
||||
else if (fatal) {
|
||||
else
|
||||
#endif // ENABLE_UI
|
||||
if (fatal) {
|
||||
fop->setError(warnings.c_str());
|
||||
return fop.release();
|
||||
}
|
||||
@ -500,6 +505,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
||||
++outputFrame;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
if (context && context->isUIAvailable() &&
|
||||
fop->m_seq.filename_list.size() > 1 &&
|
||||
OptionalAlert::show(
|
||||
@ -512,6 +518,7 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
|
||||
base::get_file_name(fop->m_seq.filename_list[1]))) != 1) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif // ENABLE_UI
|
||||
}
|
||||
else
|
||||
fop->m_filename = filename;
|
||||
|
@ -1406,45 +1406,44 @@ base::SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop)
|
||||
if (!gif_options)
|
||||
gif_options.reset(new GifOptions);
|
||||
|
||||
// Non-interactive mode
|
||||
if (!fop->context() ||
|
||||
!fop->context()->isUIAvailable())
|
||||
return gif_options;
|
||||
|
||||
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());
|
||||
#ifdef ENABLE_UI
|
||||
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||
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());
|
||||
}
|
||||
else {
|
||||
gif_options.reset(nullptr);
|
||||
|
||||
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());
|
||||
|
||||
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;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
Console::showException(e);
|
||||
return base::SharedPtr<GifOptions>(nullptr);
|
||||
}
|
||||
return gif_options;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -372,39 +372,38 @@ base::SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)
|
||||
if (!jpeg_options)
|
||||
jpeg_options.reset(new JpegOptions);
|
||||
|
||||
// Non-interactive mode
|
||||
if (!fop->context() ||
|
||||
!fop->context()->isUIAvailable())
|
||||
return jpeg_options;
|
||||
|
||||
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());
|
||||
#ifdef ENABLE_UI
|
||||
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||
try {
|
||||
auto& pref = Preferences::instance();
|
||||
|
||||
if (pref.isSet(pref.jpeg.quality))
|
||||
jpeg_options->quality = pref.jpeg.quality();
|
||||
}
|
||||
else {
|
||||
jpeg_options.reset(nullptr);
|
||||
|
||||
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());
|
||||
|
||||
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;
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
Console::showException(e);
|
||||
return base::SharedPtr<JpegOptions>(0);
|
||||
}
|
||||
return jpeg_options;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -374,95 +374,94 @@ base::SharedPtr<FormatOptions> WebPFormat::onGetFormatOptions(FileOp* fop)
|
||||
if (!opts)
|
||||
opts.reset(new WebPOptions);
|
||||
|
||||
// Non-interactive mode
|
||||
if (!fop->context() ||
|
||||
!fop->context()->isUIAvailable())
|
||||
return opts;
|
||||
|
||||
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()));
|
||||
#ifdef ENABLE_UI
|
||||
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||
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:
|
||||
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;
|
||||
|
||||
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()));
|
||||
|
||||
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;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
Console::showException(e);
|
||||
return base::SharedPtr<WebPOptions>(nullptr);
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -32,7 +32,9 @@ static Module module[] =
|
||||
// first ones.
|
||||
|
||||
DEF_MODULE(palette, 0),
|
||||
#ifdef ENABLE_UI
|
||||
DEF_MODULE(gui, REQUIRE_INTERFACE),
|
||||
#endif
|
||||
};
|
||||
|
||||
static int modules = sizeof(module) / sizeof(Module);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2015-2017 David Capello
|
||||
// Copyright (C) 2015-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -8,12 +8,13 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/document.h"
|
||||
#include "app/app.h"
|
||||
#include "app/context.h"
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/document.h"
|
||||
#include "app/script/app_scripting.h"
|
||||
#include "app/script/sprite_wrap.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "script/engine.h"
|
||||
|
||||
#include <iostream>
|
||||
@ -27,15 +28,16 @@ void App_open(script::ContextHandle handle)
|
||||
script::Context ctx(handle);
|
||||
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 =
|
||||
Commands::instance()->byId(CommandId::OpenFile());
|
||||
Params params;
|
||||
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)
|
||||
ctx.newObject("Sprite", unwrap_engine(ctx)->wrapSprite(newDoc), nullptr);
|
||||
else
|
||||
@ -45,7 +47,7 @@ void App_open(script::ContextHandle handle)
|
||||
void App_exit(script::ContextHandle handle)
|
||||
{
|
||||
script::Context ctx(handle);
|
||||
UIContext* appCtx = UIContext::instance();
|
||||
app::Context* appCtx = App::instance()->context();
|
||||
if (appCtx && appCtx->isUIAvailable()) {
|
||||
Command* exitCommand =
|
||||
Commands::instance()->byId(CommandId::Exit());
|
||||
@ -57,7 +59,8 @@ void App_exit(script::ContextHandle handle)
|
||||
void App_get_activeSprite(script::ContextHandle handle)
|
||||
{
|
||||
script::Context ctx(handle);
|
||||
app::Document* doc = UIContext::instance()->activeDocument();
|
||||
app::Context* appCtx = App::instance()->context();
|
||||
app::Document* doc = appCtx->activeDocument();
|
||||
if (doc)
|
||||
ctx.newObject("Sprite", unwrap_engine(ctx)->wrapSprite(doc), nullptr);
|
||||
else
|
||||
@ -67,7 +70,8 @@ void App_get_activeSprite(script::ContextHandle handle)
|
||||
void App_get_activeImage(script::ContextHandle handle)
|
||||
{
|
||||
script::Context ctx(handle);
|
||||
app::Document* doc = UIContext::instance()->activeDocument();
|
||||
app::Context* appCtx = App::instance()->context();
|
||||
app::Document* doc = appCtx->activeDocument();
|
||||
if (doc) {
|
||||
SpriteWrap* sprWrap = unwrap_engine(ctx)->wrapSprite(doc);
|
||||
ASSERT(sprWrap);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2015-2017 David Capello
|
||||
// Copyright (C) 2015-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -8,9 +8,11 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/cmd/set_sprite_size.h"
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/file/palette_file.h"
|
||||
@ -18,7 +20,6 @@
|
||||
#include "app/script/sprite_wrap.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/document_view.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/palette.h"
|
||||
#include "doc/site.h"
|
||||
@ -43,7 +44,8 @@ void Sprite_new(script::ContextHandle handle)
|
||||
base::UniquePtr<Document> doc(new Document(sprite));
|
||||
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);
|
||||
}
|
||||
@ -105,11 +107,11 @@ void Sprite_save(script::ContextHandle handle)
|
||||
wrap->commit();
|
||||
|
||||
auto doc = wrap->document();
|
||||
auto uiCtx = UIContext::instance();
|
||||
uiCtx->setActiveDocument(doc);
|
||||
app::Context* appCtx = App::instance()->context();
|
||||
appCtx->setActiveDocument(doc);
|
||||
Command* saveCommand =
|
||||
Commands::instance()->byId(CommandId::SaveFile());
|
||||
uiCtx->executeCommand(saveCommand);
|
||||
appCtx->executeCommand(saveCommand);
|
||||
}
|
||||
|
||||
ctx.pushUndefined();
|
||||
@ -125,15 +127,15 @@ void Sprite_saveAs(script::ContextHandle handle)
|
||||
wrap->commit();
|
||||
|
||||
auto doc = wrap->document();
|
||||
auto uiCtx = UIContext::instance();
|
||||
uiCtx->setActiveDocument(doc);
|
||||
app::Context* appCtx = App::instance()->context();
|
||||
appCtx->setActiveDocument(doc);
|
||||
|
||||
Command* saveCommand =
|
||||
Commands::instance()->byId(CommandId::SaveFile());
|
||||
|
||||
Params params;
|
||||
doc->setFilename(fn);
|
||||
uiCtx->executeCommand(saveCommand, params);
|
||||
appCtx->executeCommand(saveCommand, params);
|
||||
}
|
||||
|
||||
ctx.pushUndefined();
|
||||
@ -149,15 +151,15 @@ void Sprite_saveCopyAs(script::ContextHandle handle)
|
||||
wrap->commit();
|
||||
|
||||
auto doc = wrap->document();
|
||||
auto uiCtx = UIContext::instance();
|
||||
uiCtx->setActiveDocument(doc);
|
||||
app::Context* appCtx = App::instance()->context();
|
||||
appCtx->setActiveDocument(doc);
|
||||
|
||||
Command* saveCommand =
|
||||
Commands::instance()->byId(CommandId::SaveFileCopyAs());
|
||||
|
||||
Params params;
|
||||
params.set("filename", fn);
|
||||
uiCtx->executeCommand(saveCommand, params);
|
||||
appCtx->executeCommand(saveCommand, params);
|
||||
}
|
||||
|
||||
ctx.pushUndefined();
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2016 David Capello
|
||||
// Copyright (C) 2016-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -10,13 +10,14 @@
|
||||
|
||||
#include "app/script/sprite_wrap.h"
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/cmd/set_sprite_size.h"
|
||||
#include "app/context.h"
|
||||
#include "app/document.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/script/image_wrap.h"
|
||||
#include "app/transaction.h"
|
||||
#include "app/ui/document_view.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "doc/site.h"
|
||||
#include "doc/sprite.h"
|
||||
|
||||
@ -24,7 +25,7 @@ namespace app {
|
||||
|
||||
SpriteWrap::SpriteWrap(app::Document* doc)
|
||||
: m_doc(doc)
|
||||
, m_view(UIContext::instance()->getFirstDocumentView(m_doc))
|
||||
, m_view(App::instance()->context()->getFirstDocumentView(m_doc))
|
||||
, m_transaction(nullptr)
|
||||
{
|
||||
}
|
||||
@ -41,7 +42,7 @@ SpriteWrap::~SpriteWrap()
|
||||
Transaction& SpriteWrap::transaction()
|
||||
{
|
||||
if (!m_transaction) {
|
||||
m_transaction = new Transaction(UIContext::instance(),
|
||||
m_transaction = new Transaction(App::instance()->context(),
|
||||
"Script Execution",
|
||||
ModifyDocument);
|
||||
}
|
||||
@ -78,14 +79,18 @@ doc::Sprite* SpriteWrap::sprite()
|
||||
ImageWrap* SpriteWrap::activeImage()
|
||||
{
|
||||
if (!m_view) {
|
||||
m_view = UIContext::instance()->getFirstDocumentView(m_doc);
|
||||
m_view = App::instance()->context()->getFirstDocumentView(m_doc);
|
||||
if (!m_view)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
doc::Site site;
|
||||
m_view->getSite(&site);
|
||||
return wrapImage(site.image());
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
ImageWrap* SpriteWrap::wrapImage(doc::Image* img)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -22,23 +22,6 @@
|
||||
|
||||
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()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -28,8 +28,6 @@ namespace app {
|
||||
std::string m_dumpFilename;
|
||||
};
|
||||
|
||||
std::string memory_dump_filename();
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif // APP_SEND_CRASH_H_INCLUDED
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -32,8 +32,7 @@ namespace app {
|
||||
UIContext* UIContext::m_instance = nullptr;
|
||||
|
||||
UIContext::UIContext()
|
||||
: m_lastSelectedDoc(nullptr)
|
||||
, m_lastSelectedView(nullptr)
|
||||
: m_lastSelectedView(nullptr)
|
||||
{
|
||||
documents().add_observer(&Preferences::instance());
|
||||
|
||||
@ -121,10 +120,10 @@ void UIContext::setActiveView(DocumentView* docView)
|
||||
notifyActiveSiteChanged();
|
||||
}
|
||||
|
||||
void UIContext::setActiveDocument(Document* document)
|
||||
void UIContext::onSetActiveDocument(doc::Document* document)
|
||||
{
|
||||
bool notify = (m_lastSelectedDoc != document);
|
||||
m_lastSelectedDoc = document;
|
||||
bool notify = (lastSelectedDoc() != document);
|
||||
app::Context::onSetActiveDocument(document);
|
||||
|
||||
DocumentView* docView = getFirstDocumentView(document);
|
||||
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)
|
||||
{
|
||||
m_lastSelectedDoc = static_cast<app::Document*>(doc);
|
||||
app::Context::onAddDocument(doc);
|
||||
|
||||
// We don't create views in batch mode.
|
||||
if (!App::instance()->isGui())
|
||||
@ -188,7 +187,7 @@ void UIContext::onAddDocument(doc::Document* doc)
|
||||
|
||||
// Add a new view for this document
|
||||
DocumentView* view = new DocumentView(
|
||||
m_lastSelectedDoc,
|
||||
lastSelectedDoc(),
|
||||
DocumentView::Normal,
|
||||
App::instance()->mainWindow()->getPreviewEditor());
|
||||
|
||||
@ -201,8 +200,7 @@ void UIContext::onAddDocument(doc::Document* doc)
|
||||
|
||||
void UIContext::onRemoveDocument(doc::Document* doc)
|
||||
{
|
||||
if (doc == m_lastSelectedDoc)
|
||||
m_lastSelectedDoc = nullptr;
|
||||
app::Context::onRemoveDocument(doc);
|
||||
|
||||
// We don't destroy views in batch mode.
|
||||
if (isUIAvailable()) {
|
||||
@ -246,14 +244,8 @@ void UIContext::onGetActiveSite(Site* site) const
|
||||
}
|
||||
}
|
||||
}
|
||||
// Default/dummy site (maybe for batch/command line mode)
|
||||
else if (!isUIAvailable()) {
|
||||
if (Document* doc = m_lastSelectedDoc) {
|
||||
site->document(doc);
|
||||
site->sprite(doc->sprite());
|
||||
site->layer(doc->sprite()->root()->firstLayer());
|
||||
site->frame(0);
|
||||
}
|
||||
return app::Context::onGetActiveSite(site);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2015, 2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -28,9 +28,8 @@ namespace app {
|
||||
|
||||
DocumentView* activeView() const;
|
||||
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;
|
||||
|
||||
// Returns the current editor. It can be null.
|
||||
@ -44,9 +43,9 @@ namespace app {
|
||||
void onAddDocument(doc::Document* doc) override;
|
||||
void onRemoveDocument(doc::Document* doc) override;
|
||||
void onGetActiveSite(doc::Site* site) const override;
|
||||
void onSetActiveDocument(doc::Document* doc) override;
|
||||
|
||||
private:
|
||||
Document* m_lastSelectedDoc;
|
||||
DocumentView* m_lastSelectedView;
|
||||
static UIContext* m_instance;
|
||||
};
|
||||
|
@ -1,5 +1,12 @@
|
||||
# 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
|
||||
common/freetype_font.cpp
|
||||
@ -138,6 +145,14 @@ if(USE_SKIA_BACKEND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# None backend
|
||||
|
||||
if(USE_NONE_BACKEND)
|
||||
list(APPEND SHE_SOURCES
|
||||
none/she.cpp)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
|
||||
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