From c88f9b172bb62571f73262be073890a4748d802b Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 5 Aug 2013 21:20:19 -0300 Subject: [PATCH] Refactor: Move app files to src/app subdirectory inside app namespace - Add HAVE_CONFIG_H wrapper to #include "config.h" - Removed widgets namespace (it's in app now) - Move some functions from src/file/file.h to src/base/cfile.h - Move Vector2d to base library - Rename MenuItem2 to AppMenuItem --- TODO.md | 9 +- config.h | 2 +- scripts/update_version.sh | 4 +- src/CMakeLists.txt | 272 +-- src/app.h | 94 - src/app/CMakeLists.txt | 233 +++ src/{ => app}/app.cpp | 76 +- src/app/app.h | 103 ++ src/{ => app}/app_menus.cpp | 60 +- src/app/app_menus.h | 79 + src/app/app_options.cpp | 2 + src/app/app_options.h | 2 +- src/app/backup.cpp | 2 + src/app/check_update.cpp | 6 +- src/app/check_update.h | 9 +- src/app/color.cpp | 17 +- src/app/color.h | 148 +- src/app/color_swatches.cpp | 2 + src/app/color_utils.cpp | 12 +- src/app/color_utils.h | 34 +- src/{ => app}/commands/cmd_about.cpp | 22 +- src/{ => app}/commands/cmd_advanced_mode.cpp | 26 +- .../commands/cmd_background_from_layer.cpp | 27 +- src/{ => app}/commands/cmd_cancel.cpp | 18 +- src/{ => app}/commands/cmd_canvas_size.cpp | 37 +- src/{ => app}/commands/cmd_cel_properties.cpp | 30 +- src/{ => app}/commands/cmd_change_color.cpp | 17 +- .../commands/cmd_change_image_type.cpp | 28 +- src/{ => app}/commands/cmd_change_pen.cpp | 24 +- src/{ => app}/commands/cmd_clear.cpp | 29 +- src/{ => app}/commands/cmd_close_file.cpp | 48 +- .../commands/cmd_configure_tools.cpp | 61 +- src/{ => app}/commands/cmd_copy.cpp | 22 +- src/{ => app}/commands/cmd_copy_cel.cpp | 20 +- src/{ => app}/commands/cmd_crop.cpp | 37 +- src/{ => app}/commands/cmd_cut.cpp | 22 +- src/{ => app}/commands/cmd_deselect_mask.cpp | 23 +- .../commands/cmd_developer_console.cpp | 23 +- .../commands/cmd_duplicate_layer.cpp | 41 +- .../commands/cmd_duplicate_sprite.cpp | 31 +- src/{ => app}/commands/cmd_exit.cpp | 23 +- .../commands/cmd_export_sprite_sheet.cpp | 57 +- src/{ => app}/commands/cmd_eyedropper.cpp | 29 +- src/{ => app}/commands/cmd_film_editor.cpp | 21 +- src/{ => app}/commands/cmd_flatten_layers.cpp | 27 +- src/{ => app}/commands/cmd_flip.cpp | 25 +- src/{ => app}/commands/cmd_flip.h | 39 +- .../commands/cmd_frame_properties.cpp | 29 +- src/{ => app}/commands/cmd_goto_frame.cpp | 24 +- src/{ => app}/commands/cmd_goto_layer.cpp | 33 +- src/{ => app}/commands/cmd_goto_tab.cpp | 27 +- src/{ => app}/commands/cmd_grid.cpp | 45 +- .../commands/cmd_import_sprite_sheet.cpp | 65 +- src/{ => app}/commands/cmd_invert_mask.cpp | 27 +- src/{ => app}/commands/cmd_launch.cpp | 25 +- .../commands/cmd_layer_from_background.cpp | 25 +- .../commands/cmd_layer_properties.cpp | 27 +- src/{ => app}/commands/cmd_load_mask.cpp | 28 +- src/{ => app}/commands/cmd_mask_all.cpp | 23 +- src/{ => app}/commands/cmd_mask_by_color.cpp | 19 +- .../commands/cmd_merge_down_layer.cpp | 41 +- src/{ => app}/commands/cmd_move_cel.cpp | 20 +- src/{ => app}/commands/cmd_new_file.cpp | 43 +- src/{ => app}/commands/cmd_new_frame.cpp | 33 +- src/{ => app}/commands/cmd_new_layer.cpp | 35 +- src/{ => app}/commands/cmd_new_layer_set.cpp | 35 +- src/{ => app}/commands/cmd_open_file.cpp | 41 +- src/{ => app}/commands/cmd_open_in_folder.cpp | 24 +- src/{ => app}/commands/cmd_open_with_app.cpp | 24 +- src/{ => app}/commands/cmd_options.cpp | 38 +- src/{ => app}/commands/cmd_palette_editor.cpp | 64 +- src/{ => app}/commands/cmd_paste.cpp | 23 +- src/{ => app}/commands/cmd_play_animation.cpp | 32 +- src/{ => app}/commands/cmd_preview.cpp | 55 +- src/{ => app}/commands/cmd_refresh.cpp | 23 +- src/{ => app}/commands/cmd_remove_cel.cpp | 23 +- src/{ => app}/commands/cmd_remove_frame.cpp | 27 +- src/{ => app}/commands/cmd_remove_layer.cpp | 29 +- src/{ => app}/commands/cmd_reselect_mask.cpp | 23 +- src/{ => app}/commands/cmd_rotate_canvas.cpp | 35 +- src/{ => app}/commands/cmd_save_file.cpp | 54 +- src/{ => app}/commands/cmd_save_mask.cpp | 19 +- src/{ => app}/commands/cmd_scroll.cpp | 27 +- src/{ => app}/commands/cmd_sprite_editor.cpp | 39 +- .../commands/cmd_sprite_properties.cpp | 29 +- src/{ => app}/commands/cmd_sprite_size.cpp | 49 +- src/{ => app}/commands/cmd_switch_colors.cpp | 18 +- src/{ => app}/commands/cmd_undo.cpp | 30 +- src/{ => app}/commands/command.cpp | 12 +- src/app/commands/command.h | 62 + src/{ => app}/commands/command_factory.h | 24 +- src/{ => app}/commands/commands.cpp | 18 +- src/{ => app}/commands/commands.h | 47 +- src/{ => app}/commands/commands_list.h | 0 .../commands/filters/cmd_color_curve.cpp | 43 +- .../filters/cmd_convolution_matrix.cpp | 43 +- .../commands/filters/cmd_despeckle.cpp | 33 +- .../commands/filters/cmd_invert_color.cpp | 35 +- .../commands/filters/cmd_replace_color.cpp | 46 +- .../commands/filters/color_curve_editor.cpp | 15 +- .../commands/filters/color_curve_editor.h | 52 +- .../filters/convolution_matrix_stock.cpp | 14 +- .../filters/convolution_matrix_stock.h | 58 + .../commands/filters/filter_manager_impl.cpp | 22 +- .../commands/filters/filter_manager_impl.h | 144 ++ .../commands/filters/filter_preview.cpp | 13 +- .../commands/filters/filter_preview.h | 39 +- .../filters/filter_target_buttons.cpp | 16 +- .../commands/filters/filter_target_buttons.h | 48 +- .../commands/filters/filter_window.cpp | 17 +- src/app/commands/filters/filter_window.h | 91 + .../commands/filters/filter_worker.cpp | 37 +- .../commands/filters/filter_worker.h | 12 +- src/app/commands/params.h | 85 + src/{ => app}/console.cpp | 16 +- src/{ => app}/console.h | 11 +- src/{ => app}/context.cpp | 17 +- src/app/context.h | 104 ++ src/app/context_access.h | 99 + src/{ => app}/context_flags.cpp | 14 +- src/app/context_flags.h | 55 + src/{ => app}/context_observer.h | 11 +- src/{ => app}/context_observer_list.cpp | 10 +- src/app/context_observer_list.h | 51 + src/app/data_recovery.cpp | 6 +- src/app/data_recovery.h | 11 +- src/{ => app}/dialogs/aniedit.cpp | 61 +- src/{ => app}/dialogs/aniedit.h | 13 +- src/{ => app}/dialogs/maskcol.cpp | 36 +- src/{ => app}/dialogs/maskcol.h | 12 +- src/{ => app}/document.cpp | 61 +- src/app/document.h | 245 +++ src/app/document_access.h | 232 +++ src/{ => app}/document_api.cpp | 88 +- src/app/document_api.h | 124 ++ src/app/document_event.h | 95 + src/{ => app}/document_id.h | 4 +- src/{ => app}/document_location.cpp | 10 +- src/app/document_location.h | 79 + src/app/document_observer.h | 77 + src/{ => app}/document_undo.cpp | 12 +- src/app/document_undo.h | 97 + src/{ => app}/documents.cpp | 10 +- src/app/documents.h | 77 + src/{ => app}/drop_files.cpp | 24 +- src/{ => app}/drop_files.h | 14 +- src/{ => app}/errno_unittest.cpp | 0 src/{ => app}/file/ase_format.cpp | 42 +- src/{ => app}/file/bmp_format.cpp | 20 +- src/{ => app}/file/file.cpp | 123 +- src/app/file/file.h | 150 ++ src/{ => app}/file/file_format.cpp | 10 +- src/app/file/file_format.h | 94 + src/{ => app}/file/file_formats_manager.cpp | 12 +- src/app/file/file_formats_manager.h | 56 + src/{ => app}/file/file_handle.h | 6 +- src/{ => app}/file/file_unittest.cpp | 14 +- src/{ => app}/file/fli/README | 0 src/{ => app}/file/fli/fli.cpp | 0 src/{ => app}/file/fli/fli.h | 4 +- src/{ => app}/file/fli_format.cpp | 33 +- src/app/file/format_options.h | 34 + src/{ => app}/file/gif_format.cpp | 46 +- src/{ => app}/file/ico_format.cpp | 33 +- src/{ => app}/file/jpeg_format.cpp | 30 +- src/{ => app}/file/pcx_format.cpp | 20 +- src/{ => app}/file/png_format.cpp | 23 +- src/{ => app}/file/tga_format.cpp | 22 +- src/app/file_selector.cpp | 6 +- src/{ => app}/file_system.cpp | 35 +- src/app/file_system.h | 79 + src/app/find_widget.h | 4 +- src/{ => app}/flatten.cpp | 16 +- src/{ => app}/flatten.h | 36 +- src/{ => app}/gfxmode.cpp | 19 +- src/app/gfxmode.h | 89 + src/{ => app}/gui_xml.cpp | 16 +- src/{ => app}/gui_xml.h | 45 +- src/{ => app}/ini_file.cpp | 10 +- src/{ => app}/ini_file.h | 31 +- src/{ => app}/job.cpp | 22 +- src/app/job.h | 88 + src/app/launcher.cpp | 54 + src/{ => app}/launcher.h | 20 +- src/app/load_widget.h | 4 +- src/{ => app}/log.cpp | 27 +- src/{ => app}/log.h | 25 +- src/{ => app}/modules.cpp | 26 +- src/{ => app}/modules.h | 31 +- src/{ => app}/modules/editors.cpp | 8 +- src/{ => app}/modules/editors.h | 12 +- src/{ => app}/modules/gfx.cpp | 33 +- src/app/modules/gfx.h | 53 + src/{ => app}/modules/gui.cpp | 62 +- src/app/modules/gui.h | 94 + src/{ => app}/modules/palettes.cpp | 16 +- src/{ => app}/modules/palettes.h | 29 +- src/{ => app}/objects_container_impl.cpp | 8 +- src/{ => app}/objects_container_impl.h | 37 +- .../objects_container_impl_unittest.cpp | 5 +- src/app/project.cpp | 2 + src/app/project.h | 4 +- src/app/project_event.h | 3 +- src/{ => app}/recent_files.cpp | 12 +- src/{ => app}/recent_files.h | 47 +- src/{ => app}/resource_finder.cpp | 8 +- src/{ => app}/resource_finder.h | 47 +- src/app/settings/document_settings.h | 82 + src/{ => app}/settings/ink_type.h | 42 +- src/app/settings/settings.h | 114 ++ src/{ => app}/settings/ui_settings_impl.cpp | 41 +- src/app/settings/ui_settings_impl.h | 66 + src/{ => app}/shell.cpp | 8 +- src/{ => app}/shell.h | 25 +- src/{ => app}/thumbnail_generator.cpp | 33 +- src/app/thumbnail_generator.h | 71 + src/app/tools/controller.h | 58 + src/{ => app}/tools/controllers.h | 23 +- src/{ => app}/tools/fill.h | 21 +- src/app/tools/ink.h | 75 + src/{ => app}/tools/ink_processing.h | 17 +- src/{ => app}/tools/inks.h | 46 +- src/{ => app}/tools/intertwine.cpp | 16 +- src/{ => app}/tools/intertwine.h | 38 +- src/{ => app}/tools/intertwiners.h | 21 +- src/{ => app}/tools/point_shape.cpp | 19 +- src/{ => app}/tools/point_shape.h | 40 +- src/{ => app}/tools/point_shapes.h | 21 +- src/{ => app}/tools/shade_table.cpp | 6 +- src/{ => app}/tools/shade_table.h | 39 +- src/{ => app}/tools/shading_mode.h | 25 +- src/{ => app}/tools/shading_options.h | 24 +- src/app/tools/tool.h | 96 + src/{ => app}/tools/tool_box.cpp | 40 +- src/app/tools/tool_box.h | 96 + src/{ => app}/tools/tool_group.h | 35 +- src/app/tools/tool_loop.h | 197 ++ src/{ => app}/tools/tool_loop_manager.cpp | 29 +- src/app/tools/tool_loop_manager.h | 119 ++ .../col_file.h => app/tools/trace_policy.h} | 17 +- .../menuitem2.cpp => app/ui/app_menuitem.cpp} | 24 +- .../menuitem2.h => app/ui/app_menuitem.h} | 48 +- src/{widgets => app/ui}/button_set.cpp | 10 +- src/app/ui/button_set.h | 50 + src/{widgets => app/ui}/color_bar.cpp | 23 +- src/app/ui/color_bar.h | 87 + src/{widgets => app/ui}/color_button.cpp | 27 +- src/app/ui/color_button.h | 64 + src/{widgets => app/ui}/color_selector.cpp | 20 +- src/app/ui/color_selector.h | 89 + src/{widgets => app/ui}/color_sliders.cpp | 14 +- src/app/ui/color_sliders.h | 137 ++ src/{widgets => app/ui}/context_bar.cpp | 31 +- src/app/ui/context_bar.h | 71 + src/{widgets => app/ui}/document_view.cpp | 29 +- src/{widgets => app/ui}/document_view.h | 28 +- src/{widgets => app/ui}/drop_down_button.cpp | 17 +- src/{widgets => app/ui}/drop_down_button.h | 33 +- src/{widgets => app/ui}/editor/cursor.cpp | 23 +- .../ui}/editor/drawing_state.cpp | 18 +- src/app/ui/editor/drawing_state.h | 59 + src/{widgets => app/ui}/editor/editor.cpp | 73 +- src/app/ui/editor/editor.h | 252 +++ .../ui/editor/editor_customization_delegate.h | 62 + src/app/ui/editor/editor_decorator.h | 64 + src/app/ui/editor/editor_observer.h | 43 + .../ui}/editor/editor_observers.cpp | 10 +- .../ui/editor/editor_observers.h} | 38 +- src/app/ui/editor/editor_state.h | 113 ++ .../ui}/editor/editor_states_history.cpp | 8 +- src/app/ui/editor/editor_states_history.h | 55 + .../ui}/editor/editor_view.cpp | 15 +- src/{widgets => app/ui}/editor/editor_view.h | 31 +- src/app/ui/editor/handle_type.h | 45 + src/{widgets => app/ui}/editor/keys.cpp | 18 +- .../ui}/editor/moving_cel_state.cpp | 22 +- src/app/ui/editor/moving_cel_state.h | 55 + .../ui}/editor/moving_pixels_state.cpp | 46 +- src/app/ui/editor/moving_pixels_state.h | 78 + .../ui}/editor/pixels_movement.cpp | 35 +- src/app/ui/editor/pixels_movement.h | 126 ++ src/app/ui/editor/ruler.h | 64 + .../ui}/editor/scrolling_state.cpp | 16 +- src/app/ui/editor/scrolling_state.h | 44 + .../ui}/editor/select_box_state.cpp | 10 +- src/app/ui/editor/select_box_state.h | 88 + .../ui}/editor/standby_state.cpp | 52 +- src/app/ui/editor/standby_state.h | 83 + .../ui}/editor/tool_loop_impl.cpp | 45 +- src/app/ui/editor/tool_loop_impl.h | 38 + .../ui}/editor/transform_handles.cpp | 13 +- src/app/ui/editor/transform_handles.h | 59 + src/{widgets => app/ui}/file_list.cpp | 19 +- src/{widgets => app/ui}/file_list.h | 13 +- src/{widgets => app/ui}/file_selector.cpp | 34 +- src/{widgets => app/ui}/file_selector.h | 17 +- src/{widgets => app/ui}/hex_color_entry.cpp | 8 +- src/{widgets => app/ui}/hex_color_entry.h | 35 +- src/{widgets => app/ui}/main_menu_bar.cpp | 10 +- src/{widgets => app/ui}/main_menu_bar.h | 19 +- src/{widgets => app/ui}/main_window.cpp | 41 +- src/app/ui/main_window.h | 79 + src/{widgets => app/ui}/mini_editor.cpp | 32 +- src/{widgets => app/ui}/mini_editor.h | 14 +- src/{widgets => app/ui}/palette_view.cpp | 16 +- src/app/ui/palette_view.h | 76 + src/{widgets => app/ui}/popup_window_pin.cpp | 17 +- src/{widgets => app/ui}/popup_window_pin.h | 37 +- src/{ => app/ui}/skin/button_icon_impl.cpp | 13 +- src/app/ui/skin/button_icon_impl.h | 57 + src/app/ui/skin/skin_button.h | 79 + src/app/ui/skin/skin_parts.h | 581 ++++++ src/{ => app/ui}/skin/skin_property.cpp | 10 +- src/app/ui/skin/skin_property.h | 67 + .../ui}/skin/skin_slider_property.cpp | 10 +- src/{ => app/ui}/skin/skin_slider_property.h | 42 +- src/{ => app/ui}/skin/skin_theme.cpp | 33 +- src/app/ui/skin/skin_theme.h | 216 +++ src/{widgets => app/ui}/status_bar.cpp | 46 +- src/app/ui/status_bar.h | 163 ++ src/{widgets => app/ui}/tabs.cpp | 21 +- src/app/ui/tabs.h | 142 ++ src/{widgets => app/ui}/toolbar.cpp | 41 +- src/app/ui/toolbar.h | 95 + src/{widgets => app/ui}/workspace.cpp | 24 +- src/{widgets => app/ui}/workspace.h | 14 +- src/{widgets => app/ui}/workspace_part.cpp | 14 +- src/{widgets => app/ui}/workspace_part.h | 13 +- src/{widgets => app/ui}/workspace_view.h | 15 +- src/{widgets => app/ui}/workspace_views.h | 8 +- src/{ => app}/ui_context.cpp | 38 +- src/app/ui_context.h | 64 + src/{ => app}/undo_transaction.cpp | 272 +-- src/app/undo_transaction.h | 95 + src/{ => app}/undoers/add_cel.cpp | 14 +- src/{ => app}/undoers/add_cel.h | 41 +- src/{ => app}/undoers/add_frame.cpp | 19 +- src/{ => app}/undoers/add_frame.h | 44 +- src/{ => app}/undoers/add_image.cpp | 13 +- src/app/undoers/add_image.h | 50 + src/{ => app}/undoers/add_layer.cpp | 17 +- src/{ => app}/undoers/add_layer.h | 42 +- src/{ => app}/undoers/add_palette.cpp | 13 +- src/{ => app}/undoers/add_palette.h | 39 +- src/{ => app}/undoers/close_group.cpp | 17 +- src/app/undoers/close_group.h | 64 + src/{ => app}/undoers/dirty_area.cpp | 13 +- src/{ => app}/undoers/dirty_area.h | 47 +- src/{ => app}/undoers/flip_image.cpp | 12 +- src/{ => app}/undoers/flip_image.h | 49 +- src/{ => app}/undoers/image_area.cpp | 11 +- src/{ => app}/undoers/image_area.h | 45 +- src/{ => app}/undoers/move_layer.cpp | 11 +- src/{ => app}/undoers/move_layer.h | 41 +- src/app/undoers/object_io.h | 73 + src/{ => app}/undoers/open_group.cpp | 18 +- src/app/undoers/open_group.h | 63 + src/{ => app}/undoers/remap_palette.cpp | 16 +- src/{ => app}/undoers/remap_palette.h | 47 +- src/{ => app}/undoers/remove_cel.cpp | 16 +- src/{ => app}/undoers/remove_cel.h | 47 +- src/{ => app}/undoers/remove_frame.cpp | 20 +- src/{ => app}/undoers/remove_frame.h | 46 +- src/{ => app}/undoers/remove_image.cpp | 16 +- src/{ => app}/undoers/remove_image.h | 47 +- src/{ => app}/undoers/remove_layer.cpp | 22 +- src/app/undoers/remove_layer.h | 60 + src/{ => app}/undoers/remove_palette.cpp | 17 +- src/{ => app}/undoers/remove_palette.h | 45 +- src/{ => app}/undoers/replace_image.cpp | 13 +- src/{ => app}/undoers/replace_image.h | 47 +- src/{ => app}/undoers/set_cel_frame.cpp | 11 +- src/{ => app}/undoers/set_cel_frame.h | 41 +- src/{ => app}/undoers/set_cel_opacity.cpp | 11 +- src/{ => app}/undoers/set_cel_opacity.h | 41 +- src/{ => app}/undoers/set_cel_position.cpp | 11 +- src/{ => app}/undoers/set_cel_position.h | 41 +- src/{ => app}/undoers/set_frame_duration.cpp | 11 +- src/{ => app}/undoers/set_frame_duration.h | 41 +- src/{ => app}/undoers/set_layer_flags.cpp | 11 +- src/{ => app}/undoers/set_layer_flags.h | 39 +- src/{ => app}/undoers/set_layer_name.cpp | 11 +- src/{ => app}/undoers/set_layer_name.h | 39 +- src/{ => app}/undoers/set_mask.cpp | 17 +- src/{ => app}/undoers/set_mask.h | 45 +- src/{ => app}/undoers/set_mask_position.cpp | 13 +- src/{ => app}/undoers/set_mask_position.h | 36 +- src/{ => app}/undoers/set_palette_colors.cpp | 11 +- src/app/undoers/set_palette_colors.h | 61 + .../undoers/set_sprite_pixel_format.cpp | 11 +- .../undoers/set_sprite_pixel_format.h | 39 +- src/{ => app}/undoers/set_sprite_size.cpp | 11 +- src/{ => app}/undoers/set_sprite_size.h | 41 +- .../undoers/set_stock_pixel_format.cpp | 12 +- .../undoers/set_stock_pixel_format.h | 39 +- src/{ => app}/undoers/set_total_frames.cpp | 15 +- src/{ => app}/undoers/set_total_frames.h | 44 +- src/app/undoers/undoer_base.h | 28 + src/{ => app}/util/autocrop.cpp | 10 +- src/{util/celmove.h => app/util/autocrop.h} | 24 +- src/{ => app}/util/boundary.cpp | 16 +- src/{ => app}/util/boundary.h | 49 +- src/{ => app}/util/celmove.cpp | 34 +- .../button_set.h => app/util/celmove.h} | 36 +- src/{ => app}/util/clipboard.cpp | 68 +- src/{ => app}/util/clipboard.h | 43 +- src/{ => app}/util/clipboard_win32.h | 8 +- src/{ => app}/util/expand_cel_canvas.cpp | 28 +- src/app/util/expand_cel_canvas.h | 91 + src/{ => app}/util/filetoks.cpp | 2 + src/{ => app}/util/filetoks.h | 4 +- src/{ => app}/util/misc.cpp | 26 +- src/{ => app}/util/misc.h | 15 +- src/{ => app}/util/msk_file.cpp | 12 +- src/{ => app}/util/msk_file.h | 16 +- src/{ => app}/util/pic_file.cpp | 19 +- src/{ => app}/util/pic_file.h | 17 +- src/{ => app}/util/render.cpp | 18 +- src/app/util/render.h | 102 ++ src/{ => app}/util/thmbnail.cpp | 13 +- src/{ => app}/util/thmbnail.h | 22 +- src/app/webserver.cpp | 4 +- src/app/webserver.h | 5 +- src/app/widget_loader.cpp | 26 +- src/app/widget_loader.h | 3 +- src/app/widget_not_found.h | 3 +- src/app/widget_type_mismatch.h | 3 +- src/{ => app}/xml_exception.cpp | 9 +- src/{ => app}/xml_exception.h | 17 +- src/app_menus.h | 72 - src/base/CMakeLists.txt | 2 + src/base/cfile.cpp | 95 + src/base/cfile.h | 21 + src/base/chrono.cpp | 2 + src/base/convert_to.cpp | 2 + src/base/errno_string.cpp | 2 + src/base/exception.cpp | 7 +- src/base/exception.h | 3 +- src/base/fs.cpp | 2 + src/base/launcher.cpp | 108 ++ src/base/launcher.h | 24 + src/base/mem_utils.cpp | 6 + src/base/mem_utils.h | 6 +- src/base/memory.cpp | 10 +- src/base/memory_dump.cpp | 2 + src/base/mutex.cpp | 20 +- src/base/mutex.h | 29 +- src/base/mutex_pthread.h | 8 +- src/base/mutex_win32.h | 8 +- src/{ => base}/observable.h | 34 +- src/{ => base}/observers.h | 32 +- src/base/path.cpp | 28 +- src/base/program_options.cpp | 20 +- src/base/scoped_lock.h | 51 +- src/base/serialization.cpp | 2 + src/base/sha1.cpp | 2 + src/base/sha1_rfc3174.c | 2 + src/base/split_string.cpp | 2 + src/base/string.cpp | 10 +- src/base/system_console.cpp | 2 + src/base/temp_dir.cpp | 2 + src/base/thread.cpp | 2 + src/base/trim_string.cpp | 2 + src/base/unique_ptr.h | 150 +- src/base/unique_ptr_unittest.cpp | 5 +- src/base/vector2d.h | 78 + src/base/version.cpp | 6 +- src/base/version.h | 3 +- src/commands/command.h | 60 - .../filters/convolution_matrix_stock.h | 52 - src/commands/filters/filter_manager_impl.h | 136 -- src/commands/filters/filter_window.h | 87 - src/commands/params.h | 82 - src/context.h | 103 -- src/context_access.h | 98 - src/context_flags.h | 52 - src/context_observer_list.h | 49 - src/document.h | 230 --- src/document_access.h | 235 --- src/document_api.h | 116 -- src/document_event.h | 87 - src/document_location.h | 72 - src/document_observer.h | 74 - src/document_undo.h | 93 - src/documents.h | 75 - src/file/file.h | 144 -- src/file/file_format.h | 91 - src/file/file_formats_manager.h | 53 - src/file/format_options.h | 31 - src/file_system.h | 71 - src/filters/color_curve.cpp | 6 + src/filters/color_curve.h | 47 +- src/filters/color_curve_filter.cpp | 8 + src/filters/color_curve_filter.h | 36 +- src/filters/convolution_matrix.cpp | 6 + src/filters/convolution_matrix.h | 91 +- src/filters/convolution_matrix_filter.cpp | 50 +- src/filters/convolution_matrix_filter.h | 41 +- src/filters/filter.h | 49 +- src/filters/filter_indexed_data.h | 27 +- src/filters/filter_manager.h | 94 +- src/filters/invert_color_filter.cpp | 8 + src/filters/invert_color_filter.h | 21 +- src/filters/median_filter.cpp | 133 +- src/filters/median_filter.h | 45 +- src/filters/neighboring_pixels.h | 141 +- src/filters/replace_color_filter.cpp | 8 + src/filters/replace_color_filter.h | 43 +- src/filters/target.h | 6 +- src/filters/tiled_mode.h | 16 +- src/gfx/hsv.cpp | 5 +- src/gfx/region.cpp | 8 +- src/gfx/rgb.cpp | 5 +- src/gfx/transformation.cpp | 2 + src/gfxmode.h | 87 - src/job.h | 85 - src/la/LICENSE.txt | 29 - src/la/vector2d.h | 78 - src/launcher.cpp | 111 -- src/{ => main}/main.cpp | 59 +- src/{ => main}/resources_win32.rc | 0 src/{ => main}/xpm_icon.c | 0 src/modules/gfx.h | 48 - src/modules/gui.h | 89 - src/net/http_headers.cpp | 2 + src/net/http_request.cpp | 2 + src/net/http_response.cpp | 2 + src/raster/CMakeLists.txt | 31 + src/raster/algo.cpp | 10 +- src/raster/algo.h | 38 +- src/raster/algo_polygon.cpp | 6 + src/raster/algofill.cpp | 6 +- src/raster/algorithm/flip_image.cpp | 6 +- src/raster/algorithm/flip_image.h | 7 +- src/raster/blend.cpp | 6 + src/raster/blend.h | 36 +- src/raster/cel.cpp | 6 + src/raster/cel.h | 53 +- src/raster/cel_io.cpp | 4 +- src/raster/cel_io.h | 8 +- src/raster/color_histogram.h | 185 +- src/raster/dirty.cpp | 6 + src/raster/dirty.h | 126 +- src/raster/dirty_io.cpp | 8 +- src/raster/dirty_io.h | 8 +- src/raster/dithering_method.h | 14 +- src/{util => raster/file}/col_file.cpp | 26 +- .../gpl_file.h => raster/file/col_file.h} | 18 +- src/{util => raster/file}/gpl_file.cpp | 10 +- .../file/gpl_file.h} | 18 +- src/raster/frame_number.h | 60 +- src/raster/gfxobj.cpp | 6 + src/raster/gfxobj.h | 71 +- src/raster/image.cpp | 6 +- src/raster/image.h | 151 +- src/raster/image_impl.h | 1629 +++++++++-------- src/raster/image_io.cpp | 4 +- src/raster/image_io.h | 8 +- src/raster/image_traits.h | 377 ++-- src/raster/images_collector.cpp | 6 + src/raster/images_collector.h | 102 +- src/raster/layer.cpp | 7 +- src/raster/layer.h | 201 +- src/raster/layer_index.h | 60 +- src/raster/layer_io.cpp | 4 +- src/raster/layer_io.h | 52 +- src/raster/mask.cpp | 6 +- src/raster/mask.h | 147 +- src/raster/mask_io.cpp | 4 +- src/raster/mask_io.h | 8 +- src/raster/median_cut.h | 4 +- src/raster/palette.cpp | 20 +- src/raster/palette.h | 124 +- src/raster/palette_io.cpp | 4 +- src/raster/palette_io.h | 8 +- src/raster/path.cpp | 6 + src/raster/path.h | 85 +- src/raster/pen.cpp | 6 + src/raster/pen.h | 64 +- src/raster/pen_type.h | 18 +- src/raster/pixel_format.h | 16 +- src/raster/quantization.cpp | 22 +- src/raster/quantization.h | 37 +- src/raster/rgbmap.cpp | 12 +- src/raster/rgbmap.h | 29 +- src/raster/rotate.cpp | 6 + src/raster/rotate.h | 22 +- src/raster/sprite.cpp | 8 +- src/raster/sprite.h | 187 +- src/raster/sprite_position.h | 40 +- src/raster/stock.cpp | 11 +- src/raster/stock.h | 74 +- src/settings/document_settings.h | 79 - src/settings/settings.h | 113 -- src/settings/ui_settings_impl.h | 63 - src/skin/button_icon_impl.h | 52 - src/skin/skin_button.h | 74 - src/skin/skin_parts.h | 575 ------ src/skin/skin_property.h | 62 - src/skin/skin_theme.h | 211 --- src/tests/test.h | 6 +- src/thumbnail_generator.h | 67 - src/tools/controller.h | 57 - src/tools/ink.h | 74 - src/tools/tool.h | 95 - src/tools/tool_box.h | 95 - src/tools/tool_loop.h | 190 -- src/tools/tool_loop_manager.h | 118 -- src/tools/trace_policy.h | 33 - src/ui/CMakeLists.txt | 2 +- src/ui/accelerator.cpp | 4 +- src/ui/alert.cpp | 4 +- src/ui/box.cpp | 6 +- src/ui/button.cpp | 2 + src/ui/clipboard.cpp | 2 + src/ui/color.cpp | 2 + src/ui/combobox.cpp | 11 +- src/ui/component.cpp | 2 + src/ui/cursor.cpp | 2 + src/ui/custom_label.cpp | 3 +- src/ui/draw.cpp | 6 +- src/ui/entry.cpp | 2 + src/ui/font.cpp | 2 + src/ui/fontbmp.cpp | 2 + src/ui/graphics.cpp | 2 + src/ui/grid.cpp | 6 +- src/ui/image_view.cpp | 2 + src/ui/int_entry.cpp | 6 +- src/ui/intern.cpp | 2 + src/ui/keys.cpp | 2 + src/ui/label.cpp | 2 + src/ui/link_label.cpp | 7 +- src/ui/listbox.cpp | 6 +- src/ui/listitem.cpp | 6 +- src/ui/manager.cpp | 6 +- src/ui/menu.cpp | 8 +- src/ui/menu.h | 2 +- src/ui/message.cpp | 2 + src/ui/message_loop.cpp | 2 + src/ui/overlay.cpp | 2 + src/ui/overlay_manager.cpp | 2 + src/ui/paint_event.cpp | 2 + src/ui/popup_window.cpp | 8 +- src/ui/preferred_size_event.cpp | 6 +- src/ui/rect.cpp | 2 + src/ui/register_message.cpp | 2 + src/ui/resize_event.cpp | 6 +- src/ui/scroll_bar.cpp | 6 +- src/ui/separator.cpp | 6 +- src/ui/slider.cpp | 2 + src/ui/splitter.cpp | 6 +- src/ui/system.cpp | 2 + src/ui/textbox.cpp | 2 + src/ui/theme.cpp | 2 + src/ui/timer.cpp | 2 + src/ui/tooltips.cpp | 8 +- src/ui/tooltips.h | 4 +- src/ui/{gui.cpp => ui.cpp} | 2 + src/ui/{gui.h => ui.h} | 4 +- src/ui/view.cpp | 6 +- src/ui/viewport.cpp | 6 +- src/ui/widget.cpp | 12 +- src/ui/widget.h | 3 +- src/ui/window.cpp | 8 +- src/ui_context.h | 62 - src/undo/object_id.h | 2 +- src/undo/undo_history.cpp | 6 +- src/undo/undoers_stack.cpp | 6 +- src/undo_transaction.h | 87 - src/undoers/close_group.h | 59 - src/undoers/object_io.h | 71 - src/undoers/open_group.h | 58 - src/undoers/remove_layer.h | 54 - src/undoers/set_palette_colors.h | 56 - src/undoers/undoer_base.h | 27 - src/updater/check_update.cpp | 4 +- src/updater/check_update.h | 9 +- src/updater/user_agent.cpp | 2 + src/updater/user_agent_mac.m | 2 + src/updater/user_agent_win.c | 2 + src/util/autocrop.h | 27 - src/util/expand_cel_canvas.h | 83 - src/util/render.h | 95 - src/webserver/webserver.cpp | 2 + src/widgets/color_bar.h | 85 - src/widgets/color_button.h | 62 - src/widgets/color_selector.h | 86 - src/widgets/color_sliders.h | 137 -- src/widgets/context_bar.h | 68 - src/widgets/editor/drawing_state.h | 57 - src/widgets/editor/editor.h | 241 --- .../editor/editor_customization_delegate.h | 60 - src/widgets/editor/editor_decorator.h | 59 - src/widgets/editor/editor_observer.h | 40 - src/widgets/editor/editor_observers.h | 43 - src/widgets/editor/editor_state.h | 110 -- src/widgets/editor/editor_states_history.h | 52 - src/widgets/editor/handle_type.h | 41 - src/widgets/editor/moving_cel_state.h | 50 - src/widgets/editor/moving_pixels_state.h | 73 - src/widgets/editor/pixels_movement.h | 121 -- src/widgets/editor/ruler.h | 61 - src/widgets/editor/scrolling_state.h | 41 - src/widgets/editor/select_box_state.h | 86 - src/widgets/editor/standby_state.h | 81 - src/widgets/editor/transform_handles.h | 56 - src/widgets/main_window.h | 77 - src/widgets/palette_view.h | 73 - src/widgets/status_bar.h | 163 -- src/widgets/tabs.h | 142 -- src/widgets/toolbar.h | 93 - 711 files changed, 16806 insertions(+), 14715 deletions(-) delete mode 100644 src/app.h create mode 100644 src/app/CMakeLists.txt rename src/{ => app}/app.cpp (87%) create mode 100644 src/app/app.h rename src/{ => app}/app_menus.cpp (87%) create mode 100644 src/app/app_menus.h rename src/{ => app}/commands/cmd_about.cpp (90%) rename src/{ => app}/commands/cmd_advanced_mode.cpp (85%) rename src/{ => app}/commands/cmd_background_from_layer.cpp (87%) rename src/{ => app}/commands/cmd_cancel.cpp (87%) rename src/{ => app}/commands/cmd_canvas_size.cpp (91%) rename src/{ => app}/commands/cmd_cel_properties.cpp (90%) rename src/{ => app}/commands/cmd_change_color.cpp (93%) rename src/{ => app}/commands/cmd_change_image_type.cpp (89%) rename src/{ => app}/commands/cmd_change_pen.cpp (89%) rename src/{ => app}/commands/cmd_clear.cpp (83%) rename src/{ => app}/commands/cmd_close_file.cpp (85%) rename src/{ => app}/commands/cmd_configure_tools.cpp (84%) rename src/{ => app}/commands/cmd_copy.cpp (86%) rename src/{ => app}/commands/cmd_copy_cel.cpp (85%) rename src/{ => app}/commands/cmd_crop.cpp (84%) rename src/{ => app}/commands/cmd_cut.cpp (86%) rename src/{ => app}/commands/cmd_deselect_mask.cpp (83%) rename src/{ => app}/commands/cmd_developer_console.cpp (89%) rename src/{ => app}/commands/cmd_duplicate_layer.cpp (79%) rename src/{ => app}/commands/cmd_duplicate_sprite.cpp (84%) rename src/{ => app}/commands/cmd_exit.cpp (84%) rename src/{ => app}/commands/cmd_export_sprite_sheet.cpp (89%) rename src/{ => app}/commands/cmd_eyedropper.cpp (85%) rename src/{ => app}/commands/cmd_film_editor.cpp (81%) rename src/{ => app}/commands/cmd_flatten_layers.cpp (82%) rename src/{ => app}/commands/cmd_flip.cpp (94%) rename src/{ => app}/commands/cmd_flip.h (57%) rename src/{ => app}/commands/cmd_frame_properties.cpp (88%) rename src/{ => app}/commands/cmd_goto_frame.cpp (92%) rename src/{ => app}/commands/cmd_goto_layer.cpp (86%) rename src/{ => app}/commands/cmd_goto_tab.cpp (82%) rename src/{ => app}/commands/cmd_grid.cpp (83%) rename src/{ => app}/commands/cmd_import_sprite_sheet.cpp (88%) rename src/{ => app}/commands/cmd_invert_mask.cpp (88%) rename src/{ => app}/commands/cmd_launch.cpp (83%) rename src/{ => app}/commands/cmd_layer_from_background.cpp (84%) rename src/{ => app}/commands/cmd_layer_properties.cpp (86%) rename src/{ => app}/commands/cmd_load_mask.cpp (86%) rename src/{ => app}/commands/cmd_mask_all.cpp (85%) rename src/{ => app}/commands/cmd_mask_by_color.cpp (83%) rename src/{ => app}/commands/cmd_merge_down_layer.cpp (89%) rename src/{ => app}/commands/cmd_move_cel.cpp (85%) rename src/{ => app}/commands/cmd_new_file.cpp (89%) rename src/{ => app}/commands/cmd_new_frame.cpp (83%) rename src/{ => app}/commands/cmd_new_layer.cpp (87%) rename src/{ => app}/commands/cmd_new_layer_set.cpp (80%) rename src/{ => app}/commands/cmd_open_file.cpp (85%) rename src/{ => app}/commands/cmd_open_in_folder.cpp (82%) rename src/{ => app}/commands/cmd_open_with_app.cpp (82%) rename src/{ => app}/commands/cmd_options.cpp (91%) rename src/{ => app}/commands/cmd_palette_editor.cpp (96%) rename src/{ => app}/commands/cmd_paste.cpp (81%) rename src/{ => app}/commands/cmd_play_animation.cpp (89%) rename src/{ => app}/commands/cmd_preview.cpp (89%) rename src/{ => app}/commands/cmd_refresh.cpp (84%) rename src/{ => app}/commands/cmd_remove_cel.cpp (85%) rename src/{ => app}/commands/cmd_remove_frame.cpp (82%) rename src/{ => app}/commands/cmd_remove_layer.cpp (83%) rename src/{ => app}/commands/cmd_reselect_mask.cpp (85%) rename src/{ => app}/commands/cmd_rotate_canvas.cpp (91%) rename src/{ => app}/commands/cmd_save_file.cpp (88%) rename src/{ => app}/commands/cmd_save_mask.cpp (89%) rename src/{ => app}/commands/cmd_scroll.cpp (89%) rename src/{ => app}/commands/cmd_sprite_editor.cpp (75%) rename src/{ => app}/commands/cmd_sprite_properties.cpp (89%) rename src/{ => app}/commands/cmd_sprite_size.cpp (93%) rename src/{ => app}/commands/cmd_switch_colors.cpp (86%) rename src/{ => app}/commands/cmd_undo.cpp (89%) rename src/{ => app}/commands/command.cpp (92%) create mode 100644 src/app/commands/command.h rename src/{ => app}/commands/command_factory.h (71%) rename src/{ => app}/commands/commands.cpp (88%) rename src/{ => app}/commands/commands.h (62%) rename src/{ => app}/commands/commands_list.h (100%) rename src/{ => app}/commands/filters/cmd_color_curve.cpp (83%) rename src/{ => app}/commands/filters/cmd_convolution_matrix.cpp (88%) rename src/{ => app}/commands/filters/cmd_despeckle.cpp (88%) rename src/{ => app}/commands/filters/cmd_invert_color.cpp (80%) rename src/{ => app}/commands/filters/cmd_replace_color.cpp (85%) rename src/{ => app}/commands/filters/color_curve_editor.cpp (97%) rename src/{ => app}/commands/filters/color_curve_editor.h (51%) rename src/{ => app}/commands/filters/convolution_matrix_stock.cpp (95%) create mode 100644 src/app/commands/filters/convolution_matrix_stock.h rename src/{ => app}/commands/filters/filter_manager_impl.cpp (96%) create mode 100644 src/app/commands/filters/filter_manager_impl.h rename src/{ => app}/commands/filters/filter_preview.cpp (89%) rename src/{ => app}/commands/filters/filter_preview.h (58%) rename src/{ => app}/commands/filters/filter_target_buttons.cpp (95%) rename src/{ => app}/commands/filters/filter_target_buttons.h (50%) rename src/{ => app}/commands/filters/filter_window.cpp (93%) create mode 100644 src/app/commands/filters/filter_window.h rename src/{ => app}/commands/filters/filter_worker.cpp (88%) rename src/{ => app}/commands/filters/filter_worker.h (77%) create mode 100644 src/app/commands/params.h rename src/{ => app}/console.cpp (95%) rename src/{ => app}/console.h (89%) rename src/{ => app}/context.cpp (93%) create mode 100644 src/app/context.h create mode 100644 src/app/context_access.h rename src/{ => app}/context_flags.cpp (92%) create mode 100644 src/app/context_flags.h rename src/{ => app}/context_observer.h (89%) rename src/{ => app}/context_observer_list.cpp (93%) create mode 100644 src/app/context_observer_list.h rename src/{ => app}/dialogs/aniedit.cpp (98%) rename src/{ => app}/dialogs/aniedit.h (76%) rename src/{ => app}/dialogs/maskcol.cpp (88%) rename src/{ => app}/dialogs/maskcol.h (81%) rename src/{ => app}/document.cpp (91%) create mode 100644 src/app/document.h create mode 100644 src/app/document_access.h rename src/{ => app}/document_api.cpp (94%) create mode 100644 src/app/document_api.h create mode 100644 src/app/document_event.h rename src/{ => app}/document_id.h (92%) rename src/{ => app}/document_location.cpp (94%) create mode 100644 src/app/document_location.h create mode 100644 src/app/document_observer.h rename src/{ => app}/document_undo.cpp (94%) create mode 100644 src/app/document_undo.h rename src/{ => app}/documents.cpp (94%) create mode 100644 src/app/documents.h rename src/{ => app}/drop_files.cpp (90%) rename src/{ => app}/drop_files.h (79%) rename src/{ => app}/errno_unittest.cpp (100%) rename src/{ => app}/file/ase_format.cpp (98%) rename src/{ => app}/file/bmp_format.cpp (98%) rename src/{ => app}/file/file.cpp (92%) create mode 100644 src/app/file/file.h rename src/{ => app}/file/file_format.cpp (90%) create mode 100644 src/app/file/file_format.h rename src/{ => app}/file/file_formats_manager.cpp (92%) create mode 100644 src/app/file/file_formats_manager.h rename src/{ => app}/file/file_handle.h (89%) rename src/{ => app}/file/file_unittest.cpp (89%) rename src/{ => app}/file/fli/README (100%) rename src/{ => app}/file/fli/fli.cpp (100%) rename src/{ => app}/file/fli/fli.h (98%) rename src/{ => app}/file/fli_format.cpp (91%) create mode 100644 src/app/file/format_options.h rename src/{ => app}/file/gif_format.cpp (94%) rename src/{ => app}/file/ico_format.cpp (95%) rename src/{ => app}/file/jpeg_format.cpp (95%) rename src/{ => app}/file/pcx_format.cpp (96%) rename src/{ => app}/file/png_format.cpp (98%) rename src/{ => app}/file/tga_format.cpp (97%) rename src/{ => app}/file_system.cpp (98%) create mode 100644 src/app/file_system.h rename src/{ => app}/flatten.cpp (84%) rename src/{ => app}/flatten.h (50%) rename src/{ => app}/gfxmode.cpp (92%) create mode 100644 src/app/gfxmode.h rename src/{ => app}/gui_xml.cpp (90%) rename src/{ => app}/gui_xml.h (55%) rename src/{ => app}/ini_file.cpp (95%) rename src/{ => app}/ini_file.h (55%) rename src/{ => app}/job.cpp (88%) create mode 100644 src/app/job.h create mode 100644 src/app/launcher.cpp rename src/{ => app}/launcher.h (73%) rename src/{ => app}/log.cpp (86%) rename src/{ => app}/log.h (75%) rename src/{ => app}/modules.cpp (87%) rename src/{ => app}/modules.h (70%) rename src/{ => app}/modules/editors.cpp (89%) rename src/{ => app}/modules/editors.h (82%) rename src/{ => app}/modules/gfx.cpp (95%) create mode 100644 src/app/modules/gfx.h rename src/{ => app}/modules/gui.cpp (96%) create mode 100644 src/app/modules/gui.h rename src/{ => app}/modules/palettes.cpp (95%) rename src/{ => app}/modules/palettes.h (60%) rename src/{ => app}/objects_container_impl.cpp (95%) rename src/{ => app}/objects_container_impl.h (57%) rename src/{ => app}/objects_container_impl_unittest.cpp (96%) rename src/{ => app}/recent_files.cpp (95%) rename src/{ => app}/recent_files.h (52%) rename src/{ => app}/resource_finder.cpp (97%) rename src/{ => app}/resource_finder.h (54%) create mode 100644 src/app/settings/document_settings.h rename src/{ => app}/settings/ink_type.h (59%) create mode 100644 src/app/settings/settings.h rename src/{ => app}/settings/ui_settings_impl.cpp (96%) create mode 100644 src/app/settings/ui_settings_impl.h rename src/{ => app}/shell.cpp (92%) rename src/{ => app}/shell.h (77%) rename src/{ => app}/thumbnail_generator.cpp (91%) create mode 100644 src/app/thumbnail_generator.h create mode 100644 src/app/tools/controller.h rename src/{ => app}/tools/controllers.h (95%) rename src/{ => app}/tools/fill.h (78%) create mode 100644 src/app/tools/ink.h rename src/{ => app}/tools/ink_processing.h (98%) rename src/{ => app}/tools/inks.h (92%) rename src/{ => app}/tools/intertwine.cpp (84%) rename src/{ => app}/tools/intertwine.h (53%) rename src/{ => app}/tools/intertwiners.h (94%) rename src/{ => app}/tools/point_shape.cpp (87%) rename src/{ => app}/tools/point_shape.h (50%) rename src/{ => app}/tools/point_shapes.h (92%) rename src/{ => app}/tools/shade_table.cpp (94%) rename src/{ => app}/tools/shade_table.h (54%) rename src/{ => app}/tools/shading_mode.h (66%) rename src/{ => app}/tools/shading_options.h (71%) create mode 100644 src/app/tools/tool.h rename src/{ => app}/tools/tool_box.cpp (95%) create mode 100644 src/app/tools/tool_box.h rename src/{ => app}/tools/tool_group.h (60%) create mode 100644 src/app/tools/tool_loop.h rename src/{ => app}/tools/tool_loop_manager.cpp (95%) create mode 100644 src/app/tools/tool_loop_manager.h rename src/{util/col_file.h => app/tools/trace_policy.h} (74%) rename src/{widgets/menuitem2.cpp => app/ui/app_menuitem.cpp} (84%) rename src/{widgets/menuitem2.h => app/ui/app_menuitem.h} (50%) rename src/{widgets => app/ui}/button_set.cpp (96%) create mode 100644 src/app/ui/button_set.h rename src/{widgets => app/ui}/color_bar.cpp (94%) create mode 100644 src/app/ui/color_bar.h rename src/{widgets => app/ui}/color_button.cpp (94%) create mode 100644 src/app/ui/color_button.h rename src/{widgets => app/ui}/color_selector.cpp (96%) create mode 100644 src/app/ui/color_selector.h rename src/{widgets => app/ui}/color_sliders.cpp (96%) create mode 100644 src/app/ui/color_sliders.h rename src/{widgets => app/ui}/context_bar.cpp (96%) create mode 100644 src/app/ui/context_bar.h rename src/{widgets => app/ui}/document_view.cpp (93%) rename src/{widgets => app/ui}/document_view.h (86%) rename src/{widgets => app/ui}/drop_down_button.cpp (86%) rename src/{widgets => app/ui}/drop_down_button.h (66%) rename src/{widgets => app/ui}/editor/cursor.cpp (98%) rename src/{widgets => app/ui}/editor/drawing_state.cpp (94%) create mode 100644 src/app/ui/editor/drawing_state.h rename src/{widgets => app/ui}/editor/editor.cpp (96%) create mode 100644 src/app/ui/editor/editor.h create mode 100644 src/app/ui/editor/editor_customization_delegate.h create mode 100644 src/app/ui/editor/editor_decorator.h create mode 100644 src/app/ui/editor/editor_observer.h rename src/{widgets => app/ui}/editor/editor_observers.cpp (90%) rename src/{undoers/add_image.h => app/ui/editor/editor_observers.h} (56%) create mode 100644 src/app/ui/editor/editor_state.h rename src/{widgets => app/ui}/editor/editor_states_history.cpp (93%) create mode 100644 src/app/ui/editor/editor_states_history.h rename src/{widgets => app/ui}/editor/editor_view.cpp (91%) rename src/{widgets => app/ui}/editor/editor_view.h (64%) create mode 100644 src/app/ui/editor/handle_type.h rename src/{widgets => app/ui}/editor/keys.cpp (87%) rename src/{widgets => app/ui}/editor/moving_cel_state.cpp (92%) create mode 100644 src/app/ui/editor/moving_cel_state.h rename src/{widgets => app/ui}/editor/moving_pixels_state.cpp (93%) create mode 100644 src/app/ui/editor/moving_pixels_state.h rename src/{widgets => app/ui}/editor/pixels_movement.cpp (96%) create mode 100644 src/app/ui/editor/pixels_movement.h create mode 100644 src/app/ui/editor/ruler.h rename src/{widgets => app/ui}/editor/scrolling_state.cpp (92%) create mode 100644 src/app/ui/editor/scrolling_state.h rename src/{widgets => app/ui}/editor/select_box_state.cpp (97%) create mode 100644 src/app/ui/editor/select_box_state.h rename src/{widgets => app/ui}/editor/standby_state.cpp (94%) create mode 100644 src/app/ui/editor/standby_state.h rename src/{widgets => app/ui}/editor/tool_loop_impl.cpp (94%) create mode 100644 src/app/ui/editor/tool_loop_impl.h rename src/{widgets => app/ui}/editor/transform_handles.cpp (97%) create mode 100644 src/app/ui/editor/transform_handles.h rename src/{widgets => app/ui}/file_list.cpp (98%) rename src/{widgets => app/ui}/file_list.h (93%) rename src/{widgets => app/ui}/file_selector.cpp (98%) rename src/{widgets => app/ui}/file_selector.h (90%) rename src/{widgets => app/ui}/hex_color_entry.cpp (95%) rename src/{widgets => app/ui}/hex_color_entry.h (65%) rename src/{widgets => app/ui}/main_menu_bar.cpp (88%) rename src/{widgets => app/ui}/main_menu_bar.h (79%) rename src/{widgets => app/ui}/main_window.cpp (90%) create mode 100644 src/app/ui/main_window.h rename src/{widgets => app/ui}/mini_editor.cpp (93%) rename src/{widgets => app/ui}/mini_editor.h (87%) rename src/{widgets => app/ui}/palette_view.cpp (97%) create mode 100644 src/app/ui/palette_view.h rename src/{widgets => app/ui}/popup_window_pin.cpp (90%) rename src/{widgets => app/ui}/popup_window_pin.h (55%) rename src/{ => app/ui}/skin/button_icon_impl.cpp (91%) create mode 100644 src/app/ui/skin/button_icon_impl.h create mode 100644 src/app/ui/skin/skin_button.h create mode 100644 src/app/ui/skin/skin_parts.h rename src/{ => app/ui}/skin/skin_property.cpp (88%) create mode 100644 src/app/ui/skin/skin_property.h rename src/{ => app/ui}/skin/skin_slider_property.cpp (87%) rename src/{ => app/ui}/skin/skin_slider_property.h (54%) rename src/{ => app/ui}/skin/skin_theme.cpp (99%) create mode 100644 src/app/ui/skin/skin_theme.h rename src/{widgets => app/ui}/status_bar.cpp (97%) create mode 100644 src/app/ui/status_bar.h rename src/{widgets => app/ui}/tabs.cpp (98%) create mode 100644 src/app/ui/tabs.h rename src/{widgets => app/ui}/toolbar.cpp (97%) create mode 100644 src/app/ui/toolbar.h rename src/{widgets => app/ui}/workspace.cpp (94%) rename src/{widgets => app/ui}/workspace.h (88%) rename src/{widgets => app/ui}/workspace_part.cpp (91%) rename src/{widgets => app/ui}/workspace_part.h (85%) rename src/{widgets => app/ui}/workspace_view.h (86%) rename src/{widgets => app/ui}/workspace_views.h (87%) rename src/{ => app}/ui_context.cpp (88%) create mode 100644 src/app/ui_context.h rename src/{ => app}/undo_transaction.cpp (91%) create mode 100644 src/app/undo_transaction.h rename src/{ => app}/undoers/add_cel.cpp (87%) rename src/{ => app}/undoers/add_cel.h (56%) rename src/{ => app}/undoers/add_frame.cpp (86%) rename src/{ => app}/undoers/add_frame.h (54%) rename src/{ => app}/undoers/add_image.cpp (89%) create mode 100644 src/app/undoers/add_image.h rename src/{ => app}/undoers/add_layer.cpp (85%) rename src/{ => app}/undoers/add_layer.h (55%) rename src/{ => app}/undoers/add_palette.cpp (88%) rename src/{ => app}/undoers/add_palette.h (55%) rename src/{ => app}/undoers/close_group.cpp (84%) create mode 100644 src/app/undoers/close_group.h rename src/{ => app}/undoers/dirty_area.cpp (88%) rename src/{ => app}/undoers/dirty_area.h (51%) rename src/{ => app}/undoers/flip_image.cpp (92%) rename src/{ => app}/undoers/flip_image.h (50%) rename src/{ => app}/undoers/image_area.cpp (93%) rename src/{ => app}/undoers/image_area.h (52%) rename src/{ => app}/undoers/move_layer.cpp (91%) rename src/{ => app}/undoers/move_layer.h (55%) create mode 100644 src/app/undoers/object_io.h rename src/{ => app}/undoers/open_group.cpp (83%) create mode 100644 src/app/undoers/open_group.h rename src/{ => app}/undoers/remap_palette.cpp (89%) rename src/{ => app}/undoers/remap_palette.h (51%) rename src/{ => app}/undoers/remove_cel.cpp (86%) rename src/{ => app}/undoers/remove_cel.h (51%) rename src/{ => app}/undoers/remove_frame.cpp (86%) rename src/{ => app}/undoers/remove_frame.h (53%) rename src/{ => app}/undoers/remove_image.cpp (87%) rename src/{ => app}/undoers/remove_image.h (50%) rename src/{ => app}/undoers/remove_layer.cpp (92%) create mode 100644 src/app/undoers/remove_layer.h rename src/{ => app}/undoers/remove_palette.cpp (83%) rename src/{ => app}/undoers/remove_palette.h (51%) rename src/{ => app}/undoers/replace_image.cpp (91%) rename src/{ => app}/undoers/replace_image.h (50%) rename src/{ => app}/undoers/set_cel_frame.cpp (90%) rename src/{ => app}/undoers/set_cel_frame.h (56%) rename src/{ => app}/undoers/set_cel_opacity.cpp (90%) rename src/{ => app}/undoers/set_cel_opacity.h (55%) rename src/{ => app}/undoers/set_cel_position.cpp (90%) rename src/{ => app}/undoers/set_cel_position.h (55%) rename src/{ => app}/undoers/set_frame_duration.cpp (91%) rename src/{ => app}/undoers/set_frame_duration.h (54%) rename src/{ => app}/undoers/set_layer_flags.cpp (90%) rename src/{ => app}/undoers/set_layer_flags.h (56%) rename src/{ => app}/undoers/set_layer_name.cpp (90%) rename src/{ => app}/undoers/set_layer_name.h (56%) rename src/{ => app}/undoers/set_mask.cpp (85%) rename src/{ => app}/undoers/set_mask.h (52%) rename src/{ => app}/undoers/set_mask_position.cpp (89%) rename src/{ => app}/undoers/set_mask_position.h (57%) rename src/{ => app}/undoers/set_palette_colors.cpp (93%) create mode 100644 src/app/undoers/set_palette_colors.h rename src/{ => app}/undoers/set_sprite_pixel_format.cpp (90%) rename src/{ => app}/undoers/set_sprite_pixel_format.h (54%) rename src/{ => app}/undoers/set_sprite_size.cpp (90%) rename src/{ => app}/undoers/set_sprite_size.h (54%) rename src/{ => app}/undoers/set_stock_pixel_format.cpp (89%) rename src/{ => app}/undoers/set_stock_pixel_format.h (55%) rename src/{ => app}/undoers/set_total_frames.cpp (87%) rename src/{ => app}/undoers/set_total_frames.h (54%) create mode 100644 src/app/undoers/undoer_base.h rename src/{ => app}/util/autocrop.cpp (96%) rename src/{util/celmove.h => app/util/autocrop.h} (66%) rename src/{ => app}/util/boundary.cpp (98%) rename src/{ => app}/util/boundary.h (57%) rename src/{ => app}/util/celmove.cpp (93%) rename src/{widgets/button_set.h => app/util/celmove.h} (62%) rename src/{ => app}/util/clipboard.cpp (82%) rename src/{ => app}/util/clipboard.h (53%) rename src/{ => app}/util/clipboard_win32.h (99%) rename src/{ => app}/util/expand_cel_canvas.cpp (92%) create mode 100644 src/app/util/expand_cel_canvas.h rename src/{ => app}/util/filetoks.cpp (98%) rename src/{ => app}/util/filetoks.h (92%) rename src/{ => app}/util/misc.cpp (85%) rename src/{ => app}/util/misc.h (76%) rename src/{ => app}/util/msk_file.cpp (92%) rename src/{ => app}/util/msk_file.h (74%) rename src/{ => app}/util/pic_file.cpp (97%) rename src/{ => app}/util/pic_file.h (70%) rename src/{ => app}/util/render.cpp (98%) create mode 100644 src/app/util/render.h rename src/{ => app}/util/thmbnail.cpp (97%) rename src/{ => app}/util/thmbnail.h (69%) rename src/{ => app}/xml_exception.cpp (92%) rename src/{ => app}/xml_exception.h (79%) delete mode 100644 src/app_menus.h create mode 100644 src/base/cfile.cpp create mode 100644 src/base/cfile.h create mode 100644 src/base/launcher.cpp create mode 100644 src/base/launcher.h rename src/{ => base}/observable.h (50%) rename src/{ => base}/observers.h (72%) create mode 100644 src/base/vector2d.h delete mode 100644 src/commands/command.h delete mode 100644 src/commands/filters/convolution_matrix_stock.h delete mode 100644 src/commands/filters/filter_manager_impl.h delete mode 100644 src/commands/filters/filter_window.h delete mode 100644 src/commands/params.h delete mode 100644 src/context.h delete mode 100644 src/context_access.h delete mode 100644 src/context_flags.h delete mode 100644 src/context_observer_list.h delete mode 100644 src/document.h delete mode 100644 src/document_access.h delete mode 100644 src/document_api.h delete mode 100644 src/document_event.h delete mode 100644 src/document_location.h delete mode 100644 src/document_observer.h delete mode 100644 src/document_undo.h delete mode 100644 src/documents.h delete mode 100644 src/file/file.h delete mode 100644 src/file/file_format.h delete mode 100644 src/file/file_formats_manager.h delete mode 100644 src/file/format_options.h delete mode 100644 src/file_system.h delete mode 100644 src/gfxmode.h delete mode 100644 src/job.h delete mode 100644 src/la/LICENSE.txt delete mode 100644 src/la/vector2d.h delete mode 100644 src/launcher.cpp rename src/{ => main}/main.cpp (80%) rename src/{ => main}/resources_win32.rc (100%) rename src/{ => main}/xpm_icon.c (100%) delete mode 100644 src/modules/gfx.h delete mode 100644 src/modules/gui.h create mode 100644 src/raster/CMakeLists.txt rename src/{util => raster/file}/col_file.cpp (89%) rename src/{util/gpl_file.h => raster/file/col_file.h} (72%) rename src/{util => raster/file}/gpl_file.cpp (92%) rename src/{widgets/editor/tool_loop_impl.h => raster/file/gpl_file.h} (72%) delete mode 100644 src/settings/document_settings.h delete mode 100644 src/settings/settings.h delete mode 100644 src/settings/ui_settings_impl.h delete mode 100644 src/skin/button_icon_impl.h delete mode 100644 src/skin/skin_button.h delete mode 100644 src/skin/skin_parts.h delete mode 100644 src/skin/skin_property.h delete mode 100644 src/skin/skin_theme.h delete mode 100644 src/thumbnail_generator.h delete mode 100644 src/tools/controller.h delete mode 100644 src/tools/ink.h delete mode 100644 src/tools/tool.h delete mode 100644 src/tools/tool_box.h delete mode 100644 src/tools/tool_loop.h delete mode 100644 src/tools/tool_loop_manager.h delete mode 100644 src/tools/trace_policy.h rename src/ui/{gui.cpp => ui.cpp} (96%) rename src/ui/{gui.h => ui.h} (97%) delete mode 100644 src/ui_context.h delete mode 100644 src/undo_transaction.h delete mode 100644 src/undoers/close_group.h delete mode 100644 src/undoers/object_io.h delete mode 100644 src/undoers/open_group.h delete mode 100644 src/undoers/remove_layer.h delete mode 100644 src/undoers/set_palette_colors.h delete mode 100644 src/undoers/undoer_base.h delete mode 100644 src/util/autocrop.h delete mode 100644 src/util/expand_cel_canvas.h delete mode 100644 src/util/render.h delete mode 100644 src/widgets/color_bar.h delete mode 100644 src/widgets/color_button.h delete mode 100644 src/widgets/color_selector.h delete mode 100644 src/widgets/color_sliders.h delete mode 100644 src/widgets/context_bar.h delete mode 100644 src/widgets/editor/drawing_state.h delete mode 100644 src/widgets/editor/editor.h delete mode 100644 src/widgets/editor/editor_customization_delegate.h delete mode 100644 src/widgets/editor/editor_decorator.h delete mode 100644 src/widgets/editor/editor_observer.h delete mode 100644 src/widgets/editor/editor_observers.h delete mode 100644 src/widgets/editor/editor_state.h delete mode 100644 src/widgets/editor/editor_states_history.h delete mode 100644 src/widgets/editor/handle_type.h delete mode 100644 src/widgets/editor/moving_cel_state.h delete mode 100644 src/widgets/editor/moving_pixels_state.h delete mode 100644 src/widgets/editor/pixels_movement.h delete mode 100644 src/widgets/editor/ruler.h delete mode 100644 src/widgets/editor/scrolling_state.h delete mode 100644 src/widgets/editor/select_box_state.h delete mode 100644 src/widgets/editor/standby_state.h delete mode 100644 src/widgets/editor/transform_handles.h delete mode 100644 src/widgets/main_window.h delete mode 100644 src/widgets/palette_view.h delete mode 100644 src/widgets/status_bar.h delete mode 100644 src/widgets/tabs.h delete mode 100644 src/widgets/toolbar.h diff --git a/TODO.md b/TODO.md index 98484bf53..906a79baa 100644 --- a/TODO.md +++ b/TODO.md @@ -2,7 +2,8 @@ * Warning icon when selecting RGB/HSB color in indexed image. * Warning message when we open a file that is already opened file - (show an option to create a second view). + (show an option to create a second view, or maybe this should + be forbidden). * Paste in place doesn't work as expected sometimes (copy something from one frame, paste in other frame). * After moving a frame, all thumbnails are shown incorrectly. @@ -20,15 +21,15 @@ * Fix problem with export sprite sheet when the cel has negative pos * Add a warning when exporting RGB sprite to GIF, hinting at the quantize function. * MovingPixelsState: Add undo information in each transformation step. -* Add IntEntry class in src/gui/ with spin-buttons. +* Add IntEntry class in src/ui/ with spin-buttons. * Add feedback to "Shift+S" shortcut to switch "snap to grid". * Add color swatches bar. * Sort palette entries. * Add "Remap" button to palette editor after a palette entry is modified: This button should apply a color curve to the whole sprite to remap old indexes to the new positions. -* Move launcher.cpp to base/ lib adding an extension point for "gui" lib. -* Move src/dialogs/aniedit,filesel to src/widgets (remove dialogs/ directory). +* Move src/app/dialogs/aniedit,filesel to src/app/ui + (remove app/dialogs/ directory). * Merge everything related to configuration/settings in one class (allow configuration per document). Use cfg.cpp and settings/ dir. * Refactor src/file/ in several layers. diff --git a/config.h b/config.h index 33bc312d3..8e96ccffc 100644 --- a/config.h +++ b/config.h @@ -39,7 +39,7 @@ #define PRINTF verbose_printf -// Defined in src/log.cpp +// verbose_printf is defined in src/app/log.cpp and used through PRINTF macro void verbose_printf(const char* format, ...); #include diff --git a/scripts/update_version.sh b/scripts/update_version.sh index 6746aad34..c8bc9ac86 100644 --- a/scripts/update_version.sh +++ b/scripts/update_version.sh @@ -25,9 +25,9 @@ mv tmp ../config.h sed -e "s/gui version=\".*/gui version=\"$version\">/" < ../data/gui.xml > tmp mv tmp ../data/gui.xml -sed -e "s/FILEVERSION .*/FILEVERSION $version_win32/" < ../src/resources_win32.rc \ +sed -e "s/FILEVERSION .*/FILEVERSION $version_win32/" < ../src/main/resources_win32.rc \ | sed -e "s/PRODUCTVERSION .*/PRODUCTVERSION $version_win32/" \ | sed -e "s/FileVersion\",.*/FileVersion\", \"$version_win32\"/" \ | sed -e "s/ProductVersion\",.*/ProductVersion\", \"$version_win32\"/" \ > tmp -mv tmp ../src/resources_win32.rc +mv tmp ../src/main/resources_win32.rc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e03012980..f1a200edb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,9 +11,9 @@ if(MSVC) endif(MSVC) # Libraries in this directory -set(aseprite_libraries aseprite-library scripting-lib - undo-lib filters-lib ui-lib - she gfx-lib base-lib) +set(aseprite_libraries app-library raster-lib + scripting-lib undo-lib filters-lib ui-lib + she gfx-lib base-lib) # Directories where .h files can be found include_directories(. .. ../third_party) @@ -147,9 +147,11 @@ endif() ###################################################################### # ASEPRITE libraries +add_subdirectory(app) add_subdirectory(base) add_subdirectory(filters) add_subdirectory(gfx) +add_subdirectory(raster) add_subdirectory(scripting) add_subdirectory(she) add_subdirectory(ui) @@ -166,276 +168,18 @@ if(LIBALLEGRO4_LINK_FLAGS) set(all_libs ${all_libs} ${LIBALLEGRO4_LINK_FLAGS}) endif() -add_library(aseprite-library - app.cpp - app_menus.cpp - console.cpp - context.cpp - context_flags.cpp - context_observer_list.cpp - document.cpp - document_api.cpp - document_location.cpp - document_undo.cpp - documents.cpp - drop_files.cpp - file_system.cpp - flatten.cpp - gfxmode.cpp - gui_xml.cpp - ini_file.cpp - job.cpp - launcher.cpp - log.cpp - modules.cpp - objects_container_impl.cpp - recent_files.cpp - resource_finder.cpp - shell.cpp - thumbnail_generator.cpp - ui_context.cpp - undo_transaction.cpp - xml_exception.cpp - app/app_options.cpp - app/backup.cpp - app/check_update.cpp - app/color.cpp - app/color_swatches.cpp - app/color_utils.cpp - app/data_recovery.cpp - app/file_selector.cpp - app/project.cpp - app/webserver.cpp - app/widget_loader.cpp - commands/cmd_about.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_color.cpp - commands/cmd_change_image_type.cpp - commands/cmd_change_pen.cpp - commands/cmd_clear.cpp - commands/cmd_close_file.cpp - commands/cmd_configure_tools.cpp - commands/cmd_copy.cpp - commands/cmd_copy_cel.cpp - commands/cmd_crop.cpp - commands/cmd_cut.cpp - commands/cmd_deselect_mask.cpp - commands/cmd_developer_console.cpp - commands/cmd_duplicate_layer.cpp - commands/cmd_duplicate_sprite.cpp - commands/cmd_exit.cpp - commands/cmd_export_sprite_sheet.cpp - commands/cmd_eyedropper.cpp - commands/cmd_film_editor.cpp - commands/cmd_flatten_layers.cpp - commands/cmd_flip.cpp - commands/cmd_frame_properties.cpp - commands/cmd_goto_frame.cpp - commands/cmd_goto_layer.cpp - commands/cmd_goto_tab.cpp - commands/cmd_grid.cpp - commands/cmd_import_sprite_sheet.cpp - commands/cmd_invert_mask.cpp - commands/cmd_launch.cpp - commands/cmd_layer_from_background.cpp - commands/cmd_layer_properties.cpp - commands/cmd_load_mask.cpp - commands/cmd_mask_all.cpp - commands/cmd_mask_by_color.cpp - commands/cmd_merge_down_layer.cpp - commands/cmd_move_cel.cpp - commands/cmd_new_file.cpp - commands/cmd_new_frame.cpp - commands/cmd_new_layer.cpp - commands/cmd_new_layer_set.cpp - commands/cmd_open_file.cpp - commands/cmd_open_in_folder.cpp - commands/cmd_open_with_app.cpp - commands/cmd_options.cpp - commands/cmd_palette_editor.cpp - commands/cmd_paste.cpp - commands/cmd_play_animation.cpp - commands/cmd_preview.cpp - commands/cmd_refresh.cpp - commands/cmd_remove_cel.cpp - commands/cmd_remove_frame.cpp - commands/cmd_remove_layer.cpp - commands/cmd_reselect_mask.cpp - commands/cmd_rotate_canvas.cpp - commands/cmd_save_file.cpp - commands/cmd_save_mask.cpp - commands/cmd_scroll.cpp - commands/cmd_sprite_editor.cpp - commands/cmd_sprite_properties.cpp - commands/cmd_sprite_size.cpp - commands/cmd_switch_colors.cpp - commands/cmd_undo.cpp - commands/command.cpp - commands/commands.cpp - commands/filters/cmd_color_curve.cpp - commands/filters/cmd_convolution_matrix.cpp - commands/filters/cmd_despeckle.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 - dialogs/aniedit.cpp - dialogs/maskcol.cpp - file/ase_format.cpp - file/bmp_format.cpp - file/file.cpp - file/file_format.cpp - file/file_formats_manager.cpp - file/fli/fli.cpp - file/fli_format.cpp - file/gif_format.cpp - file/ico_format.cpp - file/jpeg_format.cpp - file/pcx_format.cpp - file/png_format.cpp - file/tga_format.cpp - modules/editors.cpp - modules/gfx.cpp - modules/gui.cpp - modules/palettes.cpp - raster/algo.cpp - raster/algo_polygon.cpp - raster/algofill.cpp - raster/algorithm/flip_image.cpp - raster/blend.cpp - raster/cel.cpp - raster/cel_io.cpp - raster/dirty.cpp - raster/dirty_io.cpp - raster/gfxobj.cpp - raster/image.cpp - raster/image_io.cpp - raster/images_collector.cpp - raster/layer.cpp - raster/layer_io.cpp - raster/mask.cpp - raster/mask_io.cpp - raster/palette.cpp - raster/palette_io.cpp - raster/pen.cpp - raster/quantization.cpp - raster/rgbmap.cpp - raster/rotate.cpp - raster/sprite.cpp - raster/stock.cpp - settings/ui_settings_impl.cpp - skin/button_icon_impl.cpp - skin/skin_theme.cpp - skin/skin_property.cpp - skin/skin_slider_property.cpp - tools/intertwine.cpp - tools/point_shape.cpp - tools/shade_table.cpp - tools/tool_box.cpp - tools/tool_loop_manager.cpp - undoers/add_cel.cpp - undoers/add_frame.cpp - undoers/add_image.cpp - undoers/add_layer.cpp - undoers/add_palette.cpp - undoers/close_group.cpp - undoers/dirty_area.cpp - undoers/flip_image.cpp - undoers/image_area.cpp - undoers/move_layer.cpp - undoers/open_group.cpp - undoers/remap_palette.cpp - undoers/remove_cel.cpp - undoers/remove_frame.cpp - undoers/remove_image.cpp - undoers/remove_layer.cpp - undoers/remove_palette.cpp - undoers/replace_image.cpp - undoers/set_cel_frame.cpp - undoers/set_cel_opacity.cpp - undoers/set_cel_position.cpp - undoers/set_frame_duration.cpp - undoers/set_layer_flags.cpp - undoers/set_layer_name.cpp - undoers/set_mask.cpp - undoers/set_mask_position.cpp - undoers/set_palette_colors.cpp - undoers/set_sprite_pixel_format.cpp - undoers/set_sprite_size.cpp - undoers/set_stock_pixel_format.cpp - undoers/set_total_frames.cpp - util/autocrop.cpp - util/boundary.cpp - util/celmove.cpp - util/clipboard.cpp - util/col_file.cpp - util/expand_cel_canvas.cpp - util/filetoks.cpp - util/gpl_file.cpp - util/misc.cpp - util/msk_file.cpp - util/pic_file.cpp - util/render.cpp - util/thmbnail.cpp - widgets/button_set.cpp - widgets/color_bar.cpp - widgets/color_button.cpp - widgets/color_selector.cpp - widgets/color_sliders.cpp - widgets/context_bar.cpp - widgets/document_view.cpp - widgets/drop_down_button.cpp - widgets/editor/cursor.cpp - widgets/editor/drawing_state.cpp - widgets/editor/editor.cpp - widgets/editor/editor_observers.cpp - widgets/editor/editor_states_history.cpp - widgets/editor/editor_view.cpp - widgets/editor/keys.cpp - widgets/editor/moving_cel_state.cpp - widgets/editor/moving_pixels_state.cpp - widgets/editor/pixels_movement.cpp - widgets/editor/scrolling_state.cpp - widgets/editor/select_box_state.cpp - widgets/editor/standby_state.cpp - widgets/editor/tool_loop_impl.cpp - widgets/editor/transform_handles.cpp - widgets/file_list.cpp - widgets/file_selector.cpp - widgets/hex_color_entry.cpp - widgets/main_menu_bar.cpp - widgets/main_window.cpp - widgets/menuitem2.cpp - widgets/mini_editor.cpp - widgets/palette_view.cpp - widgets/popup_window_pin.cpp - widgets/status_bar.cpp - widgets/tabs.cpp - widgets/toolbar.cpp - widgets/workspace.cpp - widgets/workspace_part.cpp) - ###################################################################### # ASEPRITE application if(WIN32) - set(win32_resources resources_win32.rc) + set(win32_resources main/resources_win32.rc) endif(WIN32) if(UNIX) - set(x11_resources xpm_icon.c) + set(x11_resources main/xpm_icon.c) endif(UNIX) -add_executable(aseprite WIN32 main.cpp ${win32_resources} ${x11_resources}) +add_executable(aseprite WIN32 main/main.cpp ${win32_resources} ${x11_resources}) target_link_libraries(aseprite ${all_libs}) install(TARGETS aseprite diff --git a/src/app.h b/src/app.h deleted file mode 100644 index d65792e97..000000000 --- a/src/app.h +++ /dev/null @@ -1,94 +0,0 @@ -/* ASEPRITE - * Copyright (C) 2001-2013 David Capello - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef APP_H_INCLUDED -#define APP_H_INCLUDED - -#include "base/signal.h" -#include "base/string.h" -#include "base/system_console.h" -#include "base/unique_ptr.h" -#include "raster/pixel_format.h" - -#include - -class Document; -class Layer; -class LegacyModules; -class LoggerModule; -class MainWindow; -class RecentFiles; - -namespace ui { - class MenuBar; - class Widget; - class Window; -} - -namespace tools { class ToolBox; } - -class App -{ -public: - App(int argc, const char* argv[]); - ~App(); - - static App* instance() { return m_instance; } - - // Returns true if ASEPRITE is running with GUI available. - bool isGui() const { return m_isGui; } - - // Runs the ASEPRITE application. In GUI mode it's the top-level - // window, in console/scripting it just runs the specified scripts. - int run(); - - tools::ToolBox* getToolBox() const; - RecentFiles* getRecentFiles() const; - MainWindow* getMainWindow() const { return m_mainWindow; } - - // App Signals - Signal0 Exit; - Signal0 PaletteChange; - Signal0 PenSizeBeforeChange; - Signal0 PenSizeAfterChange; - Signal0 PenAngleBeforeChange; - Signal0 PenAngleAfterChange; - Signal0 CurrentToolChange; - -private: - typedef std::vector FileList; - class Modules; - - static App* m_instance; - - base::SystemConsole m_systemConsole; - Modules* m_modules; - LegacyModules* m_legacy; - bool m_isGui; - bool m_isShell; - UniquePtr m_mainWindow; - FileList m_files; -}; - -void app_refresh_screen(); -void app_rebuild_documents_tabs(); -PixelFormat app_get_current_pixel_format(); -void app_default_statusbar_message(); -int app_get_color_to_clear_layer(Layer* layer); - -#endif diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt new file mode 100644 index 000000000..9d1f76215 --- /dev/null +++ b/src/app/CMakeLists.txt @@ -0,0 +1,233 @@ +# Aseprite +# Copyright (C) 2001-2013 David Capello + +add_library(app-library + app.cpp + app_menus.cpp + app_options.cpp + backup.cpp + check_update.cpp + color.cpp + color_swatches.cpp + color_utils.cpp + commands/cmd_about.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_color.cpp + commands/cmd_change_image_type.cpp + commands/cmd_change_pen.cpp + commands/cmd_clear.cpp + commands/cmd_close_file.cpp + commands/cmd_configure_tools.cpp + commands/cmd_copy.cpp + commands/cmd_copy_cel.cpp + commands/cmd_crop.cpp + commands/cmd_cut.cpp + commands/cmd_deselect_mask.cpp + commands/cmd_developer_console.cpp + commands/cmd_duplicate_layer.cpp + commands/cmd_duplicate_sprite.cpp + commands/cmd_exit.cpp + commands/cmd_export_sprite_sheet.cpp + commands/cmd_eyedropper.cpp + commands/cmd_film_editor.cpp + commands/cmd_flatten_layers.cpp + commands/cmd_flip.cpp + commands/cmd_frame_properties.cpp + commands/cmd_goto_frame.cpp + commands/cmd_goto_layer.cpp + commands/cmd_goto_tab.cpp + commands/cmd_grid.cpp + commands/cmd_import_sprite_sheet.cpp + commands/cmd_invert_mask.cpp + commands/cmd_launch.cpp + commands/cmd_layer_from_background.cpp + commands/cmd_layer_properties.cpp + commands/cmd_load_mask.cpp + commands/cmd_mask_all.cpp + commands/cmd_mask_by_color.cpp + commands/cmd_merge_down_layer.cpp + commands/cmd_move_cel.cpp + commands/cmd_new_file.cpp + commands/cmd_new_frame.cpp + commands/cmd_new_layer.cpp + commands/cmd_new_layer_set.cpp + commands/cmd_open_file.cpp + commands/cmd_open_in_folder.cpp + commands/cmd_open_with_app.cpp + commands/cmd_options.cpp + commands/cmd_palette_editor.cpp + commands/cmd_paste.cpp + commands/cmd_play_animation.cpp + commands/cmd_preview.cpp + commands/cmd_refresh.cpp + commands/cmd_remove_cel.cpp + commands/cmd_remove_frame.cpp + commands/cmd_remove_layer.cpp + commands/cmd_reselect_mask.cpp + commands/cmd_rotate_canvas.cpp + commands/cmd_save_file.cpp + commands/cmd_save_mask.cpp + commands/cmd_scroll.cpp + commands/cmd_sprite_editor.cpp + commands/cmd_sprite_properties.cpp + commands/cmd_sprite_size.cpp + commands/cmd_switch_colors.cpp + commands/cmd_undo.cpp + commands/command.cpp + commands/commands.cpp + commands/filters/cmd_color_curve.cpp + commands/filters/cmd_convolution_matrix.cpp + commands/filters/cmd_despeckle.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 + console.cpp + context.cpp + context_flags.cpp + context_observer_list.cpp + data_recovery.cpp + dialogs/aniedit.cpp + dialogs/maskcol.cpp + document.cpp + document_api.cpp + document_location.cpp + document_undo.cpp + documents.cpp + drop_files.cpp + file/ase_format.cpp + file/bmp_format.cpp + file/file.cpp + file/file_format.cpp + file/file_formats_manager.cpp + file/fli/fli.cpp + file/fli_format.cpp + file/gif_format.cpp + file/ico_format.cpp + file/jpeg_format.cpp + file/pcx_format.cpp + file/png_format.cpp + file/tga_format.cpp + file_selector.cpp + file_system.cpp + flatten.cpp + gfxmode.cpp + gui_xml.cpp + ini_file.cpp + job.cpp + launcher.cpp + log.cpp + modules.cpp + modules/editors.cpp + modules/gfx.cpp + modules/gui.cpp + modules/palettes.cpp + objects_container_impl.cpp + project.cpp + recent_files.cpp + resource_finder.cpp + settings/ui_settings_impl.cpp + shell.cpp + thumbnail_generator.cpp + tools/intertwine.cpp + tools/point_shape.cpp + tools/shade_table.cpp + tools/tool_box.cpp + tools/tool_loop_manager.cpp + ui/app_menuitem.cpp + ui/button_set.cpp + ui/color_bar.cpp + ui/color_button.cpp + ui/color_selector.cpp + ui/color_sliders.cpp + ui/context_bar.cpp + ui/document_view.cpp + ui/drop_down_button.cpp + ui/editor/cursor.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/keys.cpp + ui/editor/moving_cel_state.cpp + ui/editor/moving_pixels_state.cpp + ui/editor/pixels_movement.cpp + ui/editor/scrolling_state.cpp + ui/editor/select_box_state.cpp + ui/editor/standby_state.cpp + ui/editor/tool_loop_impl.cpp + ui/editor/transform_handles.cpp + ui/file_list.cpp + ui/file_selector.cpp + ui/hex_color_entry.cpp + ui/main_menu_bar.cpp + ui/main_window.cpp + ui/mini_editor.cpp + ui/palette_view.cpp + ui/popup_window_pin.cpp + ui/skin/button_icon_impl.cpp + ui/skin/skin_property.cpp + ui/skin/skin_slider_property.cpp + ui/skin/skin_theme.cpp + ui/status_bar.cpp + ui/tabs.cpp + ui/toolbar.cpp + ui/workspace.cpp + ui/workspace_part.cpp + ui_context.cpp + undo_transaction.cpp + undoers/add_cel.cpp + undoers/add_frame.cpp + undoers/add_image.cpp + undoers/add_layer.cpp + undoers/add_palette.cpp + undoers/close_group.cpp + undoers/dirty_area.cpp + undoers/flip_image.cpp + undoers/image_area.cpp + undoers/move_layer.cpp + undoers/open_group.cpp + undoers/remap_palette.cpp + undoers/remove_cel.cpp + undoers/remove_frame.cpp + undoers/remove_image.cpp + undoers/remove_layer.cpp + undoers/remove_palette.cpp + undoers/replace_image.cpp + undoers/set_cel_frame.cpp + undoers/set_cel_opacity.cpp + undoers/set_cel_position.cpp + undoers/set_frame_duration.cpp + undoers/set_layer_flags.cpp + undoers/set_layer_name.cpp + undoers/set_mask.cpp + undoers/set_mask_position.cpp + undoers/set_palette_colors.cpp + undoers/set_sprite_pixel_format.cpp + undoers/set_sprite_size.cpp + undoers/set_stock_pixel_format.cpp + undoers/set_total_frames.cpp + util/autocrop.cpp + util/boundary.cpp + util/celmove.cpp + util/clipboard.cpp + util/expand_cel_canvas.cpp + util/filetoks.cpp + util/misc.cpp + util/msk_file.cpp + util/pic_file.cpp + util/render.cpp + util/thmbnail.cpp + webserver.cpp + widget_loader.cpp + xml_exception.cpp) diff --git a/src/app.cpp b/src/app/app.cpp similarity index 87% rename from src/app.cpp rename to src/app/app.cpp index 048d5f844..1be53ab0c 100644 --- a/src/app.cpp +++ b/src/app/app.cpp @@ -16,58 +16,59 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/app_options.h" #include "app/check_update.h" #include "app/color_utils.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/console.h" #include "app/data_recovery.h" +#include "app/document_location.h" +#include "app/document_observer.h" +#include "app/drop_files.h" +#include "app/file/file.h" +#include "app/file/file_formats_manager.h" +#include "app/file_system.h" #include "app/find_widget.h" +#include "app/gui_xml.h" +#include "app/ini_file.h" #include "app/load_widget.h" +#include "app/log.h" +#include "app/modules.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/recent_files.h" +#include "app/shell.h" +#include "app/tools/tool_box.h" +#include "app/ui/color_bar.h" +#include "app/ui/editor/editor.h" +#include "app/ui/editor/editor_view.h" +#include "app/ui/main_window.h" +#include "app/ui/status_bar.h" +#include "app/ui/tabs.h" +#include "app/ui/toolbar.h" +#include "app/ui_context.h" +#include "app/util/boundary.h" +#include "app/util/render.h" #include "app/webserver.h" #include "base/exception.h" #include "base/unique_ptr.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "console.h" -#include "document_location.h" -#include "document_observer.h" -#include "drop_files.h" -#include "file/file.h" -#include "file/file_formats_manager.h" -#include "file_system.h" -#include "gui_xml.h" -#include "ini_file.h" -#include "log.h" -#include "modules.h" -#include "modules/gfx.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/palette.h" #include "raster/sprite.h" -#include "recent_files.h" #include "scripting/engine.h" -#include "shell.h" -#include "tools/tool_box.h" -#include "ui/gui.h" #include "ui/intern.h" -#include "ui_context.h" -#include "util/boundary.h" -#include "util/render.h" -#include "widgets/color_bar.h" -#include "widgets/editor/editor.h" -#include "widgets/editor/editor_view.h" -#include "widgets/main_window.h" -#include "widgets/status_bar.h" -#include "widgets/tabs.h" -#include "widgets/toolbar.h" +#include "ui/ui.h" #include -/* #include */ #include #include #include @@ -80,10 +81,11 @@ #include #endif +namespace app { + using namespace ui; -class App::Modules -{ +class App::Modules { public: ConfigModule m_configModule; LoggerModule m_loggerModule; @@ -114,7 +116,7 @@ App::App(int argc, const char* argv[]) ASSERT(m_instance == NULL); m_instance = this; - app::AppOptions options(argc, argv); + AppOptions options(argc, argv); m_modules = new Modules(!options.startUI(), options.verbose()); m_isGui = options.startUI(); @@ -136,7 +138,7 @@ App::App(int argc, const char* argv[]) const char* palFile = options.paletteFileName().c_str(); PRINTF("Loading custom palette file: %s\n", palFile); - UniquePtr pal(Palette::load(palFile)); + base::UniquePtr pal(Palette::load(palFile)); if (pal.get() == NULL) throw base::Exception("Error loading default palette from: %s", palFile); @@ -346,3 +348,5 @@ int app_get_color_to_clear_layer(Layer* layer) return color_utils::color_for_layer(color, layer); } + +} // namespace app diff --git a/src/app/app.h b/src/app/app.h new file mode 100644 index 000000000..73e1b82fe --- /dev/null +++ b/src/app/app.h @@ -0,0 +1,103 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_APP_H_INCLUDED +#define APP_APP_H_INCLUDED + +#include "base/signal.h" +#include "base/string.h" +#include "base/system_console.h" +#include "base/unique_ptr.h" +#include "raster/pixel_format.h" + +#include + +namespace ui { + class MenuBar; + class Widget; + class Window; +} + +namespace raster { + class Layer; +} + +namespace app { + class Document; + class LegacyModules; + class LoggerModule; + class MainWindow; + class RecentFiles; + + namespace tools { + class ToolBox; + } + + using namespace raster; + + class App { + public: + App(int argc, const char* argv[]); + ~App(); + + static App* instance() { return m_instance; } + + // Returns true if ASEPRITE is running with GUI available. + bool isGui() const { return m_isGui; } + + // Runs the ASEPRITE application. In GUI mode it's the top-level + // window, in console/scripting it just runs the specified scripts. + int run(); + + tools::ToolBox* getToolBox() const; + RecentFiles* getRecentFiles() const; + MainWindow* getMainWindow() const { return m_mainWindow; } + + // App Signals + Signal0 Exit; + Signal0 PaletteChange; + Signal0 PenSizeBeforeChange; + Signal0 PenSizeAfterChange; + Signal0 PenAngleBeforeChange; + Signal0 PenAngleAfterChange; + Signal0 CurrentToolChange; + + private: + typedef std::vector FileList; + class Modules; + + static App* m_instance; + + base::SystemConsole m_systemConsole; + Modules* m_modules; + LegacyModules* m_legacy; + bool m_isGui; + bool m_isShell; + base::UniquePtr m_mainWindow; + FileList m_files; + }; + + void app_refresh_screen(); + void app_rebuild_documents_tabs(); + PixelFormat app_get_current_pixel_format(); + void app_default_statusbar_message(); + int app_get_color_to_clear_layer(Layer* layer); + +} // namespace app + +#endif diff --git a/src/app_menus.cpp b/src/app/app_menus.cpp similarity index 87% rename from src/app_menus.cpp rename to src/app/app_menus.cpp index b70581a5e..fd3010d4f 100644 --- a/src/app_menus.cpp +++ b/src/app/app_menus.cpp @@ -16,24 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app_menus.h" +#include "app/app_menus.h" -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/console.h" +#include "app/gui_xml.h" +#include "app/modules/gui.h" +#include "app/recent_files.h" +#include "app/tools/tool_box.h" +#include "app/ui/app_menuitem.h" +#include "app/ui/main_window.h" +#include "app/util/filetoks.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "console.h" -#include "gui_xml.h" -#include "modules/gui.h" -#include "recent_files.h" -#include "tools/tool_box.h" -#include "ui/gui.h" -#include "util/filetoks.h" -#include "widgets/main_window.h" -#include "widgets/menuitem2.h" +#include "ui/ui.h" #include "tinyxml.h" #include @@ -41,6 +43,8 @@ #include #include +namespace app { + using namespace ui; static void destroy_instance(AppMenus* instance) @@ -238,12 +242,12 @@ bool AppMenus::rebuildRecentList() params.set("filename", filename); - menuitem = new MenuItem2(get_filename(filename), cmd_open_file, ¶ms); + menuitem = new AppMenuItem(get_filename(filename), cmd_open_file, ¶ms); submenu->addChild(menuitem); } } else { - menuitem = new MenuItem2("Nothing", NULL, NULL); + menuitem = new AppMenuItem("Nothing", NULL, NULL); menuitem->setEnabled(false); submenu->addChild(menuitem); } @@ -322,9 +326,9 @@ Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem) } } - /* create the item */ - MenuItem2* menuitem = new MenuItem2(elem->Attribute("text"), - command, command ? ¶ms: NULL); + // Create the item + AppMenuItem* menuitem = new AppMenuItem(elem->Attribute("text"), + command, command ? ¶ms: NULL); if (!menuitem) return NULL; @@ -352,14 +356,14 @@ Widget* AppMenus::convertXmlelemToMenuitem(TiXmlElement* elem) Widget* AppMenus::createInvalidVersionMenuitem() { - MenuItem2* menuitem = new MenuItem2("WARNING!", NULL, NULL); + AppMenuItem* menuitem = new AppMenuItem("WARNING!", NULL, NULL); Menu* subMenu = new Menu(); - subMenu->addChild(new MenuItem2(PACKAGE " is using a customized gui.xml (maybe from your HOME directory).", NULL, NULL)); - subMenu->addChild(new MenuItem2("You should update your customized gui.xml file to the new version to get", NULL, NULL)); - subMenu->addChild(new MenuItem2("the latest commands available.", NULL, NULL)); + subMenu->addChild(new AppMenuItem(PACKAGE " is using a customized gui.xml (maybe from your HOME directory).", NULL, NULL)); + subMenu->addChild(new AppMenuItem("You should update your customized gui.xml file to the new version to get", NULL, NULL)); + subMenu->addChild(new AppMenuItem("the latest commands available.", NULL, NULL)); subMenu->addChild(new Separator(NULL, JI_HORIZONTAL)); - subMenu->addChild(new MenuItem2("You can bypass this validation adding the correct version", NULL, NULL)); - subMenu->addChild(new MenuItem2("number in element.", NULL, NULL)); + subMenu->addChild(new AppMenuItem("You can bypass this validation adding the correct version", NULL, NULL)); + subMenu->addChild(new AppMenuItem("number in element.", NULL, NULL)); menuitem->setSubmenu(subMenu); return menuitem; } @@ -370,9 +374,9 @@ void AppMenus::applyShortcutToMenuitemsWithCommand(Menu* menu, Command *command, Widget* child = *it; if (child->getType() == kMenuItemWidget) { - ASSERT(dynamic_cast(child) != NULL); + ASSERT(dynamic_cast(child) != NULL); - MenuItem2* menuitem = static_cast(child); + AppMenuItem* menuitem = static_cast(child); Command* mi_command = menuitem->getCommand(); Params* mi_params = menuitem->getParams(); @@ -389,3 +393,5 @@ void AppMenus::applyShortcutToMenuitemsWithCommand(Menu* menu, Command *command, } } } + +} // namespace app diff --git a/src/app/app_menus.h b/src/app/app_menus.h new file mode 100644 index 000000000..cc48875ee --- /dev/null +++ b/src/app/app_menus.h @@ -0,0 +1,79 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_APP_MENUS_H_INCLUDED +#define APP_APP_MENUS_H_INCLUDED + +#include "base/disable_copying.h" +#include "base/unique_ptr.h" +#include "ui/base.h" +#include "ui/menu.h" + +class TiXmlElement; +class TiXmlHandle; + +namespace ui { + class Accelerator; +} + +namespace app { + class Command; + class Params; + + using namespace ui; + + // Class to handle/get/reload available menus in gui.xml file. + class AppMenus { + AppMenus(); + DISABLE_COPYING(AppMenus); + + public: + static AppMenus* instance(); + + void reload(); + + // Updates the menu of recent files. + bool rebuildRecentList(); + + Menu* getRootMenu() { return m_rootMenu; } + MenuItem* getRecentListMenuitem() { return m_recentListMenuitem; } + Menu* getDocumentTabPopupMenu() { return m_documentTabPopupMenu; } + Menu* getLayerPopupMenu() { return m_layerPopupMenu; } + Menu* getFramePopupMenu() { return m_framePopupMenu; } + Menu* getCelPopupMenu() { return m_celPopupMenu; } + Menu* getCelMovementPopupMenu() { return m_celMovementPopupMenu; } + + private: + Menu* loadMenuById(TiXmlHandle& handle, const char *id); + Menu* convertXmlelemToMenu(TiXmlElement* elem); + Widget* convertXmlelemToMenuitem(TiXmlElement* elem); + Widget* createInvalidVersionMenuitem(); + void applyShortcutToMenuitemsWithCommand(Menu* menu, Command* command, Params* params, Accelerator* accel); + + base::UniquePtr m_rootMenu; + MenuItem* m_recentListMenuitem; + base::UniquePtr m_documentTabPopupMenu; + base::UniquePtr m_layerPopupMenu; + base::UniquePtr m_framePopupMenu; + base::UniquePtr m_celPopupMenu; + base::UniquePtr m_celMovementPopupMenu; + }; + +} // namespace app + +#endif diff --git a/src/app/app_options.cpp b/src/app/app_options.cpp index 1cf159c2b..8cd8da384 100644 --- a/src/app/app_options.cpp +++ b/src/app/app_options.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/app_options.h" diff --git a/src/app/app_options.h b/src/app/app_options.h index d80fc9b8a..2550866bb 100644 --- a/src/app/app_options.h +++ b/src/app/app_options.h @@ -53,6 +53,6 @@ private: std::string m_paletteFileName; }; -} +} // namespace app #endif diff --git a/src/app/backup.cpp b/src/app/backup.cpp index 346843f0f..9f51f9e77 100644 --- a/src/app/backup.cpp +++ b/src/app/backup.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/backup.h" diff --git a/src/app/check_update.cpp b/src/app/check_update.cpp index 66fb9d9c4..d6402e1a0 100644 --- a/src/app/check_update.cpp +++ b/src/app/check_update.cpp @@ -16,15 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #ifdef ENABLE_UPDATER #include "app/check_update.h" +#include "app/ini_file.h" +#include "app/ui/status_bar.h" #include "base/bind.h" -#include "ini_file.h" -#include "widgets/status_bar.h" #include #include diff --git a/src/app/check_update.h b/src/app/check_update.h index 1587b22a0..2d9fae761 100644 --- a/src/app/check_update.h +++ b/src/app/check_update.h @@ -30,8 +30,7 @@ namespace app { class CheckUpdateBackgroundJob; - class CheckUpdateThreadLauncher - { + class CheckUpdateThreadLauncher { public: CheckUpdateThreadLauncher(); ~CheckUpdateThreadLauncher(); @@ -50,8 +49,8 @@ namespace app { void checkForUpdates(); updater::Uuid m_uuid; - UniquePtr m_thread; - UniquePtr m_bgJob; + base::UniquePtr m_thread; + base::UniquePtr m_bgJob; bool m_doCheck; bool m_received; updater::CheckUpdateResponse m_response; @@ -65,7 +64,7 @@ namespace app { bool m_isDeveloper; }; -} +} // namespace app #endif // ENABLE_UPDATER diff --git a/src/app/color.cpp b/src/app/color.cpp index 882b33563..b0df67ae7 100644 --- a/src/app/color.cpp +++ b/src/app/color.cpp @@ -16,25 +16,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" - -#include -#include -#include -#include +#endif #include "app/color.h" + #include "app/color_utils.h" +#include "app/modules/palettes.h" #include "gfx/hsv.h" #include "gfx/rgb.h" -#include "modules/palettes.h" #include "raster/image.h" #include "raster/palette.h" -using namespace gfx; +#include +#include +#include +#include namespace app { +using namespace gfx; + // static Color Color::fromMask() { diff --git a/src/app/color.h b/src/app/color.h index 73b66cc4a..2ad1e6b58 100644 --- a/src/app/color.h +++ b/src/app/color.h @@ -23,82 +23,86 @@ #include -class Image; -class Layer; +namespace raster { + class Image; + class Layer; +} namespace app { -class Color { -public: - enum Type { - MaskType, - RgbType, - HsvType, - GrayType, - IndexType, + using namespace raster; + + class Color { + public: + enum Type { + MaskType, + RgbType, + HsvType, + GrayType, + IndexType, + }; + + enum HumanReadableString { + ShortHumanReadableString, + LongHumanReadableString + }; + + // Default ctor is mask color + Color() : m_type(MaskType) { } + + static Color fromMask(); + static Color fromRgb(int r, int g, int b); + static Color fromHsv(int h, int s, int v); // h=[0,360], s=[0,100], v=[0,100] + static Color fromGray(int g); + static Color fromIndex(int index); + + static Color fromImage(PixelFormat pixelFormat, int pixel); + static Color fromImageGetPixel(Image* image, int x, int y); + static Color fromString(const std::string& str); + + std::string toString() const; + std::string toHumanReadableString(PixelFormat format, HumanReadableString type) const; + + bool operator==(const Color& other) const; + bool operator!=(const Color& other) const { + return !operator==(other); + } + + Type getType() const { + return m_type; + } + + bool isValid() const; + + // Getters + int getRed() const; + int getGreen() const; + int getBlue() const; + int getHue() const; + int getSaturation() const; + int getValue() const; + int getGray() const; + int getIndex() const; + + private: + Color(Type type) : m_type(type) { } + + // Color type + Type m_type; + + // Color value + union { + struct { + int r, g, b; + } rgb; + struct { + int h, s, v; + } hsv; + int gray; + int index; + } m_value; }; - enum HumanReadableString { - ShortHumanReadableString, - LongHumanReadableString - }; - - // Default ctor is mask color - Color() : m_type(MaskType) { } - - static Color fromMask(); - static Color fromRgb(int r, int g, int b); - static Color fromHsv(int h, int s, int v); // h=[0,360], s=[0,100], v=[0,100] - static Color fromGray(int g); - static Color fromIndex(int index); - - static Color fromImage(PixelFormat pixelFormat, int pixel); - static Color fromImageGetPixel(Image* image, int x, int y); - static Color fromString(const std::string& str); - - std::string toString() const; - std::string toHumanReadableString(PixelFormat format, HumanReadableString type) const; - - bool operator==(const Color& other) const; - bool operator!=(const Color& other) const { - return !operator==(other); - } - - Type getType() const { - return m_type; - } - - bool isValid() const; - - // Getters - int getRed() const; - int getGreen() const; - int getBlue() const; - int getHue() const; - int getSaturation() const; - int getValue() const; - int getGray() const; - int getIndex() const; - -private: - Color(Type type) : m_type(type) { } - - // Color type - Type m_type; - - // Color value - union { - struct { - int r, g, b; - } rgb; - struct { - int h, s, v; - } hsv; - int gray; - int index; - } m_value; -}; - -} +} // namespace app #endif diff --git a/src/app/color_swatches.cpp b/src/app/color_swatches.cpp index 1800f3173..312d90358 100644 --- a/src/app/color_swatches.cpp +++ b/src/app/color_swatches.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/color_swatches.h" diff --git a/src/app/color_utils.cpp b/src/app/color_utils.cpp index ee98b27fe..381e1e52c 100644 --- a/src/app/color_utils.cpp +++ b/src/app/color_utils.cpp @@ -16,19 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "app/color_utils.h" #include "app/color.h" +#include "app/color_utils.h" +#include "app/modules/palettes.h" #include "gfx/hsv.h" #include "gfx/rgb.h" -#include "modules/palettes.h" #include "raster/image.h" #include "raster/layer.h" -#include "raster/sprite.h" #include "raster/palette.h" +#include "raster/sprite.h" using namespace gfx; @@ -52,6 +54,8 @@ int get_mask_for_bitmap(int depth) } +namespace app { + ui::Color color_utils::blackandwhite(ui::Color color) { if ((ui::getr(color)*30+ui::getg(color)*59+ui::getb(color)*11)/100 < 128) @@ -215,3 +219,5 @@ int color_utils::fixup_color_for_background(PixelFormat format, int color) } return color; } + +} // namespace app diff --git a/src/app/color_utils.h b/src/app/color_utils.h index ccbaee379..07b76dc6a 100644 --- a/src/app/color_utils.h +++ b/src/app/color_utils.h @@ -23,21 +23,25 @@ #include "raster/pixel_format.h" #include "ui/color.h" -class Layer; - -namespace color_utils { - -ui::Color blackandwhite(ui::Color color); -ui::Color blackandwhite_neg(ui::Color color); - -ui::Color color_for_ui(const app::Color& color); -int color_for_allegro(const app::Color& color, int depth); -int color_for_image(const app::Color& color, PixelFormat format); -int color_for_layer(const app::Color& color, Layer* layer); - -int fixup_color_for_layer(Layer* layer, int color); -int fixup_color_for_background(PixelFormat format, int color); - +namespace raster { + class Layer; } +namespace app { + namespace color_utils { + + ui::Color blackandwhite(ui::Color color); + ui::Color blackandwhite_neg(ui::Color color); + + ui::Color color_for_ui(const app::Color& color); + int color_for_allegro(const app::Color& color, int depth); + int color_for_image(const app::Color& color, raster::PixelFormat format); + int color_for_layer(const app::Color& color, raster::Layer* layer); + + int fixup_color_for_layer(raster::Layer* layer, int color); + int fixup_color_for_background(raster::PixelFormat format, int color); + + } // namespace color_utils +} // namespace app + #endif diff --git a/src/commands/cmd_about.cpp b/src/app/commands/cmd_about.cpp similarity index 90% rename from src/commands/cmd_about.cpp rename to src/app/commands/cmd_about.cpp index 47a368ec8..f716c0cdc 100644 --- a/src/commands/cmd_about.cpp +++ b/src/app/commands/cmd_about.cpp @@ -16,21 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/modules/gui.h" #include "base/bind.h" -#include "ui/gui.h" +#include "ui/ui.h" -#include "commands/command.h" -#include "modules/gui.h" +namespace app { using namespace ui; -////////////////////////////////////////////////////////////////////// -// about - -class AboutCommand : public Command -{ +class AboutCommand : public Command { public: AboutCommand(); Command* clone() const { return new AboutCommand(*this); } @@ -48,7 +47,7 @@ AboutCommand::AboutCommand() void AboutCommand::onExecute(Context* context) { - UniquePtr window(new Window(false, "About " PACKAGE)); + base::UniquePtr window(new Window(false, "About " PACKAGE)); Box* box1 = new Box(JI_VERTICAL); Grid* grid = new Grid(2, false); Label* title = new Label(PACKAGE " v" VERSION); @@ -103,10 +102,9 @@ void AboutCommand::onExecute(Context* context) window->openWindowInForeground(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createAboutCommand() { return new AboutCommand; } + +} // namespace app diff --git a/src/commands/cmd_advanced_mode.cpp b/src/app/commands/cmd_advanced_mode.cpp similarity index 85% rename from src/commands/cmd_advanced_mode.cpp rename to src/app/commands/cmd_advanced_mode.cpp index 8e78f5123..09e3e1440 100644 --- a/src/commands/cmd_advanced_mode.cpp +++ b/src/app/commands/cmd_advanced_mode.cpp @@ -16,23 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" -#include "commands/command.h" -#include "ini_file.h" -#include "modules/gui.h" -#include "ui/gui.h" -#include "widgets/main_window.h" +#include "app/modules/gui.h" +#include "app/ui/main_window.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; -class AdvancedModeCommand : public Command -{ +class AdvancedModeCommand : public Command { public: AdvancedModeCommand(); Command* clone() const { return new AdvancedModeCommand(*this); } @@ -62,7 +65,7 @@ void AdvancedModeCommand::onExecute(Context* context) char warning[1024]; char buf[1024]; - UniquePtr window(app::load_widget("advanced_mode.xml", "advanced_mode_warning")); + base::UniquePtr window(app::load_widget("advanced_mode.xml", "advanced_mode_warning")); Widget* warning_label = app::find_widget(window, "warning_label"); Widget* donot_show = app::find_widget(window, "donot_show"); @@ -78,10 +81,9 @@ void AdvancedModeCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createAdvancedModeCommand() { return new AdvancedModeCommand; } + +} // namespace app diff --git a/src/commands/cmd_background_from_layer.cpp b/src/app/commands/cmd_background_from_layer.cpp similarity index 87% rename from src/commands/cmd_background_from_layer.cpp rename to src/app/commands/cmd_background_from_layer.cpp index 88ab36623..e70b61b1f 100644 --- a/src/commands/cmd_background_from_layer.cpp +++ b/src/app/commands/cmd_background_from_layer.cpp @@ -16,21 +16,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/color_utils.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "document_location.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/document_location.h" +#include "app/modules/gui.h" +#include "app/settings/settings.h" +#include "app/ui/color_bar.h" +#include "app/undo_transaction.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "undo_transaction.h" -#include "widgets/color_bar.h" -class BackgroundFromLayerCommand : public Command -{ +namespace app { + +class BackgroundFromLayerCommand : public Command { public: BackgroundFromLayerCommand(); Command* clone() const { return new BackgroundFromLayerCommand(*this); } @@ -77,10 +81,9 @@ void BackgroundFromLayerCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createBackgroundFromLayerCommand() { return new BackgroundFromLayerCommand; } + +} // namespace app diff --git a/src/commands/cmd_cancel.cpp b/src/app/commands/cmd_cancel.cpp similarity index 87% rename from src/commands/cmd_cancel.cpp rename to src/app/commands/cmd_cancel.cpp index ca16c5417..a227d280d 100644 --- a/src/commands/cmd_cancel.cpp +++ b/src/app/commands/cmd_cancel.cpp @@ -16,15 +16,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" +#include "app/commands/command.h" -#include "commands/commands.h" -#include "context.h" +#include "app/commands/commands.h" +#include "app/context.h" -class CancelCommand : public Command -{ +namespace app { + +class CancelCommand : public Command { public: CancelCommand(); Command* clone() { return new CancelCommand(*this); } @@ -49,10 +52,9 @@ void CancelCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCancelCommand() { return new CancelCommand; } + +} // namespace app diff --git a/src/commands/cmd_canvas_size.cpp b/src/app/commands/cmd_canvas_size.cpp similarity index 91% rename from src/commands/cmd_canvas_size.cpp rename to src/app/commands/cmd_canvas_size.cpp index e5870643c..53f4678dd 100644 --- a/src/commands/cmd_canvas_size.cpp +++ b/src/app/commands/cmd_canvas_size.cpp @@ -16,29 +16,34 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/color_utils.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" #include "app/find_widget.h" #include "app/load_widget.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/settings/settings.h" +#include "app/ui/color_bar.h" +#include "app/ui/editor/editor.h" +#include "app/ui/editor/select_box_state.h" +#include "app/undo_transaction.h" #include "base/bind.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/editors.h" -#include "modules/gui.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "widgets/color_bar.h" -#include "widgets/editor/editor.h" -#include "widgets/editor/select_box_state.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; // Disable warning about usage of "this" in initializer list. @@ -139,10 +144,7 @@ private: EditorStatePtr m_selectBoxState; }; -////////////////////////////////////////////////////////////////////// - -class CanvasSizeCommand : public Command -{ +class CanvasSizeCommand : public Command { int m_left, m_right, m_top, m_bottom; public: @@ -175,7 +177,7 @@ void CanvasSizeCommand::onExecute(Context* context) if (context->isUiAvailable()) { // load the window widget - UniquePtr window(new CanvasSizeWindow(0, 0, 0, 0)); + base::UniquePtr window(new CanvasSizeWindow(0, 0, 0, 0)); window->remapWindow(); window->centerWindow(); @@ -221,10 +223,9 @@ void CanvasSizeCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCanvasSizeCommand() { return new CanvasSizeCommand; } + +} // namespace app diff --git a/src/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp similarity index 90% rename from src/commands/cmd_cel_properties.cpp rename to src/app/commands/cmd_cel_properties.cpp index 6281912a6..dd9fc2884 100644 --- a/src/commands/cmd_cel_properties.cpp +++ b/src/app/commands/cmd_cel_properties.cpp @@ -16,30 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" #include "app/find_widget.h" #include "app/load_widget.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" +#include "app/undoers/set_cel_opacity.h" #include "base/mem_utils.h" -#include "commands/command.h" -#include "context_access.h" -#include "modules/gui.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "undoers/set_cel_opacity.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; -class CelPropertiesCommand : public Command -{ +class CelPropertiesCommand : public Command { public: CelPropertiesCommand(); Command* clone() const { return new CelPropertiesCommand(*this); } @@ -70,7 +73,7 @@ void CelPropertiesCommand::onExecute(Context* context) const Layer* layer = reader.layer(); const Cel* cel = reader.cel(); // Get current cel (can be NULL) - UniquePtr window(app::load_widget("cel_properties.xml", "cel_properties")); + base::UniquePtr window(app::load_widget("cel_properties.xml", "cel_properties")); Widget* label_frame = app::find_widget(window, "frame"); Widget* label_pos = app::find_widget(window, "pos"); Widget* label_size = app::find_widget(window, "size"); @@ -104,7 +107,7 @@ void CelPropertiesCommand::onExecute(Context* context) label_size->setTextf("%dx%d (%s)", sprite->getStock()->getImage(cel->getImage())->w, sprite->getStock()->getImage(cel->getImage())->h, - get_pretty_memory_size(memsize).c_str()); + base::get_pretty_memory_size(memsize).c_str()); // Opacity slider_opacity->setValue(cel->getOpacity()); @@ -149,10 +152,9 @@ void CelPropertiesCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCelPropertiesCommand() { return new CelPropertiesCommand; } + +} // namespace app diff --git a/src/commands/cmd_change_color.cpp b/src/app/commands/cmd_change_color.cpp similarity index 93% rename from src/commands/cmd_change_color.cpp rename to src/app/commands/cmd_change_color.cpp index 98367b9f1..f4b0f97ce 100644 --- a/src/commands/cmd_change_color.cpp +++ b/src/app/commands/cmd_change_color.cpp @@ -16,15 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "commands/command.h" -#include "commands/params.h" -#include "app.h" -#include "widgets/color_bar.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/ui/color_bar.h" +namespace app { + class ChangeColorCommand : public Command { enum Change { @@ -104,10 +108,9 @@ void ChangeColorCommand::onExecute(Context* context) colorbar->setFgColor(color); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createChangeColorCommand() { return new ChangeColorCommand; } + +} // namespace app diff --git a/src/commands/cmd_change_image_type.cpp b/src/app/commands/cmd_change_image_type.cpp similarity index 89% rename from src/commands/cmd_change_image_type.cpp rename to src/app/commands/cmd_change_image_type.cpp index 1ba016196..f5ef75b19 100644 --- a/src/commands/cmd_change_image_type.cpp +++ b/src/app/commands/cmd_change_image_type.cpp @@ -16,24 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "commands/params.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" -#include "modules/palettes.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/undo_transaction.h" #include "raster/dithering_method.h" #include "raster/image.h" #include "raster/sprite.h" -#include "undo_transaction.h" #include -class ChangePixelFormatCommand : public Command -{ +namespace app { + +class ChangePixelFormatCommand : public Command { PixelFormat m_format; DitheringMethod m_dithering; public: @@ -114,10 +117,9 @@ void ChangePixelFormatCommand::onExecute(Context* context) app_refresh_screen(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createChangePixelFormatCommand() { return new ChangePixelFormatCommand; } + +} // namespace app diff --git a/src/commands/cmd_change_pen.cpp b/src/app/commands/cmd_change_pen.cpp similarity index 89% rename from src/commands/cmd_change_pen.cpp rename to src/app/commands/cmd_change_pen.cpp index 86d8fad52..73b9d2ebd 100644 --- a/src/commands/cmd_change_pen.cpp +++ b/src/app/commands/cmd_change_pen.cpp @@ -16,19 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "app.h" -#include "commands/command.h" -#include "commands/params.h" -#include "context.h" -#include "settings/settings.h" -#include "tools/tool.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/context.h" +#include "app/settings/settings.h" +#include "app/tools/tool.h" -class ChangePenCommand : public Command -{ +namespace app { + +class ChangePenCommand : public Command { enum Change { None, IncrementSize, @@ -93,10 +96,9 @@ void ChangePenCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createChangePenCommand() { return new ChangePenCommand; } + +} // namespace app diff --git a/src/commands/cmd_clear.cpp b/src/app/commands/cmd_clear.cpp similarity index 83% rename from src/commands/cmd_clear.cpp rename to src/app/commands/cmd_clear.cpp index 76c57b538..9d50d9f72 100644 --- a/src/commands/cmd_clear.cpp +++ b/src/app/commands/cmd_clear.cpp @@ -16,25 +16,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "document_location.h" -#include "modules/gui.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/document_location.h" +#include "app/modules/gui.h" +#include "app/ui/color_bar.h" +#include "app/undo_transaction.h" #include "raster/layer.h" #include "raster/mask.h" #include "undo/undo_history.h" -#include "undo_transaction.h" -#include "widgets/color_bar.h" -////////////////////////////////////////////////////////////////////// -// ClearCommand +namespace app { -class ClearCommand : public Command -{ +class ClearCommand : public Command { public: ClearCommand(); Command* clone() const { return new ClearCommand(*this); } @@ -79,10 +79,9 @@ void ClearCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createClearCommand() { return new ClearCommand; } + +} // namespace app diff --git a/src/commands/cmd_close_file.cpp b/src/app/commands/cmd_close_file.cpp similarity index 85% rename from src/commands/cmd_close_file.cpp rename to src/app/commands/cmd_close_file.cpp index ceae22f2a..d49584da8 100644 --- a/src/commands/cmd_close_file.cpp +++ b/src/app/commands/cmd_close_file.cpp @@ -16,35 +16,34 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/context_access.h" +#include "app/document_access.h" +#include "app/modules/editors.h" +#include "app/ui/document_view.h" +#include "app/ui/main_window.h" +#include "app/ui/status_bar.h" +#include "app/ui/workspace.h" +#include "app/ui_context.h" #include "base/path.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "context_access.h" -#include "document_access.h" -#include "modules/editors.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "widgets/document_view.h" -#include "widgets/main_window.h" -#include "widgets/status_bar.h" -#include "widgets/workspace.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; -using namespace widgets; static bool close_active_document(Context* context); -////////////////////////////////////////////////////////////////////// -// close_file - -class CloseFileCommand : public Command -{ +class CloseFileCommand : public Command { public: CloseFileCommand() : Command("CloseFile", @@ -91,11 +90,7 @@ private: static char* read_authors_txt(const char *filename); }; -////////////////////////////////////////////////////////////////////// -// close_all_files - -class CloseAllFilesCommand : public Command -{ +class CloseAllFilesCommand : public Command { public: CloseAllFilesCommand() : Command("CloseAllFiles", @@ -127,8 +122,6 @@ protected: }; -////////////////////////////////////////////////////////////////////// - // Closes the active document, asking to the user to save it if it is // modified. static bool close_active_document(Context* context) @@ -192,9 +185,6 @@ static bool close_active_document(Context* context) return true; } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCloseFileCommand() { return new CloseFileCommand; @@ -204,3 +194,5 @@ Command* CommandFactory::createCloseAllFilesCommand() { return new CloseAllFilesCommand; } + +} // namespace app diff --git a/src/commands/cmd_configure_tools.cpp b/src/app/commands/cmd_configure_tools.cpp similarity index 84% rename from src/commands/cmd_configure_tools.cpp rename to src/app/commands/cmd_configure_tools.cpp index 3f77cbc36..d31b69c88 100644 --- a/src/commands/cmd_configure_tools.cpp +++ b/src/app/commands/cmd_configure_tools.cpp @@ -16,33 +16,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/console.h" +#include "app/context_access.h" #include "app/find_widget.h" #include "app/load_widget.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/ui/color_button.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" +#include "app/ui_context.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "console.h" -#include "context_access.h" #include "gfx/size.h" -#include "modules/gfx.h" -#include "modules/gui.h" #include "raster/mask.h" -#include "settings/document_settings.h" -#include "settings/settings.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "widgets/color_button.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" #include +namespace app { + using namespace gfx; using namespace ui; -using namespace tools; +using namespace app::tools; static Window* window = NULL; @@ -55,10 +59,7 @@ static void on_exit_delete_this_widget() delete window; } -////////////////////////////////////////////////////////////////////// - -class ConfigureTools : public Command -{ +class ConfigureTools : public Command { public: ConfigureTools(); Command* clone() const { return new ConfigureTools(*this); } @@ -134,10 +135,10 @@ void ConfigureTools::onExecute(Context* context) Tool* current_tool = m_settings->getCurrentTool(); IToolSettings* tool_settings = m_settings->getToolSettings(current_tool); - if (m_docSettings->getTiledMode() != TILED_NONE) { + if (m_docSettings->getTiledMode() != filters::TILED_NONE) { m_tiled->setSelected(true); - if (m_docSettings->getTiledMode() & TILED_X_AXIS) m_tiledX->setSelected(true); - if (m_docSettings->getTiledMode() & TILED_Y_AXIS) m_tiledY->setSelected(true); + if (m_docSettings->getTiledMode() & filters::TILED_X_AXIS) m_tiledX->setSelected(true); + if (m_docSettings->getTiledMode() & filters::TILED_Y_AXIS) m_tiledY->setSelected(true); } if (m_docSettings->getSnapToGrid()) m_snapToGrid->setSelected(true); @@ -149,8 +150,8 @@ void ConfigureTools::onExecute(Context* context) // Slots window->Close.connect(Bind(&ConfigureTools::onWindowClose, this)); m_tiled->Click.connect(Bind(&ConfigureTools::onTiledClick, this)); - m_tiledX->Click.connect(Bind(&ConfigureTools::onTiledXYClick, this, TILED_X_AXIS, m_tiledX)); - m_tiledY->Click.connect(Bind(&ConfigureTools::onTiledXYClick, this, TILED_Y_AXIS, m_tiledY)); + m_tiledX->Click.connect(Bind(&ConfigureTools::onTiledXYClick, this, filters::TILED_X_AXIS, m_tiledX)); + m_tiledY->Click.connect(Bind(&ConfigureTools::onTiledXYClick, this, filters::TILED_Y_AXIS, m_tiledY)); m_viewGrid->Click.connect(Bind(&ConfigureTools::onViewGridClick, this)); m_pixelGrid->Click.connect(Bind(&ConfigureTools::onPixelGridClick, this)); set_grid->Click.connect(Bind(&ConfigureTools::onSetGridClick, this)); @@ -179,7 +180,8 @@ void ConfigureTools::onTiledClick() { bool flag = m_tiled->isSelected(); - m_docSettings->setTiledMode(flag ? TILED_BOTH: TILED_NONE); + m_docSettings->setTiledMode(flag ? filters::TILED_BOTH: + filters::TILED_NONE); m_tiledX->setSelected(flag); m_tiledY->setSelected(flag); @@ -194,9 +196,9 @@ void ConfigureTools::onTiledXYClick(int tiled_axis, CheckBox* checkbox) else tiled_mode &= ~tiled_axis; - checkbox->findSibling("tiled")->setSelected(tiled_mode != TILED_NONE); + checkbox->findSibling("tiled")->setSelected(tiled_mode != filters::TILED_NONE); - m_docSettings->setTiledMode((TiledMode)tiled_mode); + m_docSettings->setTiledMode((filters::TiledMode)tiled_mode); } void ConfigureTools::onSnapToGridClick() @@ -243,10 +245,9 @@ void ConfigureTools::onOnionSkinClick() m_docSettings->setUseOnionskin(m_onionSkin->isSelected()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createConfigureToolsCommand() { return new ConfigureTools; } + +} // namespace app diff --git a/src/commands/cmd_copy.cpp b/src/app/commands/cmd_copy.cpp similarity index 86% rename from src/commands/cmd_copy.cpp rename to src/app/commands/cmd_copy.cpp index de391a67d..fcb19e23f 100644 --- a/src/commands/cmd_copy.cpp +++ b/src/app/commands/cmd_copy.cpp @@ -16,19 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/util/clipboard.h" +#include "app/util/misc.h" #include "raster/layer.h" #include "raster/mask.h" #include "raster/sprite.h" #include "ui/base.h" -#include "util/clipboard.h" -#include "util/misc.h" -class CopyCommand : public Command -{ +namespace app { + +class CopyCommand : public Command { public: CopyCommand(); Command* clone() const { return new CopyCommand(*this); } @@ -57,13 +60,12 @@ bool CopyCommand::onEnabled(Context* context) void CopyCommand::onExecute(Context* context) { const ContextReader reader(context); - util::clipboard::copy(reader); + clipboard::copy(reader); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCopyCommand() { return new CopyCommand; } + +} // namespace app diff --git a/src/commands/cmd_copy_cel.cpp b/src/app/commands/cmd_copy_cel.cpp similarity index 85% rename from src/commands/cmd_copy_cel.cpp rename to src/app/commands/cmd_copy_cel.cpp index 121b93ce8..27cc72743 100644 --- a/src/commands/cmd_copy_cel.cpp +++ b/src/app/commands/cmd_copy_cel.cpp @@ -16,16 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" -#include "dialogs/aniedit.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/dialogs/aniedit.h" +#include "app/util/celmove.h" #include "ui/base.h" -#include "util/celmove.h" -class CopyCelCommand : public Command -{ +namespace app { + +class CopyCelCommand : public Command { public: CopyCelCommand(); Command* clone() const { return new CopyCelCommand(*this); } @@ -53,10 +56,9 @@ void CopyCelCommand::onExecute(Context* context) copy_cel(writer); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCopyCelCommand() { return new CopyCelCommand; } + +} // namespace app diff --git a/src/commands/cmd_crop.cpp b/src/app/commands/cmd_crop.cpp similarity index 84% rename from src/commands/cmd_crop.cpp rename to src/app/commands/cmd_crop.cpp index 845ba9928..fd2c5e337 100644 --- a/src/commands/cmd_crop.cpp +++ b/src/app/commands/cmd_crop.cpp @@ -16,28 +16,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color_utils.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/ui/color_bar.h" +#include "app/undo_transaction.h" +#include "app/util/autocrop.h" +#include "app/util/misc.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "undo_transaction.h" -#include "util/autocrop.h" -#include "util/misc.h" -#include "widgets/color_bar.h" -////////////////////////////////////////////////////////////////////// -// crop_sprite +namespace app { -class CropSpriteCommand : public Command -{ +class CropSpriteCommand : public Command { public: CropSpriteCommand(); Command* clone() const { return new CropSpriteCommand(*this); } @@ -78,11 +78,7 @@ void CropSpriteCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// autocrop_sprite - -class AutocropSpriteCommand : public Command -{ +class AutocropSpriteCommand : public Command { public: AutocropSpriteCommand(); Command* clone() const { return new AutocropSpriteCommand(*this); } @@ -122,9 +118,6 @@ void AutocropSpriteCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCropSpriteCommand() { return new CropSpriteCommand; @@ -134,3 +127,5 @@ Command* CommandFactory::createAutocropSpriteCommand() { return new AutocropSpriteCommand; } + +} // namespace app diff --git a/src/commands/cmd_cut.cpp b/src/app/commands/cmd_cut.cpp similarity index 86% rename from src/commands/cmd_cut.cpp rename to src/app/commands/cmd_cut.cpp index 772fbc9b8..ab1284da0 100644 --- a/src/commands/cmd_cut.cpp +++ b/src/app/commands/cmd_cut.cpp @@ -16,19 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/util/clipboard.h" +#include "app/util/misc.h" #include "raster/layer.h" #include "raster/mask.h" #include "raster/sprite.h" #include "ui/base.h" -#include "util/clipboard.h" -#include "util/misc.h" -class CutCommand : public Command -{ +namespace app { + +class CutCommand : public Command { public: CutCommand(); Command* clone() const { return new CutCommand(*this); } @@ -57,13 +60,12 @@ bool CutCommand::onEnabled(Context* context) void CutCommand::onExecute(Context* context) { ContextWriter writer(context); - util::clipboard::cut(writer); + clipboard::cut(writer); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createCutCommand() { return new CutCommand; } + +} // namespace app diff --git a/src/commands/cmd_deselect_mask.cpp b/src/app/commands/cmd_deselect_mask.cpp similarity index 83% rename from src/commands/cmd_deselect_mask.cpp rename to src/app/commands/cmd_deselect_mask.cpp index 1118b179a..c5676f7d1 100644 --- a/src/commands/cmd_deselect_mask.cpp +++ b/src/app/commands/cmd_deselect_mask.cpp @@ -16,21 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "undo_transaction.h" -////////////////////////////////////////////////////////////////////// -// deselect_mask +namespace app { -class DeselectMaskCommand : public Command -{ +class DeselectMaskCommand : public Command { public: DeselectMaskCommand(); Command* clone() const { return new DeselectMaskCommand(*this); } @@ -66,10 +66,9 @@ void DeselectMaskCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createDeselectMaskCommand() { return new DeselectMaskCommand; } + +} // namespace app diff --git a/src/commands/cmd_developer_console.cpp b/src/app/commands/cmd_developer_console.cpp similarity index 89% rename from src/commands/cmd_developer_console.cpp rename to src/app/commands/cmd_developer_console.cpp index 9b968c1f2..10e6ce195 100644 --- a/src/commands/cmd_developer_console.cpp +++ b/src/app/commands/cmd_developer_console.cpp @@ -16,21 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context.h" -#include "document.h" -#include "documents.h" +#include "app/commands/command.h" +#include "app/context.h" +#include "app/document.h" +#include "app/documents.h" #include "ui/box.h" #include "ui/button.h" #include "ui/combobox.h" #include "ui/window.h" +namespace app { + using namespace ui; -class DeveloperConsole : public Window -{ +class DeveloperConsole : public Window { public: DeveloperConsole() : Window(false, "Developer Console") @@ -60,8 +63,7 @@ private: ComboBox m_docs; }; -class DeveloperConsoleCommand : public Command -{ +class DeveloperConsoleCommand : public Command { public: DeveloperConsoleCommand(); ~DeveloperConsoleCommand(); @@ -99,10 +101,9 @@ void DeveloperConsoleCommand::onExecute(Context* context) m_devConsole->openWindow(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createDeveloperConsoleCommand() { return new DeveloperConsoleCommand; } + +} // namespace app diff --git a/src/commands/cmd_duplicate_layer.cpp b/src/app/commands/cmd_duplicate_layer.cpp similarity index 79% rename from src/commands/cmd_duplicate_layer.cpp rename to src/app/commands/cmd_duplicate_layer.cpp index 2b8bacab8..ba8b9e295 100644 --- a/src/commands/cmd_duplicate_layer.cpp +++ b/src/app/commands/cmd_duplicate_layer.cpp @@ -16,29 +16,29 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "console.h" -#include "context_access.h" -#include "document_api.h" -#include "document_undo.h" -#include "modules/editors.h" -#include "modules/gui.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/console.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/document_undo.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/ui/editor/editor.h" +#include "app/undo_transaction.h" +#include "app/undoers/add_layer.h" +#include "app/undoers/move_layer.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "undoers/add_layer.h" -#include "undoers/move_layer.h" -#include "widgets/editor/editor.h" +#include "ui/ui.h" -////////////////////////////////////////////////////////////////////// -// Duplicate Layer command +namespace app { -class DuplicateLayerCommand : public Command -{ +class DuplicateLayerCommand : public Command { public: DuplicateLayerCommand(); Command* clone() const { return new DuplicateLayerCommand(*this); } @@ -71,7 +71,7 @@ void DuplicateLayerCommand::onExecute(Context* context) LayerImage* sourceLayer = static_cast(writer.layer()); // Create a new layer - UniquePtr newLayerPtr(new LayerImage(sprite)); + base::UniquePtr newLayerPtr(new LayerImage(sprite)); // Disable undo because the layer content is added as a whole with // AddLayer() undoer. @@ -97,10 +97,9 @@ void DuplicateLayerCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createDuplicateLayerCommand() { return new DuplicateLayerCommand; } + +} // namespace app diff --git a/src/commands/cmd_duplicate_sprite.cpp b/src/app/commands/cmd_duplicate_sprite.cpp similarity index 84% rename from src/commands/cmd_duplicate_sprite.cpp rename to src/app/commands/cmd_duplicate_sprite.cpp index d9de7b540..317f6f8c6 100644 --- a/src/commands/cmd_duplicate_sprite.cpp +++ b/src/app/commands/cmd_duplicate_sprite.cpp @@ -16,29 +16,29 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" -#include "commands/command.h" -#include "context_access.h" -#include "ini_file.h" -#include "modules/editors.h" +#include "app/modules/editors.h" +#include "app/ui_context.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "ui_context.h" +#include "ui/ui.h" #include #include +namespace app { + using namespace ui; -////////////////////////////////////////////////////////////////////// -// duplicate_sprite - -class DuplicateSpriteCommand : public Command -{ +class DuplicateSpriteCommand : public Command { public: DuplicateSpriteCommand(); Command* clone() { return new DuplicateSpriteCommand(*this); } @@ -68,7 +68,7 @@ void DuplicateSpriteCommand::onExecute(Context* context) char buf[1024]; /* load the window widget */ - UniquePtr window(app::load_widget("duplicate_sprite.xml", "duplicate_sprite")); + base::UniquePtr window(app::load_widget("duplicate_sprite.xml", "duplicate_sprite")); src_name = window->findChild("src_name"); dst_name = window->findChild("dst_name"); @@ -101,10 +101,9 @@ void DuplicateSpriteCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createDuplicateSpriteCommand() { return new DuplicateSpriteCommand; } + +} // namespace app diff --git a/src/commands/cmd_exit.cpp b/src/app/commands/cmd_exit.cpp similarity index 84% rename from src/commands/cmd_exit.cpp rename to src/app/commands/cmd_exit.cpp index 4601c75f3..50aa78daf 100644 --- a/src/commands/cmd_exit.cpp +++ b/src/app/commands/cmd_exit.cpp @@ -16,20 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "context.h" -#include "document.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context.h" +#include "app/document.h" +#include "app/ui/main_window.h" #include "ui/alert.h" -#include "widgets/main_window.h" -////////////////////////////////////////////////////////////////////// -// exit +namespace app { -class ExitCommand : public Command -{ +class ExitCommand : public Command { public: ExitCommand(); Command* clone() { return new ExitCommand(*this); } @@ -67,10 +67,9 @@ void ExitCommand::onExecute(Context* context) App::instance()->getMainWindow()->closeWindow(NULL); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createExitCommand() { return new ExitCommand; } + +} // namespace app diff --git a/src/commands/cmd_export_sprite_sheet.cpp b/src/app/commands/cmd_export_sprite_sheet.cpp similarity index 89% rename from src/commands/cmd_export_sprite_sheet.cpp rename to src/app/commands/cmd_export_sprite_sheet.cpp index 7875aa194..8e559bb7c 100644 --- a/src/commands/cmd_export_sprite_sheet.cpp +++ b/src/app/commands/cmd_export_sprite_sheet.cpp @@ -16,39 +16,39 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/context.h" +#include "app/context_access.h" +#include "app/document.h" +#include "app/document_api.h" +#include "app/document_undo.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/ui/editor/editor.h" +#include "app/undo_transaction.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "context.h" -#include "context_access.h" -#include "document.h" -#include "document_api.h" -#include "document_undo.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/palette.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "widgets/editor/editor.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; -////////////////////////////////////////////////////////////////////// -// ExportSpriteSheetFrame - -class ExportSpriteSheetWindow : public Window -{ +class ExportSpriteSheetWindow : public Window { enum SpriteSheetType { HorizontalStrip, VerticalStrip, Matrix }; enum ExportAction { SaveCopyAs, SaveAs, Save, DoNotSave }; @@ -144,8 +144,8 @@ protected: int sheet_w = sprite->getWidth()*columns; int sheet_h = sprite->getHeight()*((nframes/columns)+((nframes%columns)>0?1:0)); - UniquePtr resultImage(Image::create(sprite->getPixelFormat(), sheet_w, sheet_h)); - UniquePtr tempImage(Image::create(sprite->getPixelFormat(), sprite->getWidth(), sprite->getHeight())); + base::UniquePtr resultImage(Image::create(sprite->getPixelFormat(), sheet_w, sheet_h)); + base::UniquePtr tempImage(Image::create(sprite->getPixelFormat(), sprite->getWidth(), sprite->getHeight())); image_clear(resultImage, 0); int column = 0, row = 0; @@ -182,7 +182,7 @@ protected: resultImage.release(); // Create the cel. - UniquePtr resultCel(new Cel(FrameNumber(0), indexInStock)); + base::UniquePtr resultCel(new Cel(FrameNumber(0), indexInStock)); // Add the cel in the layer. api.addCel(resultLayer, resultCel); @@ -309,11 +309,7 @@ private: Button m_cancel; }; -////////////////////////////////////////////////////////////////////// -// ExportSpriteSheetCommand - -class ExportSpriteSheetCommand : public Command -{ +class ExportSpriteSheetCommand : public Command { public: ExportSpriteSheetCommand(); Command* clone() { return new ExportSpriteSheetCommand(*this); } @@ -337,14 +333,13 @@ bool ExportSpriteSheetCommand::onEnabled(Context* context) void ExportSpriteSheetCommand::onExecute(Context* context) { - UniquePtr window(new ExportSpriteSheetWindow(context)); + base::UniquePtr window(new ExportSpriteSheetWindow(context)); window->openWindowInForeground(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createExportSpriteSheetCommand() { return new ExportSpriteSheetCommand; } + +} // namespace app diff --git a/src/commands/cmd_eyedropper.cpp b/src/app/commands/cmd_eyedropper.cpp similarity index 85% rename from src/commands/cmd_eyedropper.cpp rename to src/app/commands/cmd_eyedropper.cpp index de7a884ed..805021085 100644 --- a/src/commands/cmd_eyedropper.cpp +++ b/src/app/commands/cmd_eyedropper.cpp @@ -16,28 +16,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "ui/gui.h" +#include "ui/ui.h" -#include "app.h" -#include "commands/command.h" -#include "commands/params.h" -#include "modules/editors.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/modules/editors.h" +#include "app/ui/color_bar.h" +#include "app/ui/editor/editor.h" #include "raster/image.h" #include "raster/sprite.h" -#include "widgets/color_bar.h" -#include "widgets/editor/editor.h" + +namespace app { using namespace ui; -////////////////////////////////////////////////////////////////////// -// eyedropper - -class EyedropperCommand : public Command -{ +class EyedropperCommand : public Command { /** * True means "pick background color", false the foreground color. */ @@ -97,10 +97,9 @@ void EyedropperCommand::onExecute(Context* context) ColorBar::instance()->setFgColor(color); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createEyedropperCommand() { return new EyedropperCommand; } + +} // namespace app diff --git a/src/commands/cmd_film_editor.cpp b/src/app/commands/cmd_film_editor.cpp similarity index 81% rename from src/commands/cmd_film_editor.cpp rename to src/app/commands/cmd_film_editor.cpp index 6556e4bbb..dfdbc390c 100644 --- a/src/commands/cmd_film_editor.cpp +++ b/src/app/commands/cmd_film_editor.cpp @@ -16,19 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "ui/gui.h" +#include "ui/ui.h" -#include "commands/command.h" -#include "context.h" -#include "dialogs/aniedit.h" +#include "app/commands/command.h" +#include "app/context.h" +#include "app/dialogs/aniedit.h" -////////////////////////////////////////////////////////////////////// -// film_editor +namespace app { -class FilmEditorCommand : public Command -{ +class FilmEditorCommand : public Command { public: FilmEditorCommand(); Command* clone() { return new FilmEditorCommand(*this); } @@ -55,10 +55,9 @@ void FilmEditorCommand::onExecute(Context* context) switch_between_animation_and_sprite_editor(context); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createFilmEditorCommand() { return new FilmEditorCommand; } + +} // namespace app diff --git a/src/commands/cmd_flatten_layers.cpp b/src/app/commands/cmd_flatten_layers.cpp similarity index 82% rename from src/commands/cmd_flatten_layers.cpp rename to src/app/commands/cmd_flatten_layers.cpp index 3e2c16827..6bbc51f6b 100644 --- a/src/commands/cmd_flatten_layers.cpp +++ b/src/app/commands/cmd_flatten_layers.cpp @@ -16,23 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color_utils.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/ui/color_bar.h" +#include "app/undo_transaction.h" #include "raster/sprite.h" -#include "undo_transaction.h" -#include "widgets/color_bar.h" -////////////////////////////////////////////////////////////////////// -// flatten_layers +namespace app { -class FlattenLayersCommand : public Command -{ +class FlattenLayersCommand : public Command { public: FlattenLayersCommand(); Command* clone() { return new FlattenLayersCommand(*this); } @@ -69,10 +69,9 @@ void FlattenLayersCommand::onExecute(Context* context) update_screen_for_document(writer.document()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createFlattenLayersCommand() { return new FlattenLayersCommand; } + +} // namespace app diff --git a/src/commands/cmd_flip.cpp b/src/app/commands/cmd_flip.cpp similarity index 94% rename from src/commands/cmd_flip.cpp rename to src/app/commands/cmd_flip.cpp index a7e21daed..bce31167d 100644 --- a/src/commands/cmd_flip.cpp +++ b/src/app/commands/cmd_flip.cpp @@ -16,23 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/cmd_flip.h" +#include "app/commands/cmd_flip.h" -#include "app.h" -#include "commands/params.h" -#include "context_access.h" -#include "document_api.h" +#include "app/app.h" +#include "app/commands/params.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" #include "gfx/size.h" -#include "modules/gui.h" #include "raster/algorithm/flip_image.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "undo_transaction.h" + +namespace app { FlipCommand::FlipCommand() : Command("Flip", @@ -115,7 +119,7 @@ void FlipCommand::onExecute(Context* context) Image* maskBitmap = mask->getBitmap(); if (maskBitmap != NULL) { // Create a flipped copy of the current mask. - UniquePtr newMask(new Mask(*mask)); + base::UniquePtr newMask(new Mask(*mask)); newMask->freeze(); raster::algorithm::flip_image(newMask->getBitmap(), gfx::Rect(gfx::Point(0, 0), @@ -165,10 +169,9 @@ void FlipCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createFlipCommand() { return new FlipCommand; } + +} // namespace app diff --git a/src/commands/cmd_flip.h b/src/app/commands/cmd_flip.h similarity index 57% rename from src/commands/cmd_flip.h rename to src/app/commands/cmd_flip.h index 292ca0b40..e5326bebd 100644 --- a/src/commands/cmd_flip.h +++ b/src/app/commands/cmd_flip.h @@ -16,28 +16,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMANDS_CMD_FLIP_H_INCLUDED -#define COMMANDS_CMD_FLIP_H_INCLUDED +#ifndef APP_COMMANDS_CMD_FLIP_H_INCLUDED +#define APP_COMMANDS_CMD_FLIP_H_INCLUDED -#include "commands/command.h" +#include "app/commands/command.h" #include "raster/algorithm/flip_type.h" -class FlipCommand : public Command -{ -public: - FlipCommand(); - Command* clone() const { return new FlipCommand(*this); } +namespace app { - raster::algorithm::FlipType getFlipType() const { return m_flipType; } + class FlipCommand : public Command { + public: + FlipCommand(); + Command* clone() const { return new FlipCommand(*this); } -protected: - void onLoadParams(Params* params); - bool onEnabled(Context* context); - void onExecute(Context* context); + raster::algorithm::FlipType getFlipType() const { return m_flipType; } -private: - bool m_flipMask; - raster::algorithm::FlipType m_flipType; -}; + protected: + void onLoadParams(Params* params); + bool onEnabled(Context* context); + void onExecute(Context* context); -#endif // COMMANDS_CMD_FLIP_H_INCLUDED + private: + bool m_flipMask; + raster::algorithm::FlipType m_flipType; + }; + +} // namespace app + +#endif // APP_COMMANDS_CMD_FLIP_H_INCLUDED diff --git a/src/commands/cmd_frame_properties.cpp b/src/app/commands/cmd_frame_properties.cpp similarity index 88% rename from src/commands/cmd_frame_properties.cpp rename to src/app/commands/cmd_frame_properties.cpp index a4a4402d9..50d367ae5 100644 --- a/src/commands/cmd_frame_properties.cpp +++ b/src/app/commands/cmd_frame_properties.cpp @@ -16,26 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/context_access.h" +#include "app/document_api.h" #include "app/find_widget.h" #include "app/load_widget.h" +#include "app/undo_transaction.h" #include "base/convert_to.h" -#include "commands/command.h" -#include "commands/params.h" -#include "context_access.h" -#include "document_api.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" +#include "ui/ui.h" + +namespace app { using namespace ui; -////////////////////////////////////////////////////////////////////// -// frame_properties - -class FramePropertiesCommand : public Command -{ +class FramePropertiesCommand : public Command { public: FramePropertiesCommand(); Command* clone() { return new FramePropertiesCommand(*this); } @@ -90,7 +90,7 @@ void FramePropertiesCommand::onExecute(Context* context) const ContextReader reader(context); const Sprite* sprite = reader.sprite(); - UniquePtr window(app::load_widget("frame_duration.xml", "frame_duration")); + base::UniquePtr window(app::load_widget("frame_duration.xml", "frame_duration")); Widget* frame = app::find_widget(window, "frame"); Widget* frlen = app::find_widget(window, "frlen"); Widget* ok = app::find_widget(window, "ok"); @@ -140,10 +140,9 @@ void FramePropertiesCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createFramePropertiesCommand() { return new FramePropertiesCommand; } + +} // namespace app diff --git a/src/commands/cmd_goto_frame.cpp b/src/app/commands/cmd_goto_frame.cpp similarity index 92% rename from src/commands/cmd_goto_frame.cpp rename to src/app/commands/cmd_goto_frame.cpp index 599c2ff0a..90eb5eb5d 100644 --- a/src/commands/cmd_goto_frame.cpp +++ b/src/app/commands/cmd_goto_frame.cpp @@ -16,24 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/params.h" #include "app/find_widget.h" #include "app/load_widget.h" -#include "commands/command.h" -#include "commands/params.h" -#include "modules/editors.h" -#include "modules/gui.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/ui/editor/editor.h" #include "raster/sprite.h" #include "ui/window.h" -#include "widgets/editor/editor.h" #include +namespace app { + using namespace ui; -class GotoCommand : public Command -{ +class GotoCommand : public Command { protected: GotoCommand(const char* short_name, const char* friendly_name) : Command(short_name, friendly_name, CmdRecordableFlag) { } @@ -145,7 +148,7 @@ protected: FrameNumber onGetFrame(Editor* editor) OVERRIDE { if (m_frame == 0) { - UniquePtr window(app::load_widget("goto_frame.xml", "goto_frame")); + base::UniquePtr window(app::load_widget("goto_frame.xml", "goto_frame")); Widget* frame = app::find_widget(window, "frame"); Widget* ok = app::find_widget(window, "ok"); @@ -167,9 +170,6 @@ private: int m_frame; }; -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createGotoFirstFrameCommand() { return new GotoFirstFrameCommand; @@ -194,3 +194,5 @@ Command* CommandFactory::createGotoFrameCommand() { return new GotoFrameCommand; } + +} // namespace app diff --git a/src/commands/cmd_goto_layer.cpp b/src/app/commands/cmd_goto_layer.cpp similarity index 86% rename from src/commands/cmd_goto_layer.cpp rename to src/app/commands/cmd_goto_layer.cpp index e8dc9f613..14c0827c9 100644 --- a/src/commands/cmd_goto_layer.cpp +++ b/src/app/commands/cmd_goto_layer.cpp @@ -16,23 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "context_access.h" -#include "modules/editors.h" -#include "modules/gui.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" -////////////////////////////////////////////////////////////////////// -// goto_previous_layer +namespace app { -class GotoPreviousLayerCommand : public Command -{ +class GotoPreviousLayerCommand : public Command { public: GotoPreviousLayerCommand(); Command* clone() { return new GotoPreviousLayerCommand(*this); } @@ -76,11 +76,7 @@ void GotoPreviousLayerCommand::onExecute(Context* context) location.layer()->getName().c_str()); } -////////////////////////////////////////////////////////////////////// -// goto_next_layer - -class GotoNextLayerCommand : public Command -{ +class GotoNextLayerCommand : public Command { public: GotoNextLayerCommand(); Command* clone() { return new GotoNextLayerCommand(*this); } @@ -124,9 +120,6 @@ void GotoNextLayerCommand::onExecute(Context* context) location.layer()->getName().c_str()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createGotoPreviousLayerCommand() { return new GotoPreviousLayerCommand; @@ -136,3 +129,5 @@ Command* CommandFactory::createGotoNextLayerCommand() { return new GotoNextLayerCommand; } + +} // namespace app diff --git a/src/commands/cmd_goto_tab.cpp b/src/app/commands/cmd_goto_tab.cpp similarity index 82% rename from src/commands/cmd_goto_tab.cpp rename to src/app/commands/cmd_goto_tab.cpp index 65c3fffbc..c97bf7a2f 100644 --- a/src/commands/cmd_goto_tab.cpp +++ b/src/app/commands/cmd_goto_tab.cpp @@ -16,16 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" +#include "app/commands/command.h" -#include "app.h" -#include "widgets/main_window.h" -#include "widgets/tabs.h" +#include "app/app.h" +#include "app/ui/main_window.h" +#include "app/ui/tabs.h" -class GotoNextTabCommand : public Command -{ +namespace app { + +class GotoNextTabCommand : public Command { public: GotoNextTabCommand(); Command* clone() { return new GotoNextTabCommand(*this); } @@ -46,12 +49,7 @@ void GotoNextTabCommand::onExecute(Context* context) App::instance()->getMainWindow()->getTabsBar()->selectNextTab(); } -////////////////////////////////////////////////////////////////////// -// goto_previous_tab - -class GotoPreviousTabCommand : public Command - -{ +class GotoPreviousTabCommand : public Command { public: GotoPreviousTabCommand(); Command* clone() { return new GotoPreviousTabCommand(*this); } @@ -72,9 +70,6 @@ void GotoPreviousTabCommand::onExecute(Context* context) App::instance()->getMainWindow()->getTabsBar()->selectPreviousTab(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createGotoNextTabCommand() { return new GotoNextTabCommand; @@ -84,3 +79,5 @@ Command* CommandFactory::createGotoPreviousTabCommand() { return new GotoPreviousTabCommand; } + +} // namespace app diff --git a/src/commands/cmd_grid.cpp b/src/app/commands/cmd_grid.cpp similarity index 83% rename from src/commands/cmd_grid.cpp rename to src/app/commands/cmd_grid.cpp index 099a89441..20c0d1fd9 100644 --- a/src/commands/cmd_grid.cpp +++ b/src/app/commands/cmd_grid.cpp @@ -16,30 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context.h" #include "app/find_widget.h" #include "app/load_widget.h" -#include "commands/command.h" -#include "context.h" -#include "modules/editors.h" -#include "settings/document_settings.h" -#include "settings/settings.h" +#include "app/modules/editors.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/ui/status_bar.h" +#include "app/ui_context.h" #include "ui/window.h" -#include "ui_context.h" -#include "widgets/status_bar.h" #include +namespace app { + using namespace ui; using namespace gfx; -////////////////////////////////////////////////////////////////////// -// show_grid - -class ShowGridCommand : public Command -{ +class ShowGridCommand : public Command { public: ShowGridCommand() : Command("ShowGrid", @@ -66,11 +66,7 @@ protected: } }; -////////////////////////////////////////////////////////////////////// -// snap_to_grid - -class SnapToGridCommand : public Command -{ +class SnapToGridCommand : public Command { public: SnapToGridCommand() : Command("SnapToGrid", @@ -103,11 +99,7 @@ protected: } }; -////////////////////////////////////////////////////////////////////// -// grid_settings - -class GridSettingsCommand : public Command -{ +class GridSettingsCommand : public Command { public: GridSettingsCommand(); Command* clone() const { return new GridSettingsCommand(*this); } @@ -131,7 +123,7 @@ bool GridSettingsCommand::onEnabled(Context* context) void GridSettingsCommand::onExecute(Context* context) { - UniquePtr window(app::load_widget("grid_settings.xml", "grid_settings")); + base::UniquePtr window(app::load_widget("grid_settings.xml", "grid_settings")); Widget* button_ok = app::find_widget(window, "ok"); Widget* grid_x = app::find_widget(window, "grid_x"); Widget* grid_y = app::find_widget(window, "grid_y"); @@ -160,9 +152,6 @@ void GridSettingsCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createShowGridCommand() { return new ShowGridCommand; @@ -177,3 +166,5 @@ Command* CommandFactory::createGridSettingsCommand() { return new GridSettingsCommand; } + +} // namespace app diff --git a/src/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp similarity index 88% rename from src/commands/cmd_import_sprite_sheet.cpp rename to src/app/commands/cmd_import_sprite_sheet.cpp index 2fe63cedb..fac53cfa5 100644 --- a/src/commands/cmd_import_sprite_sheet.cpp +++ b/src/app/commands/cmd_import_sprite_sheet.cpp @@ -16,45 +16,45 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/context.h" +#include "app/context_access.h" +#include "app/document_access.h" +#include "app/document_api.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/ui/drop_down_button.h" +#include "app/ui/editor/editor.h" +#include "app/ui/editor/editor_decorator.h" +#include "app/ui/editor/select_box_state.h" +#include "app/ui/editor/standby_state.h" +#include "app/ui/workspace.h" +#include "app/undo_transaction.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "context.h" -#include "context_access.h" -#include "document_access.h" -#include "document_api.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/palette.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "widgets/drop_down_button.h" -#include "widgets/editor/editor.h" -#include "widgets/editor/editor_decorator.h" -#include "widgets/editor/select_box_state.h" -#include "widgets/editor/standby_state.h" -#include "widgets/workspace.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; -////////////////////////////////////////////////////////////////////// -// ImportSpriteSheetWindow - class ImportSpriteSheetWindow : public Window, - public SelectBoxDelegate -{ + public SelectBoxDelegate { public: ImportSpriteSheetWindow(Context* context) : Window(false, "Import Sprite Sheet") @@ -165,7 +165,7 @@ protected: // As first step, we cut each tile and add them into "animation" list. for (int y=m_rect.y; ygetHeight(); y += m_rect.h) { for (int x=m_rect.x; xgetWidth(); x += m_rect.w) { - UniquePtr resultImage(Image::create(sprite->getPixelFormat(), m_rect.w, m_rect.h)); + base::UniquePtr resultImage(Image::create(sprite->getPixelFormat(), m_rect.w, m_rect.h)); // Clear the image with mask color. image_clear(resultImage, 0); @@ -203,7 +203,7 @@ protected: animation[i] = NULL; // Create the cel. - UniquePtr resultCel(new Cel(FrameNumber(i), indexInStock)); + base::UniquePtr resultCel(new Cel(FrameNumber(i), indexInStock)); // Add the cel in the layer. api.addCel(resultLayer, resultCel); @@ -343,11 +343,7 @@ private: bool m_fileOpened; }; -////////////////////////////////////////////////////////////////////// -// ImportSpriteSheetCommand - -class ImportSpriteSheetCommand : public Command -{ +class ImportSpriteSheetCommand : public Command { public: ImportSpriteSheetCommand(); Command* clone() { return new ImportSpriteSheetCommand(*this); } @@ -365,14 +361,13 @@ ImportSpriteSheetCommand::ImportSpriteSheetCommand() void ImportSpriteSheetCommand::onExecute(Context* context) { - UniquePtr window(new ImportSpriteSheetWindow(context)); + base::UniquePtr window(new ImportSpriteSheetWindow(context)); window->openWindowInForeground(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createImportSpriteSheetCommand() { return new ImportSpriteSheetCommand; } + +} // namespace app diff --git a/src/commands/cmd_invert_mask.cpp b/src/app/commands/cmd_invert_mask.cpp similarity index 88% rename from src/commands/cmd_invert_mask.cpp rename to src/app/commands/cmd_invert_mask.cpp index baca07fe0..e3d732af8 100644 --- a/src/commands/cmd_invert_mask.cpp +++ b/src/app/commands/cmd_invert_mask.cpp @@ -16,24 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/context_access.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" +#include "app/undoers/set_mask.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "context_access.h" -#include "modules/gui.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "undo_transaction.h" -#include "undoers/set_mask.h" -////////////////////////////////////////////////////////////////////// -// invert_mask +namespace app { -class InvertMaskCommand : public Command -{ +class InvertMaskCommand : public Command { public: InvertMaskCommand(); Command* clone() { return new InvertMaskCommand(*this); } @@ -82,7 +82,7 @@ void InvertMaskCommand::onExecute(Context* context) undo.pushUndoer(new undoers::SetMask(undo.getObjects(), document)); /* create a new mask */ - UniquePtr mask(new Mask()); + base::UniquePtr mask(new Mask()); /* select all the sprite area */ mask->replace(0, 0, sprite->getWidth(), sprite->getHeight()); @@ -116,10 +116,9 @@ void InvertMaskCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createInvertMaskCommand() { return new InvertMaskCommand; } + +} // namespace app diff --git a/src/commands/cmd_launch.cpp b/src/app/commands/cmd_launch.cpp similarity index 83% rename from src/commands/cmd_launch.cpp rename to src/app/commands/cmd_launch.cpp index d21c4ad0a..0a6e8db89 100644 --- a/src/commands/cmd_launch.cpp +++ b/src/app/commands/cmd_launch.cpp @@ -16,21 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/launcher.h" +#include "app/resource_finder.h" #include "base/compiler_specific.h" -#include "commands/command.h" -#include "commands/params.h" -#include "launcher.h" -#include "resource_finder.h" #include -////////////////////////////////////////////////////////////////////// -// launch +namespace app { -class LaunchCommand : public Command -{ +class LaunchCommand : public Command { public: LaunchCommand(); Command* clone() const { return new LaunchCommand(*this); } @@ -71,7 +71,7 @@ void LaunchCommand::onExecute(Context* context) switch (m_type) { case Url: - Launcher::openUrl(m_path); + launcher::open_url(m_path); break; case FileInDocs: @@ -83,7 +83,7 @@ void LaunchCommand::onExecute(Context* context) if (!exists(path)) continue; - Launcher::openFile(path); + launcher::open_file(path); break; } } @@ -92,10 +92,9 @@ void LaunchCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createLaunchCommand() { return new LaunchCommand; } + +} // namespace app diff --git a/src/commands/cmd_layer_from_background.cpp b/src/app/commands/cmd_layer_from_background.cpp similarity index 84% rename from src/commands/cmd_layer_from_background.cpp rename to src/app/commands/cmd_layer_from_background.cpp index 90a1508cc..2a801b8d1 100644 --- a/src/commands/cmd_layer_from_background.cpp +++ b/src/app/commands/cmd_layer_from_background.cpp @@ -16,22 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" +#include "ui/ui.h" -////////////////////////////////////////////////////////////////////// -// layer_from_background +namespace app { -class LayerFromBackgroundCommand : public Command -{ +class LayerFromBackgroundCommand : public Command { public: LayerFromBackgroundCommand(); Command* clone() { return new LayerFromBackgroundCommand(*this); } @@ -71,10 +71,9 @@ void LayerFromBackgroundCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createLayerFromBackgroundCommand() { return new LayerFromBackgroundCommand; } + +} // namespace app diff --git a/src/commands/cmd_layer_properties.cpp b/src/app/commands/cmd_layer_properties.cpp similarity index 86% rename from src/commands/cmd_layer_properties.cpp rename to src/app/commands/cmd_layer_properties.cpp index 1ed75fb97..9f0e9dccb 100644 --- a/src/commands/cmd_layer_properties.cpp +++ b/src/app/commands/cmd_layer_properties.cpp @@ -16,25 +16,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "base/bind.h" -#include "ui/gui.h" +#include "ui/ui.h" -#include "app.h" -#include "commands/command.h" -#include "context_access.h" -#include "modules/gui.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/modules/gui.h" #include "raster/image.h" #include "raster/layer.h" +namespace app { + using namespace ui; -////////////////////////////////////////////////////////////////////// -// layer_properties - -class LayerPropertiesCommand : public Command -{ +class LayerPropertiesCommand : public Command { public: LayerPropertiesCommand(); Command* clone() { return new LayerPropertiesCommand(*this); } @@ -62,7 +62,7 @@ void LayerPropertiesCommand::onExecute(Context* context) const ContextReader reader(context); const Layer* layer = reader.layer(); - UniquePtr window(new Window(false, "Layer Properties")); + base::UniquePtr window(new Window(false, "Layer Properties")); Box* box1 = new Box(JI_VERTICAL); Box* box2 = new Box(JI_HORIZONTAL); Box* box3 = new Box(JI_HORIZONTAL + JI_HOMOGENEOUS); @@ -99,10 +99,9 @@ void LayerPropertiesCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createLayerPropertiesCommand() { return new LayerPropertiesCommand; } + +} // namespace app diff --git a/src/commands/cmd_load_mask.cpp b/src/app/commands/cmd_load_mask.cpp similarity index 86% rename from src/commands/cmd_load_mask.cpp rename to src/app/commands/cmd_load_mask.cpp index 4cf97d086..14fa19bc1 100644 --- a/src/commands/cmd_load_mask.cpp +++ b/src/app/commands/cmd_load_mask.cpp @@ -16,22 +16,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/context_access.h" #include "app/file_selector.h" -#include "commands/command.h" -#include "commands/params.h" -#include "context_access.h" -#include "modules/gui.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" +#include "app/undoers/set_mask.h" +#include "app/util/msk_file.h" #include "raster/mask.h" #include "raster/sprite.h" #include "ui/alert.h" -#include "undo_transaction.h" -#include "undoers/set_mask.h" -#include "util/msk_file.h" -class LoadMaskCommand : public Command -{ +namespace app { + +class LoadMaskCommand : public Command { std::string m_filename; public: @@ -77,7 +80,7 @@ void LoadMaskCommand::onExecute(Context* context) m_filename = filename; } - UniquePtr mask(load_msk_file(m_filename.c_str())); + base::UniquePtr mask(load_msk_file(m_filename.c_str())); if (!mask) throw base::Exception("Error loading .msk file: %s", static_cast(m_filename.c_str())); @@ -99,10 +102,9 @@ void LoadMaskCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createLoadMaskCommand() { return new LoadMaskCommand; } + +} // namespace app diff --git a/src/commands/cmd_mask_all.cpp b/src/app/commands/cmd_mask_all.cpp similarity index 85% rename from src/commands/cmd_mask_all.cpp rename to src/app/commands/cmd_mask_all.cpp index 0e1d2420f..39afeb4a8 100644 --- a/src/commands/cmd_mask_all.cpp +++ b/src/app/commands/cmd_mask_all.cpp @@ -16,21 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" +#include "app/undoers/set_mask.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "undo_transaction.h" -#include "undoers/set_mask.h" -////////////////////////////////////////////////////////////////////// -// mask_all +namespace app { -class MaskAllCommand : public Command -{ +class MaskAllCommand : public Command { public: MaskAllCommand(); Command* clone() { return new MaskAllCommand(*this); } @@ -74,10 +74,9 @@ void MaskAllCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createMaskAllCommand() { return new MaskAllCommand; } + +} // namespace app diff --git a/src/commands/cmd_mask_by_color.cpp b/src/app/commands/cmd_mask_by_color.cpp similarity index 83% rename from src/commands/cmd_mask_by_color.cpp rename to src/app/commands/cmd_mask_by_color.cpp index a0912cf90..0f4f55014 100644 --- a/src/commands/cmd_mask_by_color.cpp +++ b/src/app/commands/cmd_mask_by_color.cpp @@ -16,17 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context.h" -#include "dialogs/maskcol.h" +#include "app/commands/command.h" +#include "app/context.h" +#include "app/dialogs/maskcol.h" -////////////////////////////////////////////////////////////////////// -// mask_by_color +namespace app { -class MaskByColorCommand : public Command -{ +class MaskByColorCommand : public Command { public: MaskByColorCommand(); Command* clone() { return new MaskByColorCommand(*this); } @@ -54,10 +54,9 @@ void MaskByColorCommand::onExecute(Context* context) dialogs_mask_color(context); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createMaskByColorCommand() { return new MaskByColorCommand; } + +} // namespace app diff --git a/src/commands/cmd_merge_down_layer.cpp b/src/app/commands/cmd_merge_down_layer.cpp similarity index 89% rename from src/commands/cmd_merge_down_layer.cpp rename to src/app/commands/cmd_merge_down_layer.cpp index 97c6b1854..3d852dc29 100644 --- a/src/commands/cmd_merge_down_layer.cpp +++ b/src/app/commands/cmd_merge_down_layer.cpp @@ -16,33 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" +#include "app/undoers/add_cel.h" +#include "app/undoers/add_image.h" +#include "app/undoers/remove_layer.h" +#include "app/undoers/replace_image.h" +#include "app/undoers/set_cel_position.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "context_access.h" -#include "document.h" -#include "document_api.h" -#include "modules/gui.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "undoers/add_cel.h" -#include "undoers/add_image.h" -#include "undoers/remove_layer.h" -#include "undoers/replace_image.h" -#include "undoers/set_cel_position.h" +#include "ui/ui.h" -////////////////////////////////////////////////////////////////////// -// merge_down_layer +namespace app { -class MergeDownLayerCommand : public Command -{ +class MergeDownLayerCommand : public Command { public: MergeDownLayerCommand(); Command* clone() { return new MergeDownLayerCommand(*this); } @@ -87,7 +87,7 @@ void MergeDownLayerCommand::onExecute(Context* context) Layer* dst_layer = src_layer->getPrevious(); Cel *src_cel, *dst_cel; Image *src_image; - UniquePtr dst_image; + base::UniquePtr dst_image; int index; for (FrameNumber frpos(0); frposgetTotalFrames(); ++frpos) { @@ -184,10 +184,9 @@ void MergeDownLayerCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createMergeDownLayerCommand() { return new MergeDownLayerCommand; } + +} // namespace app diff --git a/src/commands/cmd_move_cel.cpp b/src/app/commands/cmd_move_cel.cpp similarity index 85% rename from src/commands/cmd_move_cel.cpp rename to src/app/commands/cmd_move_cel.cpp index 2ebbc12d8..133a852b6 100644 --- a/src/commands/cmd_move_cel.cpp +++ b/src/app/commands/cmd_move_cel.cpp @@ -16,16 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "dialogs/aniedit.h" -#include "context_access.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/dialogs/aniedit.h" +#include "app/util/celmove.h" #include "ui/base.h" -#include "util/celmove.h" -class MoveCelCommand : public Command -{ +namespace app { + +class MoveCelCommand : public Command { public: MoveCelCommand(); Command* clone() const { return new MoveCelCommand(*this); } @@ -53,10 +56,9 @@ void MoveCelCommand::onExecute(Context* context) move_cel(writer); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createMoveCelCommand() { return new MoveCelCommand; } + +} // namespace app diff --git a/src/commands/cmd_new_file.cpp b/src/app/commands/cmd_new_file.cpp similarity index 89% rename from src/commands/cmd_new_file.cpp rename to src/app/commands/cmd_new_file.cpp index d1db343c7..af1c806b7 100644 --- a/src/commands/cmd_new_file.cpp +++ b/src/app/commands/cmd_new_file.cpp @@ -16,42 +16,42 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" +#include "app/commands/command.h" +#include "app/console.h" +#include "app/document.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" +#include "app/modules/editors.h" +#include "app/modules/palettes.h" +#include "app/ui/color_bar.h" +#include "app/ui/workspace.h" +#include "app/ui_context.h" +#include "app/util/clipboard.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "console.h" -#include "document.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/palettes.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/palette.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "util/clipboard.h" -#include "widgets/color_bar.h" -#include "widgets/workspace.h" +#include "ui/ui.h" #include #include using namespace ui; -////////////////////////////////////////////////////////////////////// -// new_file +namespace app { -class NewFileCommand : public Command -{ +class NewFileCommand : public Command { public: NewFileCommand(); Command* clone() { return new NewFileCommand(*this); } @@ -86,7 +86,7 @@ void NewFileCommand::onExecute(Context* context) }; // Load the window widget - UniquePtr window(app::load_widget("new_sprite.xml", "new_sprite")); + base::UniquePtr window(app::load_widget("new_sprite.xml", "new_sprite")); Widget* width = app::find_widget(window, "width"); Widget* height = app::find_widget(window, "height"); Widget* radio1 = app::find_widget(window, "radio1"); @@ -110,7 +110,7 @@ void NewFileCommand::onExecute(Context* context) // If the clipboard contains an image, we can show the size of the // clipboard as default image size. gfx::Size clipboardSize; - if (util::clipboard::get_image_size(clipboardSize)) { + if (clipboard::get_image_size(clipboardSize)) { w = clipboardSize.w; h = clipboardSize.h; } @@ -168,7 +168,7 @@ void NewFileCommand::onExecute(Context* context) ASSERT(format == IMAGE_RGB || format == IMAGE_GRAYSCALE || format == IMAGE_INDEXED); ASSERT(w > 0 && h > 0); - UniquePtr document( + base::UniquePtr document( Document::createBasicDocument(format, w, h, (format == IMAGE_INDEXED ? ncolors: 256))); Sprite* sprite(document->getSprite()); @@ -199,10 +199,9 @@ void NewFileCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createNewFileCommand() { return new NewFileCommand; } + +} // namespace app diff --git a/src/commands/cmd_new_frame.cpp b/src/app/commands/cmd_new_frame.cpp similarity index 83% rename from src/commands/cmd_new_frame.cpp rename to src/app/commands/cmd_new_frame.cpp index 25402afba..1bb48213a 100644 --- a/src/commands/cmd_new_frame.cpp +++ b/src/app/commands/cmd_new_frame.cpp @@ -16,30 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color.h" -#include "commands/command.h" -#include "console.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/console.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/ui/status_bar.h" +#include "app/undo_transaction.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" #include -////////////////////////////////////////////////////////////////////// -// new_frame - -class NewFrameCommand : public Command -{ +namespace app { + +class NewFrameCommand : public Command { public: NewFrameCommand(); Command* clone() { return new NewFrameCommand(*this); } @@ -84,10 +84,9 @@ void NewFrameCommand::onExecute(Context* context) (int)sprite->getTotalFrames()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createNewFrameCommand() { return new NewFrameCommand; } + +} // namespace app diff --git a/src/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp similarity index 87% rename from src/commands/cmd_new_layer.cpp rename to src/app/commands/cmd_new_layer.cpp index f8679f9b6..b678ded47 100644 --- a/src/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -16,31 +16,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/context_access.h" +#include "app/document_api.h" #include "app/find_widget.h" #include "app/load_widget.h" -#include "commands/command.h" -#include "commands/params.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/modules/gui.h" +#include "app/ui/status_bar.h" +#include "app/undo_transaction.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; -////////////////////////////////////////////////////////////////////// -// new_layer - -class NewLayerCommand : public Command -{ +class NewLayerCommand : public Command { public: NewLayerCommand(); Command* clone() { return new NewLayerCommand(*this); } @@ -97,7 +97,7 @@ void NewLayerCommand::onExecute(Context* context) // If params specify to ask the user about the name... if (m_ask) { // We open the window to ask the name - UniquePtr window(app::load_widget("new_layer.xml", "new_layer")); + base::UniquePtr window(app::load_widget("new_layer.xml", "new_layer")); Widget* name_widget = app::find_widget(window, "name"); name_widget->setText(name.c_str()); jwidget_set_min_size(name_widget, 128, 0); @@ -150,10 +150,9 @@ static int get_max_layer_num(Layer* layer) return max; } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createNewLayerCommand() { return new NewLayerCommand; } + +} // namespace app diff --git a/src/commands/cmd_new_layer_set.cpp b/src/app/commands/cmd_new_layer_set.cpp similarity index 80% rename from src/commands/cmd_new_layer_set.cpp rename to src/app/commands/cmd_new_layer_set.cpp index 0342b33c9..a4deb2310 100644 --- a/src/commands/cmd_new_layer_set.cpp +++ b/src/app/commands/cmd_new_layer_set.cpp @@ -16,29 +16,29 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/document_api.h" #include "app/find_widget.h" #include "app/load_widget.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/modules/gui.h" +#include "app/ui/status_bar.h" +#include "app/undo_transaction.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" + +namespace app { using namespace ui; -////////////////////////////////////////////////////////////////////// -// new_layer_set - -class NewLayerSetCommand : public Command -{ +class NewLayerSetCommand : public Command { public: NewLayerSetCommand(); Command* clone() { return new NewLayerSetCommand(*this); } @@ -68,7 +68,7 @@ void NewLayerSetCommand::onExecute(Context* context) Sprite* sprite(writer.sprite()); // load the window widget - UniquePtr window(app::load_widget("new_layer.xml", "new_layer_set")); + base::UniquePtr window(app::load_widget("new_layer.xml", "new_layer_set")); window->openWindowInForeground(); @@ -90,10 +90,9 @@ void NewLayerSetCommand::onExecute(Context* context) StatusBar::instance()->showTip(1000, "Layer `%s' created", name.c_str()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createNewLayerSetCommand() { return new NewLayerSetCommand; } + +} // namespace app diff --git a/src/commands/cmd_open_file.cpp b/src/app/commands/cmd_open_file.cpp similarity index 85% rename from src/commands/cmd_open_file.cpp rename to src/app/commands/cmd_open_file.cpp index 056416de7..2a66cc7b3 100644 --- a/src/commands/cmd_open_file.cpp +++ b/src/app/commands/cmd_open_file.cpp @@ -16,37 +16,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/console.h" +#include "app/document.h" +#include "app/file/file.h" #include "app/file_selector.h" +#include "app/job.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/recent_files.h" +#include "app/ui/status_bar.h" +#include "app/ui_context.h" #include "base/bind.h" #include "base/thread.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "commands/params.h" -#include "console.h" -#include "document.h" -#include "file/file.h" -#include "job.h" -#include "modules/editors.h" -#include "modules/gui.h" #include "raster/sprite.h" -#include "recent_files.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" #include #include static const int kMonitoringPeriod = 100; -////////////////////////////////////////////////////////////////////// -// open_file +namespace app { -class OpenFileCommand : public Command -{ +class OpenFileCommand : public Command { public: OpenFileCommand(); Command* clone() { return new OpenFileCommand(*this); } @@ -123,7 +123,7 @@ void OpenFileCommand::onExecute(Context* context) } if (!m_filename.empty()) { - UniquePtr fop(fop_to_load_document(m_filename.c_str(), FILE_LOAD_SEQUENCE_ASK)); + base::UniquePtr fop(fop_to_load_document(m_filename.c_str(), FILE_LOAD_SEQUENCE_ASK)); bool unrecent = false; if (fop) { @@ -165,10 +165,9 @@ void OpenFileCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createOpenFileCommand() { return new OpenFileCommand; } + +} // namespace app diff --git a/src/commands/cmd_open_in_folder.cpp b/src/app/commands/cmd_open_in_folder.cpp similarity index 82% rename from src/commands/cmd_open_in_folder.cpp rename to src/app/commands/cmd_open_in_folder.cpp index 90e696a29..2ade63790 100644 --- a/src/commands/cmd_open_in_folder.cpp +++ b/src/app/commands/cmd_open_in_folder.cpp @@ -16,17 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/context.h" +#include "app/context_access.h" +#include "app/document.h" +#include "app/launcher.h" #include "base/compiler_specific.h" -#include "commands/command.h" -#include "context.h" -#include "context_access.h" -#include "document.h" -#include "launcher.h" -class OpenInFolderCommand : public Command -{ +namespace app { + +class OpenInFolderCommand : public Command { public: OpenInFolderCommand(); Command* clone() { return new OpenInFolderCommand(*this); } @@ -53,13 +56,12 @@ bool OpenInFolderCommand::onEnabled(Context* context) void OpenInFolderCommand::onExecute(Context* context) { - Launcher::openFolder(context->getActiveDocument()->getFilename()); + launcher::open_folder(context->getActiveDocument()->getFilename()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createOpenInFolderCommand() { return new OpenInFolderCommand; } + +} // namespace app diff --git a/src/commands/cmd_open_with_app.cpp b/src/app/commands/cmd_open_with_app.cpp similarity index 82% rename from src/commands/cmd_open_with_app.cpp rename to src/app/commands/cmd_open_with_app.cpp index 91ac2d3f8..f6aab9333 100644 --- a/src/commands/cmd_open_with_app.cpp +++ b/src/app/commands/cmd_open_with_app.cpp @@ -16,17 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/context.h" +#include "app/context_access.h" +#include "app/document.h" +#include "app/launcher.h" #include "base/compiler_specific.h" -#include "commands/command.h" -#include "context.h" -#include "context_access.h" -#include "document.h" -#include "launcher.h" -class OpenWithAppCommand : public Command -{ +namespace app { + +class OpenWithAppCommand : public Command { public: OpenWithAppCommand(); Command* clone() { return new OpenWithAppCommand(*this); } @@ -53,13 +56,12 @@ bool OpenWithAppCommand::onEnabled(Context* context) void OpenWithAppCommand::onExecute(Context* context) { - Launcher::openFile(context->getActiveDocument()->getFilename()); + launcher::open_file(context->getActiveDocument()->getFilename()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createOpenWithAppCommand() { return new OpenWithAppCommand; } + +} // namespace app diff --git a/src/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp similarity index 91% rename from src/commands/cmd_options.cpp rename to src/app/commands/cmd_options.cpp index 134e10c1e..73f7548d1 100644 --- a/src/commands/cmd_options.cpp +++ b/src/app/commands/cmd_options.cpp @@ -16,32 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" +#include "app/modules/editors.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/ui/color_button.h" +#include "app/ui/editor/editor.h" +#include "app/util/render.h" #include "base/bind.h" -#include "commands/command.h" -#include "context.h" -#include "ini_file.h" -#include "modules/editors.h" #include "raster/image.h" -#include "settings/document_settings.h" -#include "ui/gui.h" -#include "util/render.h" -#include "widgets/color_button.h" -#include "widgets/editor/editor.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; -////////////////////////////////////////////////////////////////////// -// options - -class OptionsCommand : public Command -{ +class OptionsCommand : public Command { public: OptionsCommand(); Command* clone() { return new OptionsCommand(*this); } @@ -68,7 +69,7 @@ OptionsCommand::OptionsCommand() void OptionsCommand::onExecute(Context* context) { // Load the window widget - UniquePtr window(app::load_widget("options.xml", "options")); + base::UniquePtr window(app::load_widget("options.xml", "options")); Widget* check_smooth = app::find_widget(window, "smooth"); Widget* move_click2 = app::find_widget(window, "move_click2"); Widget* draw_click2 = app::find_widget(window, "draw_click2"); @@ -178,10 +179,9 @@ void OptionsCommand::onResetCheckedBg() m_checked_bg_color2->setColor(app::Color::fromRgb(192, 192, 192)); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createOptionsCommand() { return new OptionsCommand; } + +} // namespace app diff --git a/src/commands/cmd_palette_editor.cpp b/src/app/commands/cmd_palette_editor.cpp similarity index 96% rename from src/commands/cmd_palette_editor.cpp rename to src/app/commands/cmd_palette_editor.cpp index 4f77f3704..f3630ce8a 100644 --- a/src/commands/cmd_palette_editor.cpp +++ b/src/app/commands/cmd_palette_editor.cpp @@ -16,55 +16,60 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/console.h" +#include "app/context_access.h" +#include "app/document_undo.h" #include "app/file_selector.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/settings/settings.h" +#include "app/settings/settings.h" +#include "app/ui/color_bar.h" +#include "app/ui/color_sliders.h" +#include "app/ui/editor/editor.h" +#include "app/ui/hex_color_entry.h" +#include "app/ui/palette_view.h" +#include "app/ui/skin/skin_slider_property.h" +#include "app/ui/status_bar.h" +#include "app/ui/toolbar.h" +#include "app/ui_context.h" +#include "app/undo_transaction.h" +#include "app/undoers/set_palette_colors.h" #include "base/bind.h" #include "base/compiler_specific.h" -#include "commands/command.h" -#include "commands/params.h" -#include "console.h" -#include "context_access.h" -#include "document_undo.h" #include "gfx/hsv.h" #include "gfx/rgb.h" #include "gfx/size.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/image.h" #include "raster/palette.h" #include "raster/quantization.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "skin/skin_slider_property.h" #include "ui/graphics.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "undo_transaction.h" -#include "undoers/set_palette_colors.h" -#include "widgets/color_bar.h" -#include "widgets/color_sliders.h" -#include "widgets/editor/editor.h" -#include "widgets/hex_color_entry.h" -#include "widgets/palette_view.h" -#include "widgets/status_bar.h" -#include "widgets/toolbar.h" +#include "ui/ui.h" #include #include #include #include +namespace app { + using namespace gfx; using namespace ui; -class PaletteEntryEditor : public Window -{ +class PaletteEntryEditor : public Window { public: PaletteEntryEditor(); ~PaletteEntryEditor(); @@ -139,13 +144,9 @@ private: std::vector m_clipboardColors; }; -////////////////////////////////////////////////////////////////////// -// PaletteEditorCommand - static PaletteEntryEditor* g_window = NULL; -class PaletteEditorCommand : public Command -{ +class PaletteEditorCommand : public Command { public: PaletteEditorCommand(); Command* clone() { return new PaletteEditorCommand(*this); } @@ -869,10 +870,9 @@ void PaletteEntryEditor::onPalChange() } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createPaletteEditorCommand() { return new PaletteEditorCommand; } + +} // namespace app diff --git a/src/commands/cmd_paste.cpp b/src/app/commands/cmd_paste.cpp similarity index 81% rename from src/commands/cmd_paste.cpp rename to src/app/commands/cmd_paste.cpp index 153671264..1da4b6740 100644 --- a/src/commands/cmd_paste.cpp +++ b/src/app/commands/cmd_paste.cpp @@ -16,19 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context.h" +#include "app/commands/command.h" +#include "app/context.h" +#include "app/util/clipboard.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "util/clipboard.h" -////////////////////////////////////////////////////////////////////// -// paste +namespace app { -class PasteCommand : public Command -{ +class PasteCommand : public Command { public: PasteCommand(); Command* clone() { return new PasteCommand(*this); } @@ -48,7 +48,7 @@ PasteCommand::PasteCommand() bool PasteCommand::onEnabled(Context* context) { return - util::clipboard::can_paste() && + clipboard::can_paste() && context->checkFlags(ContextFlags::ActiveDocumentIsWritable | ContextFlags::ActiveLayerIsReadable | ContextFlags::ActiveLayerIsWritable | @@ -57,13 +57,12 @@ bool PasteCommand::onEnabled(Context* context) void PasteCommand::onExecute(Context* context) { - util::clipboard::paste(); + clipboard::paste(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createPasteCommand() { return new PasteCommand; } + +} // namespace app diff --git a/src/commands/cmd_play_animation.cpp b/src/app/commands/cmd_play_animation.cpp similarity index 89% rename from src/commands/cmd_play_animation.cpp rename to src/app/commands/cmd_play_animation.cpp index 400b9d0ef..5eb7cba78 100644 --- a/src/commands/cmd_play_animation.cpp +++ b/src/app/commands/cmd_play_animation.cpp @@ -16,29 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "ui/gui.h" +#include "ui/ui.h" -#include "commands/command.h" -#include "context.h" -#include "context_access.h" -#include "modules/editors.h" -#include "modules/gui.h" -#include "modules/palettes.h" +#include "app/commands/command.h" +#include "app/context.h" +#include "app/context_access.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/ui/editor/editor.h" #include "raster/image.h" #include "raster/palette.h" #include "raster/sprite.h" -#include "settings/document_settings.h" -#include "widgets/editor/editor.h" -////////////////////////////////////////////////////////////////////// -// play_animation +namespace app { -class PlayAnimationCommand : public Command -{ +class PlayAnimationCommand : public Command { public: PlayAnimationCommand(); Command* clone() { return new PlayAnimationCommand(*this); } @@ -165,10 +166,9 @@ void PlayAnimationCommand::onExecute(Context* context) ui::jmouse_show(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createPlayAnimationCommand() { return new PlayAnimationCommand; } + +} // namespace app diff --git a/src/commands/cmd_preview.cpp b/src/app/commands/cmd_preview.cpp similarity index 89% rename from src/commands/cmd_preview.cpp rename to src/app/commands/cmd_preview.cpp index 9a2d84ca0..c82b15e9d 100644 --- a/src/commands/cmd_preview.cpp +++ b/src/app/commands/cmd_preview.cpp @@ -16,38 +16,41 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "ui/gui.h" +#include "ui/ui.h" -#include "app.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "context.h" -#include "modules/editors.h" -#include "modules/gfx.h" -#include "modules/gui.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/context.h" +#include "app/modules/editors.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" +#include "app/util/render.h" #include "raster/image.h" #include "raster/palette.h" #include "raster/sprite.h" -#include "settings/document_settings.h" -#include "util/render.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" - -using namespace ui; #define PREVIEW_TILED 1 #define PREVIEW_FIT_ON_SCREEN 2 -////////////////////////////////////////////////////////////////////// -// base class +namespace app { -class PreviewCommand : public Command -{ +using namespace ui; +using namespace raster; +using namespace filters; + +class PreviewCommand : public Command { public: PreviewCommand(); Command* clone() { return new PreviewCommand(*this); } @@ -70,10 +73,7 @@ bool PreviewCommand::onEnabled(Context* context) ContextFlags::HasActiveSprite); } - -/** - * Shows the sprite using the complete screen. - */ +// Shows the sprite using the complete screen. void PreviewCommand::onExecute(Context* context) { Editor* editor = current_editor; @@ -92,7 +92,7 @@ void PreviewCommand::onExecute(Context* context) int u, v, x, y; int index_bg_color = -1; IDocumentSettings* docSettings = context->getSettings()->getDocumentSettings(document); - TiledMode tiled = docSettings->getTiledMode(); + filters::TiledMode tiled = docSettings->getTiledMode(); // Free mouse editor->getManager()->freeMouse(); @@ -121,8 +121,8 @@ void PreviewCommand::onExecute(Context* context) bool redraw = true; // Render the sprite - UniquePtr render; - UniquePtr doublebuf(Image::create(IMAGE_RGB, JI_SCREEN_W, JI_SCREEN_H)); + base::UniquePtr render; + base::UniquePtr doublebuf(Image::create(IMAGE_RGB, JI_SCREEN_W, JI_SCREEN_H)); do { // Update scroll @@ -245,10 +245,9 @@ void PreviewCommand::onExecute(Context* context) ui::Manager::getDefault()->invalidate(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createPreviewCommand() { return new PreviewCommand; } + +} // namespace app diff --git a/src/commands/cmd_refresh.cpp b/src/app/commands/cmd_refresh.cpp similarity index 84% rename from src/commands/cmd_refresh.cpp rename to src/app/commands/cmd_refresh.cpp index 657280e36..4555f65df 100644 --- a/src/commands/cmd_refresh.cpp +++ b/src/app/commands/cmd_refresh.cpp @@ -16,14 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "skin/skin_theme.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/ui/skin/skin_theme.h" +#include "app/ui/status_bar.h" #include "ui/system.h" #include "ui/theme.h" -#include "widgets/status_bar.h" #include @@ -33,11 +35,9 @@ #include #endif -////////////////////////////////////////////////////////////////////// -// refresh +namespace app { -class RefreshCommand : public Command -{ +class RefreshCommand : public Command { public: RefreshCommand(); Command* clone() { return new RefreshCommand(*this); } @@ -61,7 +61,7 @@ void RefreshCommand::onExecute(Context* context) // Reload skin { - SkinTheme* theme = (SkinTheme*)ui::CurrentTheme::get(); + skin::SkinTheme* theme = (skin::SkinTheme*)ui::CurrentTheme::get(); theme->reload_skin(); theme->regenerate(); } @@ -84,10 +84,9 @@ void RefreshCommand::onExecute(Context* context) #endif } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createRefreshCommand() { return new RefreshCommand; } + +} // namespace app diff --git a/src/commands/cmd_remove_cel.cpp b/src/app/commands/cmd_remove_cel.cpp similarity index 85% rename from src/commands/cmd_remove_cel.cpp rename to src/app/commands/cmd_remove_cel.cpp index 9549e4d6a..902452956 100644 --- a/src/commands/cmd_remove_cel.cpp +++ b/src/app/commands/cmd_remove_cel.cpp @@ -16,22 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/sprite.h" -#include "undo_transaction.h" -////////////////////////////////////////////////////////////////////// -// remove_cel +namespace app { -class RemoveCelCommand : public Command -{ +class RemoveCelCommand : public Command { public: RemoveCelCommand(); Command* clone() { return new RemoveCelCommand(*this); } @@ -70,10 +70,9 @@ void RemoveCelCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createRemoveCelCommand() { return new RemoveCelCommand; } + +} // namespace app diff --git a/src/commands/cmd_remove_frame.cpp b/src/app/commands/cmd_remove_frame.cpp similarity index 82% rename from src/commands/cmd_remove_frame.cpp rename to src/app/commands/cmd_remove_frame.cpp index d48d29ca8..dc6d8a822 100644 --- a/src/commands/cmd_remove_frame.cpp +++ b/src/app/commands/cmd_remove_frame.cpp @@ -16,21 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "undo_transaction.h" +#include "ui/ui.h" -////////////////////////////////////////////////////////////////////// -// remove_frame - -class RemoveFrameCommand : public Command -{ +namespace app { + +class RemoveFrameCommand : public Command { public: RemoveFrameCommand(); Command* clone() { return new RemoveFrameCommand(*this); } @@ -69,10 +69,9 @@ void RemoveFrameCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createRemoveFrameCommand() { return new RemoveFrameCommand; } + +} // namespace app diff --git a/src/commands/cmd_remove_layer.cpp b/src/app/commands/cmd_remove_layer.cpp similarity index 83% rename from src/commands/cmd_remove_layer.cpp rename to src/app/commands/cmd_remove_layer.cpp index 84b90f0b7..de043e6c5 100644 --- a/src/commands/cmd_remove_layer.cpp +++ b/src/app/commands/cmd_remove_layer.cpp @@ -16,24 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "modules/gui.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/ui/status_bar.h" +#include "app/undo_transaction.h" #include "raster/layer.h" #include "raster/sprite.h" #include "ui/widget.h" -#include "undo_transaction.h" -#include "widgets/status_bar.h" -////////////////////////////////////////////////////////////////////// -// remove_layer - -class RemoveLayerCommand : public Command -{ +namespace app { + +class RemoveLayerCommand : public Command { public: RemoveLayerCommand(); Command* clone() { return new RemoveLayerCommand(*this); } @@ -78,10 +78,9 @@ void RemoveLayerCommand::onExecute(Context* context) layer_name.c_str()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createRemoveLayerCommand() { return new RemoveLayerCommand; } + +} // namespace app diff --git a/src/commands/cmd_reselect_mask.cpp b/src/app/commands/cmd_reselect_mask.cpp similarity index 85% rename from src/commands/cmd_reselect_mask.cpp rename to src/app/commands/cmd_reselect_mask.cpp index 8afc26204..1bdeba956 100644 --- a/src/commands/cmd_reselect_mask.cpp +++ b/src/app/commands/cmd_reselect_mask.cpp @@ -16,21 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/command.h" -#include "context_access.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/modules/gui.h" +#include "app/undo_transaction.h" +#include "app/undoers/set_mask.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "undo_transaction.h" -#include "undoers/set_mask.h" -////////////////////////////////////////////////////////////////////// -// reselect_mask +namespace app { -class ReselectMaskCommand : public Command -{ +class ReselectMaskCommand : public Command { public: ReselectMaskCommand(); Command* clone() { return new ReselectMaskCommand(*this); } @@ -77,10 +77,9 @@ void ReselectMaskCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createReselectMaskCommand() { return new ReselectMaskCommand; } + +} // namespace app diff --git a/src/commands/cmd_rotate_canvas.cpp b/src/app/commands/cmd_rotate_canvas.cpp similarity index 91% rename from src/commands/cmd_rotate_canvas.cpp rename to src/app/commands/cmd_rotate_canvas.cpp index 69d2fedf1..a05e710dc 100644 --- a/src/commands/cmd_rotate_canvas.cpp +++ b/src/app/commands/cmd_rotate_canvas.cpp @@ -16,31 +16,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" -#include "commands/params.h" -#include "context_access.h" -#include "document_api.h" -#include "job.h" -#include "modules/gui.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/context_access.h" +#include "app/document_api.h" +#include "app/job.h" +#include "app/modules/gui.h" +#include "app/ui/color_bar.h" +#include "app/undo_transaction.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "widgets/color_bar.h" +#include "ui/ui.h" #include -////////////////////////////////////////////////////////////////////// -// rotate_canvas +namespace app { -class RotateCanvasCommand : public Command -{ +class RotateCanvasCommand : public Command { int m_angle; public: @@ -130,7 +130,7 @@ protected: // rotate mask if (m_document->isMaskVisible()) { Mask* origMask = m_document->getMask(); - UniquePtr new_mask(new Mask()); + base::UniquePtr new_mask(new Mask()); const gfx::Rect& origBounds = origMask->getBounds(); int x = 0, y = 0; @@ -205,10 +205,9 @@ void RotateCanvasCommand::onExecute(Context* context) update_screen_for_document(reader.document()); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createRotateCanvasCommand() { return new RotateCanvasCommand; } + +} // namespace app diff --git a/src/commands/cmd_save_file.cpp b/src/app/commands/cmd_save_file.cpp similarity index 88% rename from src/commands/cmd_save_file.cpp rename to src/app/commands/cmd_save_file.cpp index 0c3a688e3..faf855277 100644 --- a/src/commands/cmd_save_file.cpp +++ b/src/app/commands/cmd_save_file.cpp @@ -16,30 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/console.h" +#include "app/context_access.h" +#include "app/file/file.h" #include "app/file_selector.h" +#include "app/job.h" +#include "app/modules/gui.h" +#include "app/recent_files.h" +#include "app/ui/status_bar.h" #include "base/bind.h" #include "base/thread.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "console.h" -#include "context_access.h" -#include "file/file.h" -#include "job.h" -#include "modules/gui.h" #include "raster/sprite.h" -#include "recent_files.h" -#include "ui/gui.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" #include static const int kMonitoringPeriod = 100; -class SaveFileJob : public Job, public IFileOpProgress -{ +namespace app { + +class SaveFileJob : public Job, public IFileOpProgress { public: SaveFileJob(FileOp* fop, const char* filename) : Job("Saving file") @@ -74,7 +77,7 @@ private: static void save_document_in_background(Document* document, bool mark_as_saved) { - UniquePtr fop(fop_to_save_document(document)); + base::UniquePtr fop(fop_to_save_document(document)); if (!fop) return; @@ -96,7 +99,7 @@ static void save_document_in_background(Document* document, bool mark_as_saved) } } -/*********************************************************************/ +////////////////////////////////////////////////////////////////////// static void save_as_dialog(const ContextReader& reader, const char* dlg_title, bool mark_as_saved) { @@ -149,11 +152,7 @@ static void save_as_dialog(const ContextReader& reader, const char* dlg_title, b } } -////////////////////////////////////////////////////////////////////// -// save_file - -class SaveFileCommand : public Command -{ +class SaveFileCommand : public Command { public: SaveFileCommand(); Command* clone() { return new SaveFileCommand(*this); } @@ -201,11 +200,7 @@ void SaveFileCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// save_file_as - -class SaveFileAsCommand : public Command -{ +class SaveFileAsCommand : public Command { public: SaveFileAsCommand(); Command* clone() { return new SaveFileAsCommand(*this); } @@ -233,11 +228,7 @@ void SaveFileAsCommand::onExecute(Context* context) save_as_dialog(reader, "Save As", true); } -////////////////////////////////////////////////////////////////////// -// save_file_copy_as - -class SaveFileCopyAsCommand : public Command -{ +class SaveFileCopyAsCommand : public Command { public: SaveFileCopyAsCommand(); Command* clone() { return new SaveFileCopyAsCommand(*this); } @@ -276,9 +267,6 @@ void SaveFileCopyAsCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createSaveFileCommand() { return new SaveFileCommand; @@ -293,3 +281,5 @@ Command* CommandFactory::createSaveFileCopyAsCommand() { return new SaveFileCopyAsCommand; } + +} // namespace app diff --git a/src/commands/cmd_save_mask.cpp b/src/app/commands/cmd_save_mask.cpp similarity index 89% rename from src/commands/cmd_save_mask.cpp rename to src/app/commands/cmd_save_mask.cpp index deb829d55..66a8151ea 100644 --- a/src/commands/cmd_save_mask.cpp +++ b/src/app/commands/cmd_save_mask.cpp @@ -16,23 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include +#include "app/commands/command.h" +#include "app/context_access.h" #include "app/file_selector.h" -#include "commands/command.h" -#include "context_access.h" +#include "app/util/msk_file.h" #include "raster/mask.h" #include "raster/sprite.h" #include "ui/alert.h" -#include "util/msk_file.h" -////////////////////////////////////////////////////////////////////// -// save_mask +namespace app { -class SaveMaskCommand : public Command -{ +class SaveMaskCommand : public Command { public: SaveMaskCommand(); Command* clone() { return new SaveMaskCommand(*this); } @@ -89,10 +89,9 @@ void SaveMaskCommand::onExecute(Context* context) ui::Alert::show("Error<setEditorScroll(scroll.x+dx, scroll.y+dy, true); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createScrollCommand() { return new ScrollCommand; } + +} // namespace app diff --git a/src/commands/cmd_sprite_editor.cpp b/src/app/commands/cmd_sprite_editor.cpp similarity index 75% rename from src/commands/cmd_sprite_editor.cpp rename to src/app/commands/cmd_sprite_editor.cpp index 05b2cc316..7645c2a96 100644 --- a/src/commands/cmd_sprite_editor.cpp +++ b/src/app/commands/cmd_sprite_editor.cpp @@ -16,19 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "commands/command.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/ui/main_window.h" +#include "app/ui/workspace.h" #include "ui/base.h" -#include "widgets/main_window.h" -#include "widgets/workspace.h" -////////////////////////////////////////////////////////////////////// -// make_unique_editor +namespace app { -class MakeUniqueEditorCommand : public Command -{ +class MakeUniqueEditorCommand : public Command { public: MakeUniqueEditorCommand(); Command* clone() { return new MakeUniqueEditorCommand(*this); } @@ -46,16 +46,12 @@ MakeUniqueEditorCommand::MakeUniqueEditorCommand() void MakeUniqueEditorCommand::onExecute(Context* context) { - widgets::Workspace* workspace = App::instance()->getMainWindow()->getWorkspace(); + Workspace* workspace = App::instance()->getMainWindow()->getWorkspace(); if (workspace->getActiveView() != NULL) workspace->makeUnique(workspace->getActiveView()); } -////////////////////////////////////////////////////////////////////// -// split_editor_horizontally - -class SplitEditorHorizontallyCommand : public Command -{ +class SplitEditorHorizontallyCommand : public Command { public: SplitEditorHorizontallyCommand(); Command* clone() { return new SplitEditorHorizontallyCommand(*this); } @@ -73,16 +69,12 @@ SplitEditorHorizontallyCommand::SplitEditorHorizontallyCommand() void SplitEditorHorizontallyCommand::onExecute(Context* context) { - widgets::Workspace* workspace = App::instance()->getMainWindow()->getWorkspace(); + Workspace* workspace = App::instance()->getMainWindow()->getWorkspace(); if (workspace->getActiveView() != NULL) workspace->splitView(workspace->getActiveView(), JI_HORIZONTAL); } -////////////////////////////////////////////////////////////////////// -// split_editor_vertically - -class SplitEditorVerticallyCommand : public Command -{ +class SplitEditorVerticallyCommand : public Command { public: SplitEditorVerticallyCommand(); Command* clone() { return new SplitEditorVerticallyCommand(*this); } @@ -100,14 +92,11 @@ SplitEditorVerticallyCommand::SplitEditorVerticallyCommand() void SplitEditorVerticallyCommand::onExecute(Context* context) { - widgets::Workspace* workspace = App::instance()->getMainWindow()->getWorkspace(); + Workspace* workspace = App::instance()->getMainWindow()->getWorkspace(); if (workspace->getActiveView() != NULL) workspace->splitView(workspace->getActiveView(), JI_VERTICAL); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createMakeUniqueEditorCommand() { return new MakeUniqueEditorCommand; @@ -122,3 +111,5 @@ Command* CommandFactory::createSplitEditorVerticallyCommand() { return new SplitEditorVerticallyCommand; } + +} // namespace app diff --git a/src/commands/cmd_sprite_properties.cpp b/src/app/commands/cmd_sprite_properties.cpp similarity index 89% rename from src/commands/cmd_sprite_properties.cpp rename to src/app/commands/cmd_sprite_properties.cpp index 44c665b14..490450bdc 100644 --- a/src/commands/cmd_sprite_properties.cpp +++ b/src/app/commands/cmd_sprite_properties.cpp @@ -16,32 +16,32 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/color.h" +#include "app/commands/command.h" +#include "app/context_access.h" #include "app/find_widget.h" #include "app/load_widget.h" +#include "app/modules/gui.h" +#include "app/ui/color_button.h" #include "base/bind.h" #include "base/mem_utils.h" -#include "commands/command.h" -#include "context_access.h" -#include "modules/gui.h" #include "raster/image.h" #include "raster/palette.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "widgets/color_button.h" +#include "ui/ui.h" #include #include +namespace app { + using namespace ui; -////////////////////////////////////////////////////////////////////// -// sprite_properties - -class SpritePropertiesCommand : public Command -{ +class SpritePropertiesCommand : public Command { public: SpritePropertiesCommand(); Command* clone() { return new SpritePropertiesCommand(*this); } @@ -72,7 +72,7 @@ void SpritePropertiesCommand::onExecute(Context* context) ColorButton* color_button = NULL; // Load the window widget - UniquePtr window(app::load_widget("sprite_properties.xml", "sprite_properties")); + base::UniquePtr window(app::load_widget("sprite_properties.xml", "sprite_properties")); name = app::find_widget(window, "name"); type = app::find_widget(window, "type"); size = app::find_widget(window, "size"); @@ -114,7 +114,7 @@ void SpritePropertiesCommand::onExecute(Context* context) usprintf(buf, "%dx%d (%s)", sprite->getWidth(), sprite->getHeight(), - get_pretty_memory_size(sprite->getMemSize()).c_str()); + base::get_pretty_memory_size(sprite->getMemSize()).c_str()); size->setText(buf); @@ -158,10 +158,9 @@ void SpritePropertiesCommand::onExecute(Context* context) save_window_pos(window, "SpriteProperties"); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createSpritePropertiesCommand() { return new SpritePropertiesCommand; } + +} // namespace app diff --git a/src/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp similarity index 93% rename from src/commands/cmd_sprite_size.cpp rename to src/app/commands/cmd_sprite_size.cpp index 5ddea76df..81916b045 100644 --- a/src/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -16,36 +16,39 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_api.h" #include "app/find_widget.h" +#include "app/ini_file.h" +#include "app/job.h" #include "app/load_widget.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/ui_context.h" +#include "app/undo_transaction.h" #include "base/bind.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_api.h" -#include "ini_file.h" -#include "job.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "undo_transaction.h" +#include "ui/ui.h" #include -using namespace ui; - #define PERC_FORMAT "%.1f" -class SpriteSizeJob : public Job -{ +namespace app { + +using namespace ui; + +class SpriteSizeJob : public Job { ContextWriter m_writer; Document* m_document; Sprite* m_sprite; @@ -118,14 +121,14 @@ protected: // Resize mask if (m_document->isMaskVisible()) { - UniquePtr old_bitmap + base::UniquePtr old_bitmap (image_crop(m_document->getMask()->getBitmap(), -1, -1, m_document->getMask()->getBitmap()->w+2, m_document->getMask()->getBitmap()->h+2, 0)); int w = scale_x(old_bitmap->w); int h = scale_y(old_bitmap->h); - UniquePtr new_mask(new Mask); + base::UniquePtr new_mask(new Mask); new_mask->replace(scale_x(m_document->getMask()->getBounds().x-1), scale_y(m_document->getMask()->getBounds().y-1), MAX(1, w), MAX(1, h)); image_resize(old_bitmap, new_mask->getBitmap(), @@ -154,12 +157,7 @@ protected: }; -////////////////////////////////////////////////////////////////////// -// SpriteSize - -class SpriteSizeCommand : public Command - -{ +class SpriteSizeCommand : public Command { public: SpriteSizeCommand(); Command* clone() { return new SpriteSizeCommand(*this); } @@ -201,7 +199,7 @@ void SpriteSizeCommand::onExecute(Context* context) const Sprite* sprite(reader.sprite()); // load the window widget - UniquePtr window(app::load_widget("sprite_size.xml", "sprite_size")); + base::UniquePtr window(app::load_widget("sprite_size.xml", "sprite_size")); m_widthPx = app::find_widget(window, "width_px"); m_heightPx = app::find_widget(window, "height_px"); m_widthPerc = app::find_widget(window, "width_perc"); @@ -314,10 +312,9 @@ void SpriteSizeCommand::onHeightPercChange() } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createSpriteSizeCommand() { return new SpriteSizeCommand; } + +} // namespace app diff --git a/src/commands/cmd_switch_colors.cpp b/src/app/commands/cmd_switch_colors.cpp similarity index 86% rename from src/commands/cmd_switch_colors.cpp rename to src/app/commands/cmd_switch_colors.cpp index 6f46cbc8d..bd2cfc348 100644 --- a/src/commands/cmd_switch_colors.cpp +++ b/src/app/commands/cmd_switch_colors.cpp @@ -16,17 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "app.h" -#include "commands/command.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/ui/color_bar.h" #include "ui/base.h" -#include "widgets/color_bar.h" -class SwitchColorsCommand : public Command -{ +namespace app { + +class SwitchColorsCommand : public Command { public: SwitchColorsCommand(); @@ -51,10 +54,9 @@ void SwitchColorsCommand::onExecute(Context* context) colorbar->setBgColor(fg); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createSwitchColorsCommand() { return new SwitchColorsCommand; } + +} // namespace app diff --git a/src/commands/cmd_undo.cpp b/src/app/commands/cmd_undo.cpp similarity index 89% rename from src/commands/cmd_undo.cpp rename to src/app/commands/cmd_undo.cpp index 3f6df093b..2c3a63474 100644 --- a/src/commands/cmd_undo.cpp +++ b/src/app/commands/cmd_undo.cpp @@ -16,23 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/context_access.h" +#include "app/document_undo.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" #include "base/thread.h" -#include "commands/command.h" -#include "context_access.h" -#include "document_undo.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gui.h" #include "raster/sprite.h" #include "ui/system.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" -class UndoCommand : public Command -{ +namespace app { + +class UndoCommand : public Command { public: enum Type { Undo, Redo }; @@ -116,9 +119,6 @@ void UndoCommand::onExecute(Context* context) update_screen_for_document(document); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createUndoCommand() { return new UndoCommand(UndoCommand::Undo); @@ -128,3 +128,5 @@ Command* CommandFactory::createRedoCommand() { return new UndoCommand(UndoCommand::Redo); } + +} // namespace app diff --git a/src/commands/command.cpp b/src/app/commands/command.cpp similarity index 92% rename from src/commands/command.cpp rename to src/app/commands/command.cpp index d10b68d85..cb03e477b 100644 --- a/src/commands/command.cpp +++ b/src/app/commands/command.cpp @@ -16,11 +16,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "console.h" -#include "commands/command.h" -#include "commands/params.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/console.h" + +namespace app { Command::Command(const char* short_name, const char* friendly_name, CommandFlags flags) { @@ -96,3 +100,5 @@ void Command::onExecute(Context* context) { // Do nothing } + +} // namespace app diff --git a/src/app/commands/command.h b/src/app/commands/command.h new file mode 100644 index 000000000..9c4402646 --- /dev/null +++ b/src/app/commands/command.h @@ -0,0 +1,62 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_COMMANDS_COMMAND_H_INCLUDED +#define APP_COMMANDS_COMMAND_H_INCLUDED + +#include "app/commands/command_factory.h" + +namespace app { + class Context; + class Params; + + enum CommandFlags { + CmdUIOnlyFlag = 0x00000001, + CmdRecordableFlag = 0x00000002, + }; + + class Command { + const char* m_short_name; + const char* m_friendly_name; + CommandFlags m_flags; + + public: + + Command(const char* short_name, const char* friendly_name, CommandFlags flags); + virtual ~Command(); + + virtual Command* clone() const { return new Command(*this); } + + const char* short_name() const { return m_short_name; } + const char* friendly_name() const { return m_friendly_name; } + + void loadParams(Params* params); + bool isEnabled(Context* context); + bool isChecked(Context* context); + void execute(Context* context); + + protected: + virtual void onLoadParams(Params* params); + virtual bool onEnabled(Context* context); + virtual bool onChecked(Context* context); + virtual void onExecute(Context* context); + }; + +} // namespace app + +#endif diff --git a/src/commands/command_factory.h b/src/app/commands/command_factory.h similarity index 71% rename from src/commands/command_factory.h rename to src/app/commands/command_factory.h index 76bfd41b8..1c397e8da 100644 --- a/src/commands/command_factory.h +++ b/src/app/commands/command_factory.h @@ -16,20 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMANDS_COMMAND_FACTORY_H_INCLUDED -#define COMMANDS_COMMAND_FACTORY_H_INCLUDED +#ifndef APP_COMMANDS_COMMAND_FACTORY_H_INCLUDED +#define APP_COMMANDS_COMMAND_FACTORY_H_INCLUDED -class Command; +namespace app { + class Command; -class CommandFactory -{ -public: - #undef FOR_EACH_COMMAND - #define FOR_EACH_COMMAND(Name) \ + class CommandFactory { + public: +#undef FOR_EACH_COMMAND +#define FOR_EACH_COMMAND(Name) \ static Command* create##Name##Command(); - #include "commands/commands_list.h" - #undef FOR_EACH_COMMAND -}; +#include "app/commands/commands_list.h" +#undef FOR_EACH_COMMAND + }; + +} // namespace app #endif diff --git a/src/commands/commands.cpp b/src/app/commands/commands.cpp similarity index 88% rename from src/commands/commands.cpp rename to src/app/commands/commands.cpp index b6f51b740..21d970999 100644 --- a/src/commands/commands.cpp +++ b/src/app/commands/commands.cpp @@ -16,23 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif /* #include */ #include #include #include -#include "ui/gui.h" +#include "ui/ui.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "console.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/console.h" + +namespace app { #undef FOR_EACH_COMMAND #define FOR_EACH_COMMAND(Name) \ const char* CommandId::Name = #Name; - #include "commands/commands_list.h" + #include "app/commands/commands_list.h" #undef FOR_EACH_COMMAND CommandsModule* CommandsModule::m_instance = NULL; @@ -46,7 +50,7 @@ CommandsModule::CommandsModule() #define FOR_EACH_COMMAND(Name) \ m_commands.push_back(CommandFactory::create##Name##Command()); - #include "commands/commands_list.h" + #include "app/commands/commands_list.h" #undef FOR_EACH_COMMAND } @@ -82,3 +86,5 @@ Command* CommandsModule::getCommandByName(const char* name) return NULL; } + +} // namespace app diff --git a/src/commands/commands.h b/src/app/commands/commands.h similarity index 62% rename from src/commands/commands.h rename to src/app/commands/commands.h index 456cf3024..f6b9cb8ab 100644 --- a/src/commands/commands.h +++ b/src/app/commands/commands.h @@ -16,38 +16,39 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMANDS_COMMANDS_H_INCLUDED -#define COMMANDS_COMMANDS_H_INCLUDED +#ifndef APP_COMMANDS_COMMANDS_H_INCLUDED +#define APP_COMMANDS_COMMANDS_H_INCLUDED #include "ui/base.h" -struct CommandId -{ -#undef FOR_EACH_COMMAND - #define FOR_EACH_COMMAND(Name) \ - static const char* Name; - #include "commands/commands_list.h" -#undef FOR_EACH_COMMAND -}; - #include -class Command; +namespace app { -typedef std::vector CommandsList; + struct CommandId { +#undef FOR_EACH_COMMAND +#define FOR_EACH_COMMAND(Name) \ + static const char* Name; +#include "app/commands/commands_list.h" +#undef FOR_EACH_COMMAND + }; -class CommandsModule -{ - static CommandsModule* m_instance; - CommandsList m_commands; + class Command; + typedef std::vector CommandsList; -public: - CommandsModule(); - ~CommandsModule(); + class CommandsModule { + static CommandsModule* m_instance; + CommandsList m_commands; - static CommandsModule* instance(); + public: + CommandsModule(); + ~CommandsModule(); - Command* getCommandByName(const char* name); -}; + static CommandsModule* instance(); + + Command* getCommandByName(const char* name); + }; + +} // namespace app #endif diff --git a/src/commands/commands_list.h b/src/app/commands/commands_list.h similarity index 100% rename from src/commands/commands_list.h rename to src/app/commands/commands_list.h diff --git a/src/commands/filters/cmd_color_curve.cpp b/src/app/commands/filters/cmd_color_curve.cpp similarity index 83% rename from src/commands/filters/cmd_color_curve.cpp rename to src/app/commands/filters/cmd_color_curve.cpp index f53db94e5..0fa9f430d 100644 --- a/src/commands/filters/cmd_color_curve.cpp +++ b/src/app/commands/filters/cmd_color_curve.cpp @@ -16,24 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color.h" +#include "app/commands/command.h" +#include "app/commands/filters/color_curve_editor.h" +#include "app/commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_window.h" +#include "app/context.h" +#include "app/ini_file.h" +#include "app/modules/gui.h" +#include "app/ui/color_button.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/filters/color_curve_editor.h" -#include "commands/filters/filter_manager_impl.h" -#include "commands/filters/filter_window.h" -#include "context.h" #include "filters/color_curve.h" #include "filters/color_curve_filter.h" -#include "ini_file.h" -#include "modules/gui.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "widgets/color_button.h" +#include "ui/ui.h" + +namespace app { + +using namespace filters; static ColorCurve* the_curve = NULL; @@ -43,11 +49,7 @@ static void on_exit_delete_curve() delete the_curve; } -////////////////////////////////////////////////////////////////////// -// Color Curve window - -class ColorCurveWindow : public FilterWindow -{ +class ColorCurveWindow : public FilterWindow { public: ColorCurveWindow(ColorCurveFilter& filter, FilterManagerImpl& filterMgr) : FilterWindow("Color Curve", "ColorCurve", &filterMgr, @@ -84,11 +86,7 @@ private: ColorCurveEditor m_editor; }; -////////////////////////////////////////////////////////////////////// -// Color Curve command - -class ColorCurveCommand : public Command -{ +class ColorCurveCommand : public Command { public: ColorCurveCommand(); Command* clone() const { return new ColorCurveCommand(*this); } @@ -140,10 +138,9 @@ void ColorCurveCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createColorCurveCommand() { return new ColorCurveCommand; } + +} // namespace app diff --git a/src/commands/filters/cmd_convolution_matrix.cpp b/src/app/commands/filters/cmd_convolution_matrix.cpp similarity index 88% rename from src/commands/filters/cmd_convolution_matrix.cpp rename to src/app/commands/filters/cmd_convolution_matrix.cpp index ce778bf99..943706d7b 100644 --- a/src/commands/filters/cmd_convolution_matrix.cpp +++ b/src/app/commands/filters/cmd_convolution_matrix.cpp @@ -16,23 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/color.h" +#include "app/commands/command.h" +#include "app/commands/filters/convolution_matrix_stock.h" +#include "app/commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_window.h" +#include "app/context.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/filters/convolution_matrix_stock.h" -#include "commands/filters/filter_manager_impl.h" -#include "commands/filters/filter_window.h" -#include "context.h" #include "filters/convolution_matrix.h" #include "filters/convolution_matrix_filter.h" -#include "ini_file.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "settings/document_settings.h" #include "ui/button.h" #include "ui/label.h" #include "ui/listbox.h" @@ -44,15 +47,14 @@ #include +namespace app { + +using namespace filters; +using namespace ui; + static const char* ConfigSection = "ConvolutionMatrix"; -using namespace ui; - -////////////////////////////////////////////////////////////////////// -// Convolution Matrix window - -class ConvolutionMatrixWindow : public FilterWindow -{ +class ConvolutionMatrixWindow : public FilterWindow { public: ConvolutionMatrixWindow(ConvolutionMatrixFilter& filter, FilterManagerImpl& filterMgr, ConvolutionMatrixStock& stock) : FilterWindow("Convolution Matrix", ConfigSection, &filterMgr, @@ -144,18 +146,14 @@ private: } ConvolutionMatrixFilter& m_filter; - UniquePtr m_controlsWidget; + base::UniquePtr m_controlsWidget; ConvolutionMatrixStock& m_stock; View* m_view; ListBox* m_stockListBox; Button* m_reloadButton; }; -////////////////////////////////////////////////////////////////////// -// Convolution Matrix command - -class ConvolutionMatrixCommand : public Command -{ +class ConvolutionMatrixCommand : public Command { public: ConvolutionMatrixCommand(); Command* clone() const { return new ConvolutionMatrixCommand(*this); } @@ -203,10 +201,9 @@ void ConvolutionMatrixCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createConvolutionMatrixCommand() { return new ConvolutionMatrixCommand; } + +} // namespace app diff --git a/src/commands/filters/cmd_despeckle.cpp b/src/app/commands/filters/cmd_despeckle.cpp similarity index 88% rename from src/commands/filters/cmd_despeckle.cpp rename to src/app/commands/filters/cmd_despeckle.cpp index a7a71317b..65541865c 100644 --- a/src/commands/filters/cmd_despeckle.cpp +++ b/src/app/commands/filters/cmd_despeckle.cpp @@ -16,21 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/commands/command.h" +#include "app/commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_window.h" +#include "app/context.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/filters/filter_manager_impl.h" -#include "commands/filters/filter_window.h" -#include "context.h" #include "filters/median_filter.h" -#include "ini_file.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "settings/document_settings.h" -#include "settings/settings.h" #include "ui/button.h" #include "ui/entry.h" #include "ui/grid.h" @@ -39,13 +41,13 @@ #include +namespace app { + +using namespace filters; + static const char* ConfigSection = "Despeckle"; -////////////////////////////////////////////////////////////////////// -// Despeckle window - -class DespeckleWindow : public FilterWindow -{ +class DespeckleWindow : public FilterWindow { public: DespeckleWindow(MedianFilter& filter, FilterManagerImpl& filterMgr) : FilterWindow("Median Blur", ConfigSection, &filterMgr, @@ -80,7 +82,7 @@ private: } MedianFilter& m_filter; - UniquePtr m_controlsWidget; + base::UniquePtr m_controlsWidget; ui::Entry* m_widthEntry; ui::Entry* m_heightEntry; }; @@ -134,10 +136,9 @@ void DespeckleCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createDespeckleCommand() { return new DespeckleCommand; } + +} // namespace app diff --git a/src/commands/filters/cmd_invert_color.cpp b/src/app/commands/filters/cmd_invert_color.cpp similarity index 80% rename from src/commands/filters/cmd_invert_color.cpp rename to src/app/commands/filters/cmd_invert_color.cpp index 4c28a96fd..7c0462b16 100644 --- a/src/commands/filters/cmd_invert_color.cpp +++ b/src/app/commands/filters/cmd_invert_color.cpp @@ -16,17 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/color.h" +#include "app/ui/color_button.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/filters/filter_manager_impl.h" -#include "commands/filters/filter_window.h" -#include "context.h" +#include "app/commands/command.h" +#include "app/commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_window.h" +#include "app/context.h" #include "filters/invert_color_filter.h" -#include "ini_file.h" -#include "modules/gui.h" +#include "app/ini_file.h" +#include "app/modules/gui.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" @@ -35,15 +38,12 @@ #include "ui/slider.h" #include "ui/widget.h" #include "ui/window.h" -#include "widgets/color_button.h" + +namespace app { static const char* ConfigSection = "InvertColor"; -////////////////////////////////////////////////////////////////////// -// Invert Color window - -class InvertColorWindow : public FilterWindow -{ +class InvertColorWindow : public FilterWindow { public: InvertColorWindow(InvertColorFilter& filter, FilterManagerImpl& filterMgr) : FilterWindow("Invert Color", ConfigSection, &filterMgr, @@ -57,11 +57,7 @@ private: InvertColorFilter& m_filter; }; -////////////////////////////////////////////////////////////////////// -// Invert Color command - -class InvertColorCommand : public Command -{ +class InvertColorCommand : public Command { public: InvertColorCommand(); Command* clone() const { return new InvertColorCommand(*this); } @@ -97,10 +93,9 @@ void InvertColorCommand::onExecute(Context* context) window.doModal(); } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createInvertColorCommand() { return new InvertColorCommand; } + +} // namespace app diff --git a/src/commands/filters/cmd_replace_color.cpp b/src/app/commands/filters/cmd_replace_color.cpp similarity index 85% rename from src/commands/filters/cmd_replace_color.cpp rename to src/app/commands/filters/cmd_replace_color.cpp index 3b5cd5ba1..f547b1b18 100644 --- a/src/commands/filters/cmd_replace_color.cpp +++ b/src/app/commands/filters/cmd_replace_color.cpp @@ -16,36 +16,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" +#include "app/commands/command.h" +#include "app/commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_window.h" +#include "app/context.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" +#include "app/ui/color_bar.h" +#include "app/ui/color_button.h" #include "base/bind.h" -#include "commands/command.h" -#include "commands/filters/filter_manager_impl.h" -#include "commands/filters/filter_window.h" -#include "context.h" #include "filters/replace_color_filter.h" -#include "ini_file.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "widgets/color_bar.h" -#include "widgets/color_button.h" +#include "ui/ui.h" + +namespace app { static const char* ConfigSection = "ReplaceColor"; -////////////////////////////////////////////////////////////////////// // Wrapper for ReplaceColorFilter to handle colors in an easy way - -class ReplaceColorFilterWrapper : public ReplaceColorFilter -{ +class ReplaceColorFilterWrapper : public ReplaceColorFilter { public: ReplaceColorFilterWrapper(Layer* layer) : m_layer(layer) { } @@ -67,11 +68,7 @@ private: app::Color m_to; }; -////////////////////////////////////////////////////////////////////// -// Replace Color window - -class ReplaceColorWindow : public FilterWindow -{ +class ReplaceColorWindow : public FilterWindow { public: ReplaceColorWindow(ReplaceColorFilterWrapper& filter, FilterManagerImpl& filterMgr) : FilterWindow("Replace Color", ConfigSection, &filterMgr, @@ -115,17 +112,13 @@ protected: private: ReplaceColorFilterWrapper& m_filter; - UniquePtr m_controlsWidget; + base::UniquePtr m_controlsWidget; ColorButton* m_fromButton; ColorButton* m_toButton; ui::Slider* m_toleranceSlider; }; -////////////////////////////////////////////////////////////////////// -// Replace Color command - -class ReplaceColorCommand : public Command -{ +class ReplaceColorCommand : public Command { public: ReplaceColorCommand(); Command* clone() const { return new ReplaceColorCommand(*this); } @@ -172,10 +165,9 @@ void ReplaceColorCommand::onExecute(Context* context) } } -////////////////////////////////////////////////////////////////////// -// CommandFactory - Command* CommandFactory::createReplaceColorCommand() { return new ReplaceColorCommand; } + +} // namespace app diff --git a/src/commands/filters/color_curve_editor.cpp b/src/app/commands/filters/color_curve_editor.cpp similarity index 97% rename from src/commands/filters/color_curve_editor.cpp rename to src/app/commands/filters/color_curve_editor.cpp index 74f805e77..aa28f14b6 100644 --- a/src/commands/filters/color_curve_editor.cpp +++ b/src/app/commands/filters/color_curve_editor.cpp @@ -16,11 +16,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/find_widget.h" #include "app/load_widget.h" -#include "commands/filters/color_curve_editor.h" +#include "app/commands/filters/color_curve_editor.h" #include "filters/color_curve.h" #include "ui/alert.h" #include "ui/entry.h" @@ -65,6 +67,11 @@ * ((ypos) - m_y1) \ / (m_y2 - m_y1 + 1))) +namespace app { + +using namespace ui; +using namespace filters; + enum { STATUS_STANDBY, STATUS_MOVING_POINT, @@ -72,8 +79,6 @@ enum { STATUS_SCALING, }; -using namespace ui; - ColorCurveEditor::ColorCurveEditor(ColorCurve* curve, int x1, int y1, int x2, int y2) : Widget(kGenericWidget) , m_curve(curve) @@ -351,7 +356,7 @@ int ColorCurveEditor::editNodeManually(gfx::Point& point) gfx::Point point_copy = point; int res; - UniquePtr window(app::load_widget("color_curve.xml", "point_properties")); + base::UniquePtr window(app::load_widget("color_curve.xml", "point_properties")); entry_x = window->findChild("x"); entry_y = window->findChild("y"); @@ -374,3 +379,5 @@ int ColorCurveEditor::editNodeManually(gfx::Point& point) return res; } + +} // namespace app diff --git a/src/commands/filters/color_curve_editor.h b/src/app/commands/filters/color_curve_editor.h similarity index 51% rename from src/commands/filters/color_curve_editor.h rename to src/app/commands/filters/color_curve_editor.h index 0069627b6..8d25e1179 100644 --- a/src/commands/filters/color_curve_editor.h +++ b/src/app/commands/filters/color_curve_editor.h @@ -16,40 +16,46 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMANDS_FILTERS_COLOR_CURVE_EDITOR_H_INCLUDED -#define COMMANDS_FILTERS_COLOR_CURVE_EDITOR_H_INCLUDED +#ifndef APP_COMMANDS_FILTERS_COLOR_CURVE_EDITOR_H_INCLUDED +#define APP_COMMANDS_FILTERS_COLOR_CURVE_EDITOR_H_INCLUDED #include "base/compiler_specific.h" #include "base/signal.h" #include "gfx/point.h" #include "ui/widget.h" -class ColorCurve; +namespace filters { + class ColorCurve; +} -class ColorCurveEditor : public ui::Widget -{ -public: - ColorCurveEditor(ColorCurve* curve, int x1, int y1, int x2, int y2); +namespace app { + using namespace filters; - ColorCurve* getCurve() const { return m_curve; } + class ColorCurveEditor : public ui::Widget { + public: + ColorCurveEditor(ColorCurve* curve, int x1, int y1, int x2, int y2); - Signal0 CurveEditorChange; + ColorCurve* getCurve() const { return m_curve; } -protected: - bool onProcessMessage(ui::Message* msg) OVERRIDE; - void onPreferredSize(ui::PreferredSizeEvent& ev) OVERRIDE; + Signal0 CurveEditorChange; -private: - gfx::Point* getClosestPoint(int x, int y, int** edit_x, int** edit_y); - int editNodeManually(gfx::Point& point); + protected: + bool onProcessMessage(ui::Message* msg) OVERRIDE; + void onPreferredSize(ui::PreferredSizeEvent& ev) OVERRIDE; - ColorCurve* m_curve; - int m_x1, m_y1; - int m_x2, m_y2; - int m_status; - gfx::Point* m_editPoint; - int* m_editX; - int* m_editY; -}; + private: + gfx::Point* getClosestPoint(int x, int y, int** edit_x, int** edit_y); + int editNodeManually(gfx::Point& point); + + ColorCurve* m_curve; + int m_x1, m_y1; + int m_x2, m_y2; + int m_status; + gfx::Point* m_editPoint; + int* m_editX; + int* m_editY; + }; + +} // namespace app #endif diff --git a/src/commands/filters/convolution_matrix_stock.cpp b/src/app/commands/filters/convolution_matrix_stock.cpp similarity index 95% rename from src/commands/filters/convolution_matrix_stock.cpp rename to src/app/commands/filters/convolution_matrix_stock.cpp index 28e27bcfb..1601171b5 100644 --- a/src/commands/filters/convolution_matrix_stock.cpp +++ b/src/app/commands/filters/convolution_matrix_stock.cpp @@ -16,16 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "commands/filters/convolution_matrix_stock.h" +#include "app/commands/filters/convolution_matrix_stock.h" #include "base/unique_ptr.h" #include "filters/convolution_matrix.h" -#include "resource_finder.h" -#include "util/filetoks.h" +#include "app/resource_finder.h" +#include "app/util/filetoks.h" + +namespace app { ConvolutionMatrixStock::ConvolutionMatrixStock() { @@ -71,7 +75,7 @@ void ConvolutionMatrixStock::reloadStock() char *s, buf[256], leavings[4096]; int i, c, x, y, w, h, div, bias; SharedPtr matrix; - UniquePtr f; + base::UniquePtr f; std::string name; cleanStock(); @@ -196,3 +200,5 @@ void ConvolutionMatrixStock::cleanStock() { m_matrices.clear(); } + +} // namespace app diff --git a/src/app/commands/filters/convolution_matrix_stock.h b/src/app/commands/filters/convolution_matrix_stock.h new file mode 100644 index 000000000..55623f30e --- /dev/null +++ b/src/app/commands/filters/convolution_matrix_stock.h @@ -0,0 +1,58 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_COMMANDS_FILTERS_CONVOLUTION_MATRIX_STOCK_H_INCLUDED +#define APP_COMMANDS_FILTERS_CONVOLUTION_MATRIX_STOCK_H_INCLUDED + +#include + +#include "base/shared_ptr.h" + +namespace filters { + class ConvolutionMatrix; +} + +namespace app { + using namespace filters; + + // A container of all convolution matrices in the convmatr.def file. + class ConvolutionMatrixStock { + public: + typedef std::vector >::iterator iterator; + typedef std::vector >::const_iterator const_iterator; + + ConvolutionMatrixStock(); + virtual ~ConvolutionMatrixStock(); + + iterator begin() { return m_matrices.begin(); } + iterator end() { return m_matrices.end(); } + const_iterator begin() const { return m_matrices.begin(); } + const_iterator end() const { return m_matrices.end(); } + + SharedPtr getByName(const char* name); + + void reloadStock(); + void cleanStock(); + + private: + std::vector > m_matrices; + }; + +} // namespace app + +#endif diff --git a/src/commands/filters/filter_manager_impl.cpp b/src/app/commands/filters/filter_manager_impl.cpp similarity index 96% rename from src/commands/filters/filter_manager_impl.cpp rename to src/app/commands/filters/filter_manager_impl.cpp index 28e4aebbd..791747ab4 100644 --- a/src/commands/filters/filter_manager_impl.cpp +++ b/src/app/commands/filters/filter_manager_impl.cpp @@ -16,14 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_manager_impl.h" -#include "context_access.h" +#include "app/context_access.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/ui/editor/editor.h" +#include "app/undo_transaction.h" +#include "app/undoers/image_area.h" #include "filters/filter.h" -#include "ini_file.h" -#include "modules/editors.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/images_collector.h" @@ -35,16 +40,15 @@ #include "ui/rect.h" #include "ui/view.h" #include "ui/widget.h" -#include "undo_transaction.h" -#include "undoers/image_area.h" -#include "widgets/editor/editor.h" #include #include +namespace app { + using namespace std; using namespace ui; - + FilterManagerImpl::FilterManagerImpl(Context* context, Filter* filter) : m_context(context) , m_location(context->getActiveLocation()) @@ -390,3 +394,5 @@ bool FilterManagerImpl::updateMask(Mask* mask, const Image* image) return true; } } + +} // namespace app diff --git a/src/app/commands/filters/filter_manager_impl.h b/src/app/commands/filters/filter_manager_impl.h new file mode 100644 index 000000000..c94c8f022 --- /dev/null +++ b/src/app/commands/filters/filter_manager_impl.h @@ -0,0 +1,144 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_COMMANDS_FILTERS_FILTER_MANAGER_IMPL_H_INCLUDED +#define APP_COMMANDS_FILTERS_FILTER_MANAGER_IMPL_H_INCLUDED + +#include "app/document_location.h" +#include "base/exception.h" +#include "base/unique_ptr.h" +#include "filters/filter_indexed_data.h" +#include "filters/filter_manager.h" +#include "raster/pixel_format.h" + +#include +#include + +namespace raster { + class Image; + class Layer; + class Mask; + class Sprite; +} + +namespace filters { + class Filter; +} + +namespace app { + class Context; + class Document; + + using namespace filters; + + class InvalidAreaException : public base::Exception { + public: + InvalidAreaException() throw() + : base::Exception("The current mask/area to apply the effect is completelly invalid.") { } + }; + + class NoImageException : public base::Exception { + public: + NoImageException() throw() + : base::Exception("There are not an active image to apply the effect.\n" + "Please select a layer/cel with an image and try again.") { } + }; + + class FilterManagerImpl : public FilterManager + , public FilterIndexedData { + public: + // Interface to report progress to the user and take input from him + // to cancel the whole process. + class IProgressDelegate { + public: + virtual ~IProgressDelegate() { } + + // Called to report the progress of the filter (with progress from 0.0 to 1.0). + virtual void reportProgress(float progress) = 0; + + // Should return true if the user wants to cancel the filter. + virtual bool isCancelled() = 0; + }; + + FilterManagerImpl(Context* context, Filter* filter); + ~FilterManagerImpl(); + + void setProgressDelegate(IProgressDelegate* progressDelegate); + + PixelFormat getPixelFormat() const; + + void setTarget(Target target); + + void begin(); + void beginForPreview(); + bool applyStep(); + void applyToTarget(); + + Document* getDocument() { return m_location.document(); } + Sprite* getSprite() { return m_location.sprite(); } + Layer* getLayer() { return m_location.layer(); } + Image* getDestinationImage() const { return m_dst; } + + // Updates the current editor to show the progress of the preview. + void flush(); + + // FilterManager implementation + const void* getSourceAddress(); + void* getDestinationAddress(); + int getWidth() { return m_w; } + Target getTarget() { return m_target; } + FilterIndexedData* getIndexedData() { return this; } + bool skipPixel(); + const Image* getSourceImage() { return m_src; } + int getX() { return m_x; } + int getY() { return m_y+m_row; } + + // FilterIndexedData implementation + Palette* getPalette(); + RgbMap* getRgbMap(); + + private: + void init(const Layer* layer, Image* image, int offset_x, int offset_y); + void apply(); + void applyToImage(Layer* layer, Image* image, int x, int y); + bool updateMask(Mask* mask, const Image* image); + + Context* m_context; + DocumentLocation m_location; + Filter* m_filter; + Image* m_src; + base::UniquePtr m_dst; + int m_row; + int m_x, m_y, m_w, m_h; + int m_offset_x, m_offset_y; + Mask* m_mask; + base::UniquePtr m_preview_mask; + unsigned char* m_mask_address; + div_t m_d; + Target m_targetOrig; // Original targets + Target m_target; // Filtered targets + + // Hooks + float m_progressBase; + float m_progressWidth; + IProgressDelegate* m_progressDelegate; + }; + +} // namespace app + +#endif diff --git a/src/commands/filters/filter_preview.cpp b/src/app/commands/filters/filter_preview.cpp similarity index 89% rename from src/commands/filters/filter_preview.cpp rename to src/app/commands/filters/filter_preview.cpp index e32d815f4..0453a2b7b 100644 --- a/src/commands/filters/filter_preview.cpp +++ b/src/app/commands/filters/filter_preview.cpp @@ -16,18 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/filters/filter_preview.h" +#include "app/commands/filters/filter_preview.h" -#include "commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_manager_impl.h" #include "raster/sprite.h" #include "ui/manager.h" #include "ui/message.h" #include "ui/widget.h" -#include "util/render.h" +#include "app/util/render.h" + +namespace app { using namespace ui; +using namespace filters; FilterPreview::FilterPreview(FilterManagerImpl* filterMgr) : Widget(kGenericWidget) @@ -87,3 +92,5 @@ bool FilterPreview::onProcessMessage(Message* msg) return Widget::onProcessMessage(msg); } + +} // namespace app diff --git a/src/commands/filters/filter_preview.h b/src/app/commands/filters/filter_preview.h similarity index 58% rename from src/commands/filters/filter_preview.h rename to src/app/commands/filters/filter_preview.h index f068350dc..cc0a97412 100644 --- a/src/commands/filters/filter_preview.h +++ b/src/app/commands/filters/filter_preview.h @@ -16,32 +16,35 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMANDS_FILTERS_FILTER_PREVIEW_H_INCLUDED -#define COMMANDS_FILTERS_FILTER_PREVIEW_H_INCLUDED +#ifndef APP_COMMANDS_FILTERS_FILTER_PREVIEW_H_INCLUDED +#define APP_COMMANDS_FILTERS_FILTER_PREVIEW_H_INCLUDED #include "base/compiler_specific.h" #include "ui/timer.h" #include "ui/widget.h" -class FilterManagerImpl; +namespace app { -// Invisible widget to control a effect-preview in the current editor. -class FilterPreview : public ui::Widget -{ -public: - FilterPreview(FilterManagerImpl* filterMgr); - ~FilterPreview(); + class FilterManagerImpl; - void stop(); - void restartPreview(); - FilterManagerImpl* getFilterManager() const; + // Invisible widget to control a effect-preview in the current editor. + class FilterPreview : public ui::Widget { + public: + FilterPreview(FilterManagerImpl* filterMgr); + ~FilterPreview(); -protected: - bool onProcessMessage(ui::Message* msg) OVERRIDE; + void stop(); + void restartPreview(); + FilterManagerImpl* getFilterManager() const; -private: - FilterManagerImpl* m_filterMgr; - ui::Timer m_timer; -}; + protected: + bool onProcessMessage(ui::Message* msg) OVERRIDE; + + private: + FilterManagerImpl* m_filterMgr; + ui::Timer m_timer; + }; + +} // namespace app #endif diff --git a/src/commands/filters/filter_target_buttons.cpp b/src/app/commands/filters/filter_target_buttons.cpp similarity index 95% rename from src/commands/filters/filter_target_buttons.cpp rename to src/app/commands/filters/filter_target_buttons.cpp index d58668499..cd1e9b2bd 100644 --- a/src/commands/filters/filter_target_buttons.cpp +++ b/src/app/commands/filters/filter_target_buttons.cpp @@ -16,24 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/filters/filter_target_buttons.h" +#include "app/commands/filters/filter_target_buttons.h" #include #include +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/ui/skin/skin_parts.h" #include "base/bind.h" -#include "modules/gfx.h" -#include "modules/gui.h" #include "raster/image.h" -#include "skin/skin_parts.h" #include "ui/box.h" #include "ui/button.h" #include "ui/theme.h" #include "ui/widget.h" +namespace app { + +using namespace filters; using namespace ui; +using namespace app::skin; FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels) : Box(JI_VERTICAL) @@ -213,3 +219,5 @@ int FilterTargetButtons::getTargetSelectedIcon() const PART_TARGET_ONE_SELECTED; } } + +} // namespace app diff --git a/src/commands/filters/filter_target_buttons.h b/src/app/commands/filters/filter_target_buttons.h similarity index 50% rename from src/commands/filters/filter_target_buttons.h rename to src/app/commands/filters/filter_target_buttons.h index 6d974d1d7..7ad72e035 100644 --- a/src/commands/filters/filter_target_buttons.h +++ b/src/app/commands/filters/filter_target_buttons.h @@ -16,37 +16,43 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMANDS_FILTERS_FILTER_TARGET_BUTTONS_H_INCLUDED -#define COMMANDS_FILTERS_FILTER_TARGET_BUTTONS_H_INCLUDED +#ifndef APP_COMMANDS_FILTERS_FILTER_TARGET_BUTTONS_H_INCLUDED +#define APP_COMMANDS_FILTERS_FILTER_TARGET_BUTTONS_H_INCLUDED #include "base/signal.h" #include "filters/target.h" #include "ui/box.h" -namespace ui { class ButtonBase; } +namespace ui { + class ButtonBase; +} -class FilterTargetButtons : public ui::Box -{ -public: - // Creates a new button to handle "targets" to apply some filter in - // the a sprite. - FilterTargetButtons(int imgtype, bool withChannels); +namespace app { + using namespace filters; - Target getTarget() const { return m_target; } - void setTarget(Target target); + class FilterTargetButtons : public ui::Box { + public: + // Creates a new button to handle "targets" to apply some filter in + // the a sprite. + FilterTargetButtons(int imgtype, bool withChannels); - Signal0 TargetChange; + Target getTarget() const { return m_target; } + void setTarget(Target target); -protected: - void onChannelChange(ui::ButtonBase* button); - void onImagesChange(ui::ButtonBase* button); + Signal0 TargetChange; -private: - void selectTargetButton(const char* name, Target specificTarget); - int getTargetNormalIcon() const; - int getTargetSelectedIcon() const; + protected: + void onChannelChange(ui::ButtonBase* button); + void onImagesChange(ui::ButtonBase* button); - Target m_target; -}; + private: + void selectTargetButton(const char* name, Target specificTarget); + int getTargetNormalIcon() const; + int getTargetSelectedIcon() const; + + Target m_target; + }; + +} // namespace app #endif diff --git a/src/commands/filters/filter_window.cpp b/src/app/commands/filters/filter_window.cpp similarity index 93% rename from src/commands/filters/filter_window.cpp rename to src/app/commands/filters/filter_window.cpp index 26d1787c9..a6029c6ae 100644 --- a/src/commands/filters/filter_window.cpp +++ b/src/app/commands/filters/filter_window.cpp @@ -16,16 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "commands/filters/filter_window.h" +#include "app/commands/filters/filter_window.h" #include "base/bind.h" -#include "commands/filters/filter_manager_impl.h" -#include "commands/filters/filter_worker.h" -#include "ini_file.h" -#include "modules/gui.h" +#include "app/commands/filters/filter_manager_impl.h" +#include "app/commands/filters/filter_worker.h" +#include "app/ini_file.h" +#include "app/modules/gui.h" +namespace app { + +using namespace filters; using namespace ui; FilterWindow::FilterWindow(const char* title, const char* cfgSection, @@ -166,3 +171,5 @@ void FilterWindow::onTiledChange() // Restart the preview. restartPreview(); } + +} // namespace app diff --git a/src/app/commands/filters/filter_window.h b/src/app/commands/filters/filter_window.h new file mode 100644 index 000000000..08a4b6e07 --- /dev/null +++ b/src/app/commands/filters/filter_window.h @@ -0,0 +1,91 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_COMMANDS_FILTERS_FILTER_WINDOW_H_INCLUDED +#define APP_COMMANDS_FILTERS_FILTER_WINDOW_H_INCLUDED + +#include "app/commands/filters/filter_preview.h" +#include "app/commands/filters/filter_target_buttons.h" +#include "filters/tiled_mode.h" +#include "ui/box.h" +#include "ui/button.h" +#include "ui/window.h" + +namespace app { + class FilterManagerImpl; + + using namespace filters; + + // A generic window to show parameters for a Filter with integrated + // preview in the current editor. + class FilterWindow : public ui::Window { + public: + enum WithChannels { WithChannelsSelector, WithoutChannelsSelector }; + enum WithTiled { WithTiledCheckBox, WithoutTiledCheckBox }; + + FilterWindow(const char* title, const char* cfgSection, + FilterManagerImpl* filterMgr, + WithChannels withChannels, + WithTiled withTiled, + TiledMode tiledMode = TILED_NONE); + ~FilterWindow(); + + // Shows the window as modal (blocking interface), and returns true + // if the user pressed "OK" button (i.e. wants to apply the filter + // with the current settings). + bool doModal(); + + // Starts (or restart) the preview procedure. You should call this + // method each time the user modifies parameters of the Filter. + void restartPreview(); + + protected: + // Changes the target buttons. Used by convolution matrix filter + // which specified different targets for each matrix. + void setNewTarget(Target target); + + // Returns the container where derived classes should put controls. + ui::Widget* getContainer() { return &m_container; } + + void onOk(ui::Event& ev); + void onCancel(ui::Event& ev); + void onShowPreview(ui::Event& ev); + void onTargetButtonChange(); + void onTiledChange(); + + // Derived classes WithTiledCheckBox should set its filter's tiled + // mode overriding this method. + virtual void setupTiledMode(TiledMode tiledMode) { } + + private: + const char* m_cfgSection; + FilterManagerImpl* m_filterMgr; + ui::Box m_hbox; + ui::Box m_vbox; + ui::Box m_container; + ui::Button m_okButton; + ui::Button m_cancelButton; + FilterPreview m_preview; + FilterTargetButtons m_targetButton; + ui::CheckBox m_showPreview; + ui::CheckBox* m_tiledCheck; + }; + +} // namespace app + +#endif diff --git a/src/commands/filters/filter_worker.cpp b/src/app/commands/filters/filter_worker.cpp similarity index 88% rename from src/commands/filters/filter_worker.cpp rename to src/app/commands/filters/filter_worker.cpp index 68c106dfd..1e6a83a22 100644 --- a/src/commands/filters/filter_worker.cpp +++ b/src/app/commands/filters/filter_worker.cpp @@ -16,26 +16,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include -#include "app.h" +#include "app/app.h" +#include "app/commands/filters/filter_manager_impl.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" #include "base/mutex.h" #include "base/scoped_lock.h" #include "base/thread.h" -#include "commands/filters/filter_manager_impl.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gui.h" #include "raster/sprite.h" -#include "ui/gui.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" +namespace app { + +using namespace base; using namespace ui; - + static const int kMonitoringPeriod = 100; // Applies filters in two threads: a background worker thread to @@ -64,7 +69,7 @@ private: } FilterManagerImpl* m_filterMgr; // Effect to be applied. - Mutex m_mutex; // Mutex to access to 'pos', 'done' and 'cancelled' fields in different threads. + base::mutex m_mutex; // Mutex to access to 'pos', 'done' and 'cancelled' fields in different threads. float m_pos; // Current progress position bool m_done : 1; // Was the effect completelly applied? bool m_cancelled : 1; // Was the effect cancelled by the user? @@ -112,7 +117,7 @@ void FilterWorker::run() m_timer.stop(); { - ScopedLock lock(m_mutex); + scoped_lock lock(m_mutex); if (!m_done) m_cancelled = true; } @@ -127,7 +132,7 @@ void FilterWorker::run() // void FilterWorker::reportProgress(float progress) { - ScopedLock lock(m_mutex); + scoped_lock lock(m_mutex); m_pos = progress; } @@ -139,7 +144,7 @@ bool FilterWorker::isCancelled() { bool cancelled; - ScopedLock lock(m_mutex); + scoped_lock lock(m_mutex); cancelled = m_cancelled; return cancelled; @@ -155,7 +160,7 @@ void FilterWorker::applyFilterInBackground() m_filterMgr->applyToTarget(); // Mark the work as 'done'. - ScopedLock lock(m_mutex); + scoped_lock lock(m_mutex); m_done = true; } @@ -163,7 +168,7 @@ void FilterWorker::applyFilterInBackground() // every 100 milliseconds). void FilterWorker::onMonitoringTick() { - ScopedLock lock(m_mutex); + scoped_lock lock(m_mutex); if (m_progressBar) m_progressBar->setPos(m_pos); @@ -182,3 +187,5 @@ void start_filter_worker(FilterManagerImpl* filterMgr) FilterWorker filterWorker(filterMgr); filterWorker.run(); } + +} // namespace app diff --git a/src/commands/filters/filter_worker.h b/src/app/commands/filters/filter_worker.h similarity index 77% rename from src/commands/filters/filter_worker.h rename to src/app/commands/filters/filter_worker.h index 02ad5c83a..7b868bc1d 100644 --- a/src/commands/filters/filter_worker.h +++ b/src/app/commands/filters/filter_worker.h @@ -16,11 +16,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMANDS_FILTERS_FILTER_BG_H_INCLUDED -#define COMMANDS_FILTERS_FILTER_BG_H_INCLUDED +#ifndef APP_COMMANDS_FILTERS_FILTER_BG_H_INCLUDED +#define APP_COMMANDS_FILTERS_FILTER_BG_H_INCLUDED -class FilterManagerImpl; +namespace app { -void start_filter_worker(FilterManagerImpl* filterMgr); + class FilterManagerImpl; + + void start_filter_worker(FilterManagerImpl* filterMgr); + +} // namespace app #endif diff --git a/src/app/commands/params.h b/src/app/commands/params.h new file mode 100644 index 000000000..0ae2e933d --- /dev/null +++ b/src/app/commands/params.h @@ -0,0 +1,85 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_COMMANDS_PARAMS_H +#define APP_COMMANDS_PARAMS_H + +#include +#include +#include + +namespace app { + + class Params { + std::map m_params; + + public: + + Params() { } + Params(const Params& copy) : m_params(copy.m_params) { } + virtual ~Params() { } + + Params* clone() + { + return new Params(*this); + } + + bool empty() const + { + return m_params.empty(); + } + + bool has_param(const char* name) const + { + return m_params.find(name) != m_params.end(); + } + + bool operator==(const Params& params) const + { + return m_params == params.m_params; + } + + bool operator!=(const Params& params) const + { + return m_params != params.m_params; + } + + std::string& set(const char* name, const char* value) + { + return m_params[name] = value; + } + + std::string& get(const char* name) + { + return m_params[name]; + } + + template + T get_as(const char* name) + { + std::istringstream stream(m_params[name]); + T value; + stream >> value; + return value; + } + + }; + +} // namespace app + +#endif diff --git a/src/console.cpp b/src/app/console.cpp similarity index 95% rename from src/console.cpp rename to src/app/console.cpp index 9d6febf2b..64b2f8115 100644 --- a/src/console.cpp +++ b/src/app/console.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include @@ -24,12 +26,14 @@ #include "base/bind.h" #include "base/memory.h" -#include "ui/gui.h" +#include "ui/ui.h" -#include "app.h" -#include "console.h" -#include "modules/gui.h" -#include "widgets/status_bar.h" +#include "app/app.h" +#include "app/console.h" +#include "app/modules/gui.h" +#include "app/ui/status_bar.h" + +namespace app { using namespace ui; @@ -162,3 +166,5 @@ void Console::showException(const std::exception& e) Console console; console.printf("A problem has occurred.\n\nDetails:\n%s", e.what()); } + +} // namespace app diff --git a/src/console.h b/src/app/console.h similarity index 89% rename from src/console.h rename to src/app/console.h index 96e7a39dd..2baf33afb 100644 --- a/src/console.h +++ b/src/app/console.h @@ -16,13 +16,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef CONSOLE_H_INCLUDED -#define CONSOLE_H_INCLUDED +#ifndef APP_CONSOLE_H_INCLUDED +#define APP_CONSOLE_H_INCLUDED #include -class Console -{ +namespace app { + +class Console { public: Console(); ~Console(); @@ -32,4 +33,6 @@ public: static void showException(const std::exception& e); }; +} // namespace app + #endif diff --git a/src/context.cpp b/src/app/context.cpp similarity index 93% rename from src/context.cpp rename to src/app/context.cpp index 0ff4b49ec..0b9263d81 100644 --- a/src/context.cpp +++ b/src/app/context.cpp @@ -16,17 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "context.h" +#include "app/context.h" -#include "commands/command.h" -#include "console.h" -#include "document.h" -#include "document_location.h" +#include "app/commands/command.h" +#include "app/console.h" +#include "app/document.h" +#include "app/document_location.h" +#include "app/settings/settings.h" #include +namespace app { + Context::Context(ISettings* settings) : m_settings(settings) { @@ -153,3 +158,5 @@ void Context::onRemoveDocument(Document* document) { // do nothing } + +} // namespace app diff --git a/src/app/context.h b/src/app/context.h new file mode 100644 index 000000000..0e7fcecd6 --- /dev/null +++ b/src/app/context.h @@ -0,0 +1,104 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_CONTEXT_H_INCLUDED +#define APP_CONTEXT_H_INCLUDED + +#include "app/context_flags.h" +#include "app/context_observer.h" +#include "app/context_observer_list.h" +#include "app/documents.h" +#include "base/disable_copying.h" +#include "base/exception.h" + +#include + +namespace app { + class Command; + class Document; + class DocumentLocation; + class ISettings; + class Params; + + class CommandPreconditionException : public base::Exception { + public: + CommandPreconditionException() throw() + : base::Exception("Cannot execute the command because its pre-conditions are false.") { } + }; + + class Context { + public: + virtual ~Context(); + + virtual bool isUiAvailable() const { return false; } + virtual bool isRecordingMacro() const { return false; } + virtual bool isExecutingMacro() const { return false; } + virtual bool isExecutingScript() const { return false; } + + ISettings* getSettings() { return m_settings; } + + const Documents& getDocuments() const; + + bool checkFlags(uint32_t flags) const { return m_flags.check(flags); } + void updateFlags() { m_flags.update(this); } + + // Appends the document to the context's documents' list. + void addDocument(Document* document); + void removeDocument(Document* document); + void sendDocumentToTop(Document* document); + + Document* getActiveDocument() const; + DocumentLocation getActiveLocation() const; + + virtual void executeCommand(Command* command, Params* params = NULL); + + void addObserver(ContextObserver* observer); + void removeObserver(ContextObserver* observer); + + protected: + + // The "settings" are deleted automatically in the ~Context destructor + Context(ISettings* settings); + + virtual void onAddDocument(Document* document); + virtual void onRemoveDocument(Document* document); + virtual void onGetActiveLocation(DocumentLocation* location) const = 0; + + private: + + // Without default constructor + Context(); + + // List of all documents. + Documents m_documents; + + // Settings in this context. + ISettings* m_settings; + + // Last updated flags. + ContextFlags m_flags; + + ContextObserverList m_observers; + + DISABLE_COPYING(Context); + + }; + +} // namespace app + +#endif diff --git a/src/app/context_access.h b/src/app/context_access.h new file mode 100644 index 000000000..ccb3fa0e3 --- /dev/null +++ b/src/app/context_access.h @@ -0,0 +1,99 @@ +/* ASEPRITE + * Copyright (C) 2001-2012 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_CONTEXT_ACCESS_H_INCLUDED +#define APP_CONTEXT_ACCESS_H_INCLUDED + +#include "app/document_access.h" +#include "app/document_location.h" + +namespace app { + + class Context; + + template + class ContextAccess { + public: + const Context* context() const { return m_context; } + const DocumentLocation* location() const { return &m_location; } + const DocumentAccessT& document() const { return m_document; } + const Sprite* sprite() const { return m_location.sprite(); } + const Layer* layer() const { return m_location.layer(); } + FrameNumber frame() const { return m_location.frame(); } + const Cel* cel() const { return m_location.cel(); } + + // You cannot change the location directly from a writable ContextAccess anyway. + const DocumentLocation* location() { return &m_location; } + + Context* context() { return const_cast(m_context); } + DocumentAccessT& document() { return m_document; } + Sprite* sprite() { return m_location.sprite(); } + Layer* layer() { return m_location.layer(); } + Cel* cel() { return m_location.cel(); } + + Image* image(int* x = NULL, int* y = NULL, int* opacity = NULL) const { + return m_location.image(x, y, opacity); + } + + protected: + ContextAccess(const Context* context) + : m_context(context) + , m_document(context->getActiveDocument()) + , m_location(context->getActiveLocation()) + { + } + + template + ContextAccess(const Context* context, const DocumentReaderT& documentReader) + : m_context(context) + , m_document(documentReader) + , m_location(context->getActiveLocation()) + { + } + + private: + const Context* m_context; + DocumentAccessT m_document; + DocumentLocation m_location; + }; + + // You can use this class to access to the given context to read the + // active document. + class ContextReader : public ContextAccess { + public: + ContextReader(const Context* context) + : ContextAccess(context) { + } + }; + + // You can use this class to access to the given context to write the + // active document. + class ContextWriter : public ContextAccess { + public: + ContextWriter(const Context* context) + : ContextAccess(context) { + } + + ContextWriter(const ContextReader& reader) + : ContextAccess(reader.context(), reader.document()) { + } + }; + +} // namespace app + +#endif diff --git a/src/context_flags.cpp b/src/app/context_flags.cpp similarity index 92% rename from src/context_flags.cpp rename to src/app/context_flags.cpp index c1927a746..87d2f289d 100644 --- a/src/context_flags.cpp +++ b/src/app/context_flags.cpp @@ -16,18 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "context_flags.h" +#include "app/context_flags.h" -#include "context.h" -#include "document.h" -#include "document_location.h" +#include "app/context.h" +#include "app/document.h" +#include "app/document_location.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/stock.h" +namespace app { + ContextFlags::ContextFlags() { m_flags = 0; @@ -90,3 +94,5 @@ void ContextFlags::update(Context* context) } } } + +} // namespace app diff --git a/src/app/context_flags.h b/src/app/context_flags.h new file mode 100644 index 000000000..47e48ec23 --- /dev/null +++ b/src/app/context_flags.h @@ -0,0 +1,55 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_CONTEXT_FLAGS_H_INCLUDED +#define APP_CONTEXT_FLAGS_H_INCLUDED + +namespace app { + + class Context; + + class ContextFlags { + public: + enum { + HasActiveDocument = 1 << 0, + HasActiveSprite = 1 << 1, + HasVisibleMask = 1 << 2, + HasActiveLayer = 1 << 3, + HasActiveCel = 1 << 4, + HasActiveImage = 1 << 5, + HasBackgroundLayer = 1 << 6, + ActiveDocumentIsReadable = 1 << 7, + ActiveDocumentIsWritable = 1 << 8, + ActiveLayerIsImage = 1 << 9, + ActiveLayerIsBackground = 1 << 10, + ActiveLayerIsReadable = 1 << 11, + ActiveLayerIsWritable = 1 << 12, + }; + + ContextFlags(); + + bool check(uint32_t flags) const { return (m_flags & flags) == flags; } + void update(Context* context); + + private: + uint32_t m_flags; + }; + +} // namespace app + +#endif diff --git a/src/context_observer.h b/src/app/context_observer.h similarity index 89% rename from src/context_observer.h rename to src/app/context_observer.h index d4b588770..959a519ac 100644 --- a/src/context_observer.h +++ b/src/app/context_observer.h @@ -16,16 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef CONTEXT_OBSERVER_H_INCLUDED -#define CONTEXT_OBSERVER_H_INCLUDED +#ifndef APP_CONTEXT_OBSERVER_H_INCLUDED +#define APP_CONTEXT_OBSERVER_H_INCLUDED + +namespace app { class Context; class Document; // Observer of context events. The default implementation does nothing // in each handler, so you can override the required events. -class ContextObserver -{ +class ContextObserver { public: virtual ~ContextObserver() { } virtual void onCommandBeforeExecution(Context* context) { } @@ -34,4 +35,6 @@ public: virtual void onRemoveDocument(Context* context, Document* document) { } }; +} // namespace app + #endif diff --git a/src/context_observer_list.cpp b/src/app/context_observer_list.cpp similarity index 93% rename from src/context_observer_list.cpp rename to src/app/context_observer_list.cpp index 3f45c09fd..63352e36b 100644 --- a/src/context_observer_list.cpp +++ b/src/app/context_observer_list.cpp @@ -16,15 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "context_observer_list.h" +#include "app/context_observer_list.h" -#include "context_observer.h" +#include "app/context_observer.h" #include #include +namespace app { + ContextObserverList::ContextObserverList() { } @@ -68,3 +72,5 @@ void ContextObserverList::notifyRemoveDocument(Context* context, Document* docum for (iterator it=copy.begin(), end=copy.end(); it!=end; ++it) (*it)->onRemoveDocument(context, document); } + +} // namespace app diff --git a/src/app/context_observer_list.h b/src/app/context_observer_list.h new file mode 100644 index 000000000..b73616c18 --- /dev/null +++ b/src/app/context_observer_list.h @@ -0,0 +1,51 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_CONTEXT_OBSERVER_LIST_H_INCLUDED +#define APP_CONTEXT_OBSERVER_LIST_H_INCLUDED + +#include + +namespace app { + class Context; + class ContextObserver; + class Document; + + class ContextObserverList { + public: + typedef std::vector list_type; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; + + ContextObserverList(); + + void addObserver(ContextObserver* observer); + void removeObserver(ContextObserver* observer); + + void notifyCommandBeforeExecution(Context* context); + void notifyCommandAfterExecution(Context* context); + void notifyAddDocument(Context* context, Document* document); + void notifyRemoveDocument(Context* context, Document* document); + + private: + list_type m_observer; + }; + +} // namespace app + +#endif diff --git a/src/app/data_recovery.cpp b/src/app/data_recovery.cpp index 5bd84e7a7..2137d6b10 100644 --- a/src/app/data_recovery.cpp +++ b/src/app/data_recovery.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/data_recovery.h" @@ -24,8 +26,8 @@ #include "base/fs.h" #include "base/path.h" #include "base/temp_dir.h" -#include "document.h" -#include "ui_context.h" +#include "app/document.h" +#include "app/ui_context.h" #include diff --git a/src/app/data_recovery.h b/src/app/data_recovery.h index 18af94bb0..31557716a 100644 --- a/src/app/data_recovery.h +++ b/src/app/data_recovery.h @@ -16,20 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DATA_RECOVERY_H_INCLUDED -#define DATA_RECOVERY_H_INCLUDED +#ifndef APP_DATA_RECOVERY_H_INCLUDED +#define APP_DATA_RECOVERY_H_INCLUDED +#include "app/context_observer.h" +#include "app/document_observer.h" +#include "app/documents.h" #include "base/compiler_specific.h" #include "base/disable_copying.h" #include "base/slot.h" -#include "context_observer.h" -#include "document_observer.h" -#include "documents.h" namespace base { class TempDir; } namespace app { - class Backup; class DataRecovery : public ContextObserver diff --git a/src/dialogs/aniedit.cpp b/src/app/dialogs/aniedit.cpp similarity index 98% rename from src/dialogs/aniedit.cpp rename to src/app/dialogs/aniedit.cpp index 0835cc7f3..b479ebbad 100644 --- a/src/dialogs/aniedit.cpp +++ b/src/app/dialogs/aniedit.cpp @@ -16,41 +16,40 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app_menus.h" +#include "app/app_menus.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/console.h" +#include "app/context_access.h" +#include "app/document.h" +#include "app/document_api.h" +#include "app/document_event.h" +#include "app/document_observer.h" +#include "app/document_undo.h" +#include "app/modules/editors.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/ui/editor/editor.h" +#include "app/ui/skin/skin_theme.h" +#include "app/ui_context.h" +#include "app/undo_transaction.h" +#include "app/util/celmove.h" +#include "app/util/thmbnail.h" #include "base/compiler_specific.h" #include "base/memory.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "console.h" -#include "context_access.h" -#include "document.h" -#include "document_api.h" -#include "document_event.h" -#include "document_observer.h" -#include "document_undo.h" #include "gfx/point.h" #include "gfx/rect.h" -#include "modules/editors.h" -#include "modules/gfx.h" -#include "modules/gui.h" #include "raster/raster.h" -#include "skin/skin_theme.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "undo_transaction.h" -#include "util/celmove.h" -#include "util/thmbnail.h" -#include "widgets/editor/editor.h" +#include "ui/ui.h" #include #include -using namespace gfx; -using namespace ui; - /* Animator Editor @@ -88,6 +87,13 @@ using namespace ui; // Space between the icon-bitmap and the edge of the surrounding button. #define ICONBORDER (4*jguiscale()) +namespace app { + +using namespace app::skin; +using namespace gfx; +using namespace raster; +using namespace ui; + enum { A_PART_NOTHING, A_PART_SEPARATOR, @@ -100,8 +106,7 @@ enum { }; class AnimationEditor : public Widget - , public DocumentObserver -{ + , public DocumentObserver { public: enum State { STATE_STANDBY, @@ -216,7 +221,7 @@ void switch_between_animation_and_sprite_editor(Context* context) // Create the window & the animation-editor { - UniquePtr window(new Window(true, NULL)); + base::UniquePtr window(new Window(true, NULL)); AnimationEditor anieditor(context); window->addChild(&anieditor); @@ -1543,3 +1548,5 @@ static void icon_rect(BITMAP* icon_normal, BITMAP* icon_selected, int x1, int y1 else draw_trans_sprite(ji_screen, icon_normal, icon_x, icon_y); } + +} // namespace app diff --git a/src/dialogs/aniedit.h b/src/app/dialogs/aniedit.h similarity index 76% rename from src/dialogs/aniedit.h rename to src/app/dialogs/aniedit.h index 05762043a..5509f104d 100644 --- a/src/dialogs/aniedit.h +++ b/src/app/dialogs/aniedit.h @@ -16,13 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DIALOGS_ANIEDIT_H_INCLUDED -#define DIALOGS_ANIEDIT_H_INCLUDED +#ifndef APP_DIALOGS_ANIEDIT_H_INCLUDED +#define APP_DIALOGS_ANIEDIT_H_INCLUDED -class Context; +namespace app { + class Context; -bool animation_editor_is_movingcel(); + bool animation_editor_is_movingcel(); -void switch_between_animation_and_sprite_editor(Context* context); + void switch_between_animation_and_sprite_editor(Context* context); + +} // namespace app #endif diff --git a/src/dialogs/maskcol.cpp b/src/app/dialogs/maskcol.cpp similarity index 88% rename from src/dialogs/maskcol.cpp rename to src/app/dialogs/maskcol.cpp index 0bb7922ca..7022a7c8e 100644 --- a/src/dialogs/maskcol.cpp +++ b/src/app/dialogs/maskcol.cpp @@ -16,18 +16,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" +#include "app/context_access.h" +#include "app/document.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" +#include "app/ui/color_bar.h" +#include "app/ui/color_button.h" +#include "app/undo_transaction.h" +#include "app/undoers/set_mask.h" +#include "app/util/misc.h" #include "base/bind.h" #include "base/unique_ptr.h" -#include "context_access.h" -#include "document.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gui.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/sprite.h" @@ -37,11 +44,8 @@ #include "ui/slider.h" #include "ui/widget.h" #include "ui/window.h" -#include "undo_transaction.h" -#include "undoers/set_mask.h" -#include "util/misc.h" -#include "widgets/color_bar.h" -#include "widgets/color_button.h" + +namespace app { using namespace ui; @@ -70,7 +74,7 @@ void dialogs_mask_color(Context* context) if (!image) return; - UniquePtr window(new Window(false, "Mask by Color")); + base::UniquePtr window(new Window(false, "Mask by Color")); box1 = new Box(JI_VERTICAL); box2 = new Box(JI_HORIZONTAL); box3 = new Box(JI_HORIZONTAL); @@ -139,7 +143,7 @@ void dialogs_mask_color(Context* context) // Change the mask { - UniquePtr mask(gen_mask(sprite, image, xpos, ypos)); + base::UniquePtr mask(gen_mask(sprite, image, xpos, ypos)); document->setMask(mask); } @@ -165,7 +169,7 @@ static Mask* gen_mask(const Sprite* sprite, const Image* image, int xpos, int yp color = color_utils::color_for_image(button_color->getColor(), sprite->getPixelFormat()); tolerance = slider_tolerance->getValue(); - UniquePtr mask(new Mask()); + base::UniquePtr mask(new Mask()); mask->byColor(image, color, tolerance); mask->offsetOrigin(xpos, ypos); @@ -177,7 +181,7 @@ static void mask_preview(const ContextReader& reader) if (check_preview->isSelected()) { int xpos, ypos; const Image* image = reader.image(&xpos, &ypos); - UniquePtr mask(gen_mask(reader.sprite(), image, xpos, ypos)); + base::UniquePtr mask(gen_mask(reader.sprite(), image, xpos, ypos)); { ContextWriter writer(reader); writer.document()->generateMaskBoundaries(mask); @@ -185,3 +189,5 @@ static void mask_preview(const ContextReader& reader) } } } + +} // namespace app diff --git a/src/dialogs/maskcol.h b/src/app/dialogs/maskcol.h similarity index 81% rename from src/dialogs/maskcol.h rename to src/app/dialogs/maskcol.h index e15d86835..555cd73a6 100644 --- a/src/dialogs/maskcol.h +++ b/src/app/dialogs/maskcol.h @@ -16,11 +16,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DIALOGS_MASKCOL_H_INCLUDED -#define DIALOGS_MASKCOL_H_INCLUDED +#ifndef APP_DIALOGS_MASKCOL_H_INCLUDED +#define APP_DIALOGS_MASKCOL_H_INCLUDED -class Context; +namespace app { -void dialogs_mask_color(Context* context); + class Context; + + void dialogs_mask_color(Context* context); + +} // namespace app #endif diff --git a/src/document.cpp b/src/app/document.cpp similarity index 91% rename from src/document.cpp rename to src/app/document.cpp index 6c481e872..28f986508 100644 --- a/src/document.cpp +++ b/src/app/document.cpp @@ -16,30 +16,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "document.h" +#include "app/document.h" +#include "app/document_api.h" +#include "app/document_event.h" +#include "app/document_observer.h" +#include "app/document_undo.h" +#include "app/file/format_options.h" +#include "app/flatten.h" +#include "app/objects_container_impl.h" +#include "app/undoers/add_image.h" +#include "app/undoers/add_layer.h" +#include "app/util/boundary.h" #include "base/memory.h" #include "base/mutex.h" #include "base/scoped_lock.h" #include "base/unique_ptr.h" -#include "document_api.h" -#include "document_event.h" -#include "document_observer.h" -#include "document_undo.h" -#include "file/format_options.h" -#include "flatten.h" -#include "objects_container_impl.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/mask.h" #include "raster/palette.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "undoers/add_image.h" -#include "undoers/add_layer.h" -#include "util/boundary.h" + +namespace app { + +using namespace base; +using namespace raster; Document::Document(Sprite* sprite) : m_id(WithoutDocumentId) @@ -47,7 +54,7 @@ Document::Document(Sprite* sprite) , m_undo(new DocumentUndo) , m_filename("Sprite") , m_associated_to_file(false) - , m_mutex(new Mutex) + , m_mutex(new mutex) , m_write_lock(false) , m_read_locks(0) // Information about the file format used to load/save this document @@ -84,13 +91,13 @@ DocumentApi Document::getApi(undo::UndoersCollector* undoers) Document* Document::createBasicDocument(PixelFormat format, int width, int height, int ncolors) { // Create the sprite. - UniquePtr sprite(new Sprite(format, width, height, ncolors)); + base::UniquePtr sprite(new Sprite(format, width, height, ncolors)); sprite->setTotalFrames(FrameNumber(1)); // Create the main image. int indexInStock; { - UniquePtr image(Image::create(format, width, height)); + base::UniquePtr image(Image::create(format, width, height)); // Clear the image with mask color. image_clear(image, 0); @@ -102,12 +109,12 @@ Document* Document::createBasicDocument(PixelFormat format, int width, int heigh // Create the first transparent layer. { - UniquePtr layer(new LayerImage(sprite)); + base::UniquePtr layer(new LayerImage(sprite)); layer->setName("Layer 1"); // Create the cel. { - UniquePtr cel(new Cel(FrameNumber(0), indexInStock)); + base::UniquePtr cel(new Cel(FrameNumber(0), indexInStock)); cel->setPosition(0, 0); // Add the cel in the layer. @@ -120,7 +127,7 @@ Document* Document::createBasicDocument(PixelFormat format, int width, int heigh } // Create the document with the new sprite. - UniquePtr document(new Document(sprite)); + base::UniquePtr document(new Document(sprite)); sprite.release(); // Release the sprite because it is in the document. document->setFilename("Sprite"); @@ -224,7 +231,7 @@ int Document::getBoundariesSegmentsCount() const return m_bound.nseg; } -const _BoundSeg* Document::getBoundariesSegments() const +const BoundSeg* Document::getBoundariesSegments() const { return m_bound.seg; } @@ -373,7 +380,7 @@ void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, La for (; it != end; ++it) { const Cel* sourceCel = *it; - UniquePtr newCel(new Cel(*sourceCel)); + base::UniquePtr newCel(new Cel(*sourceCel)); ASSERT((sourceCel->getImage() >= 0) && (sourceCel->getImage() < sourceLayer->getSprite()->getStock()->size())); @@ -403,7 +410,7 @@ void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, La for (; it != end; ++it) { Layer* sourceChild = *it; - UniquePtr destChild(NULL); + base::UniquePtr destChild(NULL); if (sourceChild->isImage()) { destChild.reset(new LayerImage(destLayer->getSprite())); @@ -433,11 +440,11 @@ void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, La Document* Document::duplicate(DuplicateType type) const { const Sprite* sourceSprite = getSprite(); - UniquePtr spriteCopyPtr(new Sprite(sourceSprite->getPixelFormat(), + base::UniquePtr spriteCopyPtr(new Sprite(sourceSprite->getPixelFormat(), sourceSprite->getWidth(), sourceSprite->getHeight(), sourceSprite->getPalette(FrameNumber(0))->size())); - UniquePtr documentCopy(new Document(spriteCopyPtr)); + base::UniquePtr documentCopy(new Document(spriteCopyPtr)); Sprite* spriteCopy = spriteCopyPtr.release(); spriteCopy->setTotalFrames(sourceSprite->getTotalFrames()); @@ -503,7 +510,7 @@ Document* Document::duplicate(DuplicateType type) const bool Document::lock(LockType lockType) { - ScopedLock lock(*m_mutex); + scoped_lock lock(*m_mutex); switch (lockType) { @@ -532,7 +539,7 @@ bool Document::lock(LockType lockType) bool Document::lockToWrite() { - ScopedLock lock(*m_mutex); + scoped_lock lock(*m_mutex); // this only is possible if there are just one reader if (m_read_locks == 1) { @@ -547,7 +554,7 @@ bool Document::lockToWrite() void Document::unlockToRead() { - ScopedLock lock(*m_mutex); + scoped_lock lock(*m_mutex); ASSERT(m_read_locks == 0); ASSERT(m_write_lock); @@ -558,7 +565,7 @@ void Document::unlockToRead() void Document::unlock() { - ScopedLock lock(*m_mutex); + scoped_lock lock(*m_mutex); if (m_write_lock) { m_write_lock = false; @@ -570,3 +577,5 @@ void Document::unlock() ASSERT(false); } } + +} // namespace app diff --git a/src/app/document.h b/src/app/document.h new file mode 100644 index 000000000..f0886cf05 --- /dev/null +++ b/src/app/document.h @@ -0,0 +1,245 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENT_H_INCLUDED +#define APP_DOCUMENT_H_INCLUDED + +#include "base/disable_copying.h" +#include "base/shared_ptr.h" +#include "base/unique_ptr.h" +#include "app/document_id.h" +#include "gfx/transformation.h" +#include "base/observable.h" +#include "raster/frame_number.h" +#include "raster/pixel_format.h" + +#include + +namespace base { + class mutex; +} + +namespace raster { + class Cel; + class Image; + class Layer; + class Mask; + class Sprite; +} + +namespace gfx { + class Region; +} + +namespace undo { + class UndoersCollector; +} + +namespace app { + class DocumentApi; + class DocumentObserver; + class DocumentUndo; + class FormatOptions; + struct BoundSeg; + + using namespace raster; + + enum DuplicateType { + DuplicateExactCopy, + DuplicateWithFlattenLayers, + }; + + // An application document. It is the class used to contain one file + // opened and being edited by the user (a sprite). + class Document : public base::Observable { + public: + + enum LockType { + ReadLock, + WriteLock + }; + + // Creates a document with one sprite, with one transparent layer, + // and one frame. + static Document* createBasicDocument(PixelFormat format, int width, int height, int ncolors); + + Document(Sprite* sprite); + ~Document(); + + // Returns a high-level API: observable and undoable methods. + DocumentApi getApi(undo::UndoersCollector* undoers = NULL); + + ////////////////////////////////////////////////////////////////////// + // Main properties + + DocumentId getId() const { return m_id; } + void setId(DocumentId id) { m_id = id; } + + const Sprite* getSprite() const { return m_sprite; } + const DocumentUndo* getUndo() const { return m_undo; } + + Sprite* getSprite() { return m_sprite; } + DocumentUndo* getUndo() { return m_undo; } + + void addSprite(Sprite* sprite); + + ////////////////////////////////////////////////////////////////////// + // Notifications + + void notifyGeneralUpdate(); + void notifySpritePixelsModified(Sprite* sprite, const gfx::Region& region); + void notifyLayerMergedDown(Layer* srcLayer, Layer* targetLayer); + void notifyCelMoved(Layer* fromLayer, FrameNumber fromFrame, Layer* toLayer, FrameNumber toFrame); + void notifyCelCopied(Layer* fromLayer, FrameNumber fromFrame, Layer* toLayer, FrameNumber toFrame); + + ////////////////////////////////////////////////////////////////////// + // File related properties + + const char* getFilename() const; + void setFilename(const char* filename); + + bool isModified() const; + bool isAssociatedToFile() const; + void markAsSaved(); + + ////////////////////////////////////////////////////////////////////// + // Loaded options from file + + void setFormatOptions(const SharedPtr& format_options); + + ////////////////////////////////////////////////////////////////////// + // Boundaries + + int getBoundariesSegmentsCount() const; + const BoundSeg* getBoundariesSegments() const; + + void generateMaskBoundaries(Mask* mask = NULL); + + ////////////////////////////////////////////////////////////////////// + // Extra Cel (it is used to draw pen preview, pixels in movement, etc.) + + void prepareExtraCel(int x, int y, int w, int h, int opacity); + void destroyExtraCel(); + Cel* getExtraCel() const; + Image* getExtraCelImage() const; + + ////////////////////////////////////////////////////////////////////// + // Mask + + // Returns the current mask, it can be empty. The mask could be not + // empty but hidden to the user if the setMaskVisible(false) was + // used called before. + Mask* getMask() const; + + // Sets the current mask. The new mask will be visible by default, + // so you don't need to call setMaskVisible(true). + void setMask(const Mask* mask); + + // Returns true only when the mask is not empty, and was not yet + // hidden using setMaskVisible (e.g. when the user "deselect the + // mask"). + bool isMaskVisible() const; + + // Changes the visibility state of the mask (it is useful only if + // the getMask() is not empty and the user can see that the mask is + // being hidden and shown to him). + void setMaskVisible(bool visible); + + ////////////////////////////////////////////////////////////////////// + // Transformation + + gfx::Transformation getTransformation() const; + void setTransformation(const gfx::Transformation& transform); + void resetTransformation(); + + ////////////////////////////////////////////////////////////////////// + // Copying + + void copyLayerContent(const Layer* sourceLayer, Document* destDoc, Layer* destLayer) const; + Document* duplicate(DuplicateType type) const; + + ////////////////////////////////////////////////////////////////////// + // Multi-threading ("sprite wrappers" use this) + + // Locks the sprite to read or write on it, returning true if the + // sprite can be accessed in the desired mode. + bool lock(LockType lockType); + + // If you've locked the sprite to read, using this method you can + // raise your access level to write it. + bool lockToWrite(); + + // If you've locked the sprite to write, using this method you can + // your access level to only read it. + void unlockToRead(); + + void unlock(); + + private: + // Unique identifier for this document (it is assigned by Documents class). + DocumentId m_id; + + // The main sprite. + base::UniquePtr m_sprite; + + // Undo and redo information about the document. + base::UniquePtr m_undo; + + // Document's file name (from where it was loaded, where it is saved). + std::string m_filename; + + // True if this sprite is associated to a file in the file-system. + bool m_associated_to_file; + + // Selected mask region boundaries + struct { + int nseg; + BoundSeg* seg; + } m_bound; + + // Mutex to modify the 'locked' flag. + base::mutex* m_mutex; + + // True if some thread is writing the sprite. + bool m_write_lock; + + // Greater than zero when one or more threads are reading the sprite. + int m_read_locks; + + // Data to save the file in the same format that it was loaded + SharedPtr m_format_options; + + // Extra cel used to draw extra stuff (e.g. editor's pen preview, pixels in movement, etc.) + Cel* m_extraCel; + + // Image of the extra cel. + Image* m_extraImage; + + // Current mask. + base::UniquePtr m_mask; + bool m_maskVisible; + + // Current transformation. + gfx::Transformation m_transformation; + + DISABLE_COPYING(Document); + }; + +} // namespace app + +#endif diff --git a/src/app/document_access.h b/src/app/document_access.h new file mode 100644 index 000000000..db942f9e4 --- /dev/null +++ b/src/app/document_access.h @@ -0,0 +1,232 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENT_ACCESS_H_INCLUDED +#define APP_DOCUMENT_ACCESS_H_INCLUDED + +#include "base/exception.h" +#include "app/context.h" +#include "app/document.h" + +#include + +namespace app { + + class LockedDocumentException : public base::Exception { + public: + LockedDocumentException() throw() + : base::Exception("Cannot read or write the active document.\n" + "It is locked by a background task.\n" + "Try again later.") { } + }; + + // This class acts like a wrapper for the given document. It's + // specialized by DocumentReader/Writer to handle document read/write + // locks. + class DocumentAccess { + public: + DocumentAccess() : m_document(NULL) { } + DocumentAccess(const DocumentAccess& copy) : m_document(copy.m_document) { } + explicit DocumentAccess(Document* document) : m_document(document) { } + ~DocumentAccess() { } + + DocumentAccess& operator=(const DocumentAccess& copy) + { + m_document = copy.m_document; + return *this; + } + + operator Document* () { return m_document; } + operator const Document* () const { return m_document; } + + Document* operator->() + { + ASSERT(m_document != NULL); + return m_document; + } + + const Document* operator->() const + { + ASSERT(m_document != NULL); + return m_document; + } + + protected: + Document* m_document; + }; + + // Class to view the document's state. Its constructor request a + // reader-lock of the document, or throws an exception in case that + // the lock cannot be obtained. + class DocumentReader : public DocumentAccess { + public: + DocumentReader() + { + } + + explicit DocumentReader(Document* document) + : DocumentAccess(document) + { + if (m_document && !m_document->lock(Document::ReadLock)) + throw LockedDocumentException(); + } + + explicit DocumentReader(const DocumentReader& copy) + : DocumentAccess(copy) + { + if (m_document && !m_document->lock(Document::ReadLock)) + throw LockedDocumentException(); + } + + DocumentReader& operator=(const DocumentReader& copy) + { + // unlock old document + if (m_document) + m_document->unlock(); + + DocumentAccess::operator=(copy); + + // relock the document + if (m_document && !m_document->lock(Document::ReadLock)) + throw LockedDocumentException(); + + return *this; + } + + ~DocumentReader() + { + // unlock the document + if (m_document) + m_document->unlock(); + } + + }; + + // Class to modify the document's state. Its constructor request a + // writer-lock of the document, or throws an exception in case that + // the lock cannot be obtained. Also, it contains a special + // constructor that receives a DocumentReader, to elevate the + // reader-lock to writer-lock. + class DocumentWriter : public DocumentAccess { + public: + DocumentWriter() + : m_from_reader(false) + , m_locked(false) + { + } + + explicit DocumentWriter(Document* document) + : DocumentAccess(document) + , m_from_reader(false) + , m_locked(false) + { + if (m_document) { + if (!m_document->lock(Document::WriteLock)) + throw LockedDocumentException(); + + m_locked = true; + } + } + + // Constructor that can be used to elevate the given reader-lock to + // writer permission. + explicit DocumentWriter(const DocumentReader& document) + : DocumentAccess(document) + , m_from_reader(true) + , m_locked(false) + { + if (m_document) { + if (!m_document->lockToWrite()) + throw LockedDocumentException(); + + m_locked = true; + } + } + + ~DocumentWriter() + { + unlockWriter(); + } + + DocumentWriter& operator=(const DocumentReader& copy) + { + unlockWriter(); + + DocumentAccess::operator=(copy); + + if (m_document) { + m_from_reader = true; + + if (!m_document->lockToWrite()) + throw LockedDocumentException(); + + m_locked = true; + } + + return *this; + } + + protected: + + void unlockWriter() + { + if (m_document && m_locked) { + if (m_from_reader) + m_document->unlockToRead(); + else + m_document->unlock(); + m_locked = false; + } + } + + private: + bool m_from_reader; + bool m_locked; + + // Non-copyable + DocumentWriter(const DocumentWriter&); + DocumentWriter& operator=(const DocumentWriter&); + }; + + // Used to destroy the active document in the context. + class DocumentDestroyer : public DocumentWriter { + public: + explicit DocumentDestroyer(Context* context, Document* document) + : DocumentWriter(document) + , m_context(context) + { + } + + void destroyDocument() + { + ASSERT(m_document != NULL); + + m_context->removeDocument(m_document); + unlockWriter(); + + delete m_document; + m_document = NULL; + } + + private: + Context* m_context; + }; + +} // namespace app + +#endif diff --git a/src/document_api.cpp b/src/app/document_api.cpp similarity index 94% rename from src/document_api.cpp rename to src/app/document_api.cpp index 975d3811b..5405e4019 100644 --- a/src/document_api.cpp +++ b/src/app/document_api.cpp @@ -16,15 +16,46 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "document_api.h" +#include "app/document_api.h" +#include "app/document.h" +#include "app/document_event.h" +#include "app/document_observer.h" +#include "app/document_undo.h" +#include "app/undoers/add_cel.h" +#include "app/undoers/add_frame.h" +#include "app/undoers/add_image.h" +#include "app/undoers/add_layer.h" +#include "app/undoers/add_palette.h" +#include "app/undoers/dirty_area.h" +#include "app/undoers/flip_image.h" +#include "app/undoers/image_area.h" +#include "app/undoers/move_layer.h" +#include "app/undoers/move_layer.h" +#include "app/undoers/remove_cel.h" +#include "app/undoers/remove_frame.h" +#include "app/undoers/remove_image.h" +#include "app/undoers/remove_layer.h" +#include "app/undoers/remove_palette.h" +#include "app/undoers/replace_image.h" +#include "app/undoers/set_cel_frame.h" +#include "app/undoers/set_cel_position.h" +#include "app/undoers/set_frame_duration.h" +#include "app/undoers/set_layer_flags.h" +#include "app/undoers/set_layer_flags.h" +#include "app/undoers/set_layer_name.h" +#include "app/undoers/set_layer_name.h" +#include "app/undoers/set_mask.h" +#include "app/undoers/set_mask_position.h" +#include "app/undoers/set_sprite_pixel_format.h" +#include "app/undoers/set_sprite_size.h" +#include "app/undoers/set_stock_pixel_format.h" +#include "app/undoers/set_total_frames.h" #include "base/unique_ptr.h" -#include "document.h" -#include "document_event.h" -#include "document_observer.h" -#include "document_undo.h" #include "raster/algorithm/flip_image.h" #include "raster/blend.h" #include "raster/cel.h" @@ -36,35 +67,8 @@ #include "raster/quantization.h" #include "raster/sprite.h" #include "raster/stock.h" -#include "undoers/add_cel.h" -#include "undoers/add_frame.h" -#include "undoers/add_image.h" -#include "undoers/add_layer.h" -#include "undoers/add_palette.h" -#include "undoers/dirty_area.h" -#include "undoers/flip_image.h" -#include "undoers/image_area.h" -#include "undoers/move_layer.h" -#include "undoers/move_layer.h" -#include "undoers/remove_cel.h" -#include "undoers/remove_frame.h" -#include "undoers/remove_image.h" -#include "undoers/remove_layer.h" -#include "undoers/remove_palette.h" -#include "undoers/replace_image.h" -#include "undoers/set_cel_frame.h" -#include "undoers/set_cel_position.h" -#include "undoers/set_frame_duration.h" -#include "undoers/set_layer_flags.h" -#include "undoers/set_layer_flags.h" -#include "undoers/set_layer_name.h" -#include "undoers/set_layer_name.h" -#include "undoers/set_mask.h" -#include "undoers/set_mask_position.h" -#include "undoers/set_sprite_pixel_format.h" -#include "undoers/set_sprite_size.h" -#include "undoers/set_stock_pixel_format.h" -#include "undoers/set_total_frames.h" + +namespace app { DocumentApi::DocumentApi(Document* document, undo::UndoersCollector* undoers) : m_document(document) @@ -111,7 +115,7 @@ void DocumentApi::trimSprite(Sprite* sprite, int bgcolor) { gfx::Rect bounds; - UniquePtr image_wrap(Image::create(sprite->getPixelFormat(), + base::UniquePtr image_wrap(Image::create(sprite->getPixelFormat(), sprite->getWidth(), sprite->getHeight())); Image* image = image_wrap.get(); @@ -193,8 +197,8 @@ void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, Ditherin getObjects(), sprite, FrameNumber(0))); } - // It's a UniquePtr because setPalette'll create a copy of "graypal". - UniquePtr graypal(Palette::createGrayscale()); + // It's a base::UniquePtr because setPalette'll create a copy of "graypal". + base::UniquePtr graypal(Palette::createGrayscale()); sprite->resetPalettes(); sprite->setPalette(graypal, true); @@ -726,7 +730,7 @@ void DocumentApi::backgroundFromLayer(LayerImage* layer, int bgcolor) // create a temporary image to draw each frame of the new // `Background' layer - UniquePtr bg_image_wrap(Image::create(sprite->getPixelFormat(), + base::UniquePtr bg_image_wrap(Image::create(sprite->getPixelFormat(), sprite->getWidth(), sprite->getHeight())); Image* bg_image = bg_image_wrap.get(); @@ -815,7 +819,7 @@ void DocumentApi::flattenLayers(Sprite* sprite, int bgcolor) DocumentUndo* undo = m_document->getUndo(); // Create a temporary image. - UniquePtr image_wrap(Image::create(sprite->getPixelFormat(), + base::UniquePtr image_wrap(Image::create(sprite->getPixelFormat(), sprite->getWidth(), sprite->getHeight())); Image* image = image_wrap.get(); @@ -1017,7 +1021,7 @@ void DocumentApi::flipImage(Image* image, void DocumentApi::flipImageWithMask(Image* image, const Mask* mask, raster::algorithm::FlipType flipType, int bgcolor) { - UniquePtr flippedImage((Image::createCopy(image))); + base::UniquePtr flippedImage((Image::createCopy(image))); // Flip the portion of the bitmap. raster::algorithm::flip_image_with_mask(flippedImage, mask, flipType, bgcolor); @@ -1025,7 +1029,7 @@ void DocumentApi::flipImageWithMask(Image* image, const Mask* mask, raster::algo // Insert the undo operation. DocumentUndo* undo = m_document->getUndo(); if (undo->isEnabled()) { - UniquePtr dirty((new Dirty(image, flippedImage))); + base::UniquePtr dirty((new Dirty(image, flippedImage))); dirty->saveImagePixels(image); m_undoers->pushUndoer(new undoers::DirtyArea(getObjects(), image, dirty)); @@ -1080,3 +1084,5 @@ void DocumentApi::deselectMask() m_document->setMaskVisible(false); } + +} // namespace app diff --git a/src/app/document_api.h b/src/app/document_api.h new file mode 100644 index 000000000..99d17a842 --- /dev/null +++ b/src/app/document_api.h @@ -0,0 +1,124 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENT_API_H_INCLUDED +#define APP_DOCUMENT_API_H_INCLUDED + +#include "gfx/rect.h" +#include "raster/algorithm/flip_type.h" +#include "raster/dithering_method.h" +#include "raster/frame_number.h" +#include "raster/pixel_format.h" + +namespace raster { + class Cel; + class Image; + class Layer; + class LayerFolder; + class LayerImage; + class Mask; + class Sprite; +} + +namespace undo { + class UndoersCollector; + class ObjectsContainer; +} + +namespace app { + class Document; + + using namespace raster; + + // High-level API to modify a document in an undoable and observable way. + // Each method of this class take care of three important things: + // 1) Do the given action with low-level operations (raster + // namespace mainly), + // 2) Add undoers so the action can be undone in the + // future (undoers namespace mainly), + // 3) Notify observers of the document that a change + // was made (call DocumentObserver methods). + class DocumentApi { + public: + DocumentApi(Document* document, undo::UndoersCollector* undoers); + + // Sprite API + void setSpriteSize(Sprite* sprite, int w, int h); + void cropSprite(Sprite* sprite, const gfx::Rect& bounds, int bgcolor); + void trimSprite(Sprite* sprite, int bgcolor); + void setPixelFormat(Sprite* sprite, PixelFormat newFormat, DitheringMethod dithering_method); + + // Frames API + void addFrame(Sprite* sprite, FrameNumber newFrame); + void removeFrame(Sprite* sprite, FrameNumber frame); + void setTotalFrames(Sprite* sprite, FrameNumber frames); + void setFrameDuration(Sprite* sprite, FrameNumber frame, int msecs); + void setConstantFrameRate(Sprite* sprite, int msecs); + void moveFrameBefore(Sprite* sprite, FrameNumber frame, FrameNumber beforeFrame); + + // Cels API + void addCel(LayerImage* layer, Cel* cel); + void removeCel(LayerImage* layer, Cel* cel); + void setCelFramePosition(Sprite* sprite, Cel* cel, FrameNumber frame); + void setCelPosition(Sprite* sprite, Cel* cel, int x, int y); + void cropCel(Sprite* sprite, Cel* cel, int x, int y, int w, int h, int bgcolor); + + // Layers API + LayerImage* newLayer(Sprite* sprite); + LayerFolder* newLayerFolder(Sprite* sprite); + void addLayer(LayerFolder* folder, Layer* newLayer, Layer* afterThis); + void removeLayer(Layer* layer); + void restackLayerAfter(Layer* layer, Layer* afterThis); + void cropLayer(Layer* layer, int x, int y, int w, int h, int bgcolor); + void displaceLayers(Layer* layer, int dx, int dy); + void backgroundFromLayer(LayerImage* layer, int bgcolor); + void layerFromBackground(Layer* layer); + void flattenLayers(Sprite* sprite, int bgcolor); + + // Images stock API + int addImageInStock(Sprite* sprite, Image* image); + void removeImageFromStock(Sprite* sprite, int imageIndex); + void replaceStockImage(Sprite* sprite, int imageIndex, Image* newImage); + + // Image API + Image* getCelImage(Sprite* sprite, Cel* cel); + void clearMask(Layer* layer, Cel* cel, int bgcolor); + void flipImage(Image* image, const gfx::Rect& bounds, raster::algorithm::FlipType flipType); + void flipImageWithMask(Image* image, const Mask* mask, raster::algorithm::FlipType flipType, int bgcolor); + void pasteImage(Sprite* sprite, Cel* cel, const Image* src_image, int x, int y, int opacity); + + // Mask API + void copyToCurrentMask(Mask* mask); + void setMaskPosition(int x, int y); + void deselectMask(); + + private: + undo::ObjectsContainer* getObjects() const; + void addFrameForLayer(Layer* layer, FrameNumber frame); + void removeFrameOfLayer(Layer* layer, FrameNumber frame); + void copyPreviousFrame(Layer* layer, FrameNumber frame); + void moveFrameBeforeLayer(Layer* layer, FrameNumber frame, FrameNumber beforeFrame); + void configureLayerAsBackground(LayerImage* layer); + + Document* m_document; + undo::UndoersCollector* m_undoers; + }; + +} // namespace app + +#endif diff --git a/src/app/document_event.h b/src/app/document_event.h new file mode 100644 index 000000000..cbd094ddd --- /dev/null +++ b/src/app/document_event.h @@ -0,0 +1,95 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENT_EVENT_H_INCLUDED +#define APP_DOCUMENT_EVENT_H_INCLUDED + +#include "gfx/region.h" +#include "raster/frame_number.h" + +namespace raster { + class Cel; + class Image; + class Layer; + class LayerImage; + class Sprite; +} + +namespace app { + class Document; + + using namespace raster; + + class DocumentEvent { + public: + DocumentEvent(Document* document) + : m_document(document) + , m_sprite(NULL) + , m_layer(NULL) + , m_cel(NULL) + , m_image(NULL) + , m_imageIndex(-1) + , m_frame(0) + , m_targetLayer(NULL) + , m_targetFrame(0) { + } + + // Source of the event. + Document* document() const { return m_document; } + Sprite* sprite() const { return m_sprite; } + Layer* layer() const { return m_layer; } + Cel* cel() const { return m_cel; } + Image* image() const { return m_image; } + int imageIndex() const { return m_imageIndex; } + FrameNumber frame() const { return m_frame; } + const gfx::Region& region() const { return m_region; } + + void sprite(Sprite* sprite) { m_sprite = sprite; } + void layer(Layer* layer) { m_layer = layer; } + void cel(Cel* cel) { m_cel = cel; } + void image(Image* image) { m_image = image; } + void imageIndex(int imageIndex) { m_imageIndex = imageIndex; } + void frame(FrameNumber frame) { m_frame = frame; } + void region(const gfx::Region& rgn) { m_region = rgn; } + + // Destination of the operation. + Layer* targetLayer() const { return m_targetLayer; } + FrameNumber targetFrame() const { return m_targetFrame; } + + void targetLayer(Layer* layer) { m_targetLayer = layer; } + void targetFrame(FrameNumber frame) { m_targetFrame = frame; } + + private: + Document* m_document; + Sprite* m_sprite; + Layer* m_layer; + Cel* m_cel; + Image* m_image; + int m_imageIndex; + FrameNumber m_frame; + gfx::Region m_region; + + // For copy/move commands, the m_layer/m_frame are source of the + // operation, and these are the destination of the operation. + Layer* m_targetLayer; + FrameNumber m_targetFrame; + }; + +} // namespace app + +#endif diff --git a/src/document_id.h b/src/app/document_id.h similarity index 92% rename from src/document_id.h rename to src/app/document_id.h index ddf00f140..022318731 100644 --- a/src/document_id.h +++ b/src/app/document_id.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DOCUMENT_ID_H_INCLUDED -#define DOCUMENT_ID_H_INCLUDED +#ifndef APP_DOCUMENT_ID_H_INCLUDED +#define APP_DOCUMENT_ID_H_INCLUDED typedef uint32_t DocumentId; diff --git a/src/document_location.cpp b/src/app/document_location.cpp similarity index 94% rename from src/document_location.cpp rename to src/app/document_location.cpp index 67d70a75b..884332ae4 100644 --- a/src/document_location.cpp +++ b/src/app/document_location.cpp @@ -16,15 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "document_location.h" +#include "app/document_location.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/sprite.h" #include "raster/stock.h" +namespace app { + +using namespace raster; + LayerIndex DocumentLocation::layerIndex() const { return (m_sprite && m_layer ? @@ -77,3 +83,5 @@ Image* DocumentLocation::image(int* x, int* y, int* opacity) const return image; } + +} // namespace app diff --git a/src/app/document_location.h b/src/app/document_location.h new file mode 100644 index 000000000..23c5a3ff7 --- /dev/null +++ b/src/app/document_location.h @@ -0,0 +1,79 @@ +/* ASEPRITE + * Copyright (C) 2001-2012 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENT_LOCATION_H_INCLUDED +#define APP_DOCUMENT_LOCATION_H_INCLUDED + +#include "raster/frame_number.h" +#include "raster/layer_index.h" + +namespace raster { + class Cel; + class Image; + class Layer; + class Palette; + class Sprite; +} + +namespace app { + class Document; + + using namespace raster; + + // Specifies the current location in a context. If we are in the + // UIContext, it means the location in the current Editor (current + // document, sprite, layer, frame, etc.). + class DocumentLocation { + public: + DocumentLocation() + : m_document(NULL) + , m_sprite(NULL) + , m_layer(NULL) + , m_frame(0) { } + + const Document* document() const { return m_document; } + const Sprite* sprite() const { return m_sprite; } + const Layer* layer() const { return m_layer; } + FrameNumber frame() const { return m_frame; } + const Cel* cel() const; + + Document* document() { return m_document; } + Sprite* sprite() { return m_sprite; } + Layer* layer() { return m_layer; } + Cel* cel(); + + void document(Document* document) { m_document = document; } + void sprite(Sprite* sprite) { m_sprite = sprite; } + void layer(Layer* layer) { m_layer = layer; } + void frame(FrameNumber frame) { m_frame = frame; } + + LayerIndex layerIndex() const; + void layerIndex(LayerIndex layerIndex); + Palette* palette(); + Image* image(int* x = NULL, int* y = NULL, int* opacity = NULL) const; + + private: + Document* m_document; + Sprite* m_sprite; + Layer* m_layer; + FrameNumber m_frame; + }; + +} // namespace app + +#endif diff --git a/src/app/document_observer.h b/src/app/document_observer.h new file mode 100644 index 000000000..f9cb8ef3c --- /dev/null +++ b/src/app/document_observer.h @@ -0,0 +1,77 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENT_OBSERVER_H_INCLUDED +#define APP_DOCUMENT_OBSERVER_H_INCLUDED + +#include "raster/frame_number.h" + +namespace app { + class DocumentEvent; + + // Observer of document events. The default implementation does + // nothing in each handler, so you can override the required events. + class DocumentObserver { + public: + virtual ~DocumentObserver() { } + + // General update. If an observer receives this event, it's because + // anything in the document could be changed. + virtual void onGeneralUpdate(DocumentEvent& ev) { } + + virtual void onAddSprite(DocumentEvent& ev) { } + virtual void onAddLayer(DocumentEvent& ev) { } + virtual void onAddFrame(DocumentEvent& ev) { } + virtual void onAddCel(DocumentEvent& ev) { } + + virtual void onRemoveSprite(DocumentEvent& ev) { } + + virtual void onRemoveLayer(DocumentEvent& ev) { } + + // Called when a frame is removed. It's called after the frame was + // removed, and the sprite's total number of frames is modified. + virtual void onRemoveFrame(DocumentEvent& ev) { } + + virtual void onRemoveCel(DocumentEvent& ev) { } + + virtual void onSpriteSizeChanged(DocumentEvent& ev) { } + + virtual void onLayerRestacked(DocumentEvent& ev) { } + virtual void onLayerMergedDown(DocumentEvent& ev) { } + + virtual void onCelMoved(DocumentEvent& ev) { } + virtual void onCelCopied(DocumentEvent& ev) { } + virtual void onCelFrameChanged(DocumentEvent& ev) { } + virtual void onCelPositionChanged(DocumentEvent& ev) { } + virtual void onCelOpacityChanged(DocumentEvent& ev) { } + + virtual void onFrameDurationChanged(DocumentEvent& ev) { } + + virtual void onImagePixelsModified(DocumentEvent& ev) { } + virtual void onSpritePixelsModified(DocumentEvent& ev) { } + + // When the number of total frames available is modified. + virtual void onTotalFramesChanged(DocumentEvent& ev) { } + + // Called to destroy the observer. (Here you could call "delete this".) + virtual void dispose() { } + }; + +} // namespace app + +#endif diff --git a/src/document_undo.cpp b/src/app/document_undo.cpp similarity index 94% rename from src/document_undo.cpp rename to src/app/document_undo.cpp index 77aceebb8..8bf48c8b1 100644 --- a/src/document_undo.cpp +++ b/src/app/document_undo.cpp @@ -16,18 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "document_undo.h" +#include "app/document_undo.h" -#include "objects_container_impl.h" +#include "app/objects_container_impl.h" +#include "app/undoers/close_group.h" #include "undo/undo_history.h" -#include "undoers/close_group.h" #include // TODO remove this when get_config_int() is removed from here #include #include +namespace app { + DocumentUndo::DocumentUndo() : m_objects(new ObjectsContainerImpl) , m_undoHistory(new undo::UndoHistory(this)) @@ -128,3 +132,5 @@ undoers::CloseGroup* DocumentUndo::getNextRedoGroup() const else throw std::logic_error("There are some action without a CloseGroup"); } + +} // namespace app diff --git a/src/app/document_undo.h b/src/app/document_undo.h new file mode 100644 index 000000000..623902f76 --- /dev/null +++ b/src/app/document_undo.h @@ -0,0 +1,97 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENT_UNDO_H_INCLUDED +#define APP_DOCUMENT_UNDO_H_INCLUDED + +#include "base/compiler_specific.h" +#include "base/disable_copying.h" +#include "base/unique_ptr.h" +#include "raster/sprite_position.h" +#include "undo/undo_history.h" + +namespace undo { + class ObjectsContainer; + class Undoer; +} + +namespace app { + namespace undoers { + class CloseGroup; + } + + using namespace raster; + + class DocumentUndo : public undo::UndoHistoryDelegate { + public: + DocumentUndo(); + + bool isEnabled() const { return m_enabled; } + void setEnabled(bool state) { m_enabled = state; } + + bool canUndo() const; + bool canRedo() const; + + void doUndo(); + void doRedo(); + + void clearRedo(); + + bool isSavedState() const; + void markSavedState(); + + // UndoHistoryDelegate implementation. + undo::ObjectsContainer* getObjects() const OVERRIDE { return m_objects; } + size_t getUndoSizeLimit() const OVERRIDE; + + void pushUndoer(undo::Undoer* undoer); + + bool implantUndoerInLastGroup(undo::Undoer* undoer); + + const char* getNextUndoLabel() const; + const char* getNextRedoLabel() const; + + SpritePosition getNextUndoSpritePosition() const; + SpritePosition getNextRedoSpritePosition() const; + + undo::UndoersCollector* getDefaultUndoersCollector() { + return m_undoHistory; + } + + private: + undoers::CloseGroup* getNextUndoGroup() const; + undoers::CloseGroup* getNextRedoGroup() const; + + // Collection of objects used by UndoHistory to reference deleted + // objects that are re-created by an Undoer. The container keeps an + // ID that is saved in the serialization process, and loaded in the + // deserialization process. The ID can be used by different undoers + // to keep references to deleted objects. + base::UniquePtr m_objects; + + // Stack of undoers to undo operations. + base::UniquePtr m_undoHistory; + + bool m_enabled; + + DISABLE_COPYING(DocumentUndo); + }; + +} // namespace app + +#endif diff --git a/src/documents.cpp b/src/app/documents.cpp similarity index 94% rename from src/documents.cpp rename to src/app/documents.cpp index 593b8bb55..7d189a0bf 100644 --- a/src/documents.cpp +++ b/src/app/documents.cpp @@ -16,17 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "documents.h" +#include "app/documents.h" #include "base/mutex.h" -#include "document.h" +#include "app/document.h" #include "raster/sprite.h" #include "undo/undo_history.h" #include +namespace app { + Documents::Documents() { m_idCounter = 0; @@ -80,3 +84,5 @@ Document* Documents::getById(DocumentId id) const } return NULL; } + +} // namespace app diff --git a/src/app/documents.h b/src/app/documents.h new file mode 100644 index 000000000..e31f07fda --- /dev/null +++ b/src/app/documents.h @@ -0,0 +1,77 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_DOCUMENTS_H_INCLUDED +#define APP_DOCUMENTS_H_INCLUDED + +#include "base/disable_copying.h" +#include "app/document_id.h" + +#include + +namespace app { + class Document; + + class Documents { + public: + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; + + Documents(); + ~Documents(); + + iterator begin() { return m_documents.begin(); } + iterator end() { return m_documents.end(); } + const_iterator begin() const { return m_documents.begin(); } + const_iterator end() const { return m_documents.end(); } + + Document* front() const { return m_documents.front(); } + Document* back() const { return m_documents.back(); } + + int size() const { return m_documents.size(); } + bool empty() const { return m_documents.empty(); } + + // Adds a new document to the list. If the destructor is called the + // document is deleted automatically. + void addDocument(Document* document); + + // Removes a document from the list without deleting it. You must to + // delete the document after removing it. + void removeDocument(Document* document); + + // Moves the document to the given location in the same + // list. E.g. It is used to reorder documents when they are selected + // as active. + void moveDocument(Document* document, int index); + + Document* getByIndex(int index) const { return m_documents[index]; } + Document* getById(DocumentId id) const; + + private: + // Deletes all documents in the list (calling "delete" operation). + void deleteAll(); + + std::vector m_documents; + DocumentId m_idCounter; + + DISABLE_COPYING(Documents); + }; + +} // namespace app + +#endif diff --git a/src/drop_files.cpp b/src/app/drop_files.cpp similarity index 90% rename from src/drop_files.cpp rename to src/app/drop_files.cpp index 31f7ac097..766a255fa 100644 --- a/src/drop_files.cpp +++ b/src/app/drop_files.cpp @@ -16,17 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/ui/main_window.h" #include "base/mutex.h" #include "base/scoped_lock.h" -#include "commands/commands.h" -#include "commands/params.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" #include "ui/manager.h" #include "ui/window.h" -#include "ui_context.h" -#include "widgets/main_window.h" +#include "app/ui_context.h" #include #include @@ -43,9 +45,11 @@ typedef FARPROC wndproc_t; #endif +namespace app { + static wndproc_t base_wnd_proc = NULL; static std::vector* dropped_files; -static Mutex* dropped_files_mutex = NULL; +static base::mutex* dropped_files_mutex = NULL; static void subclass_hwnd(); static void unsubclass_hwnd(); @@ -54,7 +58,7 @@ static LRESULT CALLBACK ase_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM void install_drop_files() { dropped_files = new std::vector(); - dropped_files_mutex = new Mutex(); + dropped_files_mutex = new base::mutex(); subclass_hwnd(); } @@ -79,7 +83,7 @@ void check_for_dropped_files() if (ui::Manager::getDefault()->getForegroundWindow() != App::instance()->getMainWindow()) return; - ScopedLock lock(*dropped_files_mutex); + base::scoped_lock lock(*dropped_files_mutex); if (!dropped_files->empty()) { std::vector files = *dropped_files; dropped_files->clear(); @@ -125,7 +129,7 @@ static LRESULT CALLBACK ase_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM case WM_DROPFILES: { - ScopedLock lock(*dropped_files_mutex); + base::scoped_lock lock(*dropped_files_mutex); HDROP hdrop = (HDROP)(wparam); int index, count, length; @@ -155,3 +159,5 @@ void uninstall_drop_files() { } void check_for_dropped_files() { } #endif + +} // namespace app diff --git a/src/drop_files.h b/src/app/drop_files.h similarity index 79% rename from src/drop_files.h rename to src/app/drop_files.h index babbcf54a..3f7bb07c1 100644 --- a/src/drop_files.h +++ b/src/app/drop_files.h @@ -16,12 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DROP_FILES_H_INCLUDED -#define DROP_FILES_H_INCLUDED +#ifndef APP_DROP_FILES_H_INCLUDED +#define APP_DROP_FILES_H_INCLUDED -void install_drop_files(); -void uninstall_drop_files(); +namespace app { -void check_for_dropped_files(); + void install_drop_files(); + void uninstall_drop_files(); + + void check_for_dropped_files(); + +} // namespace app #endif diff --git a/src/errno_unittest.cpp b/src/app/errno_unittest.cpp similarity index 100% rename from src/errno_unittest.cpp rename to src/app/errno_unittest.cpp diff --git a/src/file/ase_format.cpp b/src/app/file/ase_format.cpp similarity index 98% rename from src/file/ase_format.cpp rename to src/app/file/ase_format.cpp index d63e0a5be..ee7fbad55 100644 --- a/src/file/ase_format.cpp +++ b/src/app/file/ase_format.cpp @@ -16,14 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/document.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/format_options.h" +#include "base/cfile.h" #include "base/exception.h" -#include "document.h" -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/format_options.h" #include "raster/raster.h" #include "zlib.h" @@ -43,8 +46,11 @@ #define ASE_FILE_LINK_CEL 1 #define ASE_FILE_COMPRESSED_CEL 2 -typedef struct ASE_Header -{ +namespace app { + +using namespace base; + +struct ASE_Header { long pos; uint32_t size; @@ -60,15 +66,14 @@ typedef struct ASE_Header uint8_t transparent_index; uint8_t ignore[3]; uint16_t ncolors; -} ASE_Header; +}; -typedef struct ASE_FrameHeader -{ +struct ASE_FrameHeader { uint32_t size; uint16_t magic; uint16_t chunks; uint16_t duration; -} ASE_FrameHeader; +}; // TODO Warning: the writing routines aren't thread-safe static ASE_FrameHeader *current_frame_header = NULL; @@ -104,8 +109,7 @@ static void ase_file_write_cel_chunk(FILE *f, Cel *cel, LayerImage *layer, Sprit static Mask *ase_file_read_mask_chunk(FILE *f); static void ase_file_write_mask_chunk(FILE *f, Mask *mask); -class AseFormat : public FileFormat -{ +class AseFormat : public FileFormat { const char* onGetName() const { return "ase"; } const char* onGetExtensions() const { return "ase,aseprite"; } int onGetFlags() const { @@ -173,19 +177,19 @@ bool AseFormat::onLoad(FileOp *fop) ASE_FrameHeader frame_header; ase_file_read_frame_header(f, &frame_header); - /* correct frame type */ + // Correct frame type if (frame_header.magic == ASE_FILE_FRAME_MAGIC) { - /* use frame-duration field? */ + // Use frame-duration field? if (frame_header.duration > 0) sprite->setFrameDuration(frame, frame_header.duration); - /* read chunks */ + // Read chunks for (int c=0; c cel(new Cel(frame, 0)); + base::UniquePtr cel(new Cel(frame, 0)); cel->setPosition(x, y); cel->setOpacity(opacity); @@ -1247,3 +1251,5 @@ static void ase_file_write_mask_chunk(FILE *f, Mask *mask) ase_file_write_close_chunk(f); } + +} // namespace app diff --git a/src/file/bmp_format.cpp b/src/app/file/bmp_format.cpp similarity index 98% rename from src/file/bmp_format.cpp rename to src/app/file/bmp_format.cpp index e6e7dbd9a..d2e11a614 100644 --- a/src/file/bmp_format.cpp +++ b/src/app/file/bmp_format.cpp @@ -18,18 +18,24 @@ * bmp.c - Based on the code of Seymour Shlien and Jonas Petersen. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/format_options.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/format_options.h" +#include "base/cfile.h" #include "raster/raster.h" #include -class BmpFormat : public FileFormat -{ +namespace app { + +using namespace base; + +class BmpFormat : public FileFormat { enum { BMP_OPTIONS_FORMAT_WINDOWS = 12, BMP_OPTIONS_FORMAT_OS2 = 40, @@ -810,3 +816,5 @@ bool BmpFormat::onSave(FileOp *fop) return true; } } + +} // namespace app diff --git a/src/file/file.cpp b/src/app/file/file.cpp similarity index 92% rename from src/file/file.cpp rename to src/app/file/file.cpp index b36baeec6..d5877e6dd 100644 --- a/src/file/file.cpp +++ b/src/app/file/file.cpp @@ -16,29 +16,35 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/ui/status_bar.h" #include "base/mutex.h" #include "base/scoped_lock.h" #include "base/shared_ptr.h" #include "base/string.h" -#include "console.h" -#include "document.h" -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_formats_manager.h" -#include "file/format_options.h" -#include "modules/gui.h" -#include "modules/palettes.h" +#include "app/console.h" +#include "app/document.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_formats_manager.h" +#include "app/file/format_options.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" #include "raster/quantization.h" #include "raster/raster.h" #include "ui/alert.h" -#include "widgets/status_bar.h" #include #include +namespace app { + +using namespace base; + static FileOp* fop_new(FileOpType type); static void fop_prepare_for_sequence(FileOp* fop); @@ -594,13 +600,13 @@ void fop_operate(FileOp *fop, IFileOpProgress* progress) void fop_done(FileOp *fop) { // Finally done. - ScopedLock lock(*fop->mutex); + scoped_lock lock(*fop->mutex); fop->done = true; } void fop_stop(FileOp *fop) { - ScopedLock lock(*fop->mutex); + scoped_lock lock(*fop->mutex); if (!fop->done) fop->stop = true; } @@ -730,14 +736,14 @@ void fop_error(FileOp *fop, const char *format, ...) // Concatenate the new error { - ScopedLock lock(*fop->mutex); + scoped_lock lock(*fop->mutex); fop->error += buf_error; } } void fop_progress(FileOp *fop, double progress) { - ScopedLock lock(*fop->mutex); + scoped_lock lock(*fop->mutex); if (fop->is_sequence()) { fop->progress = @@ -756,7 +762,7 @@ double fop_get_progress(FileOp *fop) { double progress; { - ScopedLock lock(*fop->mutex); + scoped_lock lock(*fop->mutex); progress = fop->progress; } return progress; @@ -768,7 +774,7 @@ bool fop_is_done(FileOp *fop) { bool done; { - ScopedLock lock(*fop->mutex); + scoped_lock lock(*fop->mutex); done = fop->done; } return done; @@ -778,7 +784,7 @@ bool fop_is_stop(FileOp *fop) { bool stop; { - ScopedLock lock(*fop->mutex); + scoped_lock lock(*fop->mutex); stop = fop->stop; } return stop; @@ -793,7 +799,7 @@ static FileOp* fop_new(FileOpType type) fop->format_data = NULL; fop->document = NULL; - fop->mutex = new Mutex(); + fop->mutex = new base::mutex(); fop->progress = 0.0f; fop->progressInterface = NULL; fop->done = false; @@ -903,83 +909,4 @@ static int split_filename(const char* filename, char* left, char* right, int* wi return ret; } - -// Reads a WORD (16 bits) using in little-endian byte ordering. -int fgetw(FILE* file) -{ - int b1, b2; - - b1 = fgetc(file); - if (b1 == EOF) - return EOF; - - b2 = fgetc(file); - if (b2 == EOF) - return EOF; - - // Little endian. - return ((b2 << 8) | b1); -} - -// Reads a DWORD (32 bits) using in little-endian byte ordering. -long fgetl(FILE* file) -{ - int b1, b2, b3, b4; - - b1 = fgetc(file); - if (b1 == EOF) - return EOF; - - b2 = fgetc(file); - if (b2 == EOF) - return EOF; - - b3 = fgetc(file); - if (b3 == EOF) - return EOF; - - b4 = fgetc(file); - if (b4 == EOF) - return EOF; - - // Little endian. - return ((b4 << 24) | (b3 << 16) | (b2 << 8) | b1); -} - -// Writes a word using in little-endian byte ordering. -// Returns 0 in success or -1 in error -int fputw(int w, FILE* file) -{ - int b1, b2; - - // Little endian. - b2 = (w & 0xFF00) >> 8; - b1 = w & 0x00FF; - - if (fputc(b1, file) == b1) - if (fputc(b2, file) == b2) - return 0; - - return -1; -} - -// Writes DWORD a using in little-endian byte ordering. -// Returns 0 in success or -1 in error -int fputl(long l, FILE* file) -{ - int b1, b2, b3, b4; - - // Little endian. - b4 = (int)((l & 0xFF000000L) >> 24); - b3 = (int)((l & 0x00FF0000L) >> 16); - b2 = (int)((l & 0x0000FF00L) >> 8); - b1 = (int)l & 0x00FF; - - if (fputc(b1, file) == b1) - if (fputc(b2, file) == b2) - if (fputc(b3, file) == b3) - if (fputc(b4, file) == b4) - return 0; - - return -1; -} +} // namespace app diff --git a/src/app/file/file.h b/src/app/file/file.h new file mode 100644 index 000000000..d5e4c7483 --- /dev/null +++ b/src/app/file/file.h @@ -0,0 +1,150 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_FILE_FILE_H_INCLUDED +#define APP_FILE_FILE_H_INCLUDED + +#include "base/shared_ptr.h" +#include "raster/frame_number.h" +#include "raster/pixel_format.h" + +#include +#include +#include + +#define FILE_LOAD_SEQUENCE_NONE 0x00000001 +#define FILE_LOAD_SEQUENCE_ASK 0x00000002 +#define FILE_LOAD_SEQUENCE_YES 0x00000004 +#define FILE_LOAD_ONE_FRAME 0x00000008 + +namespace base { + class mutex; +} + +namespace raster { + class Cel; + class Image; + class Layer; + class LayerImage; + class Palette; +} + +namespace app { + class Document; + class FileFormat; + class FormatOptions; + + using namespace raster; + + // File operations. + typedef enum { + FileOpLoad, + FileOpSave + } FileOpType; + + class IFileOpProgress + { + public: + virtual ~IFileOpProgress() { } + virtual void ackFileOpProgress(double progress) = 0; + }; + + // Structure to load & save files. + struct FileOp { + FileOpType type; // Operation type: 0=load, 1=save. + FileFormat* format; + void* format_data; // Custom data for the FileFormat::onLoad/onSave operations. + Document* document; // Loaded document, or document to be saved. + std::string filename; // File-name to load/save. + + // Shared fields between threads. + base::mutex* mutex; // Mutex to access to the next two fields. + double progress; // Progress (1.0 is ready). + IFileOpProgress* progressInterface; + std::string error; // Error string. + bool done : 1; // True if the operation finished. + bool stop : 1; // Force the break of the operation. + bool oneframe : 1; // Load just one frame (in formats + // that support animation like + // GIF/FLI/ASE). + + // Data for sequences. + struct { + std::vector filename_list; // All file names to load/save. + Palette* palette; // Palette of the sequence. + Image* image; // Image to be saved/loaded. + // For the progress bar. + double progress_offset; // Progress offset from the current frame. + double progress_fraction; // Progress fraction for one frame. + // To load sequences. + FrameNumber frame; + bool has_alpha; + LayerImage* layer; + Cel* last_cel; + SharedPtr format_options; + } seq; + + ~FileOp(); + + bool has_error() const { + return !this->error.empty(); + } + + bool is_sequence() const { + return !this->seq.filename_list.empty(); + } + + }; + + // Available extensions for each load/save operation. + + void get_readable_extensions(char* buf, int size); + void get_writable_extensions(char* buf, int size); + + // High-level routines to load/save documents. + + Document* load_document(const char* filename); + int save_document(Document* document); + + // Low-level routines to load/save documents. + + FileOp* fop_to_load_document(const char* filename, int flags); + FileOp* fop_to_save_document(Document* document); + void fop_operate(FileOp* fop, IFileOpProgress* progress); + void fop_done(FileOp* fop); + void fop_stop(FileOp* fop); + void fop_free(FileOp* fop); + + // Does extra post-load processing which may require user intervention. + void fop_post_load(FileOp* fop); + + void fop_sequence_set_format_options(FileOp* fop, const SharedPtr& format_options); + void fop_sequence_set_color(FileOp* fop, int index, int r, int g, int b); + void fop_sequence_get_color(FileOp* fop, int index, int *r, int *g, int *b); + Image* fop_sequence_image(FileOp* fi, PixelFormat pixelFormat, int w, int h); + + void fop_error(FileOp* fop, const char *error, ...); + void fop_progress(FileOp* fop, double progress); + + double fop_get_progress(FileOp* fop); + bool fop_is_done(FileOp* fop); + bool fop_is_stop(FileOp* fop); + +} // namespace app + +#endif diff --git a/src/file/file_format.cpp b/src/app/file/file_format.cpp similarity index 90% rename from src/file/file_format.cpp rename to src/app/file/file_format.cpp index 59968d2e4..c15c980b6 100644 --- a/src/file/file_format.cpp +++ b/src/app/file/file_format.cpp @@ -16,13 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "file/file_format.h" -#include "file/format_options.h" +#include "app/file/file_format.h" +#include "app/file/format_options.h" #include +namespace app { + FileFormat::FileFormat() { } @@ -62,3 +66,5 @@ void FileFormat::destroyData(FileOp* fop) { onDestroyData(fop); } + +} // namespace app diff --git a/src/app/file/file_format.h b/src/app/file/file_format.h new file mode 100644 index 000000000..288a14a71 --- /dev/null +++ b/src/app/file/file_format.h @@ -0,0 +1,94 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_FILE_FILE_FORMAT_H_INCLUDED +#define APP_FILE_FILE_FORMAT_H_INCLUDED + +#include "base/shared_ptr.h" + +#include + +#define FILE_SUPPORT_LOAD 0x00000001 +#define FILE_SUPPORT_SAVE 0x00000002 +#define FILE_SUPPORT_RGB 0x00000004 +#define FILE_SUPPORT_RGBA 0x00000008 +#define FILE_SUPPORT_GRAY 0x00000010 +#define FILE_SUPPORT_GRAYA 0x00000020 +#define FILE_SUPPORT_INDEXED 0x00000040 +#define FILE_SUPPORT_LAYERS 0x00000080 +#define FILE_SUPPORT_FRAMES 0x00000100 +#define FILE_SUPPORT_PALETTES 0x00000200 +#define FILE_SUPPORT_SEQUENCES 0x00000400 +#define FILE_SUPPORT_GET_FORMAT_OPTIONS 0x00000800 + +namespace app { + + class FormatOptions; + class FileFormat; + struct FileOp; + + // A file format supported by ASE. It is the base class to extend if + // you want to add support to load and/or save a new kind of + // image/animation format. + class FileFormat { + public: + FileFormat(); + virtual ~FileFormat(); + + const char* name() const; // File format name + const char* extensions() const; // Extensions (e.g. "jpeg,jpg") + bool load(FileOp* fop); + bool save(FileOp* fop); + + // Does post-load operation which require user intervention. + // Returns false cancelled the operation. + bool postLoad(FileOp* fop); + + // Destroys the custom data stored in "fop->format_data" field. + void destroyData(FileOp* fop); + + // Returns extra options for this format. It can return != NULL + // only if flags() returns FILE_SUPPORT_GET_FORMAT_OPTIONS. + SharedPtr getFormatOptions(FileOp* fop) { + return onGetFormatOptions(fop); + } + + // Returns true if this file format supports the given flag. + bool support(int f) const { + return ((onGetFlags() & f) == f); + } + + protected: + virtual const char* onGetName() const = 0; + virtual const char* onGetExtensions() const = 0; + virtual int onGetFlags() const = 0; + + virtual bool onLoad(FileOp* fop) = 0; + virtual bool onPostLoad(FileOp* fop) { return true; } + virtual bool onSave(FileOp* fop) = 0; + virtual void onDestroyData(FileOp* fop) { } + + virtual SharedPtr onGetFormatOptions(FileOp* fop) { + return SharedPtr(0); + } + + }; + +} // namespace app + +#endif diff --git a/src/file/file_formats_manager.cpp b/src/app/file/file_formats_manager.cpp similarity index 92% rename from src/file/file_formats_manager.cpp rename to src/app/file/file_formats_manager.cpp index 87b41c065..0d6c965b9 100644 --- a/src/file/file_formats_manager.cpp +++ b/src/app/file/file_formats_manager.cpp @@ -16,13 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "file/file_formats_manager.h" -#include "file/file_format.h" -#include "file/format_options.h" +#include "app/file/file_formats_manager.h" +#include "app/file/file_format.h" +#include "app/file/format_options.h" + +namespace app { extern FileFormat* CreateAseFormat(); extern FileFormat* CreateBmpFormat(); @@ -76,3 +80,5 @@ FileFormatsList::iterator FileFormatsManager::end() { return m_formats.end(); } + +} // namespace app diff --git a/src/app/file/file_formats_manager.h b/src/app/file/file_formats_manager.h new file mode 100644 index 000000000..e0d457698 --- /dev/null +++ b/src/app/file/file_formats_manager.h @@ -0,0 +1,56 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_FILE_FILE_FORMATS_MANAGER_H_INCLUDED +#define APP_FILE_FILE_FORMATS_MANAGER_H_INCLUDED + +#include + +namespace app { + + class FileFormat; + + // A list of file formats. Used by the FileFormatsManager to keep + // track of all known file extensions supported by ASE. + typedef std::vector FileFormatsList; + + // Manages the list of known formats by ASEPRITE (image file format that can + // be loaded and/or saved). + class FileFormatsManager { + public: + // Returns a singleton of this class. + static FileFormatsManager& instance(); + + virtual ~FileFormatsManager(); + + void registerAllFormats(); + + // Iterators to access to the list of formats. + FileFormatsList::iterator begin(); + FileFormatsList::iterator end(); + + private: + // Register one format. + void registerFormat(FileFormat* fileFormat); + + FileFormatsList m_formats; + }; + +} // namespace app + +#endif diff --git a/src/file/file_handle.h b/src/app/file/file_handle.h similarity index 89% rename from src/file/file_handle.h rename to src/app/file/file_handle.h index fa592e801..a13d10ef6 100644 --- a/src/file/file_handle.h +++ b/src/app/file/file_handle.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef FILE_HANDLE_FORMAT_H_INCLUDED -#define FILE_HANDLE_FORMAT_H_INCLUDED +#ifndef APP_FILE_HANDLE_FORMAT_H_INCLUDED +#define APP_FILE_HANDLE_FORMAT_H_INCLUDED #include "base/exception.h" #include "base/unique_ptr.h" @@ -38,7 +38,7 @@ public: operator std::FILE*() { return m_handle; } private: - UniquePtr m_handle; + base::UniquePtr m_handle; }; #endif diff --git a/src/file/file_unittest.cpp b/src/app/file/file_unittest.cpp similarity index 89% rename from src/file/file_unittest.cpp rename to src/app/file/file_unittest.cpp index aeadaca0a..dd6dace44 100644 --- a/src/file/file_unittest.cpp +++ b/src/app/file/file_unittest.cpp @@ -18,10 +18,10 @@ #include "tests/test.h" -#include "app.h" -#include "document.h" -#include "file/file.h" -#include "file/file_formats_manager.h" +#include "app/app.h" +#include "app/document.h" +#include "app/file/file.h" +#include "app/file/file_formats_manager.h" #include "raster/raster.h" #include "she/she.h" @@ -29,6 +29,8 @@ #include #include +using namespace app::file; + TEST(File, SeveralSizes) { she::ScopedHandle system(she::CreateSystem()); @@ -42,7 +44,7 @@ TEST(File, SeveralSizes) std::sprintf(&fn[0], "test.ase"); { - UniquePtr doc(Document::createBasicDocument(IMAGE_INDEXED, w, h, 256)); + base::UniquePtr doc(Document::createBasicDocument(IMAGE_INDEXED, w, h, 256)); doc->setFilename(&fn[0]); // Random pixels @@ -63,7 +65,7 @@ TEST(File, SeveralSizes) } { - UniquePtr doc(load_document(&fn[0])); + base::UniquePtr doc(load_document(&fn[0])); ASSERT_EQ(w, doc->getSprite()->getWidth()); ASSERT_EQ(h, doc->getSprite()->getHeight()); diff --git a/src/file/fli/README b/src/app/file/fli/README similarity index 100% rename from src/file/fli/README rename to src/app/file/fli/README diff --git a/src/file/fli/fli.cpp b/src/app/file/fli/fli.cpp similarity index 100% rename from src/file/fli/fli.cpp rename to src/app/file/fli/fli.cpp diff --git a/src/file/fli/fli.h b/src/app/file/fli/fli.h similarity index 98% rename from src/file/fli/fli.h rename to src/app/file/fli/fli.h index 4d52f4f36..b088ab19b 100644 --- a/src/file/fli/fli.h +++ b/src/app/file/fli/fli.h @@ -16,8 +16,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#ifndef FILE_FLI_FLI_H_INCLUDED -#define FILE_FLI_FLI_H_INCLUDED +#ifndef APP_FILE_FLI_FLI_H_INCLUDED +#define APP_FILE_FLI_FLI_H_INCLUDED /** structures */ diff --git a/src/file/fli_format.cpp b/src/app/file/fli_format.cpp similarity index 91% rename from src/file/fli_format.cpp rename to src/app/file/fli_format.cpp index 1573c8c37..9f7c66e9d 100644 --- a/src/file/fli_format.cpp +++ b/src/app/file/fli_format.cpp @@ -16,24 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "document.h" -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/fli/fli.h" -#include "file/format_options.h" -#include "modules/palettes.h" +#include "app/document.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/fli/fli.h" +#include "app/file/format_options.h" +#include "app/modules/palettes.h" #include "raster/raster.h" #include #include +namespace app { + static int get_time_precision(Sprite *sprite); -class FliFormat : public FileFormat -{ +class FliFormat : public FileFormat { const char* onGetName() const { return "flc"; } const char* onGetExtensions() const { return "flc,fli"; } int onGetFlags() const { @@ -91,9 +94,9 @@ bool FliFormat::onLoad(FileOp* fop) h = fli_header.height; // Create the bitmaps - UniquePtr bmp(Image::create(IMAGE_INDEXED, w, h)); - UniquePtr old(Image::create(IMAGE_INDEXED, w, h)); - UniquePtr pal(new Palette(FrameNumber(0), 256)); + base::UniquePtr bmp(Image::create(IMAGE_INDEXED, w, h)); + base::UniquePtr old(Image::create(IMAGE_INDEXED, w, h)); + base::UniquePtr pal(new Palette(FrameNumber(0), 256)); // Create the image Sprite* sprite = new Sprite(IMAGE_INDEXED, w, h, 256); @@ -209,8 +212,8 @@ bool FliFormat::onSave(FileOp* fop) fseek(f, 128, SEEK_SET); // Create the bitmaps - UniquePtr bmp(Image::create(IMAGE_INDEXED, sprite->getWidth(), sprite->getHeight())); - UniquePtr old(Image::create(IMAGE_INDEXED, sprite->getWidth(), sprite->getHeight())); + base::UniquePtr bmp(Image::create(IMAGE_INDEXED, sprite->getWidth(), sprite->getHeight())); + base::UniquePtr old(Image::create(IMAGE_INDEXED, sprite->getWidth(), sprite->getHeight())); // Write frame by frame for (FrameNumber frpos(0); @@ -270,3 +273,5 @@ static int get_time_precision(Sprite *sprite) return precision; } + +} // namespace app diff --git a/src/app/file/format_options.h b/src/app/file/format_options.h new file mode 100644 index 000000000..d926c2df9 --- /dev/null +++ b/src/app/file/format_options.h @@ -0,0 +1,34 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_FILE_FORMAT_OPTIONS_H_INCLUDED +#define APP_FILE_FORMAT_OPTIONS_H_INCLUDED + +namespace app { + + // Extra options loaded from a file that can be useful to save the + // file later in the same loaded format (e.g. same color depth, same + // jpeg quality, etc.). + class FormatOptions { + public: + virtual ~FormatOptions() { } + }; + +} // namespace app + +#endif diff --git a/src/file/gif_format.cpp b/src/app/file/gif_format.cpp similarity index 94% rename from src/file/gif_format.cpp rename to src/app/file/gif_format.cpp index 8bce6d8e4..0d046e3c7 100644 --- a/src/file/gif_format.cpp +++ b/src/app/file/gif_format.cpp @@ -16,20 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "base/unique_ptr.h" -#include "document.h" -#include "file/file.h" -#include "file/file_format.h" -#include "file/format_options.h" -#include "modules/gui.h" +#include "app/document.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/format_options.h" +#include "app/modules/gui.h" #include "raster/raster.h" #include "ui/alert.h" -#include "util/autocrop.h" +#include "app/util/autocrop.h" #include +namespace app { + enum DisposalMethod { DISPOSAL_METHOD_NONE, DISPOSAL_METHOD_DO_NOT_DISPOSE, @@ -37,8 +41,7 @@ enum DisposalMethod { DISPOSAL_METHOD_RESTORE_PREVIOUS, }; -struct GifFrame -{ +struct GifFrame { int x, y; int duration; int mask_index; @@ -65,8 +68,7 @@ struct GifData GifFrames frames; }; -class GifFormat : public FileFormat -{ +class GifFormat : public FileFormat { const char* onGetName() const { return "gif"; } const char* onGetExtensions() const { return "gif"; } int onGetFlags() const { @@ -98,7 +100,7 @@ static int interlaced_jumps[] = { 8, 8, 4, 2 }; bool GifFormat::onLoad(FileOp* fop) { - UniquePtr gif_file(DGifOpenFileName(fop->filename.c_str()), + base::UniquePtr gif_file(DGifOpenFileName(fop->filename.c_str()), DGifCloseFile); if (!gif_file) { fop_error(fop, "Error loading GIF header.\n"); @@ -111,8 +113,8 @@ bool GifFormat::onLoad(FileOp* fop) data->sprite_w = gif_file->SWidth; data->sprite_h = gif_file->SHeight; - UniquePtr current_palette(new Palette(FrameNumber(0), 256)); - UniquePtr previous_palette(new Palette(FrameNumber(0), 256)); + base::UniquePtr current_palette(new Palette(FrameNumber(0), 256)); + base::UniquePtr previous_palette(new Palette(FrameNumber(0), 256)); // If the GIF image has a global palette, it has a valid // background color (so the GIF is not transparent). @@ -189,7 +191,7 @@ bool GifFormat::onLoad(FileOp* fop) } // Create a temporary image to load frame pixels. - UniquePtr frame_image(Image::create(IMAGE_INDEXED, frame_w, frame_h)); + base::UniquePtr frame_image(Image::create(IMAGE_INDEXED, frame_w, frame_h)); IndexedTraits::address_t addr; if (gif_file->Image.Interlace) { @@ -332,7 +334,7 @@ bool GifFormat::onPostLoad(FileOp* fop) } // Create the sprite with the GIF dimension - UniquePtr sprite(new Sprite(pixelFormat, data->sprite_w, data->sprite_h, 256)); + base::UniquePtr sprite(new Sprite(pixelFormat, data->sprite_w, data->sprite_h, 256)); // Create the main layer LayerImage* layer = new LayerImage(sprite); @@ -348,8 +350,8 @@ bool GifFormat::onPostLoad(FileOp* fop) // The previous image is used to support the special disposal method // of GIF frames DISPOSAL_METHOD_RESTORE_PREVIOUS (number 3 in // Graphics Extension) - UniquePtr current_image(Image::create(pixelFormat, data->sprite_w, data->sprite_h)); - UniquePtr previous_image(Image::create(pixelFormat, data->sprite_w, data->sprite_h)); + base::UniquePtr current_image(Image::create(pixelFormat, data->sprite_w, data->sprite_h)); + base::UniquePtr previous_image(Image::create(pixelFormat, data->sprite_w, data->sprite_h)); // Clear both images with the transparent color (alpha = 0). uint32_t bgcolor = (pixelFormat == IMAGE_RGB ? _rgba(0, 0, 0, 0): @@ -482,7 +484,7 @@ void GifFormat::onDestroyData(FileOp* fop) bool GifFormat::onSave(FileOp* fop) { - UniquePtr gif_file(EGifOpenFileName(fop->filename.c_str(), 0), + base::UniquePtr gif_file(EGifOpenFileName(fop->filename.c_str(), 0), EGifCloseFile); if (!gif_file) throw base::Exception("Error creating GIF file.\n"); @@ -510,9 +512,9 @@ bool GifFormat::onSave(FileOp* fop) background_color, color_map) == GIF_ERROR) throw base::Exception("Error writing GIF header.\n"); - UniquePtr buffer_image; - UniquePtr current_image(Image::create(IMAGE_INDEXED, sprite_w, sprite_h)); - UniquePtr previous_image(Image::create(IMAGE_INDEXED, sprite_w, sprite_h)); + base::UniquePtr buffer_image; + base::UniquePtr current_image(Image::create(IMAGE_INDEXED, sprite_w, sprite_h)); + base::UniquePtr previous_image(Image::create(IMAGE_INDEXED, sprite_w, sprite_h)); int frame_x, frame_y, frame_w, frame_h; int u1, v1, u2, v2; int i1, j1, i2, j2; @@ -668,3 +670,5 @@ bool GifFormat::onSave(FileOp* fop) return true; } + +} // namespace app diff --git a/src/file/ico_format.cpp b/src/app/file/ico_format.cpp similarity index 95% rename from src/file/ico_format.cpp rename to src/app/file/ico_format.cpp index a02743e7d..cc310e98d 100644 --- a/src/file/ico_format.cpp +++ b/src/app/file/ico_format.cpp @@ -18,19 +18,25 @@ * ico.c - Based on the code of Elias Pschernig. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "document.h" -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/format_options.h" +#include "app/document.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/format_options.h" +#include "base/cfile.h" #include "raster/raster.h" #include -class IcoFormat : public FileFormat -{ +namespace app { + +using namespace base; + +class IcoFormat : public FileFormat { const char* onGetName() const { return "ico"; } const char* onGetExtensions() const { return "ico"; } int onGetFlags() const { @@ -51,15 +57,13 @@ FileFormat* CreateIcoFormat() return new IcoFormat; } -struct ICONDIR -{ +struct ICONDIR { uint16_t reserved; uint16_t type; uint16_t entries; }; -struct ICONDIRENTRY -{ +struct ICONDIRENTRY { uint8_t width; uint8_t height; uint8_t color_count; @@ -70,8 +74,7 @@ struct ICONDIRENTRY uint32_t image_offset; }; -struct BITMAPINFOHEADER -{ +struct BITMAPINFOHEADER { uint32_t size; uint32_t width; uint32_t height; @@ -271,7 +274,7 @@ bool IcoFormat::onSave(FileOp* fop) offset += size; } - UniquePtr image(Image::create(sprite->getPixelFormat(), + base::UniquePtr image(Image::create(sprite->getPixelFormat(), sprite->getWidth(), sprite->getHeight())); @@ -390,3 +393,5 @@ bool IcoFormat::onSave(FileOp* fop) return true; } + +} // namespace app diff --git a/src/file/jpeg_format.cpp b/src/app/file/jpeg_format.cpp similarity index 95% rename from src/file/jpeg_format.cpp rename to src/app/file/jpeg_format.cpp index c8e2f9da7..e0e085fb8 100644 --- a/src/file/jpeg_format.cpp +++ b/src/app/file/jpeg_format.cpp @@ -16,21 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/console.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/format_options.h" #include "app/find_widget.h" +#include "app/ini_file.h" #include "app/load_widget.h" #include "base/compiler_specific.h" #include "base/memory.h" -#include "console.h" -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/format_options.h" -#include "ini_file.h" #include "raster/raster.h" -#include "ui/gui.h" +#include "ui/ui.h" #include #include @@ -38,11 +40,11 @@ #include "jpeglib.h" -class JpegFormat : public FileFormat -{ +namespace app { + +class JpegFormat : public FileFormat { // Data for JPEG files - class JpegOptions : public FormatOptions - { + class JpegOptions : public FormatOptions { public: float quality; // 1.0 maximum quality. }; @@ -365,7 +367,7 @@ SharedPtr JpegFormat::onGetFormatOptions(FileOp* fop) return jpeg_options; // Load the window to ask to the user the JPEG options he wants. - UniquePtr window(app::load_widget("jpeg_options.xml", "jpeg_options")); + base::UniquePtr window(app::load_widget("jpeg_options.xml", "jpeg_options")); ui::Slider* slider_quality = app::find_widget(window, "quality"); ui::Widget* ok = app::find_widget(window, "ok"); @@ -388,3 +390,5 @@ SharedPtr JpegFormat::onGetFormatOptions(FileOp* fop) return SharedPtr(0); } } + +} // namespace app diff --git a/src/file/pcx_format.cpp b/src/app/file/pcx_format.cpp similarity index 96% rename from src/file/pcx_format.cpp rename to src/app/file/pcx_format.cpp index a03a31f71..d9810bf57 100644 --- a/src/file/pcx_format.cpp +++ b/src/app/file/pcx_format.cpp @@ -18,18 +18,24 @@ * pcx.c - Based on the code of Shawn Hargreaves. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/format_options.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/format_options.h" +#include "base/cfile.h" #include "raster/raster.h" #include -class PcxFormat : public FileFormat -{ +namespace app { + +using namespace base; + +class PcxFormat : public FileFormat { const char* onGetName() const { return "pcx"; } const char* onGetExtensions() const { return "pcx"; } int onGetFlags() const { @@ -295,3 +301,5 @@ bool PcxFormat::onSave(FileOp* fop) return true; } } + +} // namespace app diff --git a/src/file/png_format.cpp b/src/app/file/png_format.cpp similarity index 98% rename from src/file/png_format.cpp rename to src/app/file/png_format.cpp index 17be15106..94a4f87cc 100644 --- a/src/file/png_format.cpp +++ b/src/app/file/png_format.cpp @@ -16,15 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" -#include "document.h" -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/format_options.h" -#include "ini_file.h" +#include "app/app.h" +#include "app/document.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/format_options.h" +#include "app/ini_file.h" #include "raster/raster.h" #include @@ -32,8 +34,9 @@ #include "png.h" -class PngFormat : public FileFormat -{ +namespace app { + +class PngFormat : public FileFormat { const char* onGetName() const { return "png"; } const char* onGetExtensions() const { return "png"; } int onGetFlags() const { @@ -538,3 +541,5 @@ bool PngFormat::onSave(FileOp* fop) /* all right */ return true; } + +} // namespace app diff --git a/src/file/tga_format.cpp b/src/app/file/tga_format.cpp similarity index 97% rename from src/file/tga_format.cpp rename to src/app/file/tga_format.cpp index ff37cc174..4f5315b4f 100644 --- a/src/file/tga_format.cpp +++ b/src/app/file/tga_format.cpp @@ -19,18 +19,24 @@ * Eduardo Tropea and Peter Wang. */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "file/file.h" -#include "file/file_format.h" -#include "file/file_handle.h" -#include "file/format_options.h" +#include "app/file/file.h" +#include "app/file/file_format.h" +#include "app/file/file_handle.h" +#include "app/file/format_options.h" +#include "base/cfile.h" #include "raster/raster.h" #include -class TgaFormat : public FileFormat -{ +namespace app { + +using namespace base; + +class TgaFormat : public FileFormat { const char* onGetName() const { return "tga"; } const char* onGetExtensions() const { return "tga"; } int onGetFlags() const { @@ -97,7 +103,7 @@ static void rle_tga_read(unsigned char *address, int w, int type, FILE *f) /* rle_tga_read32: * Helper for reading 32 bit RLE data from TGA files. */ -static void rle_tga_read32 (uint32_t* address, int w, FILE *f) +static void rle_tga_read32(uint32_t* address, int w, FILE *f) { unsigned char value[4]; int count; @@ -472,3 +478,5 @@ bool TgaFormat::onSave(FileOp* fop) return true; } } + +} // namespace app diff --git a/src/app/file_selector.cpp b/src/app/file_selector.cpp index 88955415d..eef40f7ff 100644 --- a/src/app/file_selector.cpp +++ b/src/app/file_selector.cpp @@ -16,9 +16,11 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/file_selector.h" +#include "app/ui/file_selector.h" namespace app { @@ -26,7 +28,7 @@ base::string show_file_selector(const base::string& title, const base::string& initialPath, const base::string& showExtensions) { - widgets::FileSelector fileSelector; + FileSelector fileSelector; return fileSelector.show(title, initialPath, showExtensions); } diff --git a/src/file_system.cpp b/src/app/file_system.cpp similarity index 98% rename from src/file_system.cpp rename to src/app/file_system.cpp index 3b2914622..2bbd42908 100644 --- a/src/file_system.cpp +++ b/src/app/file_system.cpp @@ -21,13 +21,15 @@ http://vaca.sourceforge.net/ */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include -#include -#include #include +#include +#include #include +#include #include @@ -51,12 +53,13 @@ #if defined USE_PIDLS #include + #include #include #endif +#include "app/file_system.h" #include "base/path.h" -#include "file_system.h" ////////////////////////////////////////////////////////////////////// @@ -95,9 +98,10 @@ #define NOTINITIALIZED "{__not_initialized_path__}" +namespace app { + // a position in the file-system -class FileItem : public IFileItem -{ +class FileItem : public IFileItem { public: base::string keyname; base::string filename; @@ -188,9 +192,6 @@ static unsigned int current_file_system_version = 0; FileSystemModule* FileSystemModule::m_instance = NULL; -/** - * Initializes the file-system module to navigate the file-system. - */ FileSystemModule::FileSystemModule() { ASSERT(m_instance == NULL); @@ -217,9 +218,6 @@ FileSystemModule::FileSystemModule() PRINTF("File system module installed\n"); } -/** - * Shutdowns the file-system module. - */ FileSystemModule::~FileSystemModule() { PRINTF("File system module: uninstalling\n"); @@ -258,12 +256,6 @@ FileSystemModule* FileSystemModule::instance() return m_instance; } -/** - * Marks all FileItems as deprecated to be refresh the next time they - * are queried through @ref FileItem#getChildren. - * - * @see FileItem#getChildren - */ void FileSystemModule::refresh() { ++current_file_system_version; @@ -319,11 +311,6 @@ IFileItem* FileSystemModule::getRootFileItem() return fileitem; } -/** - * Returns the FileItem through the specified @a path. - * - * @warning You have to call path.fix_separators() before. - */ IFileItem* FileSystemModule::getFileItemFromPath(const base::string& path) { IFileItem* fileitem = NULL; @@ -1116,3 +1103,5 @@ static void put_fileitem(FileItem* fileitem) } #endif + +} // namespace app diff --git a/src/app/file_system.h b/src/app/file_system.h new file mode 100644 index 000000000..e93858394 --- /dev/null +++ b/src/app/file_system.h @@ -0,0 +1,79 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_FILE_SYSTEM_H_INCLUDED +#define APP_FILE_SYSTEM_H_INCLUDED + +#include "base/string.h" + +#include + +struct BITMAP; + +namespace app { + + class IFileItem; + + typedef std::vector FileItemList; + + class FileSystemModule { + static FileSystemModule* m_instance; + + public: + FileSystemModule(); + ~FileSystemModule(); + + static FileSystemModule* instance(); + + // Marks all FileItems as deprecated to be refresh the next time + // they are queried through @ref FileItem::getChildren(). + void refresh(); + + IFileItem* getRootFileItem(); + + // Returns the FileItem through the specified "path". + // Warning: You have to call path.fix_separators() before. + IFileItem* getFileItemFromPath(const base::string& path); + + bool dirExists(const base::string& path); + + }; + + class IFileItem { + public: + virtual ~IFileItem() { } + + virtual bool isFolder() const = 0; + virtual bool isBrowsable() const = 0; + + virtual base::string getKeyName() const = 0; + virtual base::string getFileName() const = 0; + virtual base::string getDisplayName() const = 0; + + virtual IFileItem* getParent() const = 0; + virtual const FileItemList& getChildren() = 0; + + virtual bool hasExtension(const base::string& csv_extensions) = 0; + + virtual BITMAP* getThumbnail() = 0; + virtual void setThumbnail(BITMAP* thumbnail) = 0; + }; + +} // namespace app + +#endif diff --git a/src/app/find_widget.h b/src/app/find_widget.h index 495c87b0f..7dfeb5c77 100644 --- a/src/app/find_widget.h +++ b/src/app/find_widget.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef APP_GUI_FIND_WIDGET_H_INCLUDED -#define APP_GUI_FIND_WIDGET_H_INCLUDED +#ifndef APP_FIND_WIDGET_H_INCLUDED +#define APP_FIND_WIDGET_H_INCLUDED #include "app/widget_not_found.h" #include "ui/widget.h" diff --git a/src/flatten.cpp b/src/app/flatten.cpp similarity index 84% rename from src/flatten.cpp rename to src/app/flatten.cpp index b4aa6470e..b95274492 100644 --- a/src/flatten.cpp +++ b/src/app/flatten.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "base/unique_ptr.h" #include "gfx/rect.h" @@ -27,33 +29,37 @@ #include "raster/sprite.h" #include "raster/stock.h" +namespace app { + +using namespace raster; + static bool has_cels(const Layer* layer, FrameNumber frame); LayerImage* create_flatten_layer_copy(Sprite* dstSprite, const Layer* srcLayer, const gfx::Rect& bounds, FrameNumber frmin, FrameNumber frmax) { - UniquePtr flatLayer(new LayerImage(dstSprite)); + base::UniquePtr flatLayer(new LayerImage(dstSprite)); for (FrameNumber frame=frmin; frame<=frmax; ++frame) { // Does this frame have cels to render? if (has_cels(srcLayer, frame)) { // Create a new image to render each frame. - UniquePtr imageWrap(Image::create(flatLayer->getSprite()->getPixelFormat(), bounds.w, bounds.h)); + base::UniquePtr imageWrap(Image::create(flatLayer->getSprite()->getPixelFormat(), bounds.w, bounds.h)); // Add the image into the sprite's stock too. int imageIndex = flatLayer->getSprite()->getStock()->addImage(imageWrap); Image* image = imageWrap.release(); // Create the new cel for the output layer. - UniquePtr cel(new Cel(frame, imageIndex)); + base::UniquePtr cel(new Cel(frame, imageIndex)); cel->setPosition(bounds.x, bounds.y); // Clear the image and render this frame. image->clear(0); layer_render(srcLayer, image, -bounds.x, -bounds.y, frame); - // Add the cel (and release the UniquePtr). + // Add the cel (and release the base::UniquePtr). flatLayer->addCel(cel); cel.release(); } @@ -89,3 +95,5 @@ static bool has_cels(const Layer* layer, FrameNumber frame) return false; } + +} // namespace app diff --git a/src/flatten.h b/src/app/flatten.h similarity index 50% rename from src/flatten.h rename to src/app/flatten.h index 23ca8f342..034cd13a9 100644 --- a/src/flatten.h +++ b/src/app/flatten.h @@ -16,25 +16,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef FLATTEN_H_INCLUDED -#define FLATTEN_H_INCLUDED +#ifndef APP_FLATTEN_H_INCLUDED +#define APP_FLATTEN_H_INCLUDED #include "gfx/rect.h" #include "raster/frame_number.h" -class Sprite; -class Layer; -class LayerImage; +namespace raster { + class Sprite; + class Layer; + class LayerImage; +} -// Returns a new layer with the given layer at "srcLayer" rendered -// frame by frame from "frmin" to "frmax" (inclusive). The routine -// flattens all children of "srcLayer" to an unique output layer. -// -// Note: The layer is not added to the given sprite, but is related to -// it, so you'll be able to add the flatten layer only into the given -// sprite. -LayerImage* create_flatten_layer_copy(Sprite* dstSprite, const Layer* srcLayer, - const gfx::Rect& bounds, - FrameNumber frmin, FrameNumber frmax); +namespace app { + + // Returns a new layer with the given layer at "srcLayer" rendered + // frame by frame from "frmin" to "frmax" (inclusive). The routine + // flattens all children of "srcLayer" to an unique output layer. + // + // Note: The layer is not added to the given sprite, but is related to + // it, so you'll be able to add the flatten layer only into the given + // sprite. + LayerImage* create_flatten_layer_copy(Sprite* dstSprite, const Layer* srcLayer, + const gfx::Rect& bounds, + FrameNumber frmin, FrameNumber frmax); + +} // namespace app #endif diff --git a/src/gfxmode.cpp b/src/app/gfxmode.cpp similarity index 92% rename from src/gfxmode.cpp rename to src/app/gfxmode.cpp index 2789b483e..468fb2da2 100644 --- a/src/gfxmode.cpp +++ b/src/app/gfxmode.cpp @@ -16,22 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "gfxmode.h" +#include "app/gfxmode.h" -#include "app.h" -#include "console.h" -#include "modules/gui.h" -#include "modules/palettes.h" +#include "app/app.h" +#include "app/console.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/ui/main_window.h" #include "ui/manager.h" #include "ui/window.h" -#include "widgets/main_window.h" #include -////////////////////////////////////////////////////////////////////// -// GfxMode +namespace app { GfxMode::GfxMode() { @@ -129,3 +130,5 @@ const GfxMode& CurrentGfxModeGuard::getOriginal() const { return m_oldMode; } + +} // namespace app diff --git a/src/app/gfxmode.h b/src/app/gfxmode.h new file mode 100644 index 000000000..45dbc48c7 --- /dev/null +++ b/src/app/gfxmode.h @@ -0,0 +1,89 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_GFXMODE_H_INCLUDED +#define APP_GFXMODE_H_INCLUDED + +namespace app { + + // Holds settings about a graphics mode. + class GfxMode { + public: + GfxMode(); + + void updateWithCurrentMode(); + bool setGfxMode() const; + + int getCard() const { return m_card; } + int getWidth() const { return m_width; } + int getHeight() const { return m_height; } + int getDepth() const { return m_depth; } + int getScaling() const { return m_scaling; } + + void setCard(int card) { m_card = card; } + void setWidth(int width) { m_width = width; } + void setHeight(int height) { m_height = height; } + void setDepth(int depth) { m_depth = depth; } + void setScaling(int scaling) { m_scaling = scaling; } + + private: + int m_card; + int m_width, m_height; + int m_depth; + int m_scaling; + }; + + // Tries a new graphics mode, and restores it back in the + // destructor. If the keep() method is used, the mode is not + // restored. + class CurrentGfxModeGuard { + public: + // Saves the current graphics mode as "the original" one. + CurrentGfxModeGuard(); + + // Restores the graphics mode to its original in case we have used + // tryGfxMode() and we did not call keep(). After calling keep(), + // this destructor will do just nothing. + ~CurrentGfxModeGuard(); + + // Changes the current graphics mode. Returns true if the mode was + // changed successfully. If the function cannot change the new mode + // and cannot restore the original one, it finishes the program + // (with exit()). + bool tryGfxMode(const GfxMode& newMode); + + // Keeps the last graphics mode set with tryGfxMode(). Indicates + // that the destructor should not restore the graphics mode to the + // original one. + void keep(); + + // It is the original graphics mode configured when the constructor + // of this class was called. + const GfxMode& getOriginal() const; + + private: + // The original gfx mode. + GfxMode m_oldMode; + + // True if we should keep any mode set with tryGfxMode() method. + bool m_keep; + }; + +} // namespace app + +#endif diff --git a/src/gui_xml.cpp b/src/app/gui_xml.cpp similarity index 90% rename from src/gui_xml.cpp rename to src/app/gui_xml.cpp index f8e0b8565..384ad854b 100644 --- a/src/gui_xml.cpp +++ b/src/app/gui_xml.cpp @@ -16,13 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include +#include "app/gui_xml.h" -#include "gui_xml.h" -#include "resource_finder.h" -#include "xml_exception.h" +#include "app/resource_finder.h" +#include "app/xml_exception.h" +#include "base/fs.h" + +namespace app { // static GuiXml* GuiXml::instance() @@ -45,7 +49,7 @@ GuiXml::GuiXml() // If the file does not exist, just ignore this location (it was // suggested by the ResourceFinder class). - if (!exists(path)) + if (!base::file_exists(path)) continue; PRINTF(" - \"%s\" found\n", path); @@ -78,3 +82,5 @@ std::string GuiXml::version() else return ""; } + +} // namespace app diff --git a/src/gui_xml.h b/src/app/gui_xml.h similarity index 55% rename from src/gui_xml.h rename to src/app/gui_xml.h index f306fe7a6..be1166763 100644 --- a/src/gui_xml.h +++ b/src/app/gui_xml.h @@ -16,35 +16,38 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef GUI_XML_INCLUDED -#define GUI_XML_INCLUDED +#ifndef APP_GUI_XML_INCLUDED +#define APP_GUI_XML_INCLUDED #include #include "tinyxml.h" -// Singleton class to load and access "gui.xml" file. -class GuiXml -{ -public: - // Returns the GuiXml singleton. If it was not created yet, the - // gui.xml file will be loaded by the first time, which could - // generated an exception if there are errors in the XML file. - static GuiXml* instance(); +namespace app { - // Returns the tinyxml document instance. - TiXmlDocument& doc(); + // Singleton class to load and access "gui.xml" file. + class GuiXml { + public: + // Returns the GuiXml singleton. If it was not created yet, the + // gui.xml file will be loaded by the first time, which could + // generated an exception if there are errors in the XML file. + static GuiXml* instance(); - // Returns the name of the gui.xml file. - const char* filename() { - return m_doc.Value(); - } + // Returns the tinyxml document instance. + TiXmlDocument& doc(); - std::string version(); + // Returns the name of the gui.xml file. + const char* filename() { + return m_doc.Value(); + } -private: - GuiXml(); + std::string version(); - TiXmlDocument m_doc; -}; + private: + GuiXml(); + + TiXmlDocument m_doc; + }; + +} // namespace app #endif diff --git a/src/ini_file.cpp b/src/app/ini_file.cpp similarity index 95% rename from src/ini_file.cpp rename to src/app/ini_file.cpp index 7cc037359..7f7eacc07 100644 --- a/src/ini_file.cpp +++ b/src/app/ini_file.cpp @@ -16,17 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "ini_file.h" +#include "app/ini_file.h" -#include "resource_finder.h" +#include "app/resource_finder.h" #include "ui/rect.h" #include #include #include +namespace app { + using namespace gfx; static char config_filename[512]; @@ -109,3 +113,5 @@ void set_config_color(const char *section, const char *name, const app::Color& v { set_config_string(section, name, value.toString().c_str()); } + +} // namespace app diff --git a/src/ini_file.h b/src/app/ini_file.h similarity index 55% rename from src/ini_file.h rename to src/app/ini_file.h index 76e14291c..6b3f3efcc 100644 --- a/src/ini_file.h +++ b/src/app/ini_file.h @@ -16,27 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef INI_FILE_H_INCLUDED -#define INI_FILE_H_INCLUDED +#ifndef APP_INI_FILE_H_INCLUDED +#define APP_INI_FILE_H_INCLUDED #include #include "gfx/rect.h" #include "app/color.h" -class ConfigModule -{ -public: - ConfigModule(); - ~ConfigModule(); -}; +namespace app { -bool get_config_bool(const char *section, const char *name, bool value); -void set_config_bool(const char *section, const char *name, bool value); + class ConfigModule { + public: + ConfigModule(); + ~ConfigModule(); + }; -gfx::Rect get_config_rect(const char *section, const char *name, const gfx::Rect& rect); -void set_config_rect(const char *section, const char *name, const gfx::Rect& rect); + bool get_config_bool(const char *section, const char *name, bool value); + void set_config_bool(const char *section, const char *name, bool value); -app::Color get_config_color(const char *section, const char *name, const app::Color& value); -void set_config_color(const char *section, const char *name, const app::Color& value); + gfx::Rect get_config_rect(const char *section, const char *name, const gfx::Rect& rect); + void set_config_rect(const char *section, const char *name, const gfx::Rect& rect); + + app::Color get_config_color(const char *section, const char *name, const app::Color& value); + void set_config_color(const char *section, const char *name, const app::Color& value); + +} // namespace app #endif diff --git a/src/job.cpp b/src/app/job.cpp similarity index 88% rename from src/job.cpp rename to src/app/job.cpp index e960a28f3..51b97a28b 100644 --- a/src/job.cpp +++ b/src/app/job.cpp @@ -16,20 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "job.h" +#include "app/job.h" +#include "app/ui/status_bar.h" #include "base/mutex.h" #include "base/scoped_lock.h" #include "base/thread.h" #include "ui/alert.h" #include "ui/widget.h" #include "ui/window.h" -#include "widgets/status_bar.h" static const int kMonitoringPeriod = 100; +namespace app { + Job::Job(const char* job_name) { m_mutex = NULL; @@ -39,7 +43,7 @@ Job::Job(const char* job_name) m_done_flag = false; m_canceled_flag = false; - m_mutex = new Mutex(); + m_mutex = new base::mutex(); m_progress = StatusBar::instance()->addProgress(); m_alert_window = ui::Alert::create("%s<setPos(m_last_progress); @@ -109,7 +113,7 @@ void Job::onMonitoringTick() void Job::done() { - ScopedLock hold(*m_mutex); + base::scoped_lock hold(*m_mutex); m_done_flag = true; } @@ -124,3 +128,5 @@ void Job::thread_proc(Job* self) } self->done(); } + +} // namespace app diff --git a/src/app/job.h b/src/app/job.h new file mode 100644 index 000000000..87c2650cf --- /dev/null +++ b/src/app/job.h @@ -0,0 +1,88 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_JOB_H_INCLUDED +#define APP_JOB_H_INCLUDED + +#include "base/unique_ptr.h" +#include "ui/alert.h" +#include "ui/timer.h" + +namespace base { + class thread; + class mutex; +} + +namespace app { + class Progress; + + class Job { + public: + Job(const char* job_name); + virtual ~Job(); + + // Starts the job calling onJob() event in another thread and + // monitoring the progress with onMonitorTick() event. + void startJob(); + + // The onJob() can use this function to report progress of the + // background job being done. 1.0 is completed. + void jobProgress(double f); + + // Returns true if the job was canceled by the user (in case he + // pressed a "Cancel" button in the GUI). The onJob() thread should + // check this variable periodically to stop working. + bool isCanceled(); + + protected: + + // This member function is called from another dedicated thread + // outside the GUI one, so you can do some image processing here. + // Remember that you cannot use any GUI element in this handler. + virtual void onJob() = 0; + + // Called each 1000 msecs by the GUI queue processing. + // It is executed from the main GUI thread. + virtual void onMonitoringTick(); + + private: + void done(); + + static void thread_proc(Job* self); + static void monitor_proc(void* data); + static void monitor_free(void* data); + + base::thread* m_thread; + base::UniquePtr m_timer; + Progress* m_progress; + base::mutex* m_mutex; + ui::AlertPtr m_alert_window; + double m_last_progress; + bool m_done_flag; + bool m_canceled_flag; + + // these methods are privated and not defined + Job(); + Job(const Job&); + Job& operator==(const Job&); + + }; + +} // namespace app + +#endif diff --git a/src/app/launcher.cpp b/src/app/launcher.cpp new file mode 100644 index 000000000..aa26f5636 --- /dev/null +++ b/src/app/launcher.cpp @@ -0,0 +1,54 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "app/launcher.h" + +#include "base/exception.h" +#include "base/launcher.h" +#include "ui/alert.h" + +namespace app { +namespace launcher { + +void open_url(const std::string& url) +{ + open_file(url); +} + +void open_file(const std::string& file) +{ + if (!base::launcher::open_file(file)) + ui::Alert::show("Problem< -class Launcher -{ -public: - static void openUrl(const std::string& url); - static void openFile(const std::string& file); - static void openFolder(const std::string& file); -}; +namespace app { + namespace launcher { + + void open_url(const std::string& url); + void open_file(const std::string& file); + void open_folder(const std::string& file); + + } // namespace launcher +} // namespace app #endif diff --git a/src/app/load_widget.h b/src/app/load_widget.h index ad672ba5a..f0a44a72a 100644 --- a/src/app/load_widget.h +++ b/src/app/load_widget.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef APP_GUI_LOAD_WIDGET_H_INCLUDED -#define APP_GUI_LOAD_WIDGET_H_INCLUDED +#ifndef APP_LOAD_WIDGET_H_INCLUDED +#define APP_LOAD_WIDGET_H_INCLUDED #include "app/widget_loader.h" #include "base/unique_ptr.h" diff --git a/src/log.cpp b/src/app/log.cpp similarity index 86% rename from src/log.cpp rename to src/app/log.cpp index 727fa550a..a1aed8d65 100644 --- a/src/log.cpp +++ b/src/app/log.cpp @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif + +#include "app/log.h" + +#include "app/app.h" +#include "app/resource_finder.h" +#include "ui/base.h" #include #include @@ -25,24 +33,19 @@ #include #include -#include "ui/base.h" - -#include "app.h" -#include "log.h" -#include "resource_finder.h" - -/* DOS and Windows needs "log" files (because their poor stderr support) */ +// DOS and Windows needs "log" files (because their poor stderr support) #if defined ALLEGRO_DOS || defined ALLEGRO_WINDOWS # define NEED_LOG #endif -/* in DOS, print in stderr is like print in the video screen */ +// in DOS, print in stderr is like print in the video screen #if defined ALLEGRO_DOS # define NO_STDERR #endif -#ifdef NEED_LOG -/* log file info */ +namespace app { + +#ifdef NEED_LOG // log file info static std::string log_filename; static FILE *log_fileptr = NULL; #endif @@ -75,10 +78,12 @@ LoggerModule::~LoggerModule() logger_instance = NULL; } -////////////////////////////////////////////////////////////////////// +} // namespace app void verbose_printf(const char* format, ...) { + using namespace app; + if (!logger_instance) { va_list ap; va_start(ap, format); diff --git a/src/log.h b/src/app/log.h similarity index 75% rename from src/log.h rename to src/app/log.h index b7f255e0c..6fdd3f9e7 100644 --- a/src/log.h +++ b/src/app/log.h @@ -16,19 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef LOG_H_INCLUDED -#define LOG_H_INCLUDED +#ifndef APP_LOG_H_INCLUDED +#define APP_LOG_H_INCLUDED -class LoggerModule -{ -public: - LoggerModule(bool verbose); - ~LoggerModule(); +namespace app { - bool isVerbose() const { return m_verbose; } + class LoggerModule { + public: + LoggerModule(bool verbose); + ~LoggerModule(); -private: - bool m_verbose; -}; + bool isVerbose() const { return m_verbose; } + + private: + bool m_verbose; + }; + +} // namespace app #endif diff --git a/src/modules.cpp b/src/app/modules.cpp similarity index 87% rename from src/modules.cpp rename to src/app/modules.cpp index 8e6f7eb26..10190f2cf 100644 --- a/src/modules.cpp +++ b/src/app/modules.cpp @@ -16,28 +16,32 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "modules.h" -#include "modules/gui.h" -#include "modules/palettes.h" +#include "app/modules.h" -#define DEF_MODULE(name, reqs) \ - { #name, init_module_##name, exit_module_##name, (reqs), false } +#include "app/modules/gui.h" +#include "app/modules/palettes.h" -typedef struct Module -{ +namespace app { + +struct Module { const char *name; int (*init)(); void (*exit)(); int reqs; bool installed; -} Module; +}; static Module module[] = { - /* This sorting is very important because last modules depend of - first ones. */ +#define DEF_MODULE(name, reqs) \ + { #name, init_module_##name, exit_module_##name, (reqs), false } + + // This sorting is very important because last modules depend of + // first ones. DEF_MODULE(palette, 0), DEF_MODULE(gui, REQUIRE_INTERFACE), @@ -68,3 +72,5 @@ LegacyModules::~LegacyModules() module[c].installed = false; } } + +} // namespace app diff --git a/src/modules.h b/src/app/modules.h similarity index 70% rename from src/modules.h rename to src/app/modules.h index 888fbb581..8fec630d9 100644 --- a/src/modules.h +++ b/src/app/modules.h @@ -16,24 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MODULES_H_INCLUDED -#define MODULES_H_INCLUDED +#ifndef APP_MODULES_H_INCLUDED +#define APP_MODULES_H_INCLUDED #include "ui/base.h" #define REQUIRE_INTERFACE 1 -/** - * Class to install and uninstall old modules. - * - * Legacy modules are programmed in C code and should be refactored to - * C++ classes. - */ -class LegacyModules -{ -public: - LegacyModules(int requirements); - ~LegacyModules(); -}; +namespace app { + + /** + * Class to install and uninstall old modules. + * + * Legacy modules are programmed in C code and should be refactored to + * C++ classes. + */ + class LegacyModules { + public: + LegacyModules(int requirements); + ~LegacyModules(); + }; + +} // namespace app #endif diff --git a/src/modules/editors.cpp b/src/app/modules/editors.cpp similarity index 89% rename from src/modules/editors.cpp rename to src/app/modules/editors.cpp index 6229fb5e3..d2ae88098 100644 --- a/src/modules/editors.cpp +++ b/src/app/modules/editors.cpp @@ -16,8 +16,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "modules/editors.h" +#include "app/modules/editors.h" + +namespace app { Editor* current_editor = NULL; + +} // namespace app diff --git a/src/modules/editors.h b/src/app/modules/editors.h similarity index 82% rename from src/modules/editors.h rename to src/app/modules/editors.h index 115cd565d..502cbd9b7 100644 --- a/src/modules/editors.h +++ b/src/app/modules/editors.h @@ -16,10 +16,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MODULES_EDITORS_H_INCLUDED -#define MODULES_EDITORS_H_INCLUDED +#ifndef APP_MODULES_EDITORS_H_INCLUDED +#define APP_MODULES_EDITORS_H_INCLUDED -class Editor; -extern Editor* current_editor; +namespace app { + + class Editor; + extern Editor* current_editor; + +} // namespace app #endif diff --git a/src/modules/gfx.cpp b/src/app/modules/gfx.cpp similarity index 95% rename from src/modules/gfx.cpp rename to src/app/modules/gfx.cpp index 9ffbcd3a2..594b37abf 100644 --- a/src/modules/gfx.cpp +++ b/src/app/modules/gfx.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include @@ -27,21 +29,24 @@ #include "ui/system.h" #include "ui/theme.h" -#include "app.h" +#include "app/app.h" #include "app/color_utils.h" -#include "console.h" +#include "app/ui/editor/editor.h" +#include "app/console.h" #include "gfx/point.h" #include "gfx/rect.h" -#include "ini_file.h" -#include "modules/gfx.h" -#include "modules/gui.h" -#include "modules/palettes.h" +#include "app/ini_file.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" #include "raster/blend.h" #include "raster/image.h" #include "raster/palette.h" -#include "skin/skin_theme.h" -#include "widgets/editor/editor.h" +#include "app/ui/skin/skin_theme.h" +namespace app { + +using namespace app::skin; using namespace gfx; void dotted_mode(int offset) @@ -161,9 +166,7 @@ void dotted_mode(int offset) drawing_mode(DRAW_MODE_COPY_PATTERN, pattern, 0, 0); } -/**********************************************************************/ -/* Rectangle Tracker (Save/Restore rectangles from/to the screen) */ - +// Save/Restore rectangles from/to the screen. struct RectTracker { BITMAP* bmp; @@ -270,9 +273,6 @@ void rect_tracker_free(RectTracker* rt) ui::jmouse_show(); } -/**********************************************************************/ -/* Rectangles */ - void rectgrid(BITMAP* bmp, int x1, int y1, int x2, int y2, int w, int h) { if (w < 1 || h < 1) @@ -304,9 +304,6 @@ void rectgrid(BITMAP* bmp, int x1, int y1, int x2, int y2, int w, int h) } } -/**********************************************************************/ -/* Specials */ - void draw_emptyset_symbol(BITMAP* bmp, const Rect& rc, ui::Color color) { Point center = rc.getCenter(); @@ -428,3 +425,5 @@ void draw_color_button(BITMAP* bmp, PART_COLORBAR_BORDER_HOTFG_NW); } } + +} // namespace app diff --git a/src/app/modules/gfx.h b/src/app/modules/gfx.h new file mode 100644 index 000000000..4c71f40c6 --- /dev/null +++ b/src/app/modules/gfx.h @@ -0,0 +1,53 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_MODULES_GFX_H_INCLUDED +#define APP_MODULES_GFX_H_INCLUDED + +#include "app/color.h" +#include "gfx/rect.h" +#include "ui/base.h" +#include "ui/color.h" + +struct FONT; +struct BITMAP; + +namespace app { + struct RectTracker; + + using namespace raster; + + void dotted_mode(int offset); + + RectTracker* rect_tracker_new(BITMAP* bmp, int x1, int y1, int x2, int y2); + void rect_tracker_free(RectTracker* tracker); + + void rectgrid(BITMAP* bmp, int x1, int y1, int x2, int y2, int w, int h); + + void draw_emptyset_symbol(BITMAP* bmp, const gfx::Rect& rc, ui::Color color); + void draw_color(BITMAP* bmp, const gfx::Rect& rc, PixelFormat pixelFormat, const app::Color& color); + void draw_color_button(BITMAP* bmp, + const gfx::Rect& rc, + bool outer_nw, bool outer_n, bool outer_ne, bool outer_e, + bool outer_se, bool outer_s, bool outer_sw, bool outer_w, + PixelFormat pixelFormat, const app::Color& color, + bool hot, bool drag); + +} // namespace app + +#endif diff --git a/src/modules/gui.cpp b/src/app/modules/gui.cpp similarity index 96% rename from src/modules/gui.cpp rename to src/app/modules/gui.cpp index ef7697166..dd917642a 100644 --- a/src/modules/gui.cpp +++ b/src/app/modules/gui.cpp @@ -16,40 +16,43 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/console.h" +#include "app/drop_files.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/settings/settings.h" +#include "app/tools/ink.h" +#include "app/tools/tool_box.h" +#include "app/ui/editor/editor.h" +#include "app/ui/main_menu_bar.h" +#include "app/ui/main_menu_bar.h" +#include "app/ui/main_window.h" +#include "app/ui/skin/button_icon_impl.h" +#include "app/ui/skin/skin_property.h" +#include "app/ui/skin/skin_theme.h" +#include "app/ui/status_bar.h" +#include "app/ui/toolbar.h" +#include "app/ui_context.h" #include "base/memory.h" #include "base/shared_ptr.h" #include "base/unique_ptr.h" -#include "commands/command.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "console.h" -#include "drop_files.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gfx.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/sprite.h" #include "she/display.h" #include "she/surface.h" #include "she/system.h" -#include "skin/button_icon_impl.h" -#include "skin/skin_property.h" -#include "skin/skin_theme.h" -#include "tools/ink.h" -#include "tools/tool_box.h" -#include "ui/gui.h" #include "ui/intern.h" -#include "ui_context.h" -#include "widgets/editor/editor.h" -#include "widgets/main_menu_bar.h" -#include "widgets/main_menu_bar.h" -#include "widgets/main_window.h" -#include "widgets/status_bar.h" -#include "widgets/toolbar.h" +#include "ui/ui.h" #include #include @@ -67,13 +70,13 @@ #define SPRITEDITOR_ACTION_MAINTAINASPECTRATIO "MaintainAspectRatio" #define SPRITEDITOR_ACTION_LOCKAXIS "LockAxis" -////////////////////////////////////////////////////////////////////// +namespace app { using namespace gfx; using namespace ui; +using namespace app::skin; -static struct -{ +static struct { int width; int height; int scale; @@ -93,8 +96,7 @@ enum ShortcutType { Shortcut_ExecuteCommand, Shortcut_EditorQuicktool, Shortcut_SpriteEditor }; -struct Shortcut -{ +struct Shortcut { Accelerator* accel; ShortcutType type; union { @@ -883,3 +885,5 @@ static void on_palette_change_signal() // Regenerate the theme CurrentTheme::get()->regenerate(); } + +} // namespace app diff --git a/src/app/modules/gui.h b/src/app/modules/gui.h new file mode 100644 index 000000000..945c42434 --- /dev/null +++ b/src/app/modules/gui.h @@ -0,0 +1,94 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_MODULES_GUI_H_INCLUDED +#define APP_MODULES_GUI_H_INCLUDED + +#include "app/ui/skin/skin_property.h" +#include "base/exception.h" +#include "ui/accelerator.h" +#include "ui/base.h" +#include +#include + +namespace ui { + class ButtonBase; + class CheckBox; + class Message; + class RadioButton; + class Widget; + class Window; +} + +namespace app { + class Command; + class Document; + class Params; + + namespace tools { + class Tool; + } + + int init_module_gui(); + void exit_module_gui(); + + int get_screen_scaling(); + void set_screen_scaling(int scaling); + + void update_screen_for_document(Document* document); + + void gui_run(); + void gui_feedback(); + void gui_setup_screen(bool reload_font); + + void load_window_pos(ui::Widget* window, const char *section); + void save_window_pos(ui::Widget* window, const char *section); + + void setup_mini_look(ui::Widget* widget); + void setup_look(ui::Widget* widget, skin::LookType lookType); + void setup_bevels(ui::Widget* widget, int b1, int b2, int b3, int b4); + + void set_gfxicon_to_button(ui::ButtonBase* button, + int normal_part_id, + int selected_part_id, + int disabled_part_id, int icon_align); + + ui::CheckBox* check_button_new(const char* text, int b1, int b2, int b3, int b4); + + ////////////////////////////////////////////////////////////////////// + // Keyboard shortcuts + + ui::Accelerator* add_keyboard_shortcut_to_execute_command(const char* shortcut, const char* command_name, Params* params); + ui::Accelerator* add_keyboard_shortcut_to_change_tool(const char* shortcut, tools::Tool* tool); + ui::Accelerator* add_keyboard_shortcut_to_quicktool(const char* shortcut, tools::Tool* tool); + ui::Accelerator* add_keyboard_shortcut_to_spriteeditor(const char* shortcut, const char* action_name); + + bool get_command_from_key_message(ui::Message* msg, Command** command, Params** params); + ui::Accelerator* get_accel_to_execute_command(const char* command, Params* params = NULL); + ui::Accelerator* get_accel_to_change_tool(tools::Tool* tool); + ui::Accelerator* get_accel_to_copy_selection(); + ui::Accelerator* get_accel_to_snap_to_grid(); + ui::Accelerator* get_accel_to_angle_snap(); + ui::Accelerator* get_accel_to_maintain_aspect_ratio(); + ui::Accelerator* get_accel_to_lock_axis(); + + tools::Tool* get_selected_quicktool(tools::Tool* currentTool); + +} // namespace app + +#endif diff --git a/src/modules/palettes.cpp b/src/app/modules/palettes.cpp similarity index 95% rename from src/modules/palettes.cpp rename to src/app/modules/palettes.cpp index ce4a0f41c..c8528080d 100644 --- a/src/modules/palettes.cpp +++ b/src/app/modules/palettes.cpp @@ -16,18 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include -#include - -#include "app.h" -#include "modules/palettes.h" +#include "app/app.h" +#include "app/modules/palettes.h" #include "raster/blend.h" #include "raster/image.h" #include "raster/palette.h" #include "raster/sprite.h" +#include +#include + +namespace app { + /** * The default color palette. */ @@ -135,3 +139,5 @@ void set_current_color(int index, int r, int g, int b) set_color(index, &rgb); } } + +} // namespace app diff --git a/src/modules/palettes.h b/src/app/modules/palettes.h similarity index 60% rename from src/modules/palettes.h rename to src/app/modules/palettes.h index eb1d278a8..202a59dd3 100644 --- a/src/modules/palettes.h +++ b/src/app/modules/palettes.h @@ -16,20 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef MODULES_PALETTES_H_INCLUDED -#define MODULES_PALETTES_H_INCLUDED +#ifndef APP_MODULES_PALETTES_H_INCLUDED +#define APP_MODULES_PALETTES_H_INCLUDED -class Palette; +namespace raster { + class Palette; +} -int init_module_palette(); -void exit_module_palette(); +namespace app { + using namespace raster; -Palette* get_default_palette(); -Palette* get_current_palette(); + int init_module_palette(); + void exit_module_palette(); -void set_default_palette(Palette* palette); -bool set_current_palette(const Palette* palette, bool forced); -void set_black_palette(); -void set_current_color(int index, int r, int g, int b); + Palette* get_default_palette(); + Palette* get_current_palette(); + + void set_default_palette(Palette* palette); + bool set_current_palette(const Palette* palette, bool forced); + void set_black_palette(); + void set_current_color(int index, int r, int g, int b); + +} // namespace app #endif diff --git a/src/objects_container_impl.cpp b/src/app/objects_container_impl.cpp similarity index 95% rename from src/objects_container_impl.cpp rename to src/app/objects_container_impl.cpp index af10590eb..77265a871 100644 --- a/src/objects_container_impl.cpp +++ b/src/app/objects_container_impl.cpp @@ -16,9 +16,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "objects_container_impl.h" +#include "app/objects_container_impl.h" + +namespace app { using namespace undo; @@ -84,3 +88,5 @@ void* ObjectsContainerImpl::getObject(ObjectId id) return it->second; } + +} // namespace app diff --git a/src/objects_container_impl.h b/src/app/objects_container_impl.h similarity index 57% rename from src/objects_container_impl.h rename to src/app/objects_container_impl.h index 65790bf6c..38da81c32 100644 --- a/src/objects_container_impl.h +++ b/src/app/objects_container_impl.h @@ -16,30 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DOC_OBJECTS_CONTAINER_H_INCLUDED -#define DOC_OBJECTS_CONTAINER_H_INCLUDED +#ifndef APP_DOC_OBJECTS_CONTAINER_H_INCLUDED +#define APP_DOC_OBJECTS_CONTAINER_H_INCLUDED #include "undo/objects_container.h" #include -class ObjectsContainerImpl : public undo::ObjectsContainer -{ -public: - ObjectsContainerImpl(); - ~ObjectsContainerImpl(); +namespace app { - // ObjectsContainer Implementation + class ObjectsContainerImpl : public undo::ObjectsContainer { + public: + ObjectsContainerImpl(); + ~ObjectsContainerImpl(); - undo::ObjectId addObject(void* object); - void insertObject(undo::ObjectId id, void* object); - void removeObject(undo::ObjectId id); - void* getObject(undo::ObjectId id); + // ObjectsContainer Implementation -private: - undo::ObjectId m_idCounter; - std::map m_idToPtr; - std::map m_ptrToId; -}; + undo::ObjectId addObject(void* object); + void insertObject(undo::ObjectId id, void* object); + void removeObject(undo::ObjectId id); + void* getObject(undo::ObjectId id); + + private: + undo::ObjectId m_idCounter; + std::map m_idToPtr; + std::map m_ptrToId; + }; + +} // namespace app #endif diff --git a/src/objects_container_impl_unittest.cpp b/src/app/objects_container_impl_unittest.cpp similarity index 96% rename from src/objects_container_impl_unittest.cpp rename to src/app/objects_container_impl_unittest.cpp index 35774d5ca..4156b7ed6 100644 --- a/src/objects_container_impl_unittest.cpp +++ b/src/app/objects_container_impl_unittest.cpp @@ -16,12 +16,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "objects_container_impl.h" +#include "app/objects_container_impl.h" +using namespace app; using namespace undo; TEST(ObjectsContainerImpl, AddObjectReturnsSameIdForSameObject) diff --git a/src/app/project.cpp b/src/app/project.cpp index 70bdb31b4..31c633443 100644 --- a/src/app/project.cpp +++ b/src/app/project.cpp @@ -16,7 +16,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include "app/project.h" diff --git a/src/app/project.h b/src/app/project.h index 985deb9b4..8cc5051c7 100644 --- a/src/app/project.h +++ b/src/app/project.h @@ -21,11 +21,11 @@ #include "app/project_observer.h" #include "base/disable_copying.h" -#include "observable.h" +#include "base/observable.h" namespace app { - class Project : public Observable { + class Project : public base::Observable { public: Project(); ~Project(); diff --git a/src/app/project_event.h b/src/app/project_event.h index b52b2f04c..f4c207a47 100644 --- a/src/app/project_event.h +++ b/src/app/project_event.h @@ -19,9 +19,8 @@ #ifndef APP_PROJECT_EVENT_H_INCLUDED #define APP_PROJECT_EVENT_H_INCLUDED -class Document; - namespace app { + class Document; class ProjectEvent { public: diff --git a/src/recent_files.cpp b/src/app/recent_files.cpp similarity index 95% rename from src/recent_files.cpp rename to src/app/recent_files.cpp index c5b676c77..72ad078aa 100644 --- a/src/recent_files.cpp +++ b/src/app/recent_files.cpp @@ -16,19 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "recent_files.h" +#include "app/recent_files.h" -#include "app_menus.h" +#include "app/app_menus.h" +#include "app/ini_file.h" #include "base/fs.h" #include "base/path.h" -#include "ini_file.h" #include #include #include +namespace app { + RecentFiles::RecentFiles() : m_files(16) , m_paths(16) @@ -107,3 +111,5 @@ void RecentFiles::removeRecentFile(const char* filename) AppMenus::instance()->rebuildRecentList(); } + +} // namespace app diff --git a/src/recent_files.h b/src/app/recent_files.h similarity index 52% rename from src/recent_files.h rename to src/app/recent_files.h index 52f7f29e1..179e051d1 100644 --- a/src/recent_files.h +++ b/src/app/recent_files.h @@ -16,36 +16,39 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef RECENT_FILES_H_INCLUDED -#define RECENT_FILES_H_INCLUDED +#ifndef APP_RECENT_FILES_H_INCLUDED +#define APP_RECENT_FILES_H_INCLUDED #include "base/recent_items.h" #include "base/string.h" -class RecentFiles -{ -public: - typedef base::RecentItems List; - typedef List::iterator iterator; - typedef List::const_iterator const_iterator; +namespace app { + + class RecentFiles { + public: + typedef base::RecentItems List; + typedef List::iterator iterator; + typedef List::const_iterator const_iterator; - // Iterate through recent files. - const_iterator files_begin() { return m_files.begin(); } - const_iterator files_end() { return m_files.end(); } + // Iterate through recent files. + const_iterator files_begin() { return m_files.begin(); } + const_iterator files_end() { return m_files.end(); } - // Iterate through recent paths. - const_iterator paths_begin() { return m_paths.begin(); } - const_iterator paths_end() { return m_paths.end(); } + // Iterate through recent paths. + const_iterator paths_begin() { return m_paths.begin(); } + const_iterator paths_end() { return m_paths.end(); } - RecentFiles(); - ~RecentFiles(); + RecentFiles(); + ~RecentFiles(); - void addRecentFile(const char* filename); - void removeRecentFile(const char* filename); + void addRecentFile(const char* filename); + void removeRecentFile(const char* filename); -private: - List m_files; - List m_paths; -}; + private: + List m_files; + List m_paths; + }; + +} // namespace app #endif diff --git a/src/resource_finder.cpp b/src/app/resource_finder.cpp similarity index 97% rename from src/resource_finder.cpp rename to src/app/resource_finder.cpp index 7adf48478..a73e31d88 100644 --- a/src/resource_finder.cpp +++ b/src/app/resource_finder.cpp @@ -16,12 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include -#include "resource_finder.h" +#include "app/resource_finder.h" + +namespace app { ResourceFinder::ResourceFinder() { @@ -174,3 +178,5 @@ void ResourceFinder::findConfigurationFile() // $BINDIR/aseprite.ini findInBinDir("aseprite.ini"); } + +} // namespace app diff --git a/src/resource_finder.h b/src/app/resource_finder.h similarity index 54% rename from src/resource_finder.h rename to src/app/resource_finder.h index f65726a18..fbe2af164 100644 --- a/src/resource_finder.h +++ b/src/app/resource_finder.h @@ -16,36 +16,39 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef RESOURCE_FINDER_H_INCLUDED -#define RESOURCE_FINDER_H_INCLUDED +#ifndef APP_RESOURCE_FINDER_H_INCLUDED +#define APP_RESOURCE_FINDER_H_INCLUDED #include #include -class ResourceFinder -{ -public: - ResourceFinder(); +namespace app { - const char* first(); - const char* next(); + class ResourceFinder { + public: + ResourceFinder(); - void addPath(std::string path); + const char* first(); + const char* next(); - void findInBinDir(const char* filename); - void findInDataDir(const char* filename); - void findInDocsDir(const char* filename); - void findInHomeDir(const char* filename); - void findConfigurationFile(); + void addPath(std::string path); -private: - // Disable copy - ResourceFinder(const ResourceFinder&); - ResourceFinder& operator==(const ResourceFinder&); + void findInBinDir(const char* filename); + void findInDataDir(const char* filename); + void findInDocsDir(const char* filename); + void findInHomeDir(const char* filename); + void findConfigurationFile(); - // Members - std::vector m_paths; - int m_current; -}; + private: + // Disable copy + ResourceFinder(const ResourceFinder&); + ResourceFinder& operator==(const ResourceFinder&); + + // Members + std::vector m_paths; + int m_current; + }; + +} // namespace app #endif diff --git a/src/app/settings/document_settings.h b/src/app/settings/document_settings.h new file mode 100644 index 000000000..920fde97e --- /dev/null +++ b/src/app/settings/document_settings.h @@ -0,0 +1,82 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_SETTINGS_DOCUMENT_SETTINGS_H_INCLUDED +#define APP_SETTINGS_DOCUMENT_SETTINGS_H_INCLUDED + +#include "app/color.h" +#include "filters/tiled_mode.h" +#include "gfx/point.h" +#include "gfx/rect.h" + +namespace app { + + enum SnapBehavior { + NormalSnap = 0, + SnapInRightBottom = 1 + }; + + class IDocumentSettings { + public: + virtual ~IDocumentSettings() { } + + // Tiled mode + + virtual filters::TiledMode getTiledMode() = 0; + virtual void setTiledMode(filters::TiledMode mode) = 0; + + // Grid settings + + virtual bool getSnapToGrid() = 0; + virtual bool getGridVisible() = 0; + virtual gfx::Rect getGridBounds() = 0; + virtual app::Color getGridColor() = 0; + + virtual void setSnapToGrid(bool state) = 0; + virtual void setGridVisible(bool state) = 0; + virtual void setGridBounds(const gfx::Rect& rect) = 0; + virtual void setGridColor(const app::Color& color) = 0; + + virtual void snapToGrid(gfx::Point& point, SnapBehavior snapBehavior) const = 0; + + // Pixel grid + + virtual bool getPixelGridVisible() = 0; + virtual app::Color getPixelGridColor() = 0; + + virtual void setPixelGridVisible(bool state) = 0; + virtual void setPixelGridColor(const app::Color& color) = 0; + + // Onionskin settings + + virtual bool getUseOnionskin() = 0; + virtual int getOnionskinPrevFrames() = 0; + virtual int getOnionskinNextFrames() = 0; + virtual int getOnionskinOpacityBase() = 0; + virtual int getOnionskinOpacityStep() = 0; + + virtual void setUseOnionskin(bool state) = 0; + virtual void setOnionskinPrevFrames(int frames) = 0; + virtual void setOnionskinNextFrames(int frames) = 0; + virtual void setOnionskinOpacityBase(int base) = 0; + virtual void setOnionskinOpacityStep(int step) = 0; + }; + +} // namespace app + +#endif diff --git a/src/settings/ink_type.h b/src/app/settings/ink_type.h similarity index 59% rename from src/settings/ink_type.h rename to src/app/settings/ink_type.h index 77a65f3e9..ed55700c8 100644 --- a/src/settings/ink_type.h +++ b/src/app/settings/ink_type.h @@ -16,25 +16,29 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SETTINGS_INK_TYPE_H_INCLUDED -#define SETTINGS_INK_TYPE_H_INCLUDED +#ifndef APP_SETTINGS_INK_TYPE_H_INCLUDED +#define APP_SETTINGS_INK_TYPE_H_INCLUDED -// If you change this enumeration, you should update the -// ContextBar::InkTypeField() UI widget. Also, remember that these -// indexes are loaded/saved from/to the user configuration file, so -// you shouldn't change them. -enum InkType { - kDefaultInk, - kOpaqueInk, - kPutAlphaInk, - kMergeInk, - kShadingInk, - kReplaceInk, - kEraseInk, - kSelectionInk, - kBlurInk, - kJumbleInk, - kMaxInks -}; +namespace app { + + // If you change this enumeration, you should update the + // ContextBar::InkTypeField() UI widget. Also, remember that these + // indexes are loaded/saved from/to the user configuration file, so + // you shouldn't change them. + enum InkType { + kDefaultInk, + kOpaqueInk, + kPutAlphaInk, + kMergeInk, + kShadingInk, + kReplaceInk, + kEraseInk, + kSelectionInk, + kBlurInk, + kJumbleInk, + kMaxInks + }; + +} // namespace app #endif // SETTINGS_INK_TYPE_H_INCLUDED diff --git a/src/app/settings/settings.h b/src/app/settings/settings.h new file mode 100644 index 000000000..ac5837f6d --- /dev/null +++ b/src/app/settings/settings.h @@ -0,0 +1,114 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_SETTINGS_SETTINGS_H_INCLUDED +#define APP_SETTINGS_SETTINGS_H_INCLUDED + +#include "app/color.h" +#include "app/settings/ink_type.h" +#include "gfx/point.h" +#include "gfx/rect.h" +#include "raster/pen_type.h" + +namespace app { + class ColorSwatches; + class Document; + class IColorSwatchesStore; + class IDocumentSettings; + class IPenSettings; + class IToolSettings; + + namespace tools { + class Tool; + } + + class ISettings { + public: + virtual ~ISettings() { } + + // General settings + + virtual app::Color getFgColor() = 0; + virtual app::Color getBgColor() = 0; + virtual tools::Tool* getCurrentTool() = 0; + virtual app::ColorSwatches* getColorSwatches() = 0; + + virtual void setFgColor(const app::Color& color) = 0; + virtual void setBgColor(const app::Color& color) = 0; + virtual void setCurrentTool(tools::Tool* tool) = 0; + virtual void setColorSwatches(app::ColorSwatches* colorSwatches) = 0; + + // Returns the specific settings for the given document. If the + // document is null, it should return an interface for + // global/default settings. + virtual IDocumentSettings* getDocumentSettings(const Document* document) = 0; + + // Specific configuration for the given tool. + virtual IToolSettings* getToolSettings(tools::Tool* tool) = 0; + + virtual IColorSwatchesStore* getColorSwatchesStore() = 0; + }; + + // Tool's settings + class IToolSettings { + public: + virtual ~IToolSettings() { } + + virtual IPenSettings* getPen() = 0; + + virtual int getOpacity() = 0; + virtual int getTolerance() = 0; + virtual bool getFilled() = 0; + virtual bool getPreviewFilled() = 0; + virtual int getSprayWidth() = 0; + virtual int getSpraySpeed() = 0; + virtual InkType getInkType() = 0; + + virtual void setOpacity(int opacity) = 0; + virtual void setTolerance(int tolerance) = 0; + virtual void setFilled(bool state) = 0; + virtual void setPreviewFilled(bool state) = 0; + virtual void setSprayWidth(int width) = 0; + virtual void setSpraySpeed(int speed) = 0; + virtual void setInkType(InkType inkType) = 0; + }; + + // Settings for a tool's pen + class IPenSettings { + public: + virtual ~IPenSettings() { } + + virtual raster::PenType getType() = 0; + virtual int getSize() = 0; + virtual int getAngle() = 0; + + virtual void setType(PenType type) = 0; + virtual void setSize(int size) = 0; + virtual void setAngle(int angle) = 0; + }; + + class IColorSwatchesStore { + public: + virtual ~IColorSwatchesStore() { } + virtual void addColorSwatches(app::ColorSwatches* colorSwatches) = 0; + virtual void removeColorSwatches(app::ColorSwatches* colorSwatches) = 0; + }; + +} // namespace app + +#endif diff --git a/src/settings/ui_settings_impl.cpp b/src/app/settings/ui_settings_impl.cpp similarity index 96% rename from src/settings/ui_settings_impl.cpp rename to src/app/settings/ui_settings_impl.cpp index 8e1727cb5..0174b4f08 100644 --- a/src/settings/ui_settings_impl.cpp +++ b/src/app/settings/ui_settings_impl.cpp @@ -16,31 +16,36 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "settings/ui_settings_impl.h" +#include "app/settings/ui_settings_impl.h" -#include "app.h" +#include "app/app.h" #include "app/color_swatches.h" -#include "ini_file.h" -#include "settings/document_settings.h" -#include "tools/point_shape.h" -#include "tools/tool.h" -#include "tools/tool_box.h" +#include "app/ini_file.h" +#include "app/settings/document_settings.h" +#include "app/tools/point_shape.h" +#include "app/tools/tool.h" +#include "app/tools/tool_box.h" +#include "app/ui/color_bar.h" +#include "app/ui/main_window.h" +#include "app/ui/workspace.h" +#include "app/ui_context.h" #include "ui/manager.h" -#include "ui_context.h" -#include "widgets/color_bar.h" -#include "widgets/main_window.h" -#include "widgets/workspace.h" #include #include #include -using namespace gfx; +namespace app { -class UIDocumentSettingsImpl : public IDocumentSettings -{ +using namespace gfx; +using namespace raster; +using namespace filters; + +class UIDocumentSettingsImpl : public IDocumentSettings { public: UIDocumentSettingsImpl() : m_tiledMode((TiledMode)get_config_int("Tools", "Tiled", (int)TILED_NONE)) @@ -403,8 +408,7 @@ void UIDocumentSettingsImpl::setOnionskinOpacityStep(int step) ////////////////////////////////////////////////////////////////////// // Tools & pen settings -class UIPenSettingsImpl : public IPenSettings -{ +class UIPenSettingsImpl : public IPenSettings { PenType m_type; int m_size; int m_angle; @@ -466,8 +470,7 @@ public: }; -class UIToolSettingsImpl : public IToolSettings -{ +class UIToolSettingsImpl : public IToolSettings { tools::Tool* m_tool; UIPenSettingsImpl m_pen; int m_opacity; @@ -569,3 +572,5 @@ IToolSettings* UISettingsImpl::getToolSettings(tools::Tool* tool) return tool_settings; } } + +} // namespace app diff --git a/src/app/settings/ui_settings_impl.h b/src/app/settings/ui_settings_impl.h new file mode 100644 index 000000000..929a19163 --- /dev/null +++ b/src/app/settings/ui_settings_impl.h @@ -0,0 +1,66 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_SETTINGS_UI_SETTINGS_H_INCLUDED +#define APP_SETTINGS_UI_SETTINGS_H_INCLUDED + +#include +#include +#include + +#include "base/compiler_specific.h" +#include "app/settings/settings.h" + +namespace app { + + class UISettingsImpl : public ISettings, + public IColorSwatchesStore { + public: + UISettingsImpl(); + ~UISettingsImpl(); + + // ISettings implementation + + app::Color getFgColor() OVERRIDE; + app::Color getBgColor() OVERRIDE; + tools::Tool* getCurrentTool() OVERRIDE; + app::ColorSwatches* getColorSwatches() OVERRIDE; + void setFgColor(const app::Color& color) OVERRIDE; + void setBgColor(const app::Color& color) OVERRIDE; + void setCurrentTool(tools::Tool* tool) OVERRIDE; + void setColorSwatches(app::ColorSwatches* colorSwatches) OVERRIDE; + IDocumentSettings* getDocumentSettings(const Document* document) OVERRIDE; + IToolSettings* getToolSettings(tools::Tool* tool) OVERRIDE; + IColorSwatchesStore* getColorSwatchesStore() OVERRIDE; + + // IColorSwatchesStore implementation + + void addColorSwatches(app::ColorSwatches* colorSwatches) OVERRIDE; + void removeColorSwatches(app::ColorSwatches* colorSwatches) OVERRIDE; + + private: + tools::Tool* m_currentTool; + IDocumentSettings* m_globalDocumentSettings; + std::map m_toolSettings; + app::ColorSwatches* m_colorSwatches; + std::vector m_colorSwatchesStore; + }; + +} // namespace app + +#endif diff --git a/src/shell.cpp b/src/app/shell.cpp similarity index 92% rename from src/shell.cpp rename to src/app/shell.cpp index 219db4460..399b87b77 100644 --- a/src/shell.cpp +++ b/src/app/shell.cpp @@ -16,15 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "shell.h" +#include "app/shell.h" #include "scripting/engine.h" #include #include +namespace app { + Shell::Shell() { } @@ -42,3 +46,5 @@ void Shell::run(scripting::Engine& engine) } std::cout << "Done\n"; } + +} // namespace app diff --git a/src/shell.h b/src/app/shell.h similarity index 77% rename from src/shell.h rename to src/app/shell.h index e55ee8f61..46ebf3ab6 100644 --- a/src/shell.h +++ b/src/app/shell.h @@ -16,18 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef SHELL_H_INCLUDED -#define SHELL_H_INCLUDED +#ifndef APP_SHELL_H_INCLUDED +#define APP_SHELL_H_INCLUDED -namespace scripting { class Engine; } +namespace scripting { + class Engine; +} -class Shell -{ -public: - Shell(); - ~Shell(); +namespace app { - void run(scripting::Engine& engine); -}; + class Shell { + public: + Shell(); + ~Shell(); + + void run(scripting::Engine& engine); + }; + +} // namespace app #endif diff --git a/src/thumbnail_generator.cpp b/src/app/thumbnail_generator.cpp similarity index 91% rename from src/thumbnail_generator.cpp rename to src/app/thumbnail_generator.cpp index 46760d858..9b3f92fad 100644 --- a/src/thumbnail_generator.cpp +++ b/src/app/thumbnail_generator.cpp @@ -16,17 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "thumbnail_generator.h" +#include "app/thumbnail_generator.h" -#include "app.h" +#include "app/app.h" +#include "app/document.h" +#include "app/file/file.h" +#include "app/file_system.h" #include "base/bind.h" #include "base/scoped_lock.h" #include "base/thread.h" -#include "document.h" -#include "file/file.h" -#include "file_system.h" #include "raster/image.h" #include "raster/palette.h" #include "raster/rotate.h" @@ -36,8 +38,9 @@ #define MAX_THUMBNAIL_SIZE 128 -class ThumbnailGenerator::Worker -{ +namespace app { + +class ThumbnailGenerator::Worker { public: Worker(FileOp* fop, IFileItem* fileitem) : m_fop(fop) @@ -75,7 +78,7 @@ private: m_palette.reset(new Palette(*sprite->getPalette(FrameNumber(0)))); // Render the 'sprite' in one plain 'image' - UniquePtr image(Image::create(sprite->getPixelFormat(), + base::UniquePtr image(Image::create(sprite->getPixelFormat(), sprite->getWidth(), sprite->getHeight())); sprite->render(image, 0, 0, FrameNumber(0)); @@ -113,9 +116,9 @@ private: FileOp* m_fop; IFileItem* m_fileitem; - UniquePtr m_thumbnail; + base::UniquePtr m_thumbnail; BITMAP* m_thumbnailBitmap; - UniquePtr m_palette; + base::UniquePtr m_palette; base::thread m_thread; }; @@ -136,7 +139,7 @@ ThumbnailGenerator* ThumbnailGenerator::instance() ThumbnailGenerator::WorkerStatus ThumbnailGenerator::getWorkerStatus(IFileItem* fileitem, double& progress) { - ScopedLock hold(m_workersAccess); + base::scoped_lock hold(m_workersAccess); for (WorkerList::iterator it=m_workers.begin(), end=m_workers.end(); it!=end; ++it) { @@ -155,7 +158,7 @@ ThumbnailGenerator::WorkerStatus ThumbnailGenerator::getWorkerStatus(IFileItem* bool ThumbnailGenerator::checkWorkers() { - ScopedLock hold(m_workersAccess); + base::scoped_lock hold(m_workersAccess); bool doingWork = !m_workers.empty(); for (WorkerList::iterator @@ -193,7 +196,7 @@ void ThumbnailGenerator::addWorkerToGenerateThumbnail(IFileItem* fileitem) else { Worker* worker = new Worker(fop, fileitem); try { - ScopedLock hold(m_workersAccess); + base::scoped_lock hold(m_workersAccess); m_workers.push_back(worker); } catch (...) { @@ -213,7 +216,7 @@ void ThumbnailGenerator::stopAllWorkersBackground() { WorkerList workersCopy; { - ScopedLock hold(m_workersAccess); + base::scoped_lock hold(m_workersAccess); workersCopy = m_workers; m_workers.clear(); } @@ -223,3 +226,5 @@ void ThumbnailGenerator::stopAllWorkersBackground() delete *it; } } + +} // namespace app diff --git a/src/app/thumbnail_generator.h b/src/app/thumbnail_generator.h new file mode 100644 index 000000000..154108bba --- /dev/null +++ b/src/app/thumbnail_generator.h @@ -0,0 +1,71 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_THUMBNAIL_GENERATOR_H_INCLUDED +#define APP_THUMBNAIL_GENERATOR_H_INCLUDED + +#include "base/mutex.h" +#include "base/unique_ptr.h" + +#include + +namespace base { + class thread; +} + +namespace app { + class IFileItem; + + class ThumbnailGenerator { + public: + enum WorkerStatus { WithoutWorker, WorkingOnThumbnail, ThumbnailIsDone }; + + static ThumbnailGenerator* instance(); + + // Generate a thumbnail for the given file-item. It must be called + // from the GUI thread. + void addWorkerToGenerateThumbnail(IFileItem* fileitem); + + // Returns the status of the worker that is generating the thumbnail + // for the given file. + WorkerStatus getWorkerStatus(IFileItem* fileitem, double& progress); + + // Checks the status of workers. If there are workers that already + // done its job, we've to destroy them. This function must be called + // from the GUI thread (because a thread is joint to it). + // Returns true if there are workers generating thumbnails. + bool checkWorkers(); + + // Stops all workers generating thumbnails. This is an non-blocking + // operation. The cancelation of all workers is done in a background + // thread. + void stopAllWorkers(); + + private: + void stopAllWorkersBackground(); + + class Worker; + typedef std::vector WorkerList; + + WorkerList m_workers; + base::mutex m_workersAccess; + base::UniquePtr m_stopThread; + }; +} // namespace app + +#endif diff --git a/src/app/tools/controller.h b/src/app/tools/controller.h new file mode 100644 index 000000000..4880d5fe8 --- /dev/null +++ b/src/app/tools/controller.h @@ -0,0 +1,58 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_TOOLS_CONTROLLER_H_INCLUDED +#define APP_TOOLS_CONTROLLER_H_INCLUDED + +#include "gfx/point.h" + +#include +#include + +namespace app { + namespace tools { + + class ToolLoop; + + // This class controls user input. + class Controller { + public: + typedef std::vector Points; + + virtual ~Controller() { } + virtual bool canSnapToGrid() { return true; } + + // Called when the user starts drawing and each time a new button is + // pressed. The controller could be sure that this method is called + // at least one time. + virtual void pressButton(Points& points, const gfx::Point& point) = 0; + + // Called each time a mouse button is released. + virtual bool releaseButton(Points& points, const gfx::Point& point) = 0; + + // Called when the mouse is moved. + virtual void movement(ToolLoop* loop, Points& points, const gfx::Point& point) = 0; + + virtual void getPointsToInterwine(const Points& input, Points& output) = 0; + virtual void getStatusBarText(const Points& points, std::string& text) = 0; + }; + + } // namespace tools +} // namespace app + +#endif // TOOLS_TOOL_INK_H_INCLUDED diff --git a/src/tools/controllers.h b/src/app/tools/controllers.h similarity index 95% rename from src/tools/controllers.h rename to src/app/tools/controllers.h index 4702d1d14..fadbd1543 100644 --- a/src/tools/controllers.h +++ b/src/app/tools/controllers.h @@ -23,9 +23,13 @@ #define M_PI 3.14159265358979323846 #endif +namespace app { +namespace tools { + +using namespace gfx; + // Controls clicks for tools like pencil -class FreehandController : public Controller -{ +class FreehandController : public Controller { public: void pressButton(Points& points, const Point& point) { @@ -65,8 +69,7 @@ public: }; // Controls clicks for tools like line -class TwoPointsController : public Controller -{ +class TwoPointsController : public Controller { Point m_center; public: void pressButton(Points& points, const Point& point) @@ -172,8 +175,7 @@ public: }; // Controls clicks for tools like polygon -class PointByPointController : public Controller -{ +class PointByPointController : public Controller { public: void pressButton(Points& points, const Point& point) { @@ -219,8 +221,7 @@ public: } }; -class OnePointController : public Controller -{ +class OnePointController : public Controller { public: // Do not apply grid to "one point tools" (e.g. magic wand, flood fill, etc.) bool canSnapToGrid() { return false; } @@ -254,8 +255,7 @@ public: } }; -class FourPointsController : public Controller -{ +class FourPointsController : public Controller { int m_clickCounter; public: void pressButton(Points& points, const Point& point) @@ -309,3 +309,6 @@ public: text = buf; } }; + +} // namespace tools +} // namespace app diff --git a/src/tools/fill.h b/src/app/tools/fill.h similarity index 78% rename from src/tools/fill.h rename to src/app/tools/fill.h index 33e1e21f6..416a6e38a 100644 --- a/src/tools/fill.h +++ b/src/app/tools/fill.h @@ -16,18 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TOOLS_FILL_H_INCLUDED -#define TOOLS_FILL_H_INCLUDED +#ifndef APP_TOOLS_FILL_H_INCLUDED +#define APP_TOOLS_FILL_H_INCLUDED -namespace tools { +namespace app { + namespace tools { -enum Fill -{ - FillNone, - FillAlways, - FillOptional, -}; + enum Fill { + FillNone, + FillAlways, + FillOptional, + }; -} // namespace tools + } // namespace tools +} // namespace app #endif // TOOLS_FILL_H_INCLUDED diff --git a/src/app/tools/ink.h b/src/app/tools/ink.h new file mode 100644 index 000000000..9b797a05a --- /dev/null +++ b/src/app/tools/ink.h @@ -0,0 +1,75 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_TOOLS_INK_H_INCLUDED +#define APP_TOOLS_INK_H_INCLUDED + +namespace app { + namespace tools { + + class ToolLoop; + + // Class used to paint directly in the destination image (loop->getDstImage()) + // + // The main task of this class is to draw scanlines through its + // inkHline function member. + class Ink { + // selection, paint, paint_fg, paint_bg, eraser, + // replace_fg_with_bg, replace_bg_with_fg, pick_fg, pick_bg, scroll, + // move, shade, blur, jumble + public: + virtual ~Ink() { } + + // Returns true if this ink modifies the selection/mask + virtual bool isSelection() const { return false; } + + // Returns true if this ink modifies the destination image + virtual bool isPaint() const { return false; } + + // Returns true if this ink is an effect (is useful to know if a ink + // is a effect so the Editor can display the cursor bounds) + virtual bool isEffect() const { return false; } + + // Returns true if this ink picks colors from the image + virtual bool isEyedropper() const { return false; } + + // Returns true if this ink moves the scroll only + virtual bool isScrollMovement() const { return false; } + + // Returns true if this ink moves cels + virtual bool isCelMovement() const { return false; } + + // It is called when the tool-loop start (generally when the user + // presses a mouse button over a sprite editor) + virtual void prepareInk(ToolLoop* loop) { } + + // It is used in the final stage of the tool-loop, it is called twice + // (first with state=true and then state=false) + virtual void setFinalStep(ToolLoop* loop, bool state) { } + + // It is used to paint scanlines in the destination image. + // PointShapes call this method when they convert a mouse-point + // to a shape (e.g. pen shape) with various scanlines. + virtual void inkHline(int x1, int y, int x2, ToolLoop* loop) = 0; + + }; + + } // namespace tools +} // namespace app + +#endif // TOOLS_INK_H_INCLUDED diff --git a/src/tools/ink_processing.h b/src/app/tools/ink_processing.h similarity index 98% rename from src/tools/ink_processing.h rename to src/app/tools/ink_processing.h index 19f3e89e2..da8a12b9d 100644 --- a/src/tools/ink_processing.h +++ b/src/app/tools/ink_processing.h @@ -16,14 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "app/modules/palettes.h" +#include "app/settings/document_settings.h" +#include "app/tools/shade_table.h" +#include "app/tools/shading_options.h" #include "filters/neighboring_pixels.h" -#include "modules/palettes.h" #include "raster/palette.h" #include "raster/rgbmap.h" #include "raster/sprite.h" -#include "settings/document_settings.h" -#include "tools/shade_table.h" -#include "tools/shading_options.h" + +namespace app { +namespace tools { + +using namespace gfx; +using namespace filters; ////////////////////////////////////////////////////////////////////// // Ink Processing @@ -547,3 +553,6 @@ static AlgoHLine ink_processing[][3] = DEF_INK(jumble), DEF_INK(shading) }; + +} // namespace tools +} // namespace app diff --git a/src/tools/inks.h b/src/app/tools/inks.h similarity index 92% rename from src/tools/inks.h rename to src/app/tools/inks.h index cc4a9b147..b10eb04b8 100644 --- a/src/tools/inks.h +++ b/src/app/tools/inks.h @@ -16,21 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "tools/ink_processing.h" +#include "app/tools/ink_processing.h" -#include "app.h" // TODO avoid to include this file +#include "app/app.h" // TODO avoid to include this file #include "app/color_utils.h" -#include "context.h" -#include "document.h" -#include "document_undo.h" +#include "app/context.h" +#include "app/document.h" +#include "app/document_undo.h" +#include "app/settings/settings.h" +#include "app/undoers/set_mask.h" #include "raster/mask.h" -#include "undoers/set_mask.h" +namespace app { +namespace tools { // Ink used for tools which paint with primary/secondary // (or foreground/background colors) -class PaintInk : public Ink -{ +class PaintInk : public Ink { public: enum Type { Merge, WithFg, WithBg, Opaque, PutAlpha }; @@ -88,8 +90,7 @@ public: }; -class ShadingInk : public Ink -{ +class ShadingInk : public Ink { private: AlgoHLine m_proc; @@ -110,8 +111,7 @@ public: }; -class PickInk : public Ink -{ +class PickInk : public Ink { public: enum Target { Fg, Bg }; @@ -136,8 +136,7 @@ public: }; -class ScrollInk : public Ink -{ +class ScrollInk : public Ink { public: bool isScrollMovement() const { return true; } @@ -155,8 +154,7 @@ public: }; -class MoveInk : public Ink -{ +class MoveInk : public Ink { public: bool isCelMovement() const { return true; } @@ -172,8 +170,7 @@ public: }; -class EraserInk : public Ink -{ +class EraserInk : public Ink { public: enum Type { Eraser, ReplaceFgWithBg, ReplaceBgWithFg }; @@ -226,8 +223,7 @@ public: }; -class BlurInk : public Ink -{ +class BlurInk : public Ink { AlgoHLine m_proc; public: @@ -246,8 +242,7 @@ public: }; -class JumbleInk : public Ink -{ +class JumbleInk : public Ink { AlgoHLine m_proc; public: @@ -267,8 +262,7 @@ public: // Ink used for selection tools (like Rectangle Marquee, Lasso, Magic Wand, etc.) -class SelectionInk : public Ink -{ +class SelectionInk : public Ink { bool m_modify_selection; public: @@ -310,3 +304,7 @@ public: } }; + + +} // namespace tools +} // namespace app diff --git a/src/tools/intertwine.cpp b/src/app/tools/intertwine.cpp similarity index 84% rename from src/tools/intertwine.cpp rename to src/app/tools/intertwine.cpp index 0209e25ee..3cd1019f2 100644 --- a/src/tools/intertwine.cpp +++ b/src/app/tools/intertwine.cpp @@ -16,16 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "tools/intertwine.h" +#include "app/tools/intertwine.h" +#include "app/tools/point_shape.h" +#include "app/tools/tool_loop.h" #include "raster/algo.h" -#include "tools/point_shape.h" -#include "tools/tool_loop.h" + +namespace app { +namespace tools { using namespace gfx; -using namespace tools; +using namespace raster; void Intertwine::doPointshapePoint(int x, int y, ToolLoop* loop) { @@ -41,3 +46,6 @@ void Intertwine::doPointshapeLine(int x1, int y1, int x2, int y2, ToolLoop* loop { algo_line(x1, y1, x2, y2, loop, (AlgoPixel)doPointshapePoint); } + +} // namespace tools +} // namespace app diff --git a/src/tools/intertwine.h b/src/app/tools/intertwine.h similarity index 53% rename from src/tools/intertwine.h rename to src/app/tools/intertwine.h index 4b35fe770..2d19e5fab 100644 --- a/src/tools/intertwine.h +++ b/src/app/tools/intertwine.h @@ -16,33 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TOOLS_INTERTWINE_H_INCLUDED -#define TOOLS_INTERTWINE_H_INCLUDED +#ifndef APP_TOOLS_INTERTWINE_H_INCLUDED +#define APP_TOOLS_INTERTWINE_H_INCLUDED #include "gfx/point.h" #include -namespace tools { +namespace app { + namespace tools { + class ToolLoop; -class ToolLoop; + class Intertwine { + public: + typedef std::vector Points; -class Intertwine -{ -public: - typedef std::vector Points; + virtual ~Intertwine() { } + virtual bool snapByAngle() { return false; } + virtual void joinPoints(ToolLoop* loop, const Points& points) = 0; + virtual void fillPoints(ToolLoop* loop, const Points& points) = 0; - virtual ~Intertwine() { } - virtual bool snapByAngle() { return false; } - virtual void joinPoints(ToolLoop* loop, const Points& points) = 0; - virtual void fillPoints(ToolLoop* loop, const Points& points) = 0; + protected: + static void doPointshapePoint(int x, int y, ToolLoop* loop); + static void doPointshapeHline(int x1, int y, int x2, ToolLoop* loop); + static void doPointshapeLine(int x1, int y1, int x2, int y2, ToolLoop* loop); + }; -protected: - static void doPointshapePoint(int x, int y, ToolLoop* loop); - static void doPointshapeHline(int x1, int y, int x2, ToolLoop* loop); - static void doPointshapeLine(int x1, int y1, int x2, int y2, ToolLoop* loop); -}; - -} // namespace tools + } // namespace tools +} // namespace app #endif // TOOLS_INTERTWINE_H_INCLUDED diff --git a/src/tools/intertwiners.h b/src/app/tools/intertwiners.h similarity index 94% rename from src/tools/intertwiners.h rename to src/app/tools/intertwiners.h index a6e6a96b1..ad08b05dc 100644 --- a/src/tools/intertwiners.h +++ b/src/app/tools/intertwiners.h @@ -16,8 +16,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -class IntertwineNone : public Intertwine -{ +namespace app { +namespace tools { + +class IntertwineNone : public Intertwine { public: void joinPoints(ToolLoop* loop, const Points& points) @@ -32,8 +34,7 @@ public: } }; -class IntertwineAsLines : public Intertwine -{ +class IntertwineAsLines : public Intertwine { public: bool snapByAngle() { return true; } @@ -79,8 +80,7 @@ public: } }; -class IntertwineAsRectangles : public Intertwine -{ +class IntertwineAsRectangles : public Intertwine { public: void joinPoints(ToolLoop* loop, const Points& points) @@ -136,8 +136,7 @@ public: } }; -class IntertwineAsEllipses : public Intertwine -{ +class IntertwineAsEllipses : public Intertwine { public: void joinPoints(ToolLoop* loop, const Points& points) @@ -184,8 +183,7 @@ public: } }; -class IntertwineAsBezier : public Intertwine -{ +class IntertwineAsBezier : public Intertwine { public: void joinPoints(ToolLoop* loop, const Points& points) @@ -221,3 +219,6 @@ public: joinPoints(loop, points); } }; + +} // namespace tools +} // namespace app diff --git a/src/tools/point_shape.cpp b/src/app/tools/point_shape.cpp similarity index 87% rename from src/tools/point_shape.cpp rename to src/app/tools/point_shape.cpp index 90c354d28..0e5b4ba61 100644 --- a/src/tools/point_shape.cpp +++ b/src/app/tools/point_shape.cpp @@ -16,17 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "tools/point_shape.h" +#include "app/tools/point_shape.h" +#include "app/settings/document_settings.h" +#include "app/tools/ink.h" +#include "app/tools/tool_loop.h" #include "raster/image.h" -#include "settings/document_settings.h" -#include "tools/ink.h" -#include "tools/tool_loop.h" -using namespace tools; +namespace app { +namespace tools { +using namespace raster; +using namespace filters; + void PointShape::doInkHline(int x1, int y, int x2, ToolLoop* loop) { register TiledMode tiledMode = loop->getDocumentSettings()->getTiledMode(); @@ -82,3 +88,6 @@ void PointShape::doInkHline(int x1, int y, int x2, ToolLoop* loop) loop->getInk()->inkHline(x1, y, x2, loop); } } + +} // namespace tools +} // namespace app diff --git a/src/tools/point_shape.h b/src/app/tools/point_shape.h similarity index 50% rename from src/tools/point_shape.h rename to src/app/tools/point_shape.h index c352043d0..f9af4779c 100644 --- a/src/tools/point_shape.h +++ b/src/app/tools/point_shape.h @@ -16,31 +16,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TOOLS_TOOL_POINT_SHAPE_INCLUDED -#define TOOLS_TOOL_POINT_SHAPE_H_INCLUDED +#ifndef APP_TOOLS_TOOL_POINT_SHAPE_INCLUDED +#define APP_TOOLS_TOOL_POINT_SHAPE_H_INCLUDED #include "gfx/rect.h" -namespace tools { +namespace app { + namespace tools { + class ToolLoop; -class ToolLoop; + // Converts a point to a shape to be drawn + class PointShape { + public: + virtual ~PointShape() { } + virtual bool isFloodFill() { return false; } + virtual bool isSpray() { return false; } + virtual void transformPoint(ToolLoop* loop, int x, int y) = 0; + virtual void getModifiedArea(ToolLoop* loop, int x, int y, gfx::Rect& area) = 0; -// Converts a point to a shape to be drawn -class PointShape -{ -public: - virtual ~PointShape() { } - virtual bool isFloodFill() { return false; } - virtual bool isSpray() { return false; } - virtual void transformPoint(ToolLoop* loop, int x, int y) = 0; - virtual void getModifiedArea(ToolLoop* loop, int x, int y, gfx::Rect& area) = 0; + protected: + // Calls loop->getInk()->inkHline() function for each horizontal-scanline + // that should be drawn (applying the "tiled" mode loop->getTiledMode()) + static void doInkHline(int x1, int y, int x2, ToolLoop* loop); + }; -protected: - // Calls loop->getInk()->inkHline() function for each horizontal-scanline - // that should be drawn (applying the "tiled" mode loop->getTiledMode()) - static void doInkHline(int x1, int y, int x2, ToolLoop* loop); -}; - -} // namespace tools + } // namespace tools +} // namespace app #endif // TOOLS_INK_H_INCLUDED diff --git a/src/tools/point_shapes.h b/src/app/tools/point_shapes.h similarity index 92% rename from src/tools/point_shapes.h rename to src/app/tools/point_shapes.h index 5ebecfbd8..70d34712e 100644 --- a/src/tools/point_shapes.h +++ b/src/app/tools/point_shapes.h @@ -16,8 +16,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -class NonePointShape : public PointShape -{ +namespace app { +namespace tools { + +class NonePointShape : public PointShape { public: void transformPoint(ToolLoop* loop, int x, int y) { @@ -29,8 +31,7 @@ public: } }; -class PixelPointShape : public PointShape -{ +class PixelPointShape : public PointShape { public: void transformPoint(ToolLoop* loop, int x, int y) { @@ -42,8 +43,7 @@ public: } }; -class PenPointShape : public PointShape -{ +class PenPointShape : public PointShape { public: void transformPoint(ToolLoop* loop, int x, int y) { @@ -69,8 +69,7 @@ public: } }; -class FloodFillPointShape : public PointShape -{ +class FloodFillPointShape : public PointShape { public: bool isFloodFill() { return true; } @@ -84,8 +83,7 @@ public: } }; -class SprayPointShape : public PointShape -{ +class SprayPointShape : public PointShape { PenPointShape m_subPointShape; public: @@ -137,3 +135,6 @@ public: area = area1.createUnion(area2); } }; + +} // namespace tools +} // namespace app diff --git a/src/tools/shade_table.cpp b/src/app/tools/shade_table.cpp similarity index 94% rename from src/tools/shade_table.cpp rename to src/app/tools/shade_table.cpp index ffa7343a6..9e56f51d3 100644 --- a/src/tools/shade_table.cpp +++ b/src/app/tools/shade_table.cpp @@ -16,13 +16,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "tools/shade_table.h" +#include "app/tools/shade_table.h" #include "app/color_swatches.h" #include "raster/palette.h" +namespace app { namespace tools { ShadeTable8::ShadeTable8(const app::ColorSwatches& colorSwatches, ShadingMode mode) @@ -65,3 +68,4 @@ ShadeTable8::ShadeTable8(const app::ColorSwatches& colorSwatches, ShadingMode mo } } // namespace tools +} // namespace app diff --git a/src/tools/shade_table.h b/src/app/tools/shade_table.h similarity index 54% rename from src/tools/shade_table.h rename to src/app/tools/shade_table.h index 1f6cecff5..df797dde2 100644 --- a/src/tools/shade_table.h +++ b/src/app/tools/shade_table.h @@ -16,32 +16,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TOOLS_SHADE_TABLE_H_INCLUDED -#define TOOLS_SHADE_TABLE_H_INCLUDED +#ifndef APP_TOOLS_SHADE_TABLE_H_INCLUDED +#define APP_TOOLS_SHADE_TABLE_H_INCLUDED +#include "app/tools/shading_mode.h" #include -#include "tools/shading_mode.h" -namespace app { class ColorSwatches; } +namespace app { + class ColorSwatches; -namespace tools { + namespace tools { -// Converts a ColorSwatches table to a temporary "shade table" used in -// shading ink so we can quickly rotate colors with left/right mouse -// buttons. -class ShadeTable8 -{ -public: - ShadeTable8(const app::ColorSwatches& colorSwatches, ShadingMode mode); + // Converts a ColorSwatches table to a temporary "shade table" used in + // shading ink so we can quickly rotate colors with left/right mouse + // buttons. + class ShadeTable8 { + public: + ShadeTable8(const app::ColorSwatches& colorSwatches, ShadingMode mode); - uint8_t left(uint8_t index) { return m_left[index]; } - uint8_t right(uint8_t index) { return m_right[index]; } + uint8_t left(uint8_t index) { return m_left[index]; } + uint8_t right(uint8_t index) { return m_right[index]; } -private: - std::vector m_left; - std::vector m_right; -}; + private: + std::vector m_left; + std::vector m_right; + }; -} // namespace tools + } // namespace tools +} // namespace app #endif // TOOLS_SHADE_TABLE_H_INCLUDED diff --git a/src/tools/shading_mode.h b/src/app/tools/shading_mode.h similarity index 66% rename from src/tools/shading_mode.h rename to src/app/tools/shading_mode.h index b9bacfce3..d11de31e3 100644 --- a/src/tools/shading_mode.h +++ b/src/app/tools/shading_mode.h @@ -16,21 +16,22 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TOOLS_SHADING_MODE_H_INCLUDED -#define TOOLS_SHADING_MODE_H_INCLUDED +#ifndef APP_TOOLS_SHADING_MODE_H_INCLUDED +#define APP_TOOLS_SHADING_MODE_H_INCLUDED -namespace tools { +namespace app { + namespace tools { -enum ShadingMode -{ - // When we reach the left/right side of the table, we stay there. - kDrainShadingMode, + enum ShadingMode { + // When we reach the left/right side of the table, we stay there. + kDrainShadingMode, - // Rotate colors (the leftmost is converted to the rightmost and - // viceversa). - kRotateShadingMode -}; + // Rotate colors (the leftmost is converted to the rightmost and + // viceversa). + kRotateShadingMode + }; -} // namespace tools + } // namespace tools +} // namespace app #endif // TOOLS_SHADING_MODE_H_INCLUDED diff --git a/src/tools/shading_options.h b/src/app/tools/shading_options.h similarity index 71% rename from src/tools/shading_options.h rename to src/app/tools/shading_options.h index 31d15d22d..bec7786cf 100644 --- a/src/tools/shading_options.h +++ b/src/app/tools/shading_options.h @@ -16,20 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TOOLS_SHADING_OPTIONS_H_INCLUDED -#define TOOLS_SHADING_OPTIONS_H_INCLUDED +#ifndef APP_TOOLS_SHADING_OPTIONS_H_INCLUDED +#define APP_TOOLS_SHADING_OPTIONS_H_INCLUDED -namespace tools { +namespace app { + namespace tools { + class ShadeTable8; -class ShadeTable8; + class ShadingOptions { + public: + virtual ~ShadingOptions() { } + virtual ShadeTable8* getShadeTable() = 0; + }; -class ShadingOptions -{ -public: - virtual ~ShadingOptions() { } - virtual ShadeTable8* getShadeTable() = 0; -}; - -} // namespace tools + } // namespace tools +} // namespace app #endif // TOOLS_SHADING_OPTIONS_H_INCLUDED diff --git a/src/app/tools/tool.h b/src/app/tools/tool.h new file mode 100644 index 000000000..5f9b4efc8 --- /dev/null +++ b/src/app/tools/tool.h @@ -0,0 +1,96 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_TOOLS_TOOL_H_INCLUDED +#define APP_TOOLS_TOOL_H_INCLUDED + +#include + +#include "app/tools/fill.h" +#include "app/tools/trace_policy.h" + +namespace app { + namespace tools { + + class Controller; + class Ink; + class Intertwine; + class PointShape; + class ToolGroup; + + // A drawing tool + class Tool { + public: + + Tool(ToolGroup* group, + const std::string& id, + const std::string& text, + const std::string& tips, + int default_pen_size) + : m_group(group) + , m_id(id) + , m_text(text) + , m_tips(tips) + , m_default_pen_size(default_pen_size) + { } + + virtual ~Tool() + { } + + const ToolGroup* getGroup() const { return m_group; } + const std::string& getId() const { return m_id; } + const std::string& getText() const { return m_text; } + const std::string& getTips() const { return m_tips; } + int getDefaultPenSize() const { return m_default_pen_size; } + + Fill getFill(int button) { return m_button[button].m_fill; } + Ink* getInk(int button) { return m_button[button].m_ink; } + Controller* getController(int button) { return m_button[button].m_controller; } + PointShape* getPointShape(int button) { return m_button[button].m_point_shape; } + Intertwine* getIntertwine(int button) { return m_button[button].m_intertwine; } + TracePolicy getTracePolicy(int button) { return m_button[button].m_trace_policy; } + + void setFill(int button, Fill fill) { m_button[button].m_fill = fill; } + void setInk(int button, Ink* ink) { m_button[button].m_ink = ink; } + void setController(int button, Controller* controller) { m_button[button].m_controller = controller; } + void setPointShape(int button, PointShape* point_shape) { m_button[button].m_point_shape = point_shape; } + void setIntertwine(int button, Intertwine* intertwine) { m_button[button].m_intertwine = intertwine; } + void setTracePolicy(int button, TracePolicy trace_policy) { m_button[button].m_trace_policy = trace_policy; } + + private: + ToolGroup* m_group; + std::string m_id; + std::string m_text; + std::string m_tips; + int m_default_pen_size; + + struct { + Fill m_fill; + Ink* m_ink; + Controller* m_controller; + PointShape* m_point_shape; + Intertwine* m_intertwine; + TracePolicy m_trace_policy; + } m_button[2]; // Two buttons: [0] left and [1] right + + }; + + } // namespace tools +} // namespace app + +#endif // TOOLS_TOOL_H_INCLUDED diff --git a/src/tools/tool_box.cpp b/src/app/tools/tool_box.cpp similarity index 95% rename from src/tools/tool_box.cpp rename to src/app/tools/tool_box.cpp index 4dbd603ac..754ba68c3 100644 --- a/src/tools/tool_box.cpp +++ b/src/app/tools/tool_box.cpp @@ -16,35 +16,40 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif +#include "app/tools/tool_box.h" + +#include "app/gui_xml.h" +#include "app/tools/controller.h" +#include "app/tools/ink.h" +#include "app/tools/intertwine.h" +#include "app/tools/point_shape.h" +#include "app/tools/tool_group.h" +#include "app/tools/tool_loop.h" #include "base/exception.h" -#include "gui_xml.h" #include "raster/algo.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/pen.h" -#include "tools/controller.h" -#include "tools/ink.h" -#include "tools/intertwine.h" -#include "tools/point_shape.h" -#include "tools/tool_box.h" -#include "tools/tool_group.h" -#include "tools/tool_loop.h" #include #include #include #include +#include "app/tools/controllers.h" +#include "app/tools/inks.h" +#include "app/tools/intertwiners.h" +#include "app/tools/point_shapes.h" + +namespace app { +namespace tools { + using namespace gfx; -using namespace tools; - -#include "tools/controllers.h" -#include "tools/inks.h" -#include "tools/intertwiners.h" -#include "tools/point_shapes.h" - + const char* WellKnownTools::RectangularMarquee = "rectangular_marquee"; const char* WellKnownInks::Selection = "selection"; @@ -64,8 +69,6 @@ const char* WellKnownInks::Move = "move"; const char* WellKnownInks::Blur = "blur"; const char* WellKnownInks::Jumble = "jumble"; -////////////////////////////////////////////////////////////////////// - ToolBox::ToolBox() { PRINTF("Toolbox module: installing\n"); @@ -271,3 +274,6 @@ void ToolBox::loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button, tool->setIntertwine(button, it_intertwiner->second); tool->setTracePolicy(button, tracepolicy_value); } + +} // namespace tools +} // namespace app diff --git a/src/app/tools/tool_box.h b/src/app/tools/tool_box.h new file mode 100644 index 000000000..a5ae6d7b4 --- /dev/null +++ b/src/app/tools/tool_box.h @@ -0,0 +1,96 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_TOOLS_TOOL_BOX_H_INCLUDED +#define APP_TOOLS_TOOL_BOX_H_INCLUDED + +#include +#include +#include + +#include "app/tools/tool.h" + +class TiXmlElement; + +namespace app { + namespace tools { + + namespace WellKnownTools { + extern const char* RectangularMarquee; + }; + + namespace WellKnownInks { + extern const char* Selection; + extern const char* Paint; + extern const char* PaintFg; + extern const char* PaintBg; + extern const char* PaintOpaque; + extern const char* PaintPutAlpha; + extern const char* Shading; + extern const char* Eraser; + extern const char* ReplaceFgWithBg; + extern const char* ReplaceBgWithFg; + extern const char* PickFg; + extern const char* PickBg; + extern const char* Scroll; + extern const char* Move; + extern const char* Blur; + extern const char* Jumble; + }; + + typedef std::list ToolList; + typedef ToolList::iterator ToolIterator; + typedef ToolList::const_iterator ToolConstIterator; + + typedef std::list ToolGroupList; + + // Loads and maintains the group of tools specified in the gui.xml file + class ToolBox { + public: + ToolBox(); + ~ToolBox(); + + ToolGroupList::iterator begin_group() { return m_groups.begin(); } + ToolGroupList::iterator end_group() { return m_groups.end(); } + + ToolIterator begin() { return m_tools.begin(); } + ToolIterator end() { return m_tools.end(); } + ToolConstIterator begin() const { return m_tools.begin(); } + ToolConstIterator end() const { return m_tools.end(); } + + Tool* getToolById(const std::string& id); + Ink* getInkById(const std::string& id); + int getGroupsCount() const { return m_groups.size(); } + + private: + void loadTools(); + void loadToolProperties(TiXmlElement* xmlTool, Tool* tool, int button, const std::string& suffix); + + std::map m_inks; + std::map m_controllers; + std::map m_pointshapers; + std::map m_intertwiners; + + ToolGroupList m_groups; + ToolList m_tools; + }; + + } // namespace tools +} // namespace app + +#endif // TOOLS_TOOL_BOX_H_INCLUDED diff --git a/src/tools/tool_group.h b/src/app/tools/tool_group.h similarity index 60% rename from src/tools/tool_group.h rename to src/app/tools/tool_group.h index baff9cde0..cbb7e401f 100644 --- a/src/tools/tool_group.h +++ b/src/app/tools/tool_group.h @@ -16,29 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef TOOLS_TOOL_GROUP_H_INCLUDED -#define TOOLS_TOOL_GROUP_H_INCLUDED +#ifndef APP_TOOLS_TOOL_GROUP_H_INCLUDED +#define APP_TOOLS_TOOL_GROUP_H_INCLUDED #include -namespace tools { +namespace app { + namespace tools { -// A group of tools. -class ToolGroup -{ -public: - ToolGroup(const char* name, - const char* label) : m_name(name) - , m_label(label) { } + // A group of tools. + class ToolGroup { + public: + ToolGroup(const char* name, + const char* label) : m_name(name) + , m_label(label) { } - const std::string& getName() const { return m_name; } - const std::string& getLabel() const { return m_label; } + const std::string& getName() const { return m_name; } + const std::string& getLabel() const { return m_label; } -private: - std::string m_name; - std::string m_label; -}; + private: + std::string m_name; + std::string m_label; + }; -} // namespace tools + } // namespace tools +} // namespace app #endif // TOOLS_TOOL_GROUP_H_INCLUDED diff --git a/src/app/tools/tool_loop.h b/src/app/tools/tool_loop.h new file mode 100644 index 000000000..57f8b6c33 --- /dev/null +++ b/src/app/tools/tool_loop.h @@ -0,0 +1,197 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_TOOLS_TOOL_LOOP_H_INCLUDED +#define APP_TOOLS_TOOL_LOOP_H_INCLUDED + +#include "app/tools/trace_policy.h" +#include "filters/tiled_mode.h" +#include "gfx/point.h" + +namespace gfx { + class Region; +} + +namespace raster { + class Image; + class Layer; + class Mask; + class Pen; + class RgbMap; + class Sprite; +} + +namespace app { + class Context; + class Document; + class IDocumentSettings; + class ISettings; + + namespace tools { + class Controller; + class Ink; + class Intertwine; + class PointShape; + class ShadingOptions; + class Tool; + + using namespace raster; + + // Interface to communicate the sprite editor with the tool when the user + // starts using a tool to paint, select, pick color, etc. + // + // All this information should be provided by the editor and consumed + // by the tool (+controller+intertwiner+pointshape+ink). + // + // TODO This interface is huge, it should be refactored. + class ToolLoop { + public: + enum Button { Left = 0, Right = 1 }; + + virtual ~ToolLoop() { } + + // Returns the tool to use to draw or use + virtual Tool* getTool() = 0; + + // Returns the pen which will be used with the tool + virtual Pen* getPen() = 0; + + // Returns the document to which belongs the sprite. + virtual Document* getDocument() = 0; + + // Returns the sprite where we will draw on + virtual Sprite* getSprite() = 0; + + // Returns the layer that will be modified if the tool paints + virtual Layer* getLayer() = 0; + + // Should return an image where we can read pixels (readonly image) + virtual Image* getSrcImage() = 0; + + // Should return an image where we can write pixels + virtual Image* getDstImage() = 0; + + // Returns the RGB map used to convert RGB values to palette index. + virtual RgbMap* getRgbMap() = 0; + + // Returns true if we should use the mask to limit the paint area. + virtual bool useMask() = 0; + + // Current mask to limit paint area + virtual Mask* getMask() = 0; + + // Gets mask X,Y origin coordinates + virtual gfx::Point getMaskOrigin() = 0; + + // Return the mouse button which start the tool-loop. It can be used + // by some tools that instead of using the primary/secondary color + // uses the pressed button for different behavior (like selection + // tools). + virtual Button getMouseButton() = 0; + + // Primary color to draw (e.g. foreground if the user start drawing + // with the left button, or background color if he used the right + // button) + virtual int getPrimaryColor() = 0; + virtual void setPrimaryColor(int color) = 0; + + // Secondary color to draw (e.g. background if the user start drawing + // with the left button, or foreground color if he used the right + // button) + virtual int getSecondaryColor() = 0; + virtual void setSecondaryColor(int color) = 0; + + // Returns the opacity to be used by the ink (Ink). + virtual int getOpacity() = 0; + + // Returns the tolerance to be used by the ink (Ink). + virtual int getTolerance() = 0; + + // Returns the current settings. Used to know current + // foreground/background color (certain tools needs to know the + // exact foreground/background color, they cannot used the + // primary/secondary). + virtual ISettings* getSettings() = 0; + + // Returns the document settings (tiled mode, grid bounds, etc.). + // It's used to know the preferred "tiled" mode of the document. + // See the method PointShape::doInkHline to check how this member is + // used. When tiled mode is activated, each scanline can be divided + // in various sub-lines if they pass the image bounds. For each of + // these scanlines a Ink::inkHline is called + // Also it's used to know the grid/snap-to-grid settings/behavior + // (see ToolLoopManager::snapToGrid). + virtual IDocumentSettings* getDocumentSettings() = 0; + + // Returns true if the figure must be filled when we release the + // mouse (e.g. a filled rectangle, etc.) + // + // To fill a shape, the Intertwine::fillPoints function is used. + virtual bool getFilled() = 0; + + // Returns true if the preview should be with filled shapes. + virtual bool getPreviewFilled() = 0; + + // Spray configuration + virtual int getSprayWidth() = 0; + virtual int getSpraySpeed() = 0; + + // Offset for each point + virtual gfx::Point getOffset() = 0; + + // Velocity vector of the mouse + virtual void setSpeed(const gfx::Point& speed) = 0; + virtual gfx::Point getSpeed() = 0; + + // Returns the ink to use with the tool. Each tool has an associated + // ink, but it could be modified for this specific loop, so + // generally you should return the same ink as the tool, but it can + // be different. The same for the other properties. + virtual Ink* getInk() = 0; + virtual Controller* getController() = 0; + virtual PointShape* getPointShape() = 0; + virtual Intertwine* getIntertwine() = 0; + virtual TracePolicy getTracePolicy() = 0; + + virtual ShadingOptions* getShadingOptions() = 0; + + // Used by the tool when the user cancels the operation pressing the + // other mouse button. + virtual void cancel() = 0; + + // Returns true if the loop was canceled by the user + virtual bool isCanceled() = 0; + + // Converts a coordinate in the screen to the sprite. + virtual gfx::Point screenToSprite(const gfx::Point& screenPoint) = 0; + + // This region is modified by the ToolLoopManager so then you know + // what must be updated in updateDirtyArea(). + virtual gfx::Region& getDirtyArea() = 0; + + // Redraws the dirty area. + virtual void updateDirtyArea() = 0; + + virtual void updateStatusBar(const char* text) = 0; + + }; + + } // namespace tools +} // namespace app + +#endif // TOOLS_TOOL_LOOP_H_INCLUDED diff --git a/src/tools/tool_loop_manager.cpp b/src/app/tools/tool_loop_manager.cpp similarity index 95% rename from src/tools/tool_loop_manager.cpp rename to src/app/tools/tool_loop_manager.cpp index 1de1dc680..f78f795ee 100644 --- a/src/tools/tool_loop_manager.cpp +++ b/src/app/tools/tool_loop_manager.cpp @@ -16,24 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "tools/tool_loop_manager.h" +#include "app/tools/tool_loop_manager.h" -#include "context.h" +#include "app/context.h" +#include "app/settings/document_settings.h" +#include "app/tools/controller.h" +#include "app/tools/ink.h" +#include "app/tools/intertwine.h" +#include "app/tools/point_shape.h" +#include "app/tools/tool_loop.h" +#include "app/util/render.h" #include "gfx/region.h" #include "raster/image.h" #include "raster/sprite.h" -#include "settings/document_settings.h" -#include "tools/controller.h" -#include "tools/ink.h" -#include "tools/intertwine.h" -#include "tools/point_shape.h" -#include "tools/tool_loop.h" -#include "util/render.h" + +namespace app { +namespace tools { using namespace gfx; -using namespace tools; +using namespace raster; +using namespace filters; ToolLoopManager::ToolLoopManager(ToolLoop* toolLoop) : m_toolLoop(toolLoop) @@ -286,3 +292,6 @@ void ToolLoopManager::calculateMinMax(const Points& points, Point& minpt, Point& maxpt.y = MAX(maxpt.y, points[c].y); } } + +} // namespace tools +} // namespace app diff --git a/src/app/tools/tool_loop_manager.h b/src/app/tools/tool_loop_manager.h new file mode 100644 index 000000000..937c85b61 --- /dev/null +++ b/src/app/tools/tool_loop_manager.h @@ -0,0 +1,119 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_TOOLS_TOOL_LOOP_MANAGER_H_INCLUDED +#define APP_TOOLS_TOOL_LOOP_MANAGER_H_INCLUDED + +#include + +#include "gfx/point.h" +#include "gfx/region.h" + +namespace gfx { class Region; } + +namespace app { + namespace tools { + + class ToolLoop; + + // Class to manage the drawing tool (editor <-> tool interface). + // + // The flow is this: + // 1. The user press a mouse button in a Editor widget + // 2. The Editor creates an implementation of ToolLoop and use it + // with the ToolLoopManager constructor + // 3. The ToolLoopManager is used to call + // the following methods: + // - ToolLoopManager::prepareLoop + // - ToolLoopManager::pressButton + // 4. If the user moves the mouse, the method + // - ToolLoopManager::movement + // is called. + // 5. When the user release the mouse: + // - ToolLoopManager::releaseButton + // - ToolLoopManager::releaseLoop + class ToolLoopManager { + public: + + // Simple container of mouse events information. + class Pointer + { + public: + enum Button { Left, Middle, Right }; + + Pointer(int x, int y, Button button) + : m_x(x), m_y(y), m_button(button) { } + + int getX() const { return m_x; } + int getY() const { return m_y; } + Button getButton() const { return m_button; } + + private: + int m_x, m_y; + Button m_button; + }; + + // Contructs a manager for the ToolLoop delegate. + ToolLoopManager(ToolLoop* toolLoop); + virtual ~ToolLoopManager(); + + bool isCanceled() const; + + // Should be called when the user start a tool-trace (pressing the + // left or right button for first time in the editor). + void prepareLoop(const Pointer& pointer); + + // Called when the loop is over. + void releaseLoop(const Pointer& pointer); + + // Should be called each time the user presses a mouse button. + void pressButton(const Pointer& pointer); + + // Should be called each time the user releases a mouse button. + // + // Returns true if the tool-loop should continue, or false + // if the editor should release the mouse capture. + bool releaseButton(const Pointer& pointer); + + // Should be called each time the user moves the mouse inside the editor. + void movement(const Pointer& pointer); + + private: + typedef std::vector Points; + + void doLoopStep(bool last_step); + void snapToGrid(bool flexible, gfx::Point& point); + + static void calculateDirtyArea(ToolLoop* loop, + const Points& points, + gfx::Region& dirty_area); + + static void calculateMinMax(const Points& points, + gfx::Point& minpt, + gfx::Point& maxpt); + + ToolLoop* m_toolLoop; + Points m_points; + gfx::Point m_oldPoint; + gfx::Region m_oldDirtyArea; + }; + + } // namespace tools +} // namespace app + +#endif // TOOLS_TOOL_H_INCLUDED diff --git a/src/util/col_file.h b/src/app/tools/trace_policy.h similarity index 74% rename from src/util/col_file.h rename to src/app/tools/trace_policy.h index 93916675f..4f8b4b10d 100644 --- a/src/util/col_file.h +++ b/src/app/tools/trace_policy.h @@ -16,12 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef UTIL_COL_FILE_H_INCLUDED -#define UTIL_COL_FILE_H_INCLUDED +#ifndef APP_TOOLS_TRACE_POLICY_H_INCLUDED +#define APP_TOOLS_TRACE_POLICY_H_INCLUDED -class Palette; +namespace app { + namespace tools { -Palette* load_col_file(const char* filename); -bool save_col_file(const Palette* pal, const char* filename); + enum TracePolicy { + TracePolicyAccumulate, + TracePolicyLast, + TracePolicyOverlap, + }; + + } // namespace tools +} // namespace app #endif diff --git a/src/widgets/menuitem2.cpp b/src/app/ui/app_menuitem.cpp similarity index 84% rename from src/widgets/menuitem2.cpp rename to src/app/ui/app_menuitem.cpp index b47261cf8..698f05429 100644 --- a/src/widgets/menuitem2.cpp +++ b/src/app/ui/app_menuitem.cpp @@ -16,37 +16,41 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/menuitem2.h" +#include "app/ui/app_menuitem.h" -#include "commands/command.h" -#include "commands/params.h" -#include "modules/gui.h" +#include "app/commands/command.h" +#include "app/commands/params.h" +#include "app/modules/gui.h" +#include "app/ui_context.h" #include "ui/menu.h" #include "ui/message.h" #include "ui/widget.h" -#include "ui_context.h" #include #include #include +namespace app { + using namespace ui; -MenuItem2::MenuItem2(const char* text, Command* command, Params* params) +AppMenuItem::AppMenuItem(const char* text, Command* command, Params* params) : MenuItem(text) , m_command(command) , m_params(params ? params->clone(): NULL) { } -MenuItem2::~MenuItem2() +AppMenuItem::~AppMenuItem() { delete m_params; } -bool MenuItem2::onProcessMessage(Message* msg) +bool AppMenuItem::onProcessMessage(Message* msg) { switch (msg->type()) { @@ -82,7 +86,7 @@ bool MenuItem2::onProcessMessage(Message* msg) return MenuItem::onProcessMessage(msg); } -void MenuItem2::onClick() +void AppMenuItem::onClick() { MenuItem::onClick(); @@ -95,3 +99,5 @@ void MenuItem2::onClick() context->executeCommand(m_command); } } + +} // namespace app diff --git a/src/widgets/menuitem2.h b/src/app/ui/app_menuitem.h similarity index 50% rename from src/widgets/menuitem2.h rename to src/app/ui/app_menuitem.h index 674af5e49..e2e1007ee 100644 --- a/src/widgets/menuitem2.h +++ b/src/app/ui/app_menuitem.h @@ -16,35 +16,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_MENUITEM_H_INCLUDED -#define WIDGETS_MENUITEM_H_INCLUDED +#ifndef APP_UI_APP_MENUITEM_H_INCLUDED +#define APP_UI_APP_MENUITEM_H_INCLUDED #include "ui/menu.h" -class Command; -class Params; +namespace app { + class Command; + class Params; -// A widget that represent a menu item of the application. -// -// It's like a MenuItme, but it has a extra properties: the name of -// the command to be executed when it's clicked (also that command is -// used to check the availability of the command). -class MenuItem2 : public ui::MenuItem -{ -public: - MenuItem2(const char* text, Command* command, Params* params); - ~MenuItem2(); + // A widget that represent a menu item of the application. + // + // It's like a MenuItme, but it has a extra properties: the name of + // the command to be executed when it's clicked (also that command is + // used to check the availability of the command). + class AppMenuItem : public ui::MenuItem { + public: + AppMenuItem(const char* text, Command* command, Params* params); + ~AppMenuItem(); - Command* getCommand() { return m_command; } - Params* getParams() { return m_params; } + Command* getCommand() { return m_command; } + Params* getParams() { return m_params; } -protected: - bool onProcessMessage(ui::Message* msg) OVERRIDE; - void onClick() OVERRIDE; + protected: + bool onProcessMessage(ui::Message* msg) OVERRIDE; + void onClick() OVERRIDE; -private: - Command* m_command; - Params* m_params; -}; + private: + Command* m_command; + Params* m_params; + }; + +} // namespace app #endif diff --git a/src/widgets/button_set.cpp b/src/app/ui/button_set.cpp similarity index 96% rename from src/widgets/button_set.cpp rename to src/app/ui/button_set.cpp index d288280fc..40ae5c487 100644 --- a/src/widgets/button_set.cpp +++ b/src/app/ui/button_set.cpp @@ -16,19 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include +#include "app/ui/button_set.h" #include "base/bind.h" -#include "modules/gui.h" +#include "app/modules/gui.h" #include "ui/box.h" #include "ui/button.h" #include "ui/system.h" #include "ui/theme.h" #include "ui/widget.h" -#include "widgets/button_set.h" + +namespace app { using namespace ui; @@ -146,3 +150,5 @@ void ButtonSet::onItemChange() { ItemChange(); } + +} // namespace app diff --git a/src/app/ui/button_set.h b/src/app/ui/button_set.h new file mode 100644 index 000000000..332aac96a --- /dev/null +++ b/src/app/ui/button_set.h @@ -0,0 +1,50 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_BUTTON_SET_H_INCLUDED +#define APP_UI_BUTTON_SET_H_INCLUDED + +#include "base/signal.h" +#include "ui/box.h" + +namespace app { + + class ButtonSet : public ui::Box { + class Item; + typedef std::vector Items; + + public: + ButtonSet(int w, int h, int firstSelected, ...); + + int getSelectedItem() const; + void setSelectedItem(int index); + + Signal0 ItemChange; + + protected: + void onItemChange(); + + private: + Item* findSelectedItem() const; + + Items m_items; + }; + +} // namespace app + +#endif diff --git a/src/widgets/color_bar.cpp b/src/app/ui/color_bar.cpp similarity index 94% rename from src/widgets/color_bar.cpp rename to src/app/ui/color_bar.cpp index 5eb43cbaa..f52511f5c 100644 --- a/src/widgets/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -16,24 +16,29 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include #include "app/color.h" +#include "app/ui/color_bar.h" +#include "app/ui/status_bar.h" #include "base/bind.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "ini_file.h" -#include "modules/gui.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/ini_file.h" +#include "app/modules/gui.h" #include "raster/image.h" -#include "skin/skin_theme.h" +#include "app/ui/skin/skin_theme.h" #include "ui/message.h" -#include "ui_context.h" -#include "widgets/color_bar.h" -#include "widgets/status_bar.h" +#include "app/ui_context.h" +namespace app { + +using namespace app::skin; using namespace ui; ////////////////////////////////////////////////////////////////////// @@ -233,3 +238,5 @@ void ColorBar::onColorButtonChange(const app::Color& color) if (color.getType() == app::Color::IndexType) m_paletteView.selectColor(color.getIndex()); } + +} // namespace app diff --git a/src/app/ui/color_bar.h b/src/app/ui/color_bar.h new file mode 100644 index 000000000..f54035993 --- /dev/null +++ b/src/app/ui/color_bar.h @@ -0,0 +1,87 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_COLOR_BAR_H_INCLUDED +#define APP_UI_COLOR_BAR_H_INCLUDED + +#include "app/color.h" +#include "app/ui/color_button.h" +#include "app/ui/palette_view.h" +#include "base/compiler_specific.h" +#include "base/signal.h" +#include "raster/pixel_format.h" +#include "ui/box.h" +#include "ui/button.h" +#include "ui/view.h" + +namespace app { + class PaletteView; + class ColorButton; + + class ColorBar : public ui::Box { + static ColorBar* m_instance; + public: + static ColorBar* instance() { return m_instance; } + + ColorBar(int align); + ~ColorBar(); + + void setPixelFormat(PixelFormat pixelFormat); + + app::Color getFgColor(); + app::Color getBgColor(); + void setFgColor(const app::Color& color); + void setBgColor(const app::Color& color); + + PaletteView* getPaletteView(); + + // Used by the Palette Editor command to change the status of button + // when the visibility of the dialog changes. + void setPaletteEditorButtonState(bool state); + + // Signals + Signal1 FgColorChange; + Signal1 BgColorChange; + + protected: + void onPaletteButtonClick(); + void onPaletteIndexChange(int index); + void onFgColorButtonChange(const app::Color& color); + void onBgColorButtonChange(const app::Color& color); + void onColorButtonChange(const app::Color& color); + + private: + class ScrollableView : public ui::View + { + public: + ScrollableView(); + protected: + bool onProcessMessage(ui::Message* msg) OVERRIDE; + }; + + ui::CheckBox m_paletteButton; + ScrollableView m_scrollableView; + PaletteView m_paletteView; + ColorButton m_fgColor; + ColorButton m_bgColor; + bool m_lock; + }; + +} // namespace app + +#endif diff --git a/src/widgets/color_button.cpp b/src/app/ui/color_button.cpp similarity index 94% rename from src/widgets/color_button.cpp rename to src/app/ui/color_button.cpp index 66a9e2d4a..b40250024 100644 --- a/src/widgets/color_button.cpp +++ b/src/app/ui/color_button.cpp @@ -16,25 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" -#include "modules/gfx.h" -#include "modules/gui.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/ui/color_bar.h" +#include "app/ui/color_button.h" +#include "app/ui/color_selector.h" +#include "app/ui/editor/editor.h" +#include "app/ui/skin/skin_theme.h" +#include "app/ui/status_bar.h" #include "raster/sprite.h" -#include "skin/skin_theme.h" -#include "ui/gui.h" #include "ui/preferred_size_event.h" -#include "widgets/color_bar.h" -#include "widgets/color_button.h" -#include "widgets/color_selector.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" +namespace app { + +using namespace app::skin; using namespace ui; static WidgetType colorbutton_type() @@ -272,3 +277,5 @@ void ColorButton::onWindowColorChange(const app::Color& color) { setColor(color); } + +} // namespace app diff --git a/src/app/ui/color_button.h b/src/app/ui/color_button.h new file mode 100644 index 000000000..72624f760 --- /dev/null +++ b/src/app/ui/color_button.h @@ -0,0 +1,64 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_COLOR_BUTTON_H_INCLUDED +#define APP_UI_COLOR_BUTTON_H_INCLUDED + +#include "app/color.h" +#include "base/compiler_specific.h" +#include "base/signal.h" +#include "raster/pixel_format.h" +#include "ui/button.h" + +namespace app { + class ColorSelector; + + class ColorButton : public ui::ButtonBase { + public: + ColorButton(const app::Color& color, PixelFormat pixelFormat); + ~ColorButton(); + + PixelFormat getPixelFormat() const; + void setPixelFormat(PixelFormat pixelFormat); + + app::Color getColor() const; + void setColor(const app::Color& color); + + // Signals + Signal1 Change; + + protected: + // Events + bool onProcessMessage(ui::Message* msg) OVERRIDE; + void onPreferredSize(ui::PreferredSizeEvent& ev) OVERRIDE; + void onPaint(ui::PaintEvent& ev) OVERRIDE; + void onClick(ui::Event& ev) OVERRIDE; + + private: + void openSelectorDialog(); + void closeSelectorDialog(); + void onWindowColorChange(const app::Color& color); + + app::Color m_color; + PixelFormat m_pixelFormat; + ColorSelector* m_window; + }; + +} // namespace app + +#endif diff --git a/src/widgets/color_selector.cpp b/src/app/ui/color_selector.cpp similarity index 96% rename from src/widgets/color_selector.cpp rename to src/app/ui/color_selector.cpp index 8800d018f..2afe05093 100644 --- a/src/widgets/color_selector.cpp +++ b/src/app/ui/color_selector.cpp @@ -16,24 +16,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include -#include "app.h" +#include "app/app.h" #include "app/color.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/ui/color_selector.h" +#include "app/ui/palette_view.h" #include "base/bind.h" #include "gfx/border.h" #include "gfx/size.h" -#include "modules/gfx.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/image.h" #include "raster/palette.h" -#include "ui/gui.h" -#include "widgets/color_selector.h" -#include "widgets/palette_view.h" +#include "ui/ui.h" + +namespace app { using namespace ui; @@ -223,3 +227,5 @@ void ColorSelector::selectColorType(app::Color::Type type) m_vbox.layout(); m_vbox.invalidate(); } + +} // namespace app diff --git a/src/app/ui/color_selector.h b/src/app/ui/color_selector.h new file mode 100644 index 000000000..33a181e16 --- /dev/null +++ b/src/app/ui/color_selector.h @@ -0,0 +1,89 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_COLOR_SELECTOR_H_INCLUDED +#define APP_UI_COLOR_SELECTOR_H_INCLUDED + +#include "app/color.h" +#include "app/ui/color_sliders.h" +#include "app/ui/hex_color_entry.h" +#include "app/ui/palette_view.h" +#include "app/ui/popup_window_pin.h" +#include "base/signal.h" +#include "ui/button.h" +#include "ui/grid.h" +#include "ui/label.h" +#include "ui/view.h" + +namespace app { + + class ColorSelector : public PopupWindowPin { + public: + enum SetColorOptions { + ChangeType, + DoNotChangeType + }; + + ColorSelector(); + ~ColorSelector(); + + void setColor(const app::Color& color, SetColorOptions options); + app::Color getColor() const; + + // Signals + Signal1 ColorChange; + + protected: + void onColorPaletteIndexChange(int index); + void onColorSlidersChange(ColorSlidersChangeEvent& ev); + void onColorHexEntryChange(const app::Color& color); + void onColorTypeButtonClick(ui::Event& ev); + void onPaletteChange(); + + private: + void selectColorType(app::Color::Type type); + void setColorWithSignal(const app::Color& color); + void findBestfitIndex(const app::Color& color); + + ui::Box m_vbox; + ui::Box m_topBox; + app::Color m_color; + ui::View m_colorPaletteContainer; + PaletteView m_colorPalette; + ui::RadioButton m_indexButton; + ui::RadioButton m_rgbButton; + ui::RadioButton m_hsvButton; + ui::RadioButton m_grayButton; + ui::RadioButton m_maskButton; + HexColorEntry m_hexColorEntry; + RgbSliders m_rgbSliders; + HsvSliders m_hsvSliders; + GraySlider m_graySlider; + ui::Label m_maskLabel; + Signal0::SlotType* m_onPaletteChangeSlot; + + // This variable is used to avoid updating the m_hexColorEntry text + // when the color change is generated from a + // HexColorEntry::ColorChange signal. In this way we don't override + // what the user is writting in the text field. + bool m_disableHexUpdate; + }; + +} // namespace app + +#endif diff --git a/src/widgets/color_sliders.cpp b/src/app/ui/color_sliders.cpp similarity index 96% rename from src/widgets/color_sliders.cpp rename to src/app/ui/color_sliders.cpp index 506a9bd96..e1fbcae70 100644 --- a/src/widgets/color_sliders.cpp +++ b/src/app/ui/color_sliders.cpp @@ -16,21 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include "app/color_utils.h" +#include "app/ui/color_sliders.h" #include "base/bind.h" -#include "skin/skin_slider_property.h" +#include "app/ui/skin/skin_slider_property.h" #include "ui/box.h" #include "ui/entry.h" #include "ui/graphics.h" #include "ui/label.h" #include "ui/preferred_size_event.h" #include "ui/slider.h" -#include "widgets/color_sliders.h" +namespace app { + +using namespace app::skin; using namespace gfx; using namespace ui; @@ -38,8 +43,7 @@ namespace { // This class is used as SkinSliderProperty for RGB/HSV sliders to // draw the background of them. - class ColorSliderBgPainter : public ISliderBgPainter - { + class ColorSliderBgPainter : public ISliderBgPainter { public: ColorSliderBgPainter(ColorSliders::Channel channel) : m_channel(channel) @@ -273,3 +277,5 @@ app::Color GraySlider::getColorFromSliders() { return app::Color::fromGray(getSliderValue(0)); } + +} // namespace app diff --git a/src/app/ui/color_sliders.h b/src/app/ui/color_sliders.h new file mode 100644 index 000000000..59e43018f --- /dev/null +++ b/src/app/ui/color_sliders.h @@ -0,0 +1,137 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_COLOR_SLIDERS_H_INCLUDED +#define APP_UI_COLOR_SLIDERS_H_INCLUDED + +#include "app/color.h" +#include "base/compiler_specific.h" +#include "base/signal.h" +#include "ui/event.h" +#include "ui/grid.h" +#include "ui/widget.h" + +#include + +namespace ui { + class Label; + class Slider; + class Entry; +} + +namespace app { + + class ColorSlidersChangeEvent; + + class ColorSliders : public ui::Widget { + public: + enum Channel { Red, Green, Blue, + Hue, Saturation, Value, + Gray }; + + ColorSliders(); + ~ColorSliders(); + + void setColor(const app::Color& color); + + // Signals + Signal1 ColorChange; + + protected: + void onPreferredSize(ui::PreferredSizeEvent& ev); + + // For derived classes + void addSlider(Channel channel, const char* labelText, int min, int max); + void setSliderValue(int sliderIndex, int value); + int getSliderValue(int sliderIndex) const; + + virtual void onSetColor(const app::Color& color) = 0; + virtual app::Color getColorFromSliders() = 0; + + private: + void onSliderChange(int i); + void onEntryChange(int i); + void onControlChange(int i); + + void updateEntryText(int entryIndex); + void updateSlidersBgColor(const app::Color& color); + void updateSliderBgColor(ui::Slider* slider, const app::Color& color); + + std::vector m_label; + std::vector m_slider; + std::vector m_entry; + std::vector m_channel; + ui::Grid m_grid; + }; + + ////////////////////////////////////////////////////////////////////// + // Derived-classes + + class RgbSliders : public ColorSliders + { + public: + RgbSliders(); + + private: + virtual void onSetColor(const app::Color& color) OVERRIDE; + virtual app::Color getColorFromSliders() OVERRIDE; + }; + + class HsvSliders : public ColorSliders + { + public: + HsvSliders(); + + private: + virtual void onSetColor(const app::Color& color) OVERRIDE; + virtual app::Color getColorFromSliders() OVERRIDE; + }; + + class GraySlider : public ColorSliders + { + public: + GraySlider(); + + private: + virtual void onSetColor(const app::Color& color) OVERRIDE; + virtual app::Color getColorFromSliders() OVERRIDE; + }; + + ////////////////////////////////////////////////////////////////////// + // Events + + class ColorSlidersChangeEvent : public ui::Event + { + public: + ColorSlidersChangeEvent(const app::Color& color, ColorSliders::Channel channel, ui::Component* source) + : Event(source) + , m_color(color) + , m_channel(channel) { } + + app::Color getColor() const { return m_color; } + + ColorSliders::Channel getModifiedChannel() const { return m_channel; } + + private: + app::Color m_color; + ColorSliders::Channel m_channel; + }; + +} // namespace app + +#endif diff --git a/src/widgets/context_bar.cpp b/src/app/ui/context_bar.cpp similarity index 96% rename from src/widgets/context_bar.cpp rename to src/app/ui/context_bar.cpp index f70a1889e..7ee005d65 100644 --- a/src/widgets/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -16,19 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" +#include "app/modules/gui.h" +#include "app/settings/ink_type.h" +#include "app/settings/settings.h" +#include "app/tools/ink.h" +#include "app/tools/point_shape.h" +#include "app/tools/tool.h" +#include "app/ui/button_set.h" +#include "app/ui/context_bar.h" +#include "app/ui/skin/skin_theme.h" +#include "app/ui_context.h" #include "base/unique_ptr.h" -#include "modules/gui.h" #include "raster/image.h" #include "raster/pen.h" -#include "settings/ink_type.h" -#include "settings/settings.h" -#include "skin/skin_theme.h" -#include "tools/ink.h" -#include "tools/point_shape.h" -#include "tools/tool.h" #include "ui/button.h" #include "ui/combobox.h" #include "ui/int_entry.h" @@ -37,12 +42,12 @@ #include "ui/preferred_size_event.h" #include "ui/theme.h" #include "ui/tooltips.h" -#include "ui_context.h" -#include "widgets/button_set.h" -#include "widgets/context_bar.h" #include +namespace app { + +using namespace app::skin; using namespace gfx; using namespace ui; using namespace tools; @@ -69,7 +74,7 @@ public: } void setPenSettings(IPenSettings* penSettings) { - UniquePtr pen(new Pen(m_penType = penSettings->getType(), + base::UniquePtr pen(new Pen(m_penType = penSettings->getType(), std::min(10, penSettings->getSize()), penSettings->getAngle())); Image* image = pen->get_image(); @@ -454,3 +459,5 @@ void ContextBar::onCurrentToolChange() layout(); } + +} // namespace app diff --git a/src/app/ui/context_bar.h b/src/app/ui/context_bar.h new file mode 100644 index 000000000..f9ff8af86 --- /dev/null +++ b/src/app/ui/context_bar.h @@ -0,0 +1,71 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_CONTEXT_BAR_H_INCLUDED +#define APP_UI_CONTEXT_BAR_H_INCLUDED + +#include "base/compiler_specific.h" +#include "ui/box.h" + +namespace ui { + class Box; + class Label; +} + +namespace app { + + class ContextBar : public ui::Box { + public: + ContextBar(); + ~ContextBar(); + + protected: + bool onProcessMessage(ui::Message* msg) OVERRIDE; + + private: + void onPenSizeChange(); + void onPenAngleChange(); + void onCurrentToolChange(); + + class BrushTypeField; + class BrushAngleField; + class BrushSizeField; + class ToleranceField; + class InkTypeField; + class InkOpacityField; + class SprayWidthField; + class SpraySpeedField; + + ui::Label* m_brushLabel; + BrushTypeField* m_brushType; + BrushAngleField* m_brushAngle; + BrushSizeField* m_brushSize; + ui::Label* m_toleranceLabel; + ToleranceField* m_tolerance; + ui::Label* m_inkLabel; + InkTypeField* m_inkType; + ui::Label* m_opacityLabel; + InkOpacityField* m_inkOpacity; + ui::Box* m_sprayBox; + SprayWidthField* m_sprayWidth; + SpraySpeedField* m_spraySpeed; + }; + +} // namespace app + +#endif diff --git a/src/widgets/document_view.cpp b/src/app/ui/document_view.cpp similarity index 93% rename from src/widgets/document_view.cpp rename to src/app/ui/document_view.cpp index e64bf0d0c..a219ddb88 100644 --- a/src/widgets/document_view.cpp +++ b/src/app/ui/document_view.cpp @@ -16,29 +16,32 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/document_view.h" +#include "app/ui/document_view.h" -#include "app.h" +#include "app/app.h" +#include "app/ui/editor/editor.h" +#include "app/ui/editor/editor_customization_delegate.h" +#include "app/ui/editor/editor_view.h" +#include "app/ui/main_window.h" +#include "app/ui/mini_editor.h" +#include "app/ui/workspace.h" #include "base/path.h" -#include "document_event.h" -#include "modules/editors.h" -#include "modules/gui.h" +#include "app/document_event.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" #include "raster/layer.h" #include "raster/sprite.h" #include "ui/accelerator.h" #include "ui/message.h" #include "ui/view.h" -#include "widgets/editor/editor.h" -#include "widgets/editor/editor_customization_delegate.h" -#include "widgets/editor/editor_view.h" -#include "widgets/main_window.h" -#include "widgets/mini_editor.h" -#include "widgets/workspace.h" + +namespace app { using namespace ui; -using namespace widgets; class AppEditor : public Editor, public EditorObserver, @@ -263,3 +266,5 @@ void DocumentView::onTotalFramesChanged(DocumentEvent& ev) m_editor->setFrame(m_editor->getSprite()->getLastFrame()); } } + +} // namespace app diff --git a/src/widgets/document_view.h b/src/app/ui/document_view.h similarity index 86% rename from src/widgets/document_view.h rename to src/app/ui/document_view.h index 80a4eeea6..5aae7efad 100644 --- a/src/widgets/document_view.h +++ b/src/app/ui/document_view.h @@ -16,28 +16,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_DOCUMENT_VIEW_H_INCLUDED -#define WIDGETS_DOCUMENT_VIEW_H_INCLUDED +#ifndef APP_UI_DOCUMENT_VIEW_H_INCLUDED +#define APP_UI_DOCUMENT_VIEW_H_INCLUDED +#include "app/document_observer.h" +#include "app/ui/tabs.h" +#include "app/ui/workspace_view.h" #include "base/compiler_specific.h" -#include "document_observer.h" #include "ui/box.h" -#include "widgets/tabs.h" -#include "widgets/workspace_view.h" -class Document; -class DocumentLocation; -class Editor; +namespace ui { + class View; +} -namespace ui { class View; } - -namespace widgets { +namespace app { + class Document; + class DocumentLocation; + class Editor; class DocumentView : public ui::Box , public TabView , public DocumentObserver - , public WorkspaceView - { + , public WorkspaceView { public: enum Type { Normal, @@ -78,6 +78,6 @@ namespace widgets { Editor* m_editor; }; -} // namespace widgets +} // namespace app #endif diff --git a/src/widgets/drop_down_button.cpp b/src/app/ui/drop_down_button.cpp similarity index 86% rename from src/widgets/drop_down_button.cpp rename to src/app/ui/drop_down_button.cpp index 613d7ff66..4f1c97fae 100644 --- a/src/widgets/drop_down_button.cpp +++ b/src/app/ui/drop_down_button.cpp @@ -16,16 +16,21 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/drop_down_button.h" +#include "app/ui/drop_down_button.h" -#include "modules/gui.h" -#include "skin/button_icon_impl.h" -#include "skin/skin_property.h" -#include "skin/skin_theme.h" +#include "app/modules/gui.h" +#include "app/ui/skin/button_icon_impl.h" +#include "app/ui/skin/skin_property.h" +#include "app/ui/skin/skin_theme.h" #include "ui/theme.h" +namespace app { + +using namespace app::skin; using namespace ui; DropDownButton::DropDownButton(const char* text) @@ -62,3 +67,5 @@ void DropDownButton::onDropDownButtonClick(Event& ev) { DropDownClick(); } + +} // namespace app diff --git a/src/widgets/drop_down_button.h b/src/app/ui/drop_down_button.h similarity index 66% rename from src/widgets/drop_down_button.h rename to src/app/ui/drop_down_button.h index ce1724383..d9d45c456 100644 --- a/src/widgets/drop_down_button.h +++ b/src/app/ui/drop_down_button.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_DROP_DOWN_BUTTON_H_INCLUDED -#define WIDGETS_DROP_DOWN_BUTTON_H_INCLUDED +#ifndef APP_UI_DROP_DOWN_BUTTON_H_INCLUDED +#define APP_UI_DROP_DOWN_BUTTON_H_INCLUDED #include "base/signal.h" #include "ui/box.h" @@ -27,21 +27,24 @@ namespace ui { class Event; } -class DropDownButton : public ui::HBox -{ -public: - DropDownButton(const char* text); +namespace app { - Signal0 Click; - Signal0 DropDownClick; + class DropDownButton : public ui::HBox { + public: + DropDownButton(const char* text); -protected: - void onButtonClick(ui::Event& ev); - void onDropDownButtonClick(ui::Event& ev); + Signal0 Click; + Signal0 DropDownClick; -private: - ui::Button* m_button; - ui::Button* m_dropDown; -}; + protected: + void onButtonClick(ui::Event& ev); + void onDropDownButtonClick(ui::Event& ev); + + private: + ui::Button* m_button; + ui::Button* m_dropDown; + }; + +} // namespace app #endif diff --git a/src/widgets/editor/cursor.cpp b/src/app/ui/editor/cursor.cpp similarity index 98% rename from src/widgets/editor/cursor.cpp rename to src/app/ui/editor/cursor.cpp index dea6ba69d..70d80386a 100644 --- a/src/widgets/editor/cursor.cpp +++ b/src/app/ui/editor/cursor.cpp @@ -16,27 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/settings/settings.h" +#include "app/tools/ink.h" +#include "app/tools/tool.h" +#include "app/ui/editor/editor.h" +#include "app/ui_context.h" +#include "app/util/boundary.h" #include "base/memory.h" -#include "ini_file.h" -#include "modules/editors.h" #include "raster/image.h" #include "raster/layer.h" #include "raster/pen.h" #include "raster/sprite.h" -#include "tools/ink.h" -#include "tools/tool.h" #include "ui/base.h" #include "ui/rect.h" #include "ui/system.h" #include "ui/widget.h" -#include "ui_context.h" -#include "util/boundary.h" -#include "widgets/editor/editor.h" #include #include @@ -46,6 +49,8 @@ #undef min #endif +namespace app { + using namespace ui; /**********************************************************************/ @@ -674,3 +679,5 @@ static int get_pen_color(Sprite* sprite, Layer* layer) else return color_utils::color_for_image(c, sprite->getPixelFormat()); } + +} // namespace app diff --git a/src/widgets/editor/drawing_state.cpp b/src/app/ui/editor/drawing_state.cpp similarity index 94% rename from src/widgets/editor/drawing_state.cpp rename to src/app/ui/editor/drawing_state.cpp index b63b0b4eb..e07d0211c 100644 --- a/src/widgets/editor/drawing_state.cpp +++ b/src/app/ui/editor/drawing_state.cpp @@ -16,20 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/drawing_state.h" +#include "app/ui/editor/drawing_state.h" -#include "tools/ink.h" -#include "tools/tool.h" -#include "tools/tool_loop.h" -#include "tools/tool_loop_manager.h" +#include "app/tools/ink.h" +#include "app/tools/tool.h" +#include "app/tools/tool_loop.h" +#include "app/tools/tool_loop_manager.h" +#include "app/ui/editor/editor.h" #include "ui/message.h" #include "ui/system.h" -#include "widgets/editor/editor.h" #include +namespace app { + using namespace ui; static tools::ToolLoopManager::Pointer::Button button_from_msg(MouseMessage* msg) @@ -174,3 +178,5 @@ void DrawingState::destroyLoop() m_toolLoopManager = NULL; m_toolLoop = NULL; } + +} // namespace app diff --git a/src/app/ui/editor/drawing_state.h b/src/app/ui/editor/drawing_state.h new file mode 100644 index 000000000..8b7ac0555 --- /dev/null +++ b/src/app/ui/editor/drawing_state.h @@ -0,0 +1,59 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_DRAWING_STATE_H_INCLUDED +#define APP_UI_EDITOR_DRAWING_STATE_H_INCLUDED + +#include "app/ui/editor/standby_state.h" +#include "base/compiler_specific.h" + +namespace app { + namespace tools { + class ToolLoop; + class ToolLoopManager; + } + + class DrawingState : public StandbyState { + public: + DrawingState(tools::ToolLoop* loop, Editor* editor, ui::MouseMessage* msg); + virtual ~DrawingState(); + virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onSetCursor(Editor* editor) OVERRIDE; + virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE; + + // Drawing state doesn't require the pen-preview because we are + // already drawing (viewing the real trace). + virtual bool requirePenPreview() OVERRIDE { return false; } + + private: + void destroyLoop(); + + // The tool-loop. + tools::ToolLoop* m_toolLoop; + + // Tool-loop manager + tools::ToolLoopManager* m_toolLoopManager; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_DRAWING_STATE_H_INCLUDED diff --git a/src/widgets/editor/editor.cpp b/src/app/ui/editor/editor.cpp similarity index 96% rename from src/widgets/editor/editor.cpp rename to src/app/ui/editor/editor.cpp index 61e66e3c1..b563b7324 100644 --- a/src/widgets/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -18,51 +18,55 @@ // #define DRAWSPRITE_DOUBLEBUFFERED +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/editor.h" +#include "app/ui/editor/editor.h" -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/document_location.h" +#include "app/ini_file.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/modules/palettes.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/tools/ink.h" +#include "app/tools/tool.h" +#include "app/tools/tool_box.h" +#include "app/ui/color_bar.h" +#include "app/ui/editor/editor_customization_delegate.h" +#include "app/ui/editor/editor_decorator.h" +#include "app/ui/editor/moving_pixels_state.h" +#include "app/ui/editor/pixels_movement.h" +#include "app/ui/editor/standby_state.h" +#include "app/ui/skin/skin_theme.h" +#include "app/ui/status_bar.h" +#include "app/ui/toolbar.h" +#include "app/ui_context.h" +#include "app/util/boundary.h" +#include "app/util/misc.h" +#include "app/util/render.h" #include "base/bind.h" #include "base/unique_ptr.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "document_location.h" -#include "ini_file.h" -#include "modules/gfx.h" -#include "modules/gui.h" -#include "modules/palettes.h" #include "raster/raster.h" -#include "settings/document_settings.h" -#include "settings/settings.h" -#include "skin/skin_theme.h" -#include "tools/ink.h" -#include "tools/tool.h" -#include "tools/tool_box.h" -#include "ui/gui.h" -#include "ui_context.h" -#include "util/boundary.h" -#include "util/misc.h" -#include "util/render.h" -#include "widgets/color_bar.h" -#include "widgets/editor/editor_customization_delegate.h" -#include "widgets/editor/editor_decorator.h" -#include "widgets/editor/moving_pixels_state.h" -#include "widgets/editor/pixels_movement.h" -#include "widgets/editor/standby_state.h" -#include "widgets/status_bar.h" -#include "widgets/toolbar.h" +#include "ui/ui.h" #include #include +namespace app { + +using namespace app::skin; using namespace gfx; using namespace ui; -class EditorPreRenderImpl : public EditorPreRender -{ +class EditorPreRenderImpl : public EditorPreRender { public: EditorPreRenderImpl(Editor* editor, Image* image, const Point& offset, int zoom) : m_editor(editor) @@ -98,8 +102,7 @@ private: int m_zoom; }; -class EditorPostRenderImpl : public EditorPostRender -{ +class EditorPostRenderImpl : public EditorPostRender { public: EditorPostRenderImpl(Editor* editor) : m_editor(editor) @@ -405,7 +408,7 @@ void Editor::drawSpriteUnclippedRect(const gfx::Rect& rc) RenderEngine renderEngine(m_document, m_sprite, m_layer, m_frame); // Generate the rendered image - UniquePtr rendered + base::UniquePtr rendered (renderEngine.renderSprite(source_x, source_y, width, height, m_frame, m_zoom, true)); @@ -504,7 +507,7 @@ void Editor::drawMask() y = vp.y - scroll.y + m_offset_y; int nseg = m_document->getBoundariesSegmentsCount(); - const _BoundSeg* seg = m_document->getBoundariesSegments(); + const BoundSeg* seg = m_document->getBoundariesSegments(); for (c=0; cx1<* m_currentToolChangeSlot; + + Slot1* m_fgColorChangeSlot; + + EditorObservers m_observers; + + EditorCustomizationDelegate* m_customizationDelegate; + + // TODO This field shouldn't be here. It should be removed when + // editors.cpp are finally replaced with a fully funtional Workspace + // widget. + DocumentView* m_docView; + }; + + ui::WidgetType editor_type(); + +} // namespace app + +#endif diff --git a/src/app/ui/editor/editor_customization_delegate.h b/src/app/ui/editor/editor_customization_delegate.h new file mode 100644 index 000000000..b912cc053 --- /dev/null +++ b/src/app/ui/editor/editor_customization_delegate.h @@ -0,0 +1,62 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_CUSTOMIZATION_DELEGATE_H_INCLUDED +#define APP_UI_EDITOR_CUSTOMIZATION_DELEGATE_H_INCLUDED + +namespace tools { + class Tool; +} + +namespace app { + class Editor; + + class EditorCustomizationDelegate { + public: + virtual ~EditorCustomizationDelegate() { } + virtual void dispose() = 0; + + // Called to know if the user is pressing a keyboard shortcut to + // select another tool temporarily (a "quick tool"). The given + // "currentTool" is the current tool selected in the toolbox. + virtual tools::Tool* getQuickTool(tools::Tool* currentTool) = 0; + + // Returns true if the user wants to copy the selection instead of + // to move it. + virtual bool isCopySelectionKeyPressed() = 0; + + // Returns true if the user wants to snap to grid when he's moving + // the selection. + virtual bool isSnapToGridKeyPressed() = 0; + + // Returns true if the user wants to activate angle snap, so he can + // easily specify common angles (45, 90, 135, 180, etc.). + virtual bool isAngleSnapKeyPressed() = 0; + + // Returns true if the user wants to maintain the aspect ratio when + // he is scaling the selection. + virtual bool isMaintainAspectRatioKeyPressed() = 0; + + // Returns true if the user wants to lock the X or Y axis when he is + // dragging the selection. + virtual bool isLockAxisKeyPressed() = 0; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_CUSTOMIZATION_DELEGATE_H_INCLUDED diff --git a/src/app/ui/editor/editor_decorator.h b/src/app/ui/editor/editor_decorator.h new file mode 100644 index 000000000..a885eebdd --- /dev/null +++ b/src/app/ui/editor/editor_decorator.h @@ -0,0 +1,64 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_EDITOR_DECORATOR_H_INCLUDED +#define APP_UI_EDITOR_EDITOR_DECORATOR_H_INCLUDED + +#include "gfx/rect.h" + +namespace raster { + class Image; +} + +namespace app { + class Editor; + class EditorDecorator; + + using namespace raster; + + // EditorPreRender and EditorPostRender are two interfaces used to + // draw elements in the editor's area. They are implemented by the + // editor and used by a EditorDecorator. + class EditorPreRender { + public: + virtual ~EditorPreRender() { } + virtual Editor* getEditor() = 0; + virtual Image* getImage() = 0; + virtual void fillRect(const gfx::Rect& rect, uint32_t rgbaColor, int opacity) = 0; + }; + + class EditorPostRender { + public: + virtual ~EditorPostRender() { } + virtual Editor* getEditor() = 0; + virtual void drawLine(int x1, int y1, int x2, int y2, int screenColor) = 0; + }; + + // Used by editor's states to pre- and post-render customized + // decorations depending of the state (e.g. SelectBoxState draws the + // selected bounds/canvas area). + class EditorDecorator { + public: + virtual ~EditorDecorator() { } + virtual void preRenderDecorator(EditorPreRender* render) = 0; + virtual void postRenderDecorator(EditorPostRender* render) = 0; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_EDITOR_DECORATOR_H_INCLUDED diff --git a/src/app/ui/editor/editor_observer.h b/src/app/ui/editor/editor_observer.h new file mode 100644 index 000000000..7cf0596bd --- /dev/null +++ b/src/app/ui/editor/editor_observer.h @@ -0,0 +1,43 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_OBSERVER_H_INCLUDED +#define APP_UI_EDITOR_OBSERVER_H_INCLUDED + +namespace app { + + class Editor; + + class EditorObserver { + public: + virtual ~EditorObserver() { } + virtual void dispose() = 0; + + // Called when the editor's state changes. + virtual void onStateChanged(Editor* editor) = 0; + + // Called when the scroll or zoom of the editor changes. + virtual void onScrollChanged(Editor* editor) = 0; + + // Called when the current frame of the editor changes. + virtual void onFrameChanged(Editor* editor) = 0; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_OBSERVER_H_INCLUDED diff --git a/src/widgets/editor/editor_observers.cpp b/src/app/ui/editor/editor_observers.cpp similarity index 90% rename from src/widgets/editor/editor_observers.cpp rename to src/app/ui/editor/editor_observers.cpp index 6e73c7587..22a037d2b 100644 --- a/src/widgets/editor/editor_observers.cpp +++ b/src/app/ui/editor/editor_observers.cpp @@ -16,13 +16,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/editor_observers.h" +#include "app/ui/editor/editor_observers.h" +#include "app/ui/editor/editor_observer.h" #include "base/bind.h" -#include "widgets/editor/editor_observer.h" +namespace app { + EditorObservers::EditorObservers() { } @@ -51,3 +55,5 @@ void EditorObservers::notifyFrameChanged(Editor* editor) { m_observers.notifyObservers(&EditorObserver::onFrameChanged, editor); } + +} // namespace app diff --git a/src/undoers/add_image.h b/src/app/ui/editor/editor_observers.h similarity index 56% rename from src/undoers/add_image.h rename to src/app/ui/editor/editor_observers.h index 1206ea5fd..935cdc854 100644 --- a/src/undoers/add_image.h +++ b/src/app/ui/editor/editor_observers.h @@ -16,30 +16,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef UNDOERS_ADD_IMAGE_H_INCLUDED -#define UNDOERS_ADD_IMAGE_H_INCLUDED +#ifndef APP_UI_EDITOR_OBSERVERS_H_INCLUDED +#define APP_UI_EDITOR_OBSERVERS_H_INCLUDED -#include "undo/object_id.h" -#include "undoers/undoer_base.h" +#include "app/ui/editor/editor_observer.h" +#include "base/observers.h" -class Stock; +namespace app { + class Editor; -namespace undoers { + class EditorObservers { + public: + EditorObservers(); -class AddImage : public UndoerBase -{ -public: - AddImage(undo::ObjectsContainer* objects, Stock* stock, int imageIndex); + void addObserver(EditorObserver* observer); + void removeObserver(EditorObserver* observer); - void dispose() OVERRIDE; - size_t getMemSize() const OVERRIDE { return sizeof(*this); } - void revert(undo::ObjectsContainer* objects, undo::UndoersCollector* redoers) OVERRIDE; + void notifyStateChanged(Editor* editor); + void notifyScrollChanged(Editor* editor); + void notifyFrameChanged(Editor* editor); -private: - undo::ObjectId m_stockId; - uint32_t m_imageIndex; -}; + private: + base::Observers m_observers; + }; -} // namespace undoers +} // namespace app -#endif // UNDOERS_ADD_IMAGE_H_INCLUDED +#endif // APP_UI_EDITOR_OBSERVERS_H_INCLUDED diff --git a/src/app/ui/editor/editor_state.h b/src/app/ui/editor/editor_state.h new file mode 100644 index 000000000..f35790601 --- /dev/null +++ b/src/app/ui/editor/editor_state.h @@ -0,0 +1,113 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_EDITOR_STATE_H_INCLUDED +#define APP_UI_EDITOR_EDITOR_STATE_H_INCLUDED + +#include "base/disable_copying.h" +#include "base/shared_ptr.h" + +namespace ui { + class MouseMessage; + class KeyMessage; +} + +namespace app { + class Editor; + class EditorDecorator; + + // Represents one state of the sprite's editor (Editor class). This + // is a base class, a dummy state that ignores all events from the + // Editor. Subclasses overrides these methods to customize the + // behavior of the Editor to do different tasks (e.g. scrolling, + // drawing in the active sprite, etc.). + class EditorState { + public: + enum BeforeChangeAction { + DiscardState, + KeepState + }; + + EditorState() { } + virtual ~EditorState() { } + + // Returns true if this state is a "temporal" state. It means that + // this state doesn't go to other state than the previous one. + virtual bool isTemporalState() const { return false; } + + // Called just before this state is replaced by a new state in the + // Editor::setState() method. Returns true if this state should be + // kept in the EditorStatesHistory. + virtual BeforeChangeAction onBeforeChangeState(Editor* editor, EditorState* newState) { + return KeepState; + } + + // Called when this instance is set as the new Editor's state when + // Editor::setState() method is used. + virtual void onAfterChangeState(Editor* editor) { } + + // Called just before the state will be removed from the + // EditorStatesHistory. This event is useful to remove the + // decorator from the editor. + virtual void onBeforePopState(Editor* editor) { } + + // Called when the current tool in the tool bar changes. It is + // useful for states which depends on the selected current tool (as + // MovingPixelsState which drops the pixels in case the user selects + // other drawing tool). + virtual void onCurrentToolChange(Editor* editor) { } + + // Called when the user presses a mouse button over the editor. + virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) { return false; } + + // Called when the user releases a mouse button. + virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) { return false; } + + // Called when the user moves the mouse over the editor. + virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) { return false; } + + // Called when the user moves the mouse wheel over the editor. + virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) { return false; } + + // Called each time the mouse changes its position so we can set an + // appropiated cursor depending on the new coordinates of the mouse + // pointer. + virtual bool onSetCursor(Editor* editor) { return false; } + + // Called when a key is pressed over the current editor. + virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) { return false; } + + // Called when a key is released. + virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) { return false; } + + // Called when a key is released. + virtual bool onUpdateStatusBar(Editor* editor) { return false; } + + // Returns true if the this state requires the pen-preview as + // drawing cursor. + virtual bool requirePenPreview() { return false; } + + private: + DISABLE_COPYING(EditorState); + }; + + typedef SharedPtr EditorStatePtr; + +} // namespace app + +#endif // APP_UI_EDITOR_EDITOR_STATE_H_INCLUDED diff --git a/src/widgets/editor/editor_states_history.cpp b/src/app/ui/editor/editor_states_history.cpp similarity index 93% rename from src/widgets/editor/editor_states_history.cpp rename to src/app/ui/editor/editor_states_history.cpp index 3bc0187f1..c1c9bc374 100644 --- a/src/widgets/editor/editor_states_history.cpp +++ b/src/app/ui/editor/editor_states_history.cpp @@ -16,9 +16,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/editor_states_history.h" +#include "app/ui/editor/editor_states_history.h" + +namespace app { EditorStatesHistory::EditorStatesHistory() { @@ -56,3 +60,5 @@ void EditorStatesHistory::clear() m_states.clear(); } + +} // namespace app diff --git a/src/app/ui/editor/editor_states_history.h b/src/app/ui/editor/editor_states_history.h new file mode 100644 index 000000000..63fce9689 --- /dev/null +++ b/src/app/ui/editor/editor_states_history.h @@ -0,0 +1,55 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_STATES_HISTORY_H_INCLUDED +#define APP_UI_EDITOR_STATES_HISTORY_H_INCLUDED + +#include "app/ui/editor/editor_state.h" + +#include + +namespace app { + + // Stack of states in the editor. The top state is the current state + // of the editor. + class EditorStatesHistory { + public: + EditorStatesHistory(); + ~EditorStatesHistory(); + + // Gets the current state. + EditorStatePtr top(); + + // Adds a new state in the history. + void push(const EditorStatePtr& state); + + // Removes a state from the history (you should keep a reference of + // the state with top() if you want to keep it in memory). + void pop(); + + // Deletes all the history. + void clear(); + + private: + // Stack of states (the back of the vector is the top of the stack). + std::vector m_states; + }; + +} // namespace app + +#endif diff --git a/src/widgets/editor/editor_view.cpp b/src/app/ui/editor/editor_view.cpp similarity index 91% rename from src/widgets/editor/editor_view.cpp rename to src/app/ui/editor/editor_view.cpp index 4f0cd3012..1d4a8327c 100644 --- a/src/widgets/editor/editor_view.cpp +++ b/src/app/ui/editor/editor_view.cpp @@ -16,18 +16,23 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/editor_view.h" +#include "app/ui/editor/editor_view.h" -#include "modules/editors.h" -#include "skin/skin_theme.h" +#include "app/ui/editor/editor.h" +#include "app/modules/editors.h" +#include "app/ui/skin/skin_theme.h" #include "ui/message.h" #include "ui/resize_event.h" -#include "widgets/editor/editor.h" #include +namespace app { + +using namespace app::skin; using namespace ui; EditorView::EditorView(EditorView::Type type) @@ -88,3 +93,5 @@ void EditorView::onResize(ResizeEvent& ev) setBoundsQuietly(ev.getBounds()); updateView(); } + +} // namespace app diff --git a/src/widgets/editor/editor_view.h b/src/app/ui/editor/editor_view.h similarity index 64% rename from src/widgets/editor/editor_view.h rename to src/app/ui/editor/editor_view.h index 6001a4033..15cbe15a4 100644 --- a/src/widgets/editor/editor_view.h +++ b/src/app/ui/editor/editor_view.h @@ -16,24 +16,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_EDITOR_VIEW_H_INCLUDED -#define WIDGETS_EDITOR_VIEW_H_INCLUDED +#ifndef APP_UI_EDITOR_VIEW_H_INCLUDED +#define APP_UI_EDITOR_VIEW_H_INCLUDED #include "ui/view.h" -class EditorView : public ui::View -{ -public: - enum Type { CurrentEditorMode, AlwaysSelected }; +namespace app { - EditorView(Type type); + class EditorView : public ui::View { + public: + enum Type { CurrentEditorMode, AlwaysSelected }; -protected: - bool onProcessMessage(ui::Message* msg) OVERRIDE; - void onResize(ui::ResizeEvent& ev) OVERRIDE; + EditorView(Type type); -private: - Type m_type; -}; + protected: + bool onProcessMessage(ui::Message* msg) OVERRIDE; + void onResize(ui::ResizeEvent& ev) OVERRIDE; -#endif // WIDGETS_EDITOR_VIEW_H_INCLUDED + private: + Type m_type; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_VIEW_H_INCLUDED diff --git a/src/app/ui/editor/handle_type.h b/src/app/ui/editor/handle_type.h new file mode 100644 index 000000000..8555eb9af --- /dev/null +++ b/src/app/ui/editor/handle_type.h @@ -0,0 +1,45 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_HANDLE_TYPE_H_INCLUDED +#define APP_UI_EDITOR_HANDLE_TYPE_H_INCLUDED + +namespace app { + + // Handles available to transform a region of pixels in the editor. + enum HandleType { + // No handle selected + NoHandle, + // This is the handle to move the pixels region, generally, the + // whole region activates this handle. + MoveHandle, + // One of the region's corders to scale. + ScaleNWHandle, ScaleNHandle, ScaleNEHandle, + ScaleWHandle, ScaleEHandle, + ScaleSWHandle, ScaleSHandle, ScaleSEHandle, + // One of the region's corders to rotate. + RotateNWHandle, RotateNHandle, RotateNEHandle, + RotateWHandle, RotateEHandle, + RotateSWHandle, RotateSHandle, RotateSEHandle, + // Handle used to move the pivot + PivotHandle, + }; + +} // namespace app + +#endif diff --git a/src/widgets/editor/keys.cpp b/src/app/ui/editor/keys.cpp similarity index 87% rename from src/widgets/editor/keys.cpp rename to src/app/ui/editor/keys.cpp index 6a375a3f3..265a1375c 100644 --- a/src/widgets/editor/keys.cpp +++ b/src/app/ui/editor/keys.cpp @@ -16,24 +16,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include -#include "app.h" +#include "app/app.h" #include "app/color.h" -#include "modules/gui.h" +#include "app/ui/color_bar.h" +#include "app/ui/editor/editor.h" +#include "app/modules/gui.h" #include "raster/image.h" #include "raster/sprite.h" -#include "settings/settings.h" +#include "app/settings/settings.h" #include "ui/message.h" #include "ui/rect.h" #include "ui/system.h" #include "ui/view.h" #include "ui/widget.h" -#include "ui_context.h" -#include "widgets/color_bar.h" -#include "widgets/editor/editor.h" +#include "app/ui_context.h" + +namespace app { using namespace ui; @@ -66,3 +70,5 @@ bool Editor::processKeysToSetZoom(KeyMessage* msg) return false; } + +} // namespace app diff --git a/src/widgets/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp similarity index 92% rename from src/widgets/editor/moving_cel_state.cpp rename to src/app/ui/editor/moving_cel_state.cpp index cb4a20803..80b48e57d 100644 --- a/src/widgets/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -16,22 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/moving_cel_state.h" +#include "app/ui/editor/moving_cel_state.h" -#include "app.h" -#include "context_access.h" -#include "document_api.h" +#include "app/app.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" +#include "app/context_access.h" +#include "app/document_api.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/mask.h" #include "raster/sprite.h" #include "ui/message.h" -#include "ui_context.h" -#include "undo_transaction.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" +#include "app/ui_context.h" +#include "app/undo_transaction.h" + +namespace app { using namespace ui; @@ -142,3 +146,5 @@ bool MovingCelState::onUpdateStatusBar(Editor* editor) return true; } + +} // namespace app diff --git a/src/app/ui/editor/moving_cel_state.h b/src/app/ui/editor/moving_cel_state.h new file mode 100644 index 000000000..60d8e53ea --- /dev/null +++ b/src/app/ui/editor/moving_cel_state.h @@ -0,0 +1,55 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_MOVING_CEL_STATE_H_INCLUDED +#define APP_UI_EDITOR_MOVING_CEL_STATE_H_INCLUDED + +#include "app/ui/editor/standby_state.h" +#include "base/compiler_specific.h" + +namespace raster { + class Cel; +} + +namespace app { + class Editor; + + class MovingCelState : public StandbyState { + public: + MovingCelState(Editor* editor, ui::MouseMessage* msg); + virtual ~MovingCelState(); + + virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE; + + private: + Cel* m_cel; + int m_celStartX; + int m_celStartY; + int m_mouseStartX; + int m_mouseStartY; + int m_celNewX; + int m_celNewY; + bool m_canceled; + bool m_maskVisible; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_MOVING_CEL_STATE_H_INCLUDED diff --git a/src/widgets/editor/moving_pixels_state.cpp b/src/app/ui/editor/moving_pixels_state.cpp similarity index 93% rename from src/widgets/editor/moving_pixels_state.cpp rename to src/app/ui/editor/moving_pixels_state.cpp index 54e873131..0f9beb769 100644 --- a/src/widgets/editor/moving_pixels_state.cpp +++ b/src/app/ui/editor/moving_pixels_state.cpp @@ -16,38 +16,42 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/moving_pixels_state.h" +#include "app/ui/editor/moving_pixels_state.h" -#include "app.h" +#include "app/app.h" #include "app/color_utils.h" +#include "app/commands/cmd_flip.h" +#include "app/commands/command.h" +#include "app/commands/commands.h" +#include "app/modules/gui.h" +#include "app/tools/ink.h" +#include "app/tools/tool.h" +#include "app/ui/editor/editor.h" +#include "app/ui/editor/editor_customization_delegate.h" +#include "app/ui/editor/pixels_movement.h" +#include "app/ui/editor/standby_state.h" +#include "app/ui/editor/transform_handles.h" +#include "app/ui/status_bar.h" +#include "app/ui_context.h" +#include "app/util/clipboard.h" #include "base/unique_ptr.h" -#include "commands/cmd_flip.h" -#include "commands/command.h" -#include "commands/commands.h" #include "gfx/rect.h" -#include "modules/gui.h" #include "raster/algorithm/flip_image.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "tools/ink.h" -#include "tools/tool.h" #include "ui/manager.h" #include "ui/message.h" #include "ui/system.h" #include "ui/view.h" -#include "ui_context.h" -#include "util/clipboard.h" -#include "widgets/editor/editor.h" -#include "widgets/editor/editor_customization_delegate.h" -#include "widgets/editor/pixels_movement.h" -#include "widgets/editor/standby_state.h" -#include "widgets/editor/transform_handles.h" -#include "widgets/status_bar.h" #include +namespace app { + using namespace ui; MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMovement* pixelsMovement, HandleType handle) @@ -319,10 +323,10 @@ bool MovingPixelsState::onKeyDown(Editor* editor, KeyMessage* msg) { Document* document = editor->getDocument(); gfx::Point origin; - UniquePtr floatingImage(m_pixelsMovement->getDraggedImageCopy(origin)); - util::clipboard::copy_image(floatingImage.get(), - document->getSprite()->getPalette(editor->getFrame()), - origin); + base::UniquePtr floatingImage(m_pixelsMovement->getDraggedImageCopy(origin)); + clipboard::copy_image(floatingImage.get(), + document->getSprite()->getPalette(editor->getFrame()), + origin); } // In case of "Cut" command. @@ -422,3 +426,5 @@ gfx::Transformation MovingPixelsState::getTransformation(Editor* editor) { return m_pixelsMovement->getTransformation(); } + +} // namespace app diff --git a/src/app/ui/editor/moving_pixels_state.h b/src/app/ui/editor/moving_pixels_state.h new file mode 100644 index 000000000..f7d858d01 --- /dev/null +++ b/src/app/ui/editor/moving_pixels_state.h @@ -0,0 +1,78 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_MOVING_PIXELS_STATE_H_INCLUDED +#define APP_UI_EDITOR_MOVING_PIXELS_STATE_H_INCLUDED + +#include "app/context_observer.h" +#include "app/ui/editor/handle_type.h" +#include "app/ui/editor/standby_state.h" +#include "app/ui/status_bar.h" +#include "base/compiler_specific.h" + +namespace raster { + class Image; +} + +namespace app { + class Editor; + class PixelsMovement; + + class MovingPixelsState : public StandbyState, StatusBarObserver, ContextObserver { + public: + MovingPixelsState(Editor* editor, ui::MouseMessage* msg, PixelsMovement* pixelsMovement, HandleType handle); + virtual ~MovingPixelsState(); + + // EditorState + virtual BeforeChangeAction onBeforeChangeState(Editor* editor, EditorState* newState) OVERRIDE; + virtual void onCurrentToolChange(Editor* editor) OVERRIDE; + virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onSetCursor(Editor* editor) OVERRIDE; + virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE; + + // ContextObserver + virtual void onCommandBeforeExecution(Context* context) OVERRIDE; + + virtual gfx::Transformation getTransformation(Editor* editor) OVERRIDE; + + protected: + // StatusBarObserver interface + virtual void dispose() OVERRIDE; + virtual void onChangeTransparentColor(const app::Color& color) OVERRIDE; + + private: + void setTransparentColor(const app::Color& color); + void dropPixels(Editor* editor); + + // Helper member to move/translate selection and pixels. + PixelsMovement* m_pixelsMovement; + Editor* m_currentEditor; + + // True if the image was discarded (e.g. when a "Cut" command was + // used to remove the dragged image). + bool m_discarded; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_MOVING_PIXELS_STATE_H_INCLUDED diff --git a/src/widgets/editor/pixels_movement.cpp b/src/app/ui/editor/pixels_movement.cpp similarity index 96% rename from src/widgets/editor/pixels_movement.cpp rename to src/app/ui/editor/pixels_movement.cpp index f78b767fb..035dab4b5 100644 --- a/src/widgets/editor/pixels_movement.cpp +++ b/src/app/ui/editor/pixels_movement.cpp @@ -16,29 +16,34 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/pixels_movement.h" +#include "app/ui/editor/pixels_movement.h" -#include "app.h" -#include "document.h" -#include "document_api.h" +#include "app/app.h" +#include "app/document.h" +#include "app/document_api.h" +#include "app/modules/gui.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/ui_context.h" +#include "app/util/expand_cel_canvas.h" +#include "base/vector2d.h" #include "gfx/region.h" -#include "la/vector2d.h" -#include "modules/gui.h" #include "raster/algorithm/flip_image.h" #include "raster/cel.h" #include "raster/image.h" #include "raster/mask.h" #include "raster/rotate.h" #include "raster/sprite.h" -#include "settings/document_settings.h" -#include "ui_context.h" -#include "util/expand_cel_canvas.h" + +namespace app { template -static inline const la::Vector2d point2Vector(const gfx::PointT& pt) { - return la::Vector2d(pt.x, pt.y); +static inline const base::Vector2d point2Vector(const gfx::PointT& pt) { + return base::Vector2d(pt.x, pt.y); } PixelsMovement::PixelsMovement(Context* context, @@ -433,7 +438,7 @@ Image* PixelsMovement::getDraggedImageCopy(gfx::Point& origin) int width = rightBottom.x - leftTop.x; int height = rightBottom.y - leftTop.y; - UniquePtr image(Image::create(m_sprite->getPixelFormat(), width, height)); + base::UniquePtr image(Image::create(m_sprite->getPixelFormat(), width, height)); image_clear(image, image->mask_color); image_parallelogram(image, m_originalImage, corners.leftTop().x-leftTop.x, corners.leftTop().y-leftTop.y, @@ -500,8 +505,8 @@ void PixelsMovement::dropImageTemporarily() // corner a distance equal to the transformed bounds's // width/height multiplied with the previously calculated X/Y // factor. - la::Vector2d newPivot(corners.leftTop().x, - corners.leftTop().y); + base::Vector2d newPivot(corners.leftTop().x, + corners.leftTop().y); newPivot += pivotPosFactor.x * point2Vector(corners.rightTop() - corners.leftTop()); newPivot += pivotPosFactor.y * point2Vector(corners.leftBottom() - corners.leftTop()); @@ -613,3 +618,5 @@ void PixelsMovement::redrawCurrentMask() corners.leftBottom().x, corners.leftBottom().y); m_currentMask->unfreeze(); } + +} // namespace app diff --git a/src/app/ui/editor/pixels_movement.h b/src/app/ui/editor/pixels_movement.h new file mode 100644 index 000000000..29e193d8a --- /dev/null +++ b/src/app/ui/editor/pixels_movement.h @@ -0,0 +1,126 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_PIXELS_MOVEMENT_H_INCLUDED +#define APP_UI_EDITOR_PIXELS_MOVEMENT_H_INCLUDED + +#include "app/ui/editor/handle_type.h" +#include "app/context_access.h" +#include "gfx/size.h" +#include "raster/algorithm/flip_type.h" +#include "app/undo_transaction.h" + +namespace raster { + class Image; + class Sprite; +} + +namespace app { + class Document; + + // Helper class to move pixels interactively and control undo history + // correctly. The extra cel of the sprite is temporally used to show + // feedback, drag, and drop the specified image in the constructor + // (which generally would be the selected region or the clipboard + // content). + class PixelsMovement { + public: + enum MoveModifier { + NormalMovement = 1, + SnapToGridMovement = 2, + AngleSnapMovement = 4, + MaintainAspectRatioMovement = 8, + LockAxisMovement = 16 + }; + + // The "moveThis" image specifies the chunk of pixels to be moved. + // The "x" and "y" parameters specify the initial position of the image. + PixelsMovement(Context* context, + Document* document, Sprite* sprite, Layer* layer, + const Image* moveThis, int x, int y, int opacity, + const char* operationName); + ~PixelsMovement(); + + void cutMask(); + void copyMask(); + void catchImage(int x, int y, HandleType handle); + void catchImageAgain(int x, int y, HandleType handle); + + // Creates a mask for the given image. Useful when the user paste a + // image from the clipboard. + void maskImage(const Image* image, int x, int y); + + // Moves the image to the new position (relative to the start + // position given in the ctor). + void moveImage(int x, int y, MoveModifier moveModifier); + + // Returns a copy of the current image being dragged with the + // current transformation. + Image* getDraggedImageCopy(gfx::Point& origin); + + // Copies the image being dragged in the current position. + void stampImage(); + + void dropImageTemporarily(); + void dropImage(); + void discardImage(); + bool isDragging() const; + + gfx::Rect getImageBounds(); + gfx::Size getInitialImageSize() const; + + void setMaskColor(uint32_t mask_color); + + // Flips the image and mask in the given direction in "flipType". + // Flip Horizontally/Vertically commands are replaced calling this + // function, so they work more as the user would expect (flip the + // current selection instead of dropping and flipping it). + void flipImage(raster::algorithm::FlipType flipType); + + const gfx::Transformation& getTransformation() const { return m_currentData; } + + private: + void redrawExtraImage(); + void redrawCurrentMask(); + + const ContextReader m_reader; + Document* m_document; + Sprite* m_sprite; + Layer* m_layer; + UndoTransaction m_undoTransaction; + bool m_firstDrop; + bool m_isDragging; + bool m_adjustPivot; + HandleType m_handle; + Image* m_originalImage; + int m_catchX, m_catchY; + gfx::Transformation m_initialData; + gfx::Transformation m_currentData; + Mask* m_initialMask; + Mask* m_currentMask; + }; + + inline PixelsMovement::MoveModifier& operator|=(PixelsMovement::MoveModifier& a, + const PixelsMovement::MoveModifier& b) { + a = static_cast(a | b); + return a; + } + +} // namespace app + +#endif diff --git a/src/app/ui/editor/ruler.h b/src/app/ui/editor/ruler.h new file mode 100644 index 000000000..dad740ad4 --- /dev/null +++ b/src/app/ui/editor/ruler.h @@ -0,0 +1,64 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_RULER_H_INCLUDED +#define APP_UI_EDITOR_RULER_H_INCLUDED + +namespace app { + + // A ruler inside the editor. It is used by SelectBoxState to show + // rulers that can be dragged by the user. + class Ruler { + public: + enum Orientation { Horizontal, Vertical }; + + Ruler() + : m_orientation(Horizontal) + , m_position(0) + { + } + + Ruler(Orientation orientation, int position) + : m_orientation(orientation) + , m_position(position) + { + } + + Orientation getOrientation() const + { + return m_orientation; + } + + int getPosition() const + { + return m_position; + } + + void setPosition(int position) + { + m_position = position; + } + + private: + Orientation m_orientation; + int m_position; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_RULER_H_INCLUDED diff --git a/src/widgets/editor/scrolling_state.cpp b/src/app/ui/editor/scrolling_state.cpp similarity index 92% rename from src/widgets/editor/scrolling_state.cpp rename to src/app/ui/editor/scrolling_state.cpp index e5473fe3d..76fd66b55 100644 --- a/src/widgets/editor/scrolling_state.cpp +++ b/src/app/ui/editor/scrolling_state.cpp @@ -16,21 +16,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/scrolling_state.h" +#include "app/ui/editor/scrolling_state.h" -#include "app.h" +#include "app/app.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" #include "gfx/rect.h" #include "raster/sprite.h" #include "ui/message.h" #include "ui/system.h" #include "ui/view.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" + +namespace app { using namespace ui; - + ScrollingState::ScrollingState() { } @@ -98,3 +102,5 @@ bool ScrollingState::onUpdateStatusBar(Editor* editor) { return false; } + +} // namespace app diff --git a/src/app/ui/editor/scrolling_state.h b/src/app/ui/editor/scrolling_state.h new file mode 100644 index 000000000..fb9a33c9f --- /dev/null +++ b/src/app/ui/editor/scrolling_state.h @@ -0,0 +1,44 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_SCROLLING_STATE_H_INCLUDED +#define APP_UI_EDITOR_SCROLLING_STATE_H_INCLUDED + +#include "app/ui/editor/editor_state.h" +#include "base/compiler_specific.h" + +namespace app { + + class ScrollingState : public EditorState { + public: + ScrollingState(); + virtual ~ScrollingState(); + virtual bool isTemporalState() const OVERRIDE { return true; } + virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onSetCursor(Editor* editor) OVERRIDE; + virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_SCROLLING_STATE_H_INCLUDED diff --git a/src/widgets/editor/select_box_state.cpp b/src/app/ui/editor/select_box_state.cpp similarity index 97% rename from src/widgets/editor/select_box_state.cpp rename to src/app/ui/editor/select_box_state.cpp index 5f3bf45eb..f851c3e88 100644 --- a/src/widgets/editor/select_box_state.cpp +++ b/src/app/ui/editor/select_box_state.cpp @@ -16,20 +16,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/select_box_state.h" +#include "app/ui/editor/select_box_state.h" +#include "app/ui/editor/editor.h" #include "gfx/rect.h" #include "raster/image.h" #include "raster/sprite.h" #include "ui/message.h" #include "ui/system.h" #include "ui/view.h" -#include "widgets/editor/editor.h" #include +namespace app { + using namespace ui; SelectBoxState::SelectBoxState(SelectBoxDelegate* delegate, const gfx::Rect& rc, PaintFlags paintFlags) @@ -236,3 +240,5 @@ bool SelectBoxState::hasPaintFlag(PaintFlags flag) const { return ((m_paintFlags & flag) == flag); } + +} // namespace app diff --git a/src/app/ui/editor/select_box_state.h b/src/app/ui/editor/select_box_state.h new file mode 100644 index 000000000..6843e125c --- /dev/null +++ b/src/app/ui/editor/select_box_state.h @@ -0,0 +1,88 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_SELECT_BOX_STATE_H_INCLUDED +#define APP_UI_EDITOR_SELECT_BOX_STATE_H_INCLUDED + +#include "app/ui/editor/editor_decorator.h" +#include "app/ui/editor/ruler.h" +#include "app/ui/editor/standby_state.h" +#include "base/compiler_specific.h" + +#include + +namespace app { + + class SelectBoxDelegate { + public: + virtual ~SelectBoxDelegate() { } + virtual void onChangeRectangle(const gfx::Rect& rect) = 0; + }; + + class SelectBoxState : public StandbyState + , public EditorDecorator { + enum { H1, H2, V1, V2 }; + + public: + typedef int PaintFlags; + static const int PaintRulers = 1; + static const int PaintDarkOutside = 2; + static const int PaintGrid = 4; + + SelectBoxState(SelectBoxDelegate* delegate, + const gfx::Rect& rc, + PaintFlags paintFlags); + + // Returns the bounding box arranged by the rulers. + gfx::Rect getBoxBounds() const; + void setBoxBounds(const gfx::Rect& rc); + + // EditorState overrides + virtual void onAfterChangeState(Editor* editor) OVERRIDE; + virtual void onBeforePopState(Editor* editor) OVERRIDE; + virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onSetCursor(Editor* editor) OVERRIDE; + + // Returns false as it overrides default standby state behavior & + // look. This state uses normal arrow cursors. + virtual bool requirePenPreview() OVERRIDE { return false; } + + // EditorDecorator overrides + virtual void preRenderDecorator(EditorPreRender* render) OVERRIDE; + virtual void postRenderDecorator(EditorPostRender* render) OVERRIDE; + + private: + typedef std::vector Rulers; + + // Returns true if the position screen position (x, y) is touching + // the given ruler. + bool touchRuler(Editor* editor, Ruler& ruler, int x, int y); + + bool hasPaintFlag(PaintFlags flag) const; + + SelectBoxDelegate* m_delegate; + Rulers m_rulers; + int m_movingRuler; + PaintFlags m_paintFlags; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_SELECT_BOX_STATE_H_INCLUDED diff --git a/src/widgets/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp similarity index 94% rename from src/widgets/editor/standby_state.cpp rename to src/app/ui/editor/standby_state.cpp index e9ebfd7bf..620d993f0 100644 --- a/src/widgets/editor/standby_state.cpp +++ b/src/app/ui/editor/standby_state.cpp @@ -16,42 +16,46 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/standby_state.h" +#include "app/ui/editor/standby_state.h" -#include "app.h" -#include "commands/commands.h" -#include "commands/params.h" -#include "document_location.h" +#include "app/app.h" +#include "app/commands/commands.h" +#include "app/commands/params.h" +#include "app/document_location.h" +#include "app/ini_file.h" +#include "app/tools/ink.h" +#include "app/tools/tool.h" +#include "app/ui/color_bar.h" +#include "app/ui/editor/drawing_state.h" +#include "app/ui/editor/editor.h" +#include "app/ui/editor/editor_customization_delegate.h" +#include "app/ui/editor/handle_type.h" +#include "app/ui/editor/moving_cel_state.h" +#include "app/ui/editor/moving_pixels_state.h" +#include "app/ui/editor/pixels_movement.h" +#include "app/ui/editor/scrolling_state.h" +#include "app/ui/editor/tool_loop_impl.h" +#include "app/ui/editor/transform_handles.h" +#include "app/ui/status_bar.h" +#include "app/ui_context.h" +#include "app/util/misc.h" #include "gfx/rect.h" -#include "ini_file.h" #include "raster/layer.h" #include "raster/mask.h" #include "raster/sprite.h" -#include "tools/ink.h" -#include "tools/tool.h" #include "ui/alert.h" #include "ui/message.h" #include "ui/system.h" #include "ui/view.h" -#include "ui_context.h" -#include "util/misc.h" -#include "widgets/color_bar.h" -#include "widgets/editor/drawing_state.h" -#include "widgets/editor/editor.h" -#include "widgets/editor/editor_customization_delegate.h" -#include "widgets/editor/handle_type.h" -#include "widgets/editor/moving_cel_state.h" -#include "widgets/editor/moving_pixels_state.h" -#include "widgets/editor/pixels_movement.h" -#include "widgets/editor/scrolling_state.h" -#include "widgets/editor/tool_loop_impl.h" -#include "widgets/editor/transform_handles.h" -#include "widgets/status_bar.h" #include +namespace app { + using namespace ui; enum WHEEL_ACTION { WHEEL_NONE, @@ -488,7 +492,7 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT { EditorCustomizationDelegate* customization = editor->getCustomizationDelegate(); Document* document = editor->getDocument(); - UniquePtr tmpImage(NewImageFromMask(editor->getDocumentLocation())); + base::UniquePtr tmpImage(NewImageFromMask(editor->getDocumentLocation())); int x = document->getMask()->getBounds().x; int y = document->getMask()->getBounds().y; int opacity = 255; @@ -618,3 +622,5 @@ void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render) m_standbyState->getTransformation(editor)); } } + +} // namespace app diff --git a/src/app/ui/editor/standby_state.h b/src/app/ui/editor/standby_state.h new file mode 100644 index 000000000..6fb066ddc --- /dev/null +++ b/src/app/ui/editor/standby_state.h @@ -0,0 +1,83 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_STANDBY_STATE_H_INCLUDED +#define APP_UI_EDITOR_STANDBY_STATE_H_INCLUDED + +#include "app/ui/editor/editor_decorator.h" +#include "app/ui/editor/editor_state.h" +#include "app/ui/editor/handle_type.h" +#include "base/compiler_specific.h" +#include "gfx/transformation.h" + +namespace app { + class TransformHandles; + + class StandbyState : public EditorState + { + public: + StandbyState(); + virtual ~StandbyState(); + virtual void onAfterChangeState(Editor* editor) OVERRIDE; + virtual void onCurrentToolChange(Editor* editor) OVERRIDE; + virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onMouseWheel(Editor* editor, ui::MouseMessage* msg) OVERRIDE; + virtual bool onSetCursor(Editor* editor) OVERRIDE; + virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) OVERRIDE; + virtual bool onUpdateStatusBar(Editor* editor) OVERRIDE; + + // Returns true as the standby state is the only one which shows the + // pen-preview. + virtual bool requirePenPreview() OVERRIDE { return true; } + + virtual gfx::Transformation getTransformation(Editor* editor); + + protected: + // Returns true and changes to ScrollingState when "msg" says "the + // user wants to scroll". + bool checkForScroll(Editor* editor, ui::MouseMessage* msg); + + class Decorator : public EditorDecorator { + public: + Decorator(StandbyState* standbyState); + virtual ~Decorator(); + + TransformHandles* getTransformHandles(Editor* editor); + + bool onSetCursor(Editor* editor); + + // EditorDecorator overrides + void preRenderDecorator(EditorPreRender* render) OVERRIDE; + void postRenderDecorator(EditorPostRender* render) OVERRIDE; + private: + TransformHandles* m_transfHandles; + StandbyState* m_standbyState; + }; + + private: + void transformSelection(Editor* editor, ui::MouseMessage* msg, HandleType handle); + + Decorator* m_decorator; + }; + +} // namespace app + +#endif // APP_UI_EDITOR_STANDBY_STATE_H_INCLUDED diff --git a/src/widgets/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp similarity index 94% rename from src/widgets/editor/tool_loop_impl.cpp rename to src/app/ui/editor/tool_loop_impl.cpp index 666796830..a89fc948e 100644 --- a/src/widgets/editor/tool_loop_impl.cpp +++ b/src/app/ui/editor/tool_loop_impl.cpp @@ -16,42 +16,45 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/tool_loop_impl.h" +#include "app/ui/editor/tool_loop_impl.h" -#include "app.h" +#include "app/app.h" #include "app/color.h" #include "app/color_utils.h" -#include "context.h" -#include "context_access.h" +#include "app/context.h" +#include "app/context_access.h" +#include "app/settings/document_settings.h" +#include "app/settings/settings.h" +#include "app/tools/ink.h" +#include "app/tools/shade_table.h" +#include "app/tools/shading_options.h" +#include "app/tools/tool.h" +#include "app/tools/tool_box.h" +#include "app/tools/tool_loop.h" +#include "app/ui/color_bar.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" +#include "app/undo_transaction.h" +#include "app/util/expand_cel_canvas.h" #include "raster/cel.h" #include "raster/layer.h" #include "raster/mask.h" #include "raster/pen.h" #include "raster/sprite.h" -#include "settings/document_settings.h" -#include "settings/settings.h" -#include "tools/ink.h" -#include "tools/shade_table.h" -#include "tools/shading_options.h" -#include "tools/tool.h" -#include "tools/tool_box.h" -#include "tools/tool_loop.h" -#include "ui/gui.h" -#include "undo_transaction.h" -#include "util/expand_cel_canvas.h" -#include "widgets/color_bar.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" +#include "ui/ui.h" #include +namespace app { + using namespace ui; class ToolLoopImpl : public tools::ToolLoop, - public tools::ShadingOptions -{ + public tools::ShadingOptions { Editor* m_editor; Context* m_context; tools::Tool* m_tool; @@ -365,3 +368,5 @@ tools::ToolLoop* create_tool_loop(Editor* editor, Context* context, MouseMessage msg->left() ? fg: bg, msg->left() ? bg: fg); } + +} // namespace app diff --git a/src/app/ui/editor/tool_loop_impl.h b/src/app/ui/editor/tool_loop_impl.h new file mode 100644 index 000000000..071f6ee4d --- /dev/null +++ b/src/app/ui/editor/tool_loop_impl.h @@ -0,0 +1,38 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_TOOL_LOOP_IMPL_H_INCLUDED +#define APP_UI_EDITOR_TOOL_LOOP_IMPL_H_INCLUDED + +namespace ui { + class MouseMessage; +} + +namespace app { + class Context; + class Editor; + + namespace tools { + class ToolLoop; + } + + tools::ToolLoop* create_tool_loop(Editor* editor, Context* context, ui::MouseMessage* msg); + +} // namespace app + +#endif diff --git a/src/widgets/editor/transform_handles.cpp b/src/app/ui/editor/transform_handles.cpp similarity index 97% rename from src/widgets/editor/transform_handles.cpp rename to src/app/ui/editor/transform_handles.cpp index 9c2f0c741..d29a8ba18 100644 --- a/src/widgets/editor/transform_handles.cpp +++ b/src/app/ui/editor/transform_handles.cpp @@ -16,15 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/editor/transform_handles.h" +#include "app/ui/editor/transform_handles.h" -#include "skin/skin_theme.h" -#include "widgets/editor/editor.h" +#include "app/ui/editor/editor.h" +#include "app/ui/skin/skin_theme.h" #include +namespace app { + +using namespace app::skin; using namespace ui; static const int HANDLES = 8; @@ -277,3 +282,5 @@ void TransformHandles::adjustHandle(int& x, int& y, int handle_w, int handle_h, break; } } + +} // namespace app diff --git a/src/app/ui/editor/transform_handles.h b/src/app/ui/editor/transform_handles.h new file mode 100644 index 000000000..e933e5ddb --- /dev/null +++ b/src/app/ui/editor/transform_handles.h @@ -0,0 +1,59 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_EDITOR_TRANSFORM_HANDLES_H_INCLUDED +#define APP_UI_EDITOR_TRANSFORM_HANDLES_H_INCLUDED + +#include "app/ui/editor/handle_type.h" +#include "gfx/point.h" +#include "gfx/transformation.h" + +#include + +struct BITMAP; + +namespace app { + class Editor; + + // Helper class to do hit-detection and render transformation handles + // and rotation pivot. + class TransformHandles { + public: + TransformHandles(); + ~TransformHandles(); + + // Returns the handle in the given mouse point (pt) when the user + // has applied the given transformation to the selection. + HandleType getHandleAtPoint(Editor* editor, const gfx::Point& pt, const gfx::Transformation& transform); + + void drawHandles(Editor* editor, const gfx::Transformation& transform); + void invalidateHandles(Editor* editor, const gfx::Transformation& transform); + + private: + gfx::Rect getPivotHandleBounds(Editor* editor, + const gfx::Transformation& transform, + const gfx::Transformation::Corners& corners); + + bool inHandle(const gfx::Point& pt, int x, int y, int gfx_w, int gfx_h, fixed angle); + void drawHandle(BITMAP* bmp, int x, int y, fixed angle); + void adjustHandle(int& x, int& y, int handle_w, int handle_h, fixed angle); + }; + +} // namespace app + +#endif diff --git a/src/widgets/file_list.cpp b/src/app/ui/file_list.cpp similarity index 98% rename from src/widgets/file_list.cpp rename to src/app/ui/file_list.cpp index 37d4d3341..a66446cff 100644 --- a/src/widgets/file_list.cpp +++ b/src/app/ui/file_list.cpp @@ -16,25 +16,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/file_list.h" +#include "app/ui/file_list.h" -#include "modules/gfx.h" -#include "skin/skin_theme.h" -#include "thumbnail_generator.h" -#include "ui/gui.h" +#include "app/modules/gfx.h" +#include "app/thumbnail_generator.h" +#include "app/ui/skin/skin_theme.h" +#include "ui/ui.h" #include #include #define ISEARCH_KEYPRESS_INTERVAL_MSECS 500 +namespace app { + +using namespace app::skin; using namespace gfx; using namespace ui; -namespace widgets { - FileList::FileList() : Widget(kGenericWidget) , m_generateThumbnailTimer(200, this) @@ -578,4 +581,4 @@ void FileList::generatePreviewOfSelectedItem() } } -} // namespace widgets +} // namespace app diff --git a/src/widgets/file_list.h b/src/app/ui/file_list.h similarity index 93% rename from src/widgets/file_list.h rename to src/app/ui/file_list.h index d0c55c25a..4545ce6a0 100644 --- a/src/widgets/file_list.h +++ b/src/app/ui/file_list.h @@ -16,20 +16,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_FILE_LIST_H_INCLUDED -#define WIDGETS_FILE_LIST_H_INCLUDED +#ifndef APP_UI_FILE_LIST_H_INCLUDED +#define APP_UI_FILE_LIST_H_INCLUDED +#include "app/file_system.h" #include "base/compiler_specific.h" #include "base/signal.h" #include "base/string.h" -#include "file_system.h" #include "ui/timer.h" #include "ui/widget.h" -namespace widgets { +namespace app { - class FileList : public ui::Widget - { + class FileList : public ui::Widget { public: FileList(); virtual ~FileList(); @@ -89,6 +88,6 @@ namespace widgets { }; -} // namespace widgets +} // namespace app #endif diff --git a/src/widgets/file_selector.cpp b/src/app/ui/file_selector.cpp similarity index 98% rename from src/widgets/file_selector.cpp rename to src/app/ui/file_selector.cpp index 28857e21e..931898169 100644 --- a/src/widgets/file_selector.cpp +++ b/src/app/ui/file_selector.cpp @@ -16,24 +16,26 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/file_selector.h" +#include "app/ui/file_selector.h" -#include "app.h" +#include "app/app.h" +#include "app/file/file.h" #include "app/find_widget.h" +#include "app/ini_file.h" +#include "app/modules/gfx.h" +#include "app/modules/gui.h" +#include "app/recent_files.h" +#include "app/ui/file_list.h" +#include "app/ui/skin/skin_parts.h" #include "app/widget_loader.h" #include "base/bind.h" #include "base/path.h" #include "base/split_string.h" -#include "file/file.h" -#include "ini_file.h" -#include "modules/gfx.h" -#include "modules/gui.h" -#include "recent_files.h" -#include "skin/skin_parts.h" -#include "ui/gui.h" -#include "widgets/file_list.h" +#include "ui/ui.h" #include #include @@ -46,8 +48,6 @@ #include #include -using namespace ui; - #if (DEVICE_SEPARATOR != 0) && (DEVICE_SEPARATOR != '\0') # define HAVE_DRIVES #endif @@ -56,11 +56,13 @@ using namespace ui; # define MAX_PATH 4096 /* TODO this is needed for Linux, is it correct? */ #endif -namespace widgets { +namespace app { + +using namespace app::skin; +using namespace ui; template -class NullableIterator -{ +class NullableIterator { public: typedef typename Container::iterator iterator; @@ -683,4 +685,4 @@ void FileSelector::onFileListCurrentFolderChanged() updateNavigationButtons(); } -} // namespace widgets +} // namespace app diff --git a/src/widgets/file_selector.h b/src/app/ui/file_selector.h similarity index 90% rename from src/widgets/file_selector.h rename to src/app/ui/file_selector.h index 52fd72241..1ffdfc50d 100644 --- a/src/widgets/file_selector.h +++ b/src/app/ui/file_selector.h @@ -16,28 +16,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_FILE_SELECTOR_H_INCLUDED -#define WIDGETS_FILE_SELECTOR_H_INCLUDED +#ifndef APP_UI_FILE_SELECTOR_H_INCLUDED +#define APP_UI_FILE_SELECTOR_H_INCLUDED #include "base/string.h" #include "base/unique_ptr.h" #include "ui/window.h" -class IFileItem; - namespace ui { class Button; class ComboBox; class Entry; } -namespace widgets { - - class FileList; +namespace app { class CustomFileNameEntry; + class FileList; + class IFileItem; - class FileSelector : public ui::Window - { + class FileSelector : public ui::Window { public: FileSelector(); @@ -69,6 +66,6 @@ namespace widgets { FileList* m_fileList; }; -} // namespace widgets +} // namespace app #endif diff --git a/src/widgets/hex_color_entry.cpp b/src/app/ui/hex_color_entry.cpp similarity index 95% rename from src/widgets/hex_color_entry.cpp rename to src/app/ui/hex_color_entry.cpp index 406ef5262..3d693f225 100644 --- a/src/widgets/hex_color_entry.cpp +++ b/src/app/ui/hex_color_entry.cpp @@ -16,14 +16,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include +#include "app/ui/hex_color_entry.h" #include "gfx/border.h" #include "ui/theme.h" -#include "widgets/hex_color_entry.h" + +namespace app { using namespace ui; @@ -80,3 +84,5 @@ void HexColorEntry::onEntryChange() ColorChange(app::Color::fromRgb(r, g, b)); } + +} // namespace app diff --git a/src/widgets/hex_color_entry.h b/src/app/ui/hex_color_entry.h similarity index 65% rename from src/widgets/hex_color_entry.h rename to src/app/ui/hex_color_entry.h index 3a8feed6a..fb0cd5d2d 100644 --- a/src/widgets/hex_color_entry.h +++ b/src/app/ui/hex_color_entry.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_HEX_COLOR_ENTRY_H_INCLUDED -#define WIDGETS_HEX_COLOR_ENTRY_H_INCLUDED +#ifndef APP_UI_HEX_COLOR_ENTRY_H_INCLUDED +#define APP_UI_HEX_COLOR_ENTRY_H_INCLUDED #include "app/color.h" #include "base/signal.h" @@ -25,23 +25,26 @@ #include "ui/entry.h" #include "ui/label.h" -// Little widget to show a color in hexadecimal format (as HTML). -class HexColorEntry : public ui::Box -{ -public: - HexColorEntry(); +namespace app { - void setColor(const app::Color& color); + // Little widget to show a color in hexadecimal format (as HTML). + class HexColorEntry : public ui::Box { + public: + HexColorEntry(); - // Signals - Signal1 ColorChange; + void setColor(const app::Color& color); -protected: - void onEntryChange(); + // Signals + Signal1 ColorChange; -private: - ui::Label m_label; - ui::Entry m_entry; -}; + protected: + void onEntryChange(); + + private: + ui::Label m_label; + ui::Entry m_entry; + }; + +} // namespace app #endif diff --git a/src/widgets/main_menu_bar.cpp b/src/app/ui/main_menu_bar.cpp similarity index 88% rename from src/widgets/main_menu_bar.cpp rename to src/app/ui/main_menu_bar.cpp index c6215e2cc..261fb3311 100644 --- a/src/widgets/main_menu_bar.cpp +++ b/src/app/ui/main_menu_bar.cpp @@ -16,11 +16,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/main_menu_bar.h" +#include "app/ui/main_menu_bar.h" -#include "app_menus.h" +#include "app/app_menus.h" + +namespace app { MainMenuBar::MainMenuBar() { @@ -35,3 +39,5 @@ void MainMenuBar::reload() setMenu(AppMenus::instance()->getRootMenu()); } + +} // namespace app diff --git a/src/widgets/main_menu_bar.h b/src/app/ui/main_menu_bar.h similarity index 79% rename from src/widgets/main_menu_bar.h rename to src/app/ui/main_menu_bar.h index 5d211c655..32f342043 100644 --- a/src/widgets/main_menu_bar.h +++ b/src/app/ui/main_menu_bar.h @@ -16,17 +16,20 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef WIDGETS_MAIN_MENU_BAR_H_INCLUDED -#define WIDGETS_MAIN_MENU_BAR_H_INCLUDED +#ifndef APP_UI_MAIN_MENU_BAR_H_INCLUDED +#define APP_UI_MAIN_MENU_BAR_H_INCLUDED #include "ui/menu.h" -class MainMenuBar : public ui::MenuBar -{ -public: - MainMenuBar(); +namespace app { - void reload(); -}; + class MainMenuBar : public ui::MenuBar { + public: + MainMenuBar(); + + void reload(); + }; + +} // namespace app #endif diff --git a/src/widgets/main_window.cpp b/src/app/ui/main_window.cpp similarity index 90% rename from src/widgets/main_window.cpp rename to src/app/ui/main_window.cpp index bffa2e1b8..0486ef309 100644 --- a/src/widgets/main_window.cpp +++ b/src/app/ui/main_window.cpp @@ -16,33 +16,36 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/main_window.h" +#include "app/ui/main_window.h" -#include "app.h" +#include "app/app.h" +#include "app/app_menus.h" #include "app/load_widget.h" -#include "app_menus.h" -#include "commands/commands.h" -#include "modules/editors.h" +#include "app/ui/color_bar.h" +#include "app/ui/context_bar.h" +#include "app/ui/document_view.h" +#include "app/ui/editor/editor.h" +#include "app/ui/editor/editor_view.h" +#include "app/ui/main_menu_bar.h" +#include "app/ui/mini_editor.h" +#include "app/ui/status_bar.h" +#include "app/ui/tabs.h" +#include "app/ui/toolbar.h" +#include "app/ui/workspace.h" +#include "app/commands/commands.h" +#include "app/modules/editors.h" #include "ui/splitter.h" #include "ui/system.h" #include "ui/view.h" -#include "ui_context.h" -#include "widgets/color_bar.h" -#include "widgets/context_bar.h" -#include "widgets/document_view.h" -#include "widgets/editor/editor.h" -#include "widgets/editor/editor_view.h" -#include "widgets/main_menu_bar.h" -#include "widgets/mini_editor.h" -#include "widgets/status_bar.h" -#include "widgets/tabs.h" -#include "widgets/toolbar.h" -#include "widgets/workspace.h" +#include "app/ui_context.h" + +namespace app { using namespace ui; -using namespace widgets; MainWindow::MainWindow() : Window(true, NULL) @@ -209,3 +212,5 @@ void MainWindow::mouseOverTab(Tabs* tabs, TabView* tabView) m_statusBar->clearText(); } } + +} // namespace app diff --git a/src/app/ui/main_window.h b/src/app/ui/main_window.h new file mode 100644 index 000000000..2640af006 --- /dev/null +++ b/src/app/ui/main_window.h @@ -0,0 +1,79 @@ +/* ASEPRITE + * Copyright (C) 2001-2013 David Capello + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef APP_UI_MAIN_WINDOW_H_INCLUDED +#define APP_UI_MAIN_WINDOW_H_INCLUDED + +#include "app/ui/tabs.h" +#include "ui/window.h" + +namespace ui { + class Splitter; +} + +namespace app { + class ColorBar; + class ContextBar; + class MainMenuBar; + class MiniEditorWindow; + class StatusBar; + class Tabs; + class Workspace; + + class MainWindow : public ui::Window + , public TabsDelegate { + public: + MainWindow(); + ~MainWindow(); + + MainMenuBar* getMenuBar() { return m_menuBar; } + ContextBar* getContextBar() { return m_contextBar; } + Tabs* getTabsBar() { return m_tabsBar; } + Workspace* getWorkspace() { return m_workspace; } + MiniEditorWindow* getMiniEditor() { return m_miniEditor; } + + void reloadMenus(); + + bool isAdvancedMode() const { return m_advancedMode; } + void setAdvancedMode(bool advanced); + + // TabsDelegate implementation. + void clickTab(Tabs* tabs, TabView* tabView, ui::MouseButtons buttons); + void mouseOverTab(Tabs* tabs, TabView* tabView); + + protected: + void onSaveLayout(ui::SaveLayoutEvent& ev) OVERRIDE; + void onActiveViewChange(); + + private: + MainMenuBar* m_menuBar; + ContextBar* m_contextBar; + StatusBar* m_statusBar; + ColorBar* m_colorBar; + ui::Splitter* m_colorBarSplitter; + ui::Widget* m_toolBar; + Tabs* m_tabsBar; + double m_lastSplitterPos; + bool m_advancedMode; + Workspace* m_workspace; + MiniEditorWindow* m_miniEditor; + }; + +} + +#endif diff --git a/src/widgets/mini_editor.cpp b/src/app/ui/mini_editor.cpp similarity index 93% rename from src/widgets/mini_editor.cpp rename to src/app/ui/mini_editor.cpp index 3a51b43e4..30ada58da 100644 --- a/src/widgets/mini_editor.cpp +++ b/src/app/ui/mini_editor.cpp @@ -16,35 +16,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif -#include "widgets/mini_editor.h" +#include "app/ui/mini_editor.h" +#include "app/ui/editor/editor.h" +#include "app/ui/status_bar.h" +#include "app/ui/toolbar.h" #include "base/bind.h" -#include "document.h" +#include "app/document.h" #include "gfx/rect.h" -#include "ini_file.h" -#include "modules/editors.h" -#include "modules/gui.h" +#include "app/ini_file.h" +#include "app/modules/editors.h" +#include "app/modules/gui.h" #include "raster/sprite.h" -#include "skin/skin_button.h" -#include "skin/skin_theme.h" +#include "app/ui/skin/skin_button.h" +#include "app/ui/skin/skin_theme.h" #include "ui/base.h" #include "ui/button.h" #include "ui/close_event.h" #include "ui/message.h" #include "ui/rect.h" #include "ui/system.h" -#include "widgets/editor/editor.h" -#include "widgets/status_bar.h" -#include "widgets/toolbar.h" +namespace app { + +using namespace app::skin; using namespace ui; -namespace widgets { - -class MiniPlayButton : public SkinButton