Permalink
Browse files

Merge branch 'feature/continuous-cels'

  • Loading branch information...
dacap committed Feb 9, 2015
2 parents b788837 + 3ebb708 commit 52003da72163e388930d45c9d894c1f881d93372
Showing with 1,771 additions and 626 deletions.
  1. +1 −0 TODO.md
  2. +1 −0 data/gui.xml
  3. BIN data/skins/default/sheet.png
  4. +31 −0 data/skins/default/skin.xml
  5. +1 −0 docs/files/ase.txt
  6. +3 −1 src/app/CMakeLists.txt
  7. +26 −3 src/app/cmd/add_cel.cpp
  8. +5 −4 src/app/cmd/add_layer.cpp
  9. +30 −19 src/app/cmd/copy_cel.cpp
  10. +2 −0 src/app/cmd/flatten_layers.cpp
  11. +43 −40 src/app/cmd/move_cel.cpp
  12. +0 −85 src/app/cmd/object_io.cpp
  13. +0 −92 src/app/cmd/object_io.h
  14. +1 −0 src/app/cmd/remove_frame.cpp
  15. +6 −6 src/app/cmd/replace_image.cpp
  16. +0 −1 src/app/cmd/replace_image.h
  17. +96 −0 src/app/cmd/set_cel_data.cpp
  18. +64 −0 src/app/cmd/set_cel_data.h
  19. +3 −5 src/app/cmd/set_pixel_format.cpp
  20. +75 −0 src/app/cmd/unlink_cel.cpp
  21. +48 −0 src/app/cmd/unlink_cel.h
  22. +20 −9 src/app/commands/cmd_clear_cel.cpp
  23. +9 −14 src/app/commands/cmd_flip.cpp
  24. +4 −0 src/app/commands/cmd_merge_down_layer.cpp
  25. +33 −27 src/app/commands/cmd_rotate.cpp
  26. +18 −19 src/app/commands/cmd_sprite_size.cpp
  27. +119 −0 src/app/commands/cmd_unlink_cel.cpp
  28. +1 −0 src/app/commands/commands_list.h
  29. +15 −4 src/app/commands/filters/filter_manager_impl.cpp
  30. +15 −6 src/app/document.cpp
  31. +43 −65 src/app/document_api.cpp
  32. +0 −4 src/app/document_api.h
  33. +44 −0 src/app/document_range.cpp
  34. +9 −1 src/app/document_range.h
  35. +5 −2 src/app/document_range_tests.cpp
  36. +25 −14 src/app/file/ase_format.cpp
  37. +1 −1 src/app/file/file.cpp
  38. +1 −1 src/app/file/fli_format.cpp
  39. +1 −1 src/app/file/gif_format.cpp
  40. +8 −9 src/app/ui/editor/moving_cel_state.cpp
  41. +1 −1 src/app/ui/status_bar.cpp
  42. +159 −12 src/app/ui/timeline.cpp
  43. +9 −0 src/app/ui/timeline.h
  44. +4 −4 src/app/util/expand_cel_canvas.cpp
  45. +15 −16 src/app/util/range_utils.cpp
  46. +8 −2 src/app/util/range_utils.h
  47. +5 −1 src/doc/CMakeLists.txt
  48. +1 −1 src/doc/LICENSE.txt
  49. +1 −1 src/doc/README.md
  50. +57 −18 src/doc/cel.cpp
  51. +25 −20 src/doc/cel.h
  52. +43 −0 src/doc/cel_data.cpp
  53. +50 −0 src/doc/cel_data.h
  54. +51 −0 src/doc/cel_data_io.cpp
  55. +23 −0 src/doc/cel_data_io.h
  56. +10 −29 src/doc/cel_io.cpp
  57. +2 −3 src/doc/cel_io.h
  58. +84 −0 src/doc/cels_range.cpp
  59. +66 −0 src/doc/cels_range.h
  60. +3 −0 src/doc/image_io.cpp
  61. +3 −1 src/doc/layer.cpp
  62. +3 −0 src/doc/layer.h
  63. +61 −14 src/doc/layer_io.cpp
  64. +2 −6 src/doc/layer_io.h
  65. +1 −0 src/doc/object_type.h
  66. +47 −36 src/doc/sprite.cpp
  67. +13 −4 src/doc/sprite.h
  68. +108 −0 src/doc/sprite_tests.cpp
  69. +70 −0 src/doc/subobjects_io.cpp
  70. +24 −14 src/doc/subobjects_io.h
  71. +15 −10 src/render/quantization.cpp
View
@@ -43,6 +43,7 @@
# Refactoring
* Replace get_unique_cels() with CelsRange
* Make one level of layers (folders should modify only timeline/UI)
* Convert doc::PixelFormat to a enum class
* Add doc::Spec with width/height/channels/ColorMode/ncolors
View
@@ -648,6 +648,7 @@
<item command="CelProperties" text="&amp;Properties..." />
<separator />
<item command="ClearCel" text="&amp;Clear" />
<item command="UnlinkCel" text="&amp;Unlink" />
</menu>
<menu id="cel_movement_popup">
Binary file not shown.
@@ -296,6 +296,10 @@
<part id="timeline_open_padlock_active" x="252" y="36" w="12" h="12" />
<part id="timeline_closed_padlock_normal" x="240" y="48" w="12" h="12" />
<part id="timeline_closed_padlock_active" x="252" y="48" w="12" h="12" />
<part id="timeline_continuous_normal" x="276" y="36" w="12" h="12" />
<part id="timeline_continuous_active" x="288" y="36" w="12" h="12" />
<part id="timeline_discontinuous_normal" x="276" y="48" w="12" h="12" />
<part id="timeline_discontinuous_active" x="288" y="48" w="12" h="12" />
<part id="timeline_empty_frame_normal" x="240" y="60" w="12" h="12" />
<part id="timeline_empty_frame_active" x="252" y="60" w="12" h="12" />
<part id="timeline_keyframe_normal" x="240" y="72" w="12" h="12" />
@@ -306,6 +310,9 @@
<part id="timeline_fromright_active" x="252" y="96" w="12" h="12" />
<part id="timeline_fromboth_normal" x="240" y="108" w="12" h="12" />
<part id="timeline_fromboth_active" x="252" y="108" w="12" h="12" />
<part id="timeline_leftlink_active" x="264" y="84" w="12" h="12" />
<part id="timeline_bothlinks_active" x="264" y="96" w="12" h="12" />
<part id="timeline_rightlink_active" x="264" y="108" w="12" h="12" />
<part id="timeline_gear" x="264" y="12" w="12" h="12" />
<part id="timeline_gear_active" x="264" y="24" w="12" h="12" />
<part id="timeline_onionskin" x="264" y="36" w="12" h="12" />
@@ -434,6 +441,20 @@
<icon part="timeline_closed_padlock_active" />
</style>
<!-- timeline_continuous -->
<style id="timeline_continuous" base="timeline_box">
<icon part="timeline_continuous_normal" />
</style>
<style id="timeline_continuous:active">
<icon part="timeline_continuous_active" />
</style>
<style id="timeline_discontinuous" base="timeline_box">
<icon part="timeline_discontinuous_normal" />
</style>
<style id="timeline_discontinuous:active">
<icon part="timeline_discontinuous_active" />
</style>
<!-- timeline_layer -->
<style id="timeline_layer" base="timeline_box">
<text align="left" valign="middle" padding-left="4" />
@@ -482,6 +503,16 @@
<icon part="timeline_fromboth_active" />
</style>
<style id="timeline_leftlink">
<icon part="timeline_leftlink_active" />
</style>
<style id="timeline_rightlink">
<icon part="timeline_rightlink_active" />
</style>
<style id="timeline_bothlinks">
<icon part="timeline_bothlinks_active" />
</style>
<!-- timeline_gear -->
<style id="timeline_gear" base="timeline_box">
<icon part="timeline_gear" />
View
@@ -119,6 +119,7 @@ Layer Chunk (0x2004)
2 = Editable
4 = Lock movement
8 = Background
16 = Prefer linked cels
WORD Layer type (0=normal (image) layer, 1=layer set)
WORD Layer child level (see NOTE.1)
WORD Default layer width in pixels (ignored)
View
@@ -75,13 +75,13 @@ add_library(app-lib
cmd/layer_from_background.cpp
cmd/move_cel.cpp
cmd/move_layer.cpp
cmd/object_io.cpp
cmd/remove_cel.cpp
cmd/remove_frame.cpp
cmd/remove_layer.cpp
cmd/remove_palette.cpp
cmd/replace_image.cpp
cmd/reselect_mask.cpp
cmd/set_cel_data.cpp
cmd/set_cel_frame.cpp
cmd/set_cel_opacity.cpp
cmd/set_cel_position.cpp
@@ -95,6 +95,7 @@ add_library(app-lib
cmd/set_sprite_size.cpp
cmd/set_total_frames.cpp
cmd/set_transparent_color.cpp
cmd/unlink_cel.cpp
cmd/with_cel.cpp
cmd/with_document.cpp
cmd/with_image.cpp
@@ -185,6 +186,7 @@ add_library(app-lib
commands/cmd_switch_colors.cpp
commands/cmd_timeline.cpp
commands/cmd_undo.cpp
commands/cmd_unlink_cel.cpp
commands/cmd_zoom.cpp
commands/command.cpp
commands/commands.cpp
View
@@ -22,15 +22,21 @@
#include "app/cmd/add_cel.h"
#include "app/cmd/object_io.h"
#include "base/serialization.h"
#include "doc/cel.h"
#include "doc/cel_io.h"
#include "doc/cel_data_io.h"
#include "doc/document.h"
#include "doc/document_event.h"
#include "doc/image_io.h"
#include "doc/layer.h"
#include "doc/subobjects_io.h"
namespace app {
namespace cmd {
using namespace base::serialization;
using namespace base::serialization::little_endian;
using namespace doc;
AddCel::AddCel(Layer* layer, Cel* cel)
@@ -52,15 +58,32 @@ void AddCel::onUndo()
Layer* layer = this->layer();
Cel* cel = this->cel();
ObjectIO(layer->sprite()).write_cel(m_stream, cel);
// Save the CelData only if the cel isn't linked
bool has_data = (cel->links() == 0);
write8(m_stream, has_data ? 1: 0);
if (has_data) {
write_image(m_stream, cel->image());
write_celdata(m_stream, cel->data());
}
write_cel(m_stream, cel);
removeCel(layer, cel);
}
void AddCel::onRedo()
{
Layer* layer = this->layer();
Cel* cel = ObjectIO(layer->sprite()).read_cel(m_stream);
SubObjectsIO io(layer->sprite());
bool has_data = (read8(m_stream) != 0);
if (has_data) {
ImageRef image(read_image(m_stream));
io.addImageRef(image);
CelDataRef celdata(read_celdata(m_stream, &io));
io.addCelDataRef(celdata);
}
Cel* cel = read_cel(m_stream, &io);
addCel(layer, cel);
@@ -22,11 +22,11 @@
#include "app/cmd/add_layer.h"
#include "app/cmd/object_io.h"
#include "doc/layer.h"
#include "doc/document.h"
#include "doc/document_event.h"
#include "doc/layer.h"
#include "doc/layer_io.h"
#include "doc/subobjects_io.h"
namespace app {
namespace cmd {
@@ -54,15 +54,16 @@ void AddLayer::onUndo()
Layer* folder = m_folder.layer();
Layer* layer = m_newLayer.layer();
ObjectIO(folder->sprite()).write_layer(m_stream, layer);
write_layer(m_stream, layer);
removeLayer(folder, layer);
}
void AddLayer::onRedo()
{
Layer* folder = m_folder.layer();
Layer* newLayer = ObjectIO(folder->sprite()).read_layer(m_stream);
SubObjectsIO io(folder->sprite());
Layer* newLayer = read_layer(m_stream, &io);
Layer* afterThis = m_afterThis.layer();
addLayer(folder, newLayer, afterThis);
View
@@ -27,6 +27,8 @@
#include "app/cmd/clear_cel.h"
#include "app/cmd/copy_rect.h"
#include "app/cmd/remove_cel.h"
#include "app/cmd/set_cel_data.h"
#include "app/cmd/unlink_cel.h"
#include "app/document.h"
#include "doc/cel.h"
#include "doc/layer.h"
@@ -70,8 +72,11 @@ void CopyCel::onExecute()
// Clear destination cel if it does exist. It'll be overriden by the
// copy of srcCel.
if (dstCel)
if (dstCel) {
if (dstCel->links())
executeAndAdd(new cmd::UnlinkCel(dstCel));
executeAndAdd(new cmd::ClearCel(dstCel));
}
// Add empty frames until newFrame
while (dstSprite->totalFrames() <= m_dstFrame)
@@ -83,35 +88,41 @@ void CopyCel::onExecute()
if (dstCel)
dstImage = dstCel->imageRef();
bool createLink =
(srcLayer == dstLayer && dstLayer->isContinuous());
// For background layer
if (dstLayer->isBackground()) {
if (srcCel) {
ASSERT(dstImage);
if (dstImage) {
int blend = (srcLayer->isBackground() ?
BLEND_MODE_COPY: BLEND_MODE_NORMAL);
ImageRef tmp(Image::createCopy(dstImage));
render::composite_image(tmp, srcImage,
srcCel->x(), srcCel->y(), 255, blend);
executeAndAdd(new cmd::CopyRect(dstImage, tmp, gfx::Clip(tmp->bounds())));
}
ASSERT(dstCel);
ASSERT(dstImage);
if (!dstCel || !dstImage ||
!srcCel || !srcImage)
return;
if (createLink) {
executeAndAdd(new cmd::SetCelData(dstCel, srcCel->dataRef()));
}
else {
ASSERT(dstCel);
if (dstCel)
executeAndAdd(new cmd::ClearCel(dstCel));
int blend = (srcLayer->isBackground() ?
BLEND_MODE_COPY: BLEND_MODE_NORMAL);
ImageRef tmp(Image::createCopy(dstImage));
render::composite_image(tmp, srcImage,
srcCel->x(), srcCel->y(), 255, blend);
executeAndAdd(new cmd::CopyRect(dstImage, tmp, gfx::Clip(tmp->bounds())));
}
}
// For transparent layers
else {
if (dstCel)
executeAndAdd(new cmd::RemoveCel(dstCel));
if (srcCel) {
dstImage.reset(Image::createCopy(srcImage));
dstCel = new Cel(*srcCel);
if (createLink)
dstCel = Cel::createLink(srcCel);
else
dstCel = Cel::createCopy(srcCel);
dstCel->setFrame(m_dstFrame);
dstCel->setImage(dstImage);
executeAndAdd(new cmd::AddCel(dstLayer, dstCel));
}
@@ -70,6 +70,8 @@ void FlattenLayers::onExecute()
clear_image(image, bgcolor);
render.renderSprite(image, sprite, frame);
// TODO Keep cel links when possible
ImageRef cel_image;
Cel* cel = background->cel(frame);
if (cel) {
Oops, something went wrong.

0 comments on commit 52003da

Please sign in to comment.