Rename FrameTag -> Tag

This commit is contained in:
David Capello 2019-10-01 14:55:08 -03:00
parent c25c67733b
commit 1c8b8051a8
100 changed files with 994 additions and 959 deletions

View File

@ -1024,7 +1024,7 @@
</item>
</menu>
<menu id="frame_tag_popup_menu">
<menu id="tag_popup_menu">
<item command="FrameTagProperties" text="@main_menu.frame_tags_tag_properties" />
<item command="RemoveFrameTag" text="@main_menu.frame_tags_delete_tag" />
</menu>

View File

@ -75,7 +75,7 @@ Warning
||&Yes||&No
END
file_format_alpha_channel = Alpha channel
file_format_frame_tags = Frame tags
file_format_tags = Tags
file_format_frames = Frames
file_format_grayscale_mode = Grayscale mode
file_format_indexed_mode = Indexed mode
@ -273,7 +273,7 @@ Flip_Horizontally = Horizontally
Flip_Selection = Selection
Flip_Vertically = Vertically
FrameProperties = Frame Properties
FrameTagProperties = Frame Tag Properties
FrameTagProperties = Tag Properties
FullscreenPreview = Fullscreen Preview
GotoFirstFrame = Go to First Frame
GotoFirstFrameInTag = Go to First Frame In Tag
@ -340,7 +340,7 @@ NewFrame_NewEmptyFrame = New Empty Frame
NewFrame_DuplicateCels = Duplicate Cels w/Layer Mode
NewFrame_DuplicateCelsCopies = Duplicate Cels
NewFrame_DuplicateCelsLinked = Duplicate Linked Cels
NewFrameTag = New Frame Tag
NewFrameTag = New Tag
NewLayer = New {}
NewLayer_BeforeActiveLayer = New {} Below
NewLayer_Layer = Layer
@ -379,7 +379,7 @@ PlayPreviewAnimation = Play Preview Animation
Redo = Redo
Refresh = Refresh
RemoveFrame = Remove Frame
RemoveFrameTag = Remove Frame Tag
RemoveFrameTag = Remove Tag
RemoveLayer = Remove Layer
RemoveSlice = Remove Slice
ReopenClosedFile = Reopen Closed File
@ -555,7 +555,7 @@ json_data_hash = Hash
json_data_array = Array
meta = Meta:
meta_layers = Layers
meta_frame_tags = Frame Tags
meta_tags = Tags
meta_slices = Slices
open_sprite_sheet = Open generated sprite sheet
export = &Export
@ -588,14 +588,6 @@ title = Frame Properties
frame_number = Frame number:
duration = Duration (milliseconds):
[frame_tag_properties]
title = Frame Tag Properties
name = Name:
from = From:
to = To:
color = Color:
ani_dir = Animation Direction:
[general]
ok = &OK
close = &Close
@ -1361,6 +1353,14 @@ pixel_scale = Pixel Scale:
[tab_popup_menu]
close = &Close
[tag_properties]
title = Tag Properties
name = Name:
from = From:
to = To:
color = Color:
ani_dir = Animation Direction:
[timeline_conf]
position = Position:
left = &Left

View File

@ -1,5 +1,6 @@
<!-- Aseprite -->
<!-- Copyright (C) 2001-2018 by David Capello -->
<!-- Copyright (C) 2019 Igara Studio S.A. -->
<!-- Copyright (C) 2001-2018 David Capello -->
<gui>
<window id="export_sprite_sheet" text="@.title">
<grid columns="4">
@ -61,7 +62,7 @@
</combobox>
<label text="@.meta" />
<check id="list_layers" text="@.meta_layers" />
<check id="list_tags" text="@.meta_frame_tags" />
<check id="list_tags" text="@.meta_tags" />
<check id="list_slices" text="@.meta_slices" />
</hbox>

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Aseprite -->
<!-- Copyright (C) 2015-2018 by David Capello -->
<!-- Copyright (C) 2019 Igara Studio S.A. -->
<!-- Copyright (C) 2015-2018 David Capello -->
<gui>
<window id="frame_tag_properties" text="@.title">
<window id="tag_properties" text="@.title">
<grid columns="2">
<label text="@.name" />
<entry maxsize="256" id="name" magnet="true" />

View File

@ -347,7 +347,6 @@ if(ENABLE_UI)
ui/file_selector.cpp
ui/filename_field.cpp
ui/font_popup.cpp
ui/frame_tag_window.cpp
ui/hex_color_entry.cpp
ui/home_view.cpp
ui/icon_button.cpp
@ -377,6 +376,7 @@ if(ENABLE_UI)
ui/slider2.cpp
ui/status_bar.cpp
ui/tabs.cpp
ui/tag_window.cpp
ui/task_widget.cpp
ui/timeline/ani_controls.cpp
ui/timeline/timeline.cpp
@ -411,10 +411,10 @@ add_library(app-lib
cmd.cpp
cmd/add_cel.cpp
cmd/add_frame.cpp
cmd/add_frame_tag.cpp
cmd/add_layer.cpp
cmd/add_palette.cpp
cmd/add_slice.cpp
cmd/add_tag.cpp
cmd/assign_color_profile.cpp
cmd/background_from_layer.cpp
cmd/clear_cel.cpp
@ -440,10 +440,10 @@ add_library(app-lib
cmd/remap_colors.cpp
cmd/remove_cel.cpp
cmd/remove_frame.cpp
cmd/remove_frame_tag.cpp
cmd/remove_layer.cpp
cmd/remove_palette.cpp
cmd/remove_slice.cpp
cmd/remove_tag.cpp
cmd/replace_image.cpp
cmd/reselect_mask.cpp
cmd/set_cel_bounds.cpp
@ -452,10 +452,6 @@ add_library(app-lib
cmd/set_cel_opacity.cpp
cmd/set_cel_position.cpp
cmd/set_frame_duration.cpp
cmd/set_frame_tag_anidir.cpp
cmd/set_frame_tag_color.cpp
cmd/set_frame_tag_name.cpp
cmd/set_frame_tag_range.cpp
cmd/set_last_point.cpp
cmd/set_layer_blend_mode.cpp
cmd/set_layer_flags.cpp
@ -469,6 +465,10 @@ add_library(app-lib
cmd/set_slice_key.cpp
cmd/set_slice_name.cpp
cmd/set_sprite_size.cpp
cmd/set_tag_anidir.cpp
cmd/set_tag_color.cpp
cmd/set_tag_name.cpp
cmd/set_tag_range.cpp
cmd/set_total_frames.cpp
cmd/set_transparent_color.cpp
cmd/set_user_data.cpp
@ -477,11 +477,11 @@ add_library(app-lib
cmd/unlink_cel.cpp
cmd/with_cel.cpp
cmd/with_document.cpp
cmd/with_frame_tag.cpp
cmd/with_image.cpp
cmd/with_layer.cpp
cmd/with_slice.cpp
cmd/with_sprite.cpp
cmd/with_tag.cpp
cmd_sequence.cpp
cmd_transaction.cpp
color.cpp

View File

@ -343,7 +343,7 @@ void AppMenus::reload()
m_framePopupMenu.reset(loadMenuById(handle, "frame_popup_menu"));
m_celPopupMenu.reset(loadMenuById(handle, "cel_popup_menu"));
m_celMovementPopupMenu.reset(loadMenuById(handle, "cel_movement_popup_menu"));
m_frameTagPopupMenu.reset(loadMenuById(handle, "frame_tag_popup_menu"));
m_tagPopupMenu.reset(loadMenuById(handle, "tag_popup_menu"));
m_slicePopupMenu.reset(loadMenuById(handle, "slice_popup_menu"));
m_palettePopupMenu.reset(loadMenuById(handle, "palette_popup_menu"));
m_inkPopupMenu.reset(loadMenuById(handle, "ink_popup_menu"));
@ -706,7 +706,7 @@ void AppMenus::updateMenusList()
m_menus.push_back(m_framePopupMenu.get());
m_menus.push_back(m_celPopupMenu.get());
m_menus.push_back(m_celMovementPopupMenu.get());
m_menus.push_back(m_frameTagPopupMenu.get());
m_menus.push_back(m_tagPopupMenu.get());
m_menus.push_back(m_slicePopupMenu.get());
m_menus.push_back(m_palettePopupMenu.get());
m_menus.push_back(m_inkPopupMenu.get());

View File

@ -56,7 +56,7 @@ namespace app {
Menu* getFramePopupMenu() { return m_framePopupMenu.get(); }
Menu* getCelPopupMenu() { return m_celPopupMenu.get(); }
Menu* getCelMovementPopupMenu() { return m_celMovementPopupMenu.get(); }
Menu* getFrameTagPopupMenu() { return m_frameTagPopupMenu.get(); }
Menu* getTagPopupMenu() { return m_tagPopupMenu.get(); }
Menu* getSlicePopupMenu() { return m_slicePopupMenu.get(); }
Menu* getPalettePopupMenu() { return m_palettePopupMenu.get(); }
Menu* getInkPopupMenu() { return m_inkPopupMenu.get(); }
@ -92,7 +92,7 @@ namespace app {
std::unique_ptr<Menu> m_framePopupMenu;
std::unique_ptr<Menu> m_celPopupMenu;
std::unique_ptr<Menu> m_celMovementPopupMenu;
std::unique_ptr<Menu> m_frameTagPopupMenu;
std::unique_ptr<Menu> m_tagPopupMenu;
std::unique_ptr<Menu> m_slicePopupMenu;
std::unique_ptr<Menu> m_palettePopupMenu;
std::unique_ptr<Menu> m_inkPopupMenu;

View File

@ -52,7 +52,7 @@ AppOptions::AppOptions(int argc, const char* argv[])
, m_layer(m_po.add("layer").alias("import-layer").requiresValue("<name>").description("Include just the given layer in the sheet\nor save as operation"))
, m_allLayers(m_po.add("all-layers").description("Make all layers visible\nBy default hidden layers will be ignored"))
, m_ignoreLayer(m_po.add("ignore-layer").requiresValue("<name>").description("Exclude the given layer in the sheet\nor save as operation"))
, m_frameTag(m_po.add("frame-tag").requiresValue("<name>").description("Include tagged frames in the sheet"))
, m_tag(m_po.add("tag").alias("frame-tag").requiresValue("<name>").description("Include tagged frames in the sheet"))
, m_frameRange(m_po.add("frame-range").requiresValue("from,to").description("Only export frames in the [from,to] range"))
, m_ignoreEmpty(m_po.add("ignore-empty").description("Do not export empty frames/cels"))
, m_borderPadding(m_po.add("border-padding").requiresValue("<value>").description("Add padding on the texture borders"))

View File

@ -66,7 +66,7 @@ public:
const Option& layer() const { return m_layer; }
const Option& allLayers() const { return m_allLayers; }
const Option& ignoreLayer() const { return m_ignoreLayer; }
const Option& frameTag() const { return m_frameTag; }
const Option& tag() const { return m_tag; }
const Option& frameRange() const { return m_frameRange; }
const Option& ignoreEmpty() const { return m_ignoreEmpty; }
const Option& borderPadding() const { return m_borderPadding; }
@ -126,7 +126,7 @@ private:
Option& m_layer;
Option& m_allLayers;
Option& m_ignoreLayer;
Option& m_frameTag;
Option& m_tag;
Option& m_frameRange;
Option& m_ignoreEmpty;
Option& m_borderPadding;

View File

@ -13,9 +13,9 @@
#include "app/doc.h"
#include "app/file/file.h"
#include "doc/frame_tag.h"
#include "doc/frame_tags.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "doc/tags.h"
namespace app {
@ -48,7 +48,7 @@ FileOpROI CliOpenFile::roi() const
return FileOpROI(document,
slice,
frameTag,
tag,
selFrames,
true);
}

View File

@ -24,7 +24,7 @@ namespace app {
Doc* document;
std::string filename;
std::string filenameFormat;
std::string frameTag;
std::string tag;
std::string slice;
std::vector<std::string> includeLayers;
std::vector<std::string> excludeLayers;
@ -44,8 +44,8 @@ namespace app {
CliOpenFile();
bool hasFrameTag() const {
return (!frameTag.empty());
bool hasTag() const {
return (!tag.empty());
}
bool hasSlice() const {

View File

@ -26,12 +26,12 @@
#include "base/convert_to.h"
#include "base/fs.h"
#include "base/split_string.h"
#include "doc/frame_tag.h"
#include "doc/frame_tags.h"
#include "doc/layer.h"
#include "doc/selected_frames.h"
#include "doc/selected_layers.h"
#include "doc/slice.h"
#include "doc/tag.h"
#include "doc/tags.h"
#include "render/dithering_algorithm.h"
#include <queue>
@ -283,9 +283,9 @@ void CliProcessor::process(Context* ctx)
else if (opt == &m_options.allLayers()) {
cof.allLayers = true;
}
// --frame-tag <tag-name>
else if (opt == &m_options.frameTag()) {
cof.frameTag = value.value();
// --tag <tag-name>
else if (opt == &m_options.tag()) {
cof.tag = value.value();
}
// --frame-range from,to
else if (opt == &m_options.frameRange()) {
@ -531,7 +531,7 @@ void CliProcessor::process(Context* ctx)
// --list-tags
else if (opt == &m_options.listTags()) {
if (m_exporter)
m_exporter->setListFrameTags(true);
m_exporter->setListTags(true);
else
cof.listTags = true;
}
@ -606,18 +606,18 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
// Add document to exporter
if (m_exporter) {
FrameTag* frameTag = nullptr;
Tag* tag = nullptr;
SelectedFrames selFrames;
if (cof.hasFrameTag()) {
frameTag = doc->sprite()->frameTags().getByName(cof.frameTag);
if (cof.hasTag()) {
tag = doc->sprite()->tags().getByName(cof.tag);
}
if (cof.hasFrameRange()) {
// --frame-range with --frame-tag
if (frameTag) {
if (tag) {
selFrames.insert(
frameTag->fromFrame()+MID(0, cof.fromFrame, frameTag->frames()-1),
frameTag->fromFrame()+MID(0, cof.toFrame, frameTag->frames()-1));
tag->fromFrame()+MID(0, cof.fromFrame, tag->frames()-1),
tag->fromFrame()+MID(0, cof.toFrame, tag->frames()-1));
}
// --frame-range without --frame-tag
else {
@ -634,12 +634,12 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
SelectedLayers oneLayer;
oneLayer.insert(layer);
m_exporter->addDocument(doc, frameTag, &oneLayer,
m_exporter->addDocument(doc, tag, &oneLayer,
(!selFrames.empty() ? &selFrames: nullptr));
}
}
else {
m_exporter->addDocument(doc, frameTag, &filteredLayers,
m_exporter->addDocument(doc, tag, &filteredLayers,
(!selFrames.empty() ? &selFrames: nullptr));
}
}
@ -648,12 +648,12 @@ bool CliProcessor::openFile(Context* ctx, CliOpenFile& cof)
SelectedLayers oneLayer;
oneLayer.insert(layer);
m_exporter->addDocument(doc, frameTag, &oneLayer,
m_exporter->addDocument(doc, tag, &oneLayer,
(!selFrames.empty() ? &selFrames: nullptr));
}
}
else {
m_exporter->addDocument(doc, frameTag, nullptr,
m_exporter->addDocument(doc, tag, nullptr,
(!selFrames.empty() ? &selFrames: nullptr));
}
}
@ -712,26 +712,26 @@ void CliProcessor::saveFile(Context* ctx, const CliOpenFile& cof)
layers.push_back(nullptr);
}
std::vector<doc::FrameTag*> frameTags;
if (cof.hasFrameTag()) {
frameTags.push_back(
doc->sprite()->frameTags().getByName(cof.frameTag));
std::vector<doc::Tag*> tags;
if (cof.hasTag()) {
tags.push_back(
doc->sprite()->tags().getByName(cof.tag));
}
else {
doc::FrameTags& origFrameTags = cof.document->sprite()->frameTags();
if (cof.splitTags && !origFrameTags.empty()) {
for (doc::FrameTag* frameTag : origFrameTags) {
doc::Tags& origTags = cof.document->sprite()->tags();
if (cof.splitTags && !origTags.empty()) {
for (doc::Tag* tag : origTags) {
// In case the tag is outside the given --frame-range
if (cof.hasFrameRange()) {
if (frameTag->toFrame() < cof.fromFrame ||
frameTag->fromFrame() > cof.toFrame)
if (tag->toFrame() < cof.fromFrame ||
tag->fromFrame() > cof.toFrame)
continue;
}
frameTags.push_back(frameTag);
tags.push_back(tag);
}
}
else
frameTags.push_back(nullptr);
tags.push_back(nullptr);
}
std::vector<doc::Slice*> slices;
@ -753,7 +753,7 @@ void CliProcessor::saveFile(Context* ctx, const CliOpenFile& cof)
bool groupInFormat = is_group_in_filename_format(fn);
for (doc::Slice* slice : slices) {
for (doc::FrameTag* frameTag : frameTags) {
for (doc::Tag* tag : tags) {
// For each layer, hide other ones and save the sprite.
for (doc::Layer* layer : layers) {
RestoreVisibleLayers layersVisibility;
@ -804,11 +804,11 @@ void CliProcessor::saveFile(Context* ctx, const CliOpenFile& cof)
itemCof.includeLayers.push_back(layer->name());
}
if (frameTag) {
if (tag) {
fnInfo
.innerTagName(frameTag->name())
.outerTagName(frameTag->name());
itemCof.frameTag = frameTag->name();
.innerTagName(tag->name())
.outerTagName(tag->name());
itemCof.tag = tag->name();
}
if (slice) {
fnInfo.sliceName(slice->name());

View File

@ -21,11 +21,11 @@
#include "app/file/palette_file.h"
#include "app/ui_context.h"
#include "base/convert_to.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "doc/palette.h"
#include "doc/slice.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#ifdef ENABLE_SCRIPTING
#include "app/app.h"
@ -65,7 +65,7 @@ void DefaultCliDelegate::afterOpenFile(const CliOpenFile& cof)
}
if (cof.listTags) {
for (doc::FrameTag* tag : cof.document->sprite()->frameTags())
for (doc::Tag* tag : cof.document->sprite()->tags())
std::cout << tag->name() << "\n";
}
@ -82,8 +82,8 @@ void DefaultCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
params.set("filename", cof.filename.c_str());
params.set("filename-format", cof.filenameFormat.c_str());
if (cof.hasFrameTag()) {
params.set("frame-tag", cof.frameTag.c_str());
if (cof.hasTag()) {
params.set("frame-tag", cof.tag.c_str());
}
if (cof.hasFrameRange()) {
params.set("from-frame", base::convert_to<std::string>(cof.fromFrame).c_str());

View File

@ -115,8 +115,8 @@ void PreviewCliDelegate::saveFile(Context* ctx, const CliOpenFile& cof)
std::cout << " - Visible Layer:\n";
showLayerVisibility(cof.document->sprite()->root(), " ");
if (cof.hasFrameTag()) {
std::cout << " - Frame tag: '" << cof.frameTag << "'\n";
if (cof.hasTag()) {
std::cout << " - Tag: '" << cof.tag << "'\n";
}
if (cof.hasSlice()) {

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -8,47 +9,47 @@
#include "config.h"
#endif
#include "app/cmd/add_frame_tag.h"
#include "app/cmd/add_tag.h"
#include "app/doc.h"
#include "app/doc_event.h"
#include "doc/frame_tag.h"
#include "doc/frame_tag_io.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "doc/tag_io.h"
namespace app {
namespace cmd {
using namespace doc;
AddFrameTag::AddFrameTag(Sprite* sprite, FrameTag* frameTag)
AddTag::AddTag(Sprite* sprite, Tag* tag)
: WithSprite(sprite)
, WithFrameTag(frameTag)
, WithTag(tag)
, m_size(0)
{
}
void AddFrameTag::onExecute()
void AddTag::onExecute()
{
Sprite* sprite = this->sprite();
FrameTag* frameTag = this->frameTag();
Tag* tag = this->tag();
sprite->frameTags().add(frameTag);
sprite->tags().add(tag);
sprite->incrementVersion();
// Notify observers about the new frame.
Doc* doc = static_cast<Doc*>(sprite->document());
DocEvent ev(doc);
ev.sprite(sprite);
ev.frameTag(frameTag);
doc->notify_observers<DocEvent&>(&DocObserver::onAddFrameTag, ev);
ev.tag(tag);
doc->notify_observers<DocEvent&>(&DocObserver::onAddTag, ev);
}
void AddFrameTag::onUndo()
void AddTag::onUndo()
{
Sprite* sprite = this->sprite();
FrameTag* frameTag = this->frameTag();
write_frame_tag(m_stream, frameTag);
Tag* tag = this->tag();
write_tag(m_stream, tag);
m_size = size_t(m_stream.tellp());
// Notify observers about the new frame.
@ -56,21 +57,21 @@ void AddFrameTag::onUndo()
Doc* doc = static_cast<Doc*>(sprite->document());
DocEvent ev(doc);
ev.sprite(sprite);
ev.frameTag(frameTag);
doc->notify_observers<DocEvent&>(&DocObserver::onRemoveFrameTag, ev);
ev.tag(tag);
doc->notify_observers<DocEvent&>(&DocObserver::onRemoveTag, ev);
}
sprite->frameTags().remove(frameTag);
sprite->tags().remove(tag);
sprite->incrementVersion();
delete frameTag;
delete tag;
}
void AddFrameTag::onRedo()
void AddTag::onRedo()
{
Sprite* sprite = this->sprite();
FrameTag* frameTag = read_frame_tag(m_stream);
Tag* tag = read_tag(m_stream);
sprite->frameTags().add(frameTag);
sprite->tags().add(tag);
sprite->incrementVersion();
m_stream.str(std::string());
@ -81,8 +82,8 @@ void AddFrameTag::onRedo()
Doc* doc = static_cast<Doc*>(sprite->document());
DocEvent ev(doc);
ev.sprite(sprite);
ev.frameTag(frameTag);
doc->notify_observers<DocEvent&>(&DocObserver::onAddFrameTag, ev);
ev.tag(tag);
doc->notify_observers<DocEvent&>(&DocObserver::onAddTag, ev);
}
} // namespace cmd

View File

@ -1,15 +1,16 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_CMD_ADD_FRAME_TAG_H_INCLUDED
#define APP_CMD_ADD_FRAME_TAG_H_INCLUDED
#ifndef APP_CMD_ADD_TAG_H_INCLUDED
#define APP_CMD_ADD_TAG_H_INCLUDED
#pragma once
#include "app/cmd.h"
#include "app/cmd/with_frame_tag.h"
#include "app/cmd/with_tag.h"
#include "app/cmd/with_sprite.h"
#include <sstream>
@ -18,11 +19,11 @@ namespace app {
namespace cmd {
using namespace doc;
class AddFrameTag : public Cmd
, public WithSprite
, public WithFrameTag {
class AddTag : public Cmd
, public WithSprite
, public WithTag {
public:
AddFrameTag(Sprite* sprite, FrameTag* tag);
AddTag(Sprite* sprite, Tag* tag);
protected:
void onExecute() override;

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
@ -8,31 +9,31 @@
#include "config.h"
#endif
#include "app/cmd/remove_frame_tag.h"
#include "app/cmd/remove_tag.h"
namespace app {
namespace cmd {
using namespace doc;
RemoveFrameTag::RemoveFrameTag(Sprite* sprite, FrameTag* tag)
: AddFrameTag(sprite, tag)
RemoveTag::RemoveTag(Sprite* sprite, Tag* tag)
: AddTag(sprite, tag)
{
}
void RemoveFrameTag::onExecute()
void RemoveTag::onExecute()
{
AddFrameTag::onUndo();
AddTag::onUndo();
}
void RemoveFrameTag::onUndo()
void RemoveTag::onUndo()
{
AddFrameTag::onRedo();
AddTag::onRedo();
}
void RemoveFrameTag::onRedo()
void RemoveTag::onRedo()
{
AddFrameTag::onUndo();
AddTag::onUndo();
}
} // namespace cmd

View File

@ -1,22 +1,23 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_CMD_REMOVE_FRAME_TAG_H_INCLUDED
#define APP_CMD_REMOVE_FRAME_TAG_H_INCLUDED
#ifndef APP_CMD_REMOVE_TAG_H_INCLUDED
#define APP_CMD_REMOVE_TAG_H_INCLUDED
#pragma once
#include "app/cmd/add_frame_tag.h"
#include "app/cmd/add_tag.h"
namespace app {
namespace cmd {
using namespace doc;
class RemoveFrameTag : public AddFrameTag {
class RemoveTag : public AddTag {
public:
RemoveFrameTag(Sprite* sprite, FrameTag* tag);
RemoveTag(Sprite* sprite, Tag* tag);
protected:
void onExecute() override;

View File

@ -1,38 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_frame_tag_anidir.h"
#include "doc/frame_tag.h"
namespace app {
namespace cmd {
SetFrameTagAniDir::SetFrameTagAniDir(FrameTag* tag, doc::AniDir anidir)
: WithFrameTag(tag)
, m_oldAniDir(tag->aniDir())
, m_newAniDir(anidir)
{
}
void SetFrameTagAniDir::onExecute()
{
frameTag()->setAniDir(m_newAniDir);
frameTag()->incrementVersion();
}
void SetFrameTagAniDir::onUndo()
{
frameTag()->setAniDir(m_oldAniDir);
frameTag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -1,38 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_frame_tag_color.h"
#include "doc/frame_tag.h"
namespace app {
namespace cmd {
SetFrameTagColor::SetFrameTagColor(FrameTag* tag, doc::color_t color)
: WithFrameTag(tag)
, m_oldColor(tag->color())
, m_newColor(color)
{
}
void SetFrameTagColor::onExecute()
{
frameTag()->setColor(m_newColor);
frameTag()->incrementVersion();
}
void SetFrameTagColor::onUndo()
{
frameTag()->setColor(m_oldColor);
frameTag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -1,38 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_frame_tag_name.h"
#include "doc/frame_tag.h"
namespace app {
namespace cmd {
SetFrameTagName::SetFrameTagName(FrameTag* tag, const std::string& name)
: WithFrameTag(tag)
, m_oldName(tag->name())
, m_newName(name)
{
}
void SetFrameTagName::onExecute()
{
frameTag()->setName(m_newName);
frameTag()->incrementVersion();
}
void SetFrameTagName::onUndo()
{
frameTag()->setName(m_oldName);
frameTag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -1,40 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_frame_tag_range.h"
#include "doc/frame_tag.h"
namespace app {
namespace cmd {
SetFrameTagRange::SetFrameTagRange(FrameTag* tag, frame_t from, frame_t to)
: WithFrameTag(tag)
, m_oldFrom(tag->fromFrame())
, m_oldTo(tag->toFrame())
, m_newFrom(from)
, m_newTo(to)
{
}
void SetFrameTagRange::onExecute()
{
frameTag()->setFrameRange(m_newFrom, m_newTo);
frameTag()->incrementVersion();
}
void SetFrameTagRange::onUndo()
{
frameTag()->setFrameRange(m_oldFrom, m_oldTo);
frameTag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -0,0 +1,39 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_tag_anidir.h"
#include "doc/tag.h"
namespace app {
namespace cmd {
SetTagAniDir::SetTagAniDir(Tag* tag, doc::AniDir anidir)
: WithTag(tag)
, m_oldAniDir(tag->aniDir())
, m_newAniDir(anidir)
{
}
void SetTagAniDir::onExecute()
{
tag()->setAniDir(m_newAniDir);
tag()->incrementVersion();
}
void SetTagAniDir::onUndo()
{
tag()->setAniDir(m_oldAniDir);
tag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -1,25 +1,26 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_CMD_SET_FRAME_TAG_ANIDIR_H_INCLUDED
#define APP_CMD_SET_FRAME_TAG_ANIDIR_H_INCLUDED
#ifndef APP_CMD_SET_TAG_ANIDIR_H_INCLUDED
#define APP_CMD_SET_TAG_ANIDIR_H_INCLUDED
#pragma once
#include "app/cmd.h"
#include "app/cmd/with_frame_tag.h"
#include "app/cmd/with_tag.h"
#include "doc/anidir.h"
namespace app {
namespace cmd {
using namespace doc;
class SetFrameTagAniDir : public Cmd
, public WithFrameTag {
class SetTagAniDir : public Cmd
, public WithTag {
public:
SetFrameTagAniDir(FrameTag* tag, doc::AniDir anidir);
SetTagAniDir(Tag* tag, doc::AniDir anidir);
protected:
void onExecute() override;

View File

@ -0,0 +1,39 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_tag_color.h"
#include "doc/tag.h"
namespace app {
namespace cmd {
SetTagColor::SetTagColor(Tag* tag, doc::color_t color)
: WithTag(tag)
, m_oldColor(tag->color())
, m_newColor(color)
{
}
void SetTagColor::onExecute()
{
tag()->setColor(m_newColor);
tag()->incrementVersion();
}
void SetTagColor::onUndo()
{
tag()->setColor(m_oldColor);
tag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -1,25 +1,26 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_CMD_SET_FRAME_TAG_COLOR_H_INCLUDED
#define APP_CMD_SET_FRAME_TAG_COLOR_H_INCLUDED
#ifndef APP_CMD_SET_TAG_COLOR_H_INCLUDED
#define APP_CMD_SET_TAG_COLOR_H_INCLUDED
#pragma once
#include "app/cmd.h"
#include "app/cmd/with_frame_tag.h"
#include "app/cmd/with_tag.h"
#include "doc/color.h"
namespace app {
namespace cmd {
using namespace doc;
class SetFrameTagColor : public Cmd
, public WithFrameTag {
class SetTagColor : public Cmd
, public WithTag {
public:
SetFrameTagColor(FrameTag* tag, doc::color_t color);
SetTagColor(Tag* tag, doc::color_t color);
protected:
void onExecute() override;

View File

@ -0,0 +1,39 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_tag_name.h"
#include "doc/tag.h"
namespace app {
namespace cmd {
SetTagName::SetTagName(doc::Tag* tag, const std::string& name)
: WithTag(tag)
, m_oldName(tag->name())
, m_newName(name)
{
}
void SetTagName::onExecute()
{
tag()->setName(m_newName);
tag()->incrementVersion();
}
void SetTagName::onUndo()
{
tag()->setName(m_oldName);
tag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -1,15 +1,16 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_CMD_SET_FRAME_TAG_NAME_H_INCLUDED
#define APP_CMD_SET_FRAME_TAG_NAME_H_INCLUDED
#ifndef APP_CMD_SET_TAG_NAME_H_INCLUDED
#define APP_CMD_SET_TAG_NAME_H_INCLUDED
#pragma once
#include "app/cmd.h"
#include "app/cmd/with_frame_tag.h"
#include "app/cmd/with_tag.h"
#include <string>
@ -17,10 +18,10 @@ namespace app {
namespace cmd {
using namespace doc;
class SetFrameTagName : public Cmd
, public WithFrameTag {
class SetTagName : public Cmd
, public WithTag {
public:
SetFrameTagName(FrameTag* tag, const std::string& name);
SetTagName(Tag* tag, const std::string& name);
protected:
void onExecute() override;

View File

@ -0,0 +1,41 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/cmd/set_tag_range.h"
#include "doc/tag.h"
namespace app {
namespace cmd {
SetTagRange::SetTagRange(Tag* tag, frame_t from, frame_t to)
: WithTag(tag)
, m_oldFrom(tag->fromFrame())
, m_oldTo(tag->toFrame())
, m_newFrom(from)
, m_newTo(to)
{
}
void SetTagRange::onExecute()
{
tag()->setFrameRange(m_newFrom, m_newTo);
tag()->incrementVersion();
}
void SetTagRange::onUndo()
{
tag()->setFrameRange(m_oldFrom, m_oldTo);
tag()->incrementVersion();
}
} // namespace cmd
} // namespace app

View File

@ -1,25 +1,26 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_CMD_SET_FRAME_TAG_RANGE_H_INCLUDED
#define APP_CMD_SET_FRAME_TAG_RANGE_H_INCLUDED
#ifndef APP_CMD_SET_TAG_RANGE_H_INCLUDED
#define APP_CMD_SET_TAG_RANGE_H_INCLUDED
#pragma once
#include "app/cmd.h"
#include "app/cmd/with_frame_tag.h"
#include "app/cmd/with_tag.h"
#include "doc/frame.h"
namespace app {
namespace cmd {
using namespace doc;
class SetFrameTagRange : public Cmd
, public WithFrameTag {
class SetTagRange : public Cmd
, public WithTag {
public:
SetFrameTagRange(FrameTag* tag, frame_t from, frame_t to);
SetTagRange(Tag* tag, frame_t from, frame_t to);
protected:
void onExecute() override;

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
@ -8,23 +9,23 @@
#include "config.h"
#endif
#include "app/cmd/with_frame_tag.h"
#include "app/cmd/with_tag.h"
#include "doc/frame_tag.h"
#include "doc/tag.h"
namespace app {
namespace cmd {
using namespace doc;
WithFrameTag::WithFrameTag(FrameTag* frameTag)
: m_frameTagId(frameTag->id())
WithTag::WithTag(Tag* tag)
: m_tagId(tag->id())
{
}
FrameTag* WithFrameTag::frameTag()
Tag* WithTag::tag()
{
return get<FrameTag>(m_frameTagId);
return get<Tag>(m_tagId);
}
} // namespace cmd

View File

@ -1,30 +1,31 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_CMD_WITH_FRAME_TAG_H_INCLUDED
#define APP_CMD_WITH_FRAME_TAG_H_INCLUDED
#ifndef APP_CMD_WITH_TAG_H_INCLUDED
#define APP_CMD_WITH_TAG_H_INCLUDED
#pragma once
#include "doc/object_id.h"
namespace doc {
class FrameTag;
class Tag;
}
namespace app {
namespace cmd {
using namespace doc;
class WithFrameTag {
class WithTag {
public:
WithFrameTag(FrameTag* tag);
FrameTag* frameTag();
WithTag(Tag* tag);
Tag* tag();
private:
ObjectId m_frameTagId;
ObjectId m_tagId;
};
} // namespace cmd

View File

@ -31,8 +31,8 @@
#include "base/convert_to.h"
#include "base/fs.h"
#include "base/string.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "doc/tag.h"
#include "fmt/format.h"
#include "export_sprite_sheet.xml.h"
@ -427,7 +427,7 @@ public:
return layers()->getValue();
}
std::string frameTagValue() const {
std::string tagValue() const {
return frames()->getValue();
}
@ -435,7 +435,7 @@ public:
return listLayers()->isSelected();
}
bool listFrameTagsValue() const {
bool listTagsValue() const {
return listTags()->isSelected();
}
@ -602,7 +602,7 @@ private:
void updateSizeFields() {
SelectedFrames selFrames;
calculate_selected_frames(m_site,
frameTagValue(),
tagValue(),
selFrames);
frame_t nframes = selFrames.size();
@ -737,9 +737,9 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
docPref.spriteSheet.extrude (params.extrude (window.extrudeValue()));
docPref.spriteSheet.openGenerated (params.openGenerated (window.openGeneratedValue()));
docPref.spriteSheet.layer (params.layer (window.layerValue()));
docPref.spriteSheet.frameTag (params.tag (window.frameTagValue()));
docPref.spriteSheet.frameTag (params.tag (window.tagValue()));
docPref.spriteSheet.listLayers (params.listLayers (window.listLayersValue()));
docPref.spriteSheet.listFrameTags (params.listTags (window.listFrameTagsValue()));
docPref.spriteSheet.listFrameTags (params.listTags (window.listTagsValue()));
docPref.spriteSheet.listSlices (params.listSlices (window.listSlicesValue()));
// Default preferences for future sprites
@ -787,8 +787,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
#endif
SelectedFrames selFrames;
FrameTag* frameTag =
calculate_selected_frames(site, tagName, selFrames);
Tag* tag = calculate_selected_frames(site, tagName, selFrames);
frame_t nframes = selFrames.size();
ASSERT(nframes > 0);
@ -861,9 +860,9 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
exporter.setTrimByGrid(trimByGrid);
exporter.setExtrude(extrude);
if (listLayers) exporter.setListLayers(true);
if (listTags) exporter.setListFrameTags(true);
if (listTags) exporter.setListTags(true);
if (listSlices) exporter.setListSlices(true);
exporter.addDocument(document, frameTag,
exporter.addDocument(document, tag,
(!selLayers.empty() ? &selLayers: nullptr),
(!selFrames.empty() ? &selFrames: nullptr));

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -8,21 +9,21 @@
#include "config.h"
#endif
#include "app/cmd/set_frame_tag_anidir.h"
#include "app/cmd/set_frame_tag_color.h"
#include "app/cmd/set_frame_tag_name.h"
#include "app/cmd/set_frame_tag_range.h"
#include "app/cmd/set_tag_anidir.h"
#include "app/cmd/set_tag_color.h"
#include "app/cmd/set_tag_name.h"
#include "app/cmd/set_tag_range.h"
#include "app/color.h"
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/loop_tag.h"
#include "app/tx.h"
#include "app/ui/frame_tag_window.h"
#include "app/ui/tag_window.h"
#include "base/convert_to.h"
#include "doc/anidir.h"
#include "doc/frame_tag.h"
#include "doc/sprite.h"
#include "doc/tag.h"
namespace app {
@ -69,44 +70,44 @@ void FrameTagPropertiesCommand::onExecute(Context* context)
const ContextReader reader(context);
const Sprite* sprite = reader.sprite();
frame_t frame = reader.frame();
const FrameTag* foundTag = nullptr;
const Tag* foundTag = nullptr;
if (!m_tagName.empty())
foundTag = sprite->frameTags().getByName(m_tagName);
foundTag = sprite->tags().getByName(m_tagName);
else if (m_tagId != NullId)
foundTag = sprite->frameTags().getById(m_tagId);
foundTag = sprite->tags().getById(m_tagId);
else
foundTag = sprite->frameTags().innerTag(frame);
foundTag = sprite->tags().innerTag(frame);
if (!foundTag)
return;
FrameTagWindow window(sprite, foundTag);
TagWindow window(sprite, foundTag);
if (!window.show())
return;
ContextWriter writer(reader);
Tx tx(writer.context(), "Change Frame Tag Properties");
FrameTag* tag = const_cast<FrameTag*>(foundTag);
Tx tx(writer.context(), friendlyName());
Tag* tag = const_cast<Tag*>(foundTag);
std::string name = window.nameValue();
if (tag->name() != name)
tx(new cmd::SetFrameTagName(tag, name));
tx(new cmd::SetTagName(tag, name));
doc::frame_t from, to;
window.rangeValue(from, to);
if (tag->fromFrame() != from ||
tag->toFrame() != to) {
tx(new cmd::SetFrameTagRange(tag, from, to));
tx(new cmd::SetTagRange(tag, from, to));
}
doc::color_t docColor = window.colorValue();
if (tag->color() != docColor)
tx(new cmd::SetFrameTagColor(tag, docColor));
tx(new cmd::SetTagColor(tag, docColor));
doc::AniDir anidir = window.aniDirValue();
if (tag->aniDir() != anidir)
tx(new cmd::SetFrameTagAniDir(tag, anidir));
tx(new cmd::SetTagAniDir(tag, anidir));
tx.commit();
}

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -17,8 +18,8 @@
#include "app/ui/editor/editor.h"
#include "app/ui/editor/editor_customization_delegate.h"
#include "app/ui/search_entry.h"
#include "doc/frame_tag.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "ui/combobox.h"
#include "ui/window.h"
@ -66,10 +67,10 @@ public:
protected:
frame_t onGetFrame(Editor* editor) override {
frame_t frame = editor->frame();
FrameTag* tag = editor
Tag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(frame, false);
->getTagProvider()
->getTagByFrame(frame, false);
return (tag ? tag->fromFrame(): 0);
}
};
@ -108,10 +109,10 @@ public:
protected:
frame_t onGetFrame(Editor* editor) override {
frame_t frame = editor->frame();
FrameTag* tag = editor
Tag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(frame, false);
->getTagProvider()
->getTagByFrame(frame, false);
frame_t first = (tag ? tag->fromFrame(): 0);
frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());
@ -126,10 +127,10 @@ public:
protected:
frame_t onGetFrame(Editor* editor) override {
frame_t frame = editor->frame();
FrameTag* tag = editor
Tag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(frame, false);
->getTagProvider()
->getTagByFrame(frame, false);
frame_t first = (tag ? tag->fromFrame(): 0);
frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());
@ -155,10 +156,10 @@ public:
protected:
frame_t onGetFrame(Editor* editor) override {
frame_t frame = editor->frame();
FrameTag* tag = editor
Tag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(frame, false);
->getTagProvider()
->getTagByFrame(frame, false);
return (tag ? tag->toFrame(): editor->sprite()->lastFrame());
}
};
@ -173,8 +174,8 @@ private:
// TODO this combobox is similar to FileSelector::CustomFileNameEntry
class TagsEntry : public ComboBox {
public:
TagsEntry(FrameTags& frameTags)
: m_frameTags(frameTags) {
TagsEntry(Tags& tags)
: m_tags(tags) {
setEditable(true);
getEntryWidget()->Change.connect(&TagsEntry::onEntryChange, this);
fill(true);
@ -187,15 +188,15 @@ private:
MatchWords match(getEntryWidget()->text());
bool matchAny = false;
for (const auto& frameTag : m_frameTags) {
if (match(frameTag->name())) {
for (const auto& tag : m_tags) {
if (match(tag->name())) {
matchAny = true;
break;
}
}
for (const auto& frameTag : m_frameTags) {
if (all || !matchAny || match(frameTag->name()))
addItem(frameTag->name());
for (const auto& tag : m_tags) {
if (all || !matchAny || match(tag->name()))
addItem(tag->name());
}
}
@ -206,7 +207,7 @@ private:
openListBox();
}
FrameTags& m_frameTags;
Tags& m_tags;
};
void onLoadParams(const Params& params) override {
@ -224,7 +225,7 @@ private:
if (m_showUI) {
app::gen::GotoFrame window;
TagsEntry combobox(editor->sprite()->frameTags());
TagsEntry combobox(editor->sprite()->tags());
window.framePlaceholder()->addChild(&combobox);
@ -245,10 +246,10 @@ private:
// Search a tag name
else {
MatchWords match(text);
for (const auto& frameTag : editor->sprite()->frameTags()) {
if (match(frameTag->name())) {
for (const auto& tag : editor->sprite()->tags()) {
if (match(tag->name())) {
m_frame =
frameTag->fromFrame()+docPref.timeline.firstFrame();
tag->fromFrame()+docPref.timeline.firstFrame();
break;
}
}

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -9,14 +10,14 @@
#endif
#include "app/app.h"
#include "app/cmd/add_frame_tag.h"
#include "app/cmd/add_tag.h"
#include "app/commands/command.h"
#include "app/context.h"
#include "app/context_access.h"
#include "app/tx.h"
#include "app/ui/frame_tag_window.h"
#include "app/ui/tag_window.h"
#include "app/ui/timeline/timeline.h"
#include "doc/frame_tag.h"
#include "doc/tag.h"
#include <stdexcept>
@ -59,22 +60,22 @@ void NewFrameTagCommand::onExecute(Context* context)
to = range.selectedFrames().lastFrame();
}
std::unique_ptr<FrameTag> frameTag(new FrameTag(from, to));
FrameTagWindow window(sprite, frameTag.get());
std::unique_ptr<Tag> tag(new Tag(from, to));
TagWindow window(sprite, tag.get());
if (!window.show())
return;
window.rangeValue(from, to);
frameTag->setFrameRange(from, to);
frameTag->setName(window.nameValue());
frameTag->setColor(window.colorValue());
frameTag->setAniDir(window.aniDirValue());
tag->setFrameRange(from, to);
tag->setName(window.nameValue());
tag->setColor(window.colorValue());
tag->setAniDir(window.aniDirValue());
{
ContextWriter writer(reader);
Tx tx(writer.context(), "New Frames Tag");
tx(new cmd::AddFrameTag(writer.sprite(), frameTag.get()));
frameTag.release();
Tx tx(writer.context(), friendlyName());
tx(new cmd::AddTag(writer.sprite(), tag.get()));
tag.release();
tx.commit();
}

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -9,7 +10,7 @@
#endif
#include "app/app.h"
#include "app/cmd/remove_frame_tag.h"
#include "app/cmd/remove_tag.h"
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/context.h"
@ -18,7 +19,7 @@
#include "app/tx.h"
#include "app/ui/timeline/timeline.h"
#include "base/convert_to.h"
#include "doc/frame_tag.h"
#include "doc/tag.h"
namespace app {
@ -64,20 +65,20 @@ void RemoveFrameTagCommand::onExecute(Context* context)
ContextWriter writer(context);
Sprite* sprite(writer.sprite());
frame_t frame = writer.frame();
FrameTag* foundTag = nullptr;
Tag* foundTag = nullptr;
if (!m_tagName.empty())
foundTag = sprite->frameTags().getByName(m_tagName);
foundTag = sprite->tags().getByName(m_tagName);
else if (m_tagId != NullId)
foundTag = sprite->frameTags().getById(m_tagId);
foundTag = sprite->tags().getById(m_tagId);
else
foundTag = sprite->frameTags().innerTag(frame);
foundTag = sprite->tags().innerTag(frame);
if (!foundTag)
return;
Tx tx(writer.context(), "Remove Frame Tag");
tx(new cmd::RemoveFrameTag(sprite, foundTag));
Tx tx(writer.context(), friendlyName());
tx(new cmd::RemoveTag(sprite, foundTag));
tx.commit();
App::instance()->timeline()->invalidate();

View File

@ -38,8 +38,8 @@
#include "base/fs.h"
#include "base/scoped_value.h"
#include "base/thread.h"
#include "doc/frame_tag.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "fmt/format.h"
#include "ui/ui.h"
#include "undo/undo_state.h"
@ -97,7 +97,7 @@ void SaveFileBaseCommand::onLoadParams(const Params& params)
{
m_filename = params.get("filename");
m_filenameFormat = params.get("filename-format");
m_frameTag = params.get("frame-tag");
m_tag = params.get("frame-tag");
m_aniDir = params.get("ani-dir");
m_slice = params.get("slice");
@ -106,11 +106,11 @@ void SaveFileBaseCommand::onLoadParams(const Params& params)
doc::frame_t fromFrame = params.get_as<doc::frame_t>("from-frame");
doc::frame_t toFrame = params.get_as<doc::frame_t>("to-frame");
m_selFrames.insert(fromFrame, toFrame);
m_adjustFramesByFrameTag = true;
m_adjustFramesByTag = true;
}
else {
m_selFrames.clear();
m_adjustFramesByFrameTag = false;
m_adjustFramesByTag = false;
}
std::string useUI = params.get("useUI");
@ -218,8 +218,8 @@ void SaveFileBaseCommand::saveDocumentInBackground(
}
}
FileOpROI roi(document, m_slice, m_frameTag,
m_selFrames, m_adjustFramesByFrameTag);
FileOpROI roi(document, m_slice, m_tag,
m_selFrames, m_adjustFramesByTag);
std::unique_ptr<FileOp> fop(
FileOp::createSaveDocumentOperation(
@ -446,12 +446,12 @@ void SaveFileCopyAsCommand::onExecute(Context* context)
// Selected frames to export
SelectedFrames selFrames;
FrameTag* frameTag = calculate_selected_frames(
Tag* tag = calculate_selected_frames(
site, frames, selFrames);
if (frameTag)
m_frameTag = frameTag->name();
if (tag)
m_tag = tag->name();
m_selFrames = selFrames;
m_adjustFramesByFrameTag = false;
m_adjustFramesByTag = false;
}
base::ScopedValue<std::string> restoreAniDir(

View File

@ -39,11 +39,11 @@ namespace app {
std::string m_filename;
std::string m_filenameFormat;
std::string m_frameTag;
std::string m_tag;
std::string m_aniDir;
std::string m_slice;
doc::SelectedFrames m_selFrames;
bool m_adjustFramesByFrameTag;
bool m_adjustFramesByTag;
bool m_useUI;
bool m_ignoreEmpty;
};

View File

@ -9,9 +9,9 @@
#endif
#include "app/app.h"
#include "app/cmd/add_frame_tag.h"
#include "app/cmd/remove_frame_tag.h"
#include "app/cmd/set_frame_tag_range.h"
#include "app/cmd/add_tag.h"
#include "app/cmd/remove_tag.h"
#include "app/cmd/set_tag_range.h"
#include "app/commands/command.h"
#include "app/commands/commands.h"
#include "app/commands/params.h"
@ -19,7 +19,7 @@
#include "app/loop_tag.h"
#include "app/tx.h"
#include "app/ui/timeline/timeline.h"
#include "doc/frame_tag.h"
#include "doc/tag.h"
namespace app {
@ -101,21 +101,21 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
}
doc::FrameTag* loopTag = get_loop_tag(sprite);
doc::Tag* loopTag = get_loop_tag(sprite);
if (on) {
if (!loopTag) {
loopTag = create_loop_tag(begin, end);
ContextWriter writer(ctx);
Tx tx(writer.context(), "Add Loop");
tx(new cmd::AddFrameTag(sprite, loopTag));
tx(new cmd::AddTag(sprite, loopTag));
tx.commit();
}
else if (loopTag->fromFrame() != begin ||
loopTag->toFrame() != end) {
ContextWriter writer(ctx);
Tx tx(writer.context(), "Set Loop Range");
tx(new cmd::SetFrameTagRange(loopTag, begin, end));
tx(new cmd::SetTagRange(loopTag, begin, end));
tx.commit();
}
else {
@ -127,7 +127,7 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
if (loopTag) {
ContextWriter writer(ctx);
Tx tx(writer.context(), "Remove Loop");
tx(new cmd::RemoveFrameTag(sprite, loopTag));
tx(new cmd::RemoveTag(sprite, loopTag));
tx.commit();
}
}

View File

@ -25,8 +25,6 @@
#include "doc/cel_io.h"
#include "doc/cels_range.h"
#include "doc/frame.h"
#include "doc/frame_tag.h"
#include "doc/frame_tag_io.h"
#include "doc/image_io.h"
#include "doc/layer.h"
#include "doc/palette.h"
@ -36,6 +34,8 @@
#include "doc/sprite.h"
#include "doc/string_io.h"
#include "doc/subobjects_io.h"
#include "doc/tag.h"
#include "doc/tag_io.h"
#include "fixmath/fixmath.h"
#include <fstream>
@ -320,9 +320,9 @@ private:
return nullptr;
ObjectId tagId = read32(s);
FrameTag* tag = loadObject<FrameTag*>("frtag", tagId, &Reader::readFrameTag);
Tag* tag = loadObject<Tag*>("frtag", tagId, &Reader::readTag);
if (tag)
spr->frameTags().add(tag);
spr->tags().add(tag);
}
}
@ -423,8 +423,8 @@ private:
return read_palette(s);
}
FrameTag* readFrameTag(std::ifstream& s) {
return read_frame_tag(s, false);
Tag* readTag(std::ifstream& s) {
return read_tag(s, false);
}
Slice* readSlice(std::ifstream& s) {

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -24,8 +24,6 @@
#include "doc/cel_io.h"
#include "doc/cels_range.h"
#include "doc/frame.h"
#include "doc/frame_tag.h"
#include "doc/frame_tag_io.h"
#include "doc/image_io.h"
#include "doc/layer.h"
#include "doc/palette.h"
@ -34,6 +32,8 @@
#include "doc/slice_io.h"
#include "doc/sprite.h"
#include "doc/string_io.h"
#include "doc/tag.h"
#include "doc/tag_io.h"
#include "fixmath/fixmath.h"
#include <fstream>
@ -71,7 +71,7 @@ public:
if (!saveObject("pal", pal, &Writer::writePalette))
return false;
for (FrameTag* frtag : spr->frameTags())
for (Tag* frtag : spr->tags())
if (!saveObject("frtag", frtag, &Writer::writeFrameTag))
return false;
@ -158,8 +158,8 @@ private:
write32(s, pal->id());
// IDs of all frame tags
write32(s, spr->frameTags().size());
for (FrameTag* frtag : spr->frameTags())
write32(s, spr->tags().size());
for (Tag* frtag : spr->tags())
write32(s, frtag->id());
// IDs of all slices
@ -248,8 +248,8 @@ private:
return true;
}
bool writeFrameTag(std::ofstream& s, FrameTag* frameTag) {
write_frame_tag(s, frameTag);
bool writeFrameTag(std::ofstream& s, Tag* frameTag) {
write_tag(s, frameTag);
return true;
}

View File

@ -26,12 +26,12 @@
#include "app/util/create_cel_copy.h"
#include "base/memory.h"
#include "doc/cel.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "doc/mask.h"
#include "doc/mask_boundaries.h"
#include "doc/palette.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "os/display.h"
#include "os/system.h"
#include "ui/system.h"
@ -460,8 +460,8 @@ Doc* Doc::duplicate(DuplicateType type) const
spriteCopy->setFrameDuration(i, sourceSprite->frameDuration(i));
// Copy frame tags
for (const FrameTag* tag : sourceSprite->frameTags())
spriteCopy->frameTags().add(new FrameTag(*tag));
for (const Tag* tag : sourceSprite->tags())
spriteCopy->tags().add(new Tag(*tag));
// Copy color palettes
{

View File

@ -26,20 +26,20 @@
#include "app/cmd/move_layer.h"
#include "app/cmd/remove_cel.h"
#include "app/cmd/remove_frame.h"
#include "app/cmd/remove_frame_tag.h"
#include "app/cmd/remove_layer.h"
#include "app/cmd/remove_tag.h"
#include "app/cmd/replace_image.h"
#include "app/cmd/set_cel_bounds.h"
#include "app/cmd/set_cel_frame.h"
#include "app/cmd/set_cel_opacity.h"
#include "app/cmd/set_cel_position.h"
#include "app/cmd/set_frame_duration.h"
#include "app/cmd/set_frame_tag_range.h"
#include "app/cmd/set_mask.h"
#include "app/cmd/set_mask_position.h"
#include "app/cmd/set_palette.h"
#include "app/cmd/set_slice_key.h"
#include "app/cmd/set_sprite_size.h"
#include "app/cmd/set_tag_range.h"
#include "app/cmd/set_total_frames.h"
#include "app/cmd/set_transparent_color.h"
#include "app/color_target.h"
@ -52,11 +52,11 @@
#include "doc/algorithm/flip_image.h"
#include "doc/algorithm/shrink_bounds.h"
#include "doc/cel.h"
#include "doc/frame_tag.h"
#include "doc/frame_tags.h"
#include "doc/mask.h"
#include "doc/palette.h"
#include "doc/slice.h"
#include "doc/tag.h"
#include "doc/tags.h"
#include "render/render.h"
#include <algorithm>
@ -361,9 +361,9 @@ void DocApi::addFrame(Sprite* sprite, frame_t newFrame)
void DocApi::addEmptyFrame(Sprite* sprite, frame_t newFrame)
{
m_transaction.execute(new cmd::AddFrame(sprite, newFrame));
adjustFrameTags(sprite, newFrame, +1,
kDropBeforeFrame,
kDefaultTagsAdjustment);
adjustTags(sprite, newFrame, +1,
kDropBeforeFrame,
kDefaultTagsAdjustment);
}
void DocApi::addEmptyFramesTo(Sprite* sprite, frame_t newFrame)
@ -399,18 +399,18 @@ void DocApi::copyFrame(Sprite* sprite,
}
}
adjustFrameTags(sprite, newFrame0, +1,
dropFramePlace,
tagsHandling);
adjustTags(sprite, newFrame0, +1,
dropFramePlace,
tagsHandling);
}
void DocApi::removeFrame(Sprite* sprite, frame_t frame)
{
ASSERT(frame >= 0);
m_transaction.execute(new cmd::RemoveFrame(sprite, frame));
adjustFrameTags(sprite, frame, -1,
kDropBeforeFrame,
kDefaultTagsAdjustment);
adjustTags(sprite, frame, -1,
kDropBeforeFrame,
kDefaultTagsAdjustment);
}
void DocApi::setTotalFrames(Sprite* sprite, frame_t frames)
@ -446,7 +446,7 @@ void DocApi::moveFrame(Sprite* sprite,
if (frame >= 0 && frame <= sprite->lastFrame() &&
beforeFrame >= 0 && beforeFrame <= sprite->lastFrame()+1 &&
((frame != beforeFrame) ||
(!sprite->frameTags().empty() &&
(!sprite->tags().empty() &&
tagsHandling != kDontAdjustTags))) {
// Change the frame-lengths.
int frlen_aux = sprite->frameDuration(frame);
@ -465,10 +465,10 @@ void DocApi::moveFrame(Sprite* sprite,
}
if (tagsHandling != kDontAdjustTags) {
adjustFrameTags(sprite, frame, -1, dropFramePlace, tagsHandling);
adjustTags(sprite, frame, -1, dropFramePlace, tagsHandling);
if (targetFrame >= frame)
--targetFrame;
adjustFrameTags(sprite, targetFrame, +1, dropFramePlace, tagsHandling);
adjustTags(sprite, targetFrame, +1, dropFramePlace, tagsHandling);
}
// Change cel positions.
@ -806,14 +806,14 @@ void DocApi::setPalette(Sprite* sprite, frame_t frame, const Palette* newPalette
}
}
void DocApi::adjustFrameTags(Sprite* sprite,
const frame_t frame,
const frame_t delta,
const DropFramePlace dropFramePlace,
const TagsHandling tagsHandling)
void DocApi::adjustTags(Sprite* sprite,
const frame_t frame,
const frame_t delta,
const DropFramePlace dropFramePlace,
const TagsHandling tagsHandling)
{
TRACE_DOCAPI(
"\n adjustFrameTags %s frame %d delta=%d tags=%s:\n",
"\n adjustTags %s frame %d delta=%d tags=%s:\n",
(dropFramePlace == kDropBeforeFrame ? "before": "after"),
frame, delta,
(tagsHandling == kDefaultTagsAdjustment ? "default":
@ -823,9 +823,9 @@ void DocApi::adjustFrameTags(Sprite* sprite,
// As FrameTag::setFrameRange() changes m_frameTags, we need to use
// a copy of this collection
std::vector<FrameTag*> tags(sprite->frameTags().begin(), sprite->frameTags().end());
std::vector<Tag*> tags(sprite->tags().begin(), sprite->tags().end());
for (FrameTag* tag : tags) {
for (Tag* tag : tags) {
frame_t from = tag->fromFrame();
frame_t to = tag->toFrame();
@ -866,9 +866,9 @@ void DocApi::adjustFrameTags(Sprite* sprite,
if (from != tag->fromFrame() ||
to != tag->toFrame()) {
if (from > to)
m_transaction.execute(new cmd::RemoveFrameTag(sprite, tag));
m_transaction.execute(new cmd::RemoveTag(sprite, tag));
else
m_transaction.execute(new cmd::SetFrameTagRange(tag, from, to));
m_transaction.execute(new cmd::SetTagRange(tag, from, to));
}
}
}

View File

@ -126,11 +126,11 @@ namespace app {
const bool trimOutside);
void setCelFramePosition(Cel* cel, frame_t frame);
void moveFrameLayer(Layer* layer, frame_t frame, frame_t beforeFrame);
void adjustFrameTags(Sprite* sprite,
const frame_t frame,
const frame_t delta,
const DropFramePlace dropFramePlace,
const TagsHandling tagsHandling);
void adjustTags(Sprite* sprite,
const frame_t frame,
const frame_t delta,
const DropFramePlace dropFramePlace,
const TagsHandling tagsHandling);
class HandleLinkedCels {
public:

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
@ -12,12 +13,12 @@
#include "app/doc.h"
#include "doc/cel.h"
#include "doc/frame_tag.h"
#include "doc/image.h"
#include "doc/layer.h"
#include "doc/palette.h"
#include "doc/primitives.h"
#include "doc/sprite.h"
#include "doc/tag.h"
namespace app {
@ -50,21 +51,21 @@ DocDiff compare_docs(const Doc* a,
}
// Tags
if (a->sprite()->frameTags().size() != b->sprite()->frameTags().size()) {
diff.anything = diff.frameTags = true;
if (a->sprite()->tags().size() != b->sprite()->tags().size()) {
diff.anything = diff.tags = true;
}
else {
auto aIt = a->sprite()->frameTags().begin(), aEnd = a->sprite()->frameTags().end();
auto bIt = b->sprite()->frameTags().begin(), bEnd = b->sprite()->frameTags().end();
auto aIt = a->sprite()->tags().begin(), aEnd = a->sprite()->tags().end();
auto bIt = b->sprite()->tags().begin(), bEnd = b->sprite()->tags().end();
for (; aIt != aEnd && bIt != bEnd; ++aIt, ++bIt) {
const FrameTag* aTag = *aIt;
const FrameTag* bTag = *bIt;
const Tag* aTag = *aIt;
const Tag* bTag = *bIt;
if (aTag->fromFrame() != bTag->fromFrame() ||
aTag->toFrame() != bTag->toFrame() ||
aTag->name() != bTag->name() ||
aTag->color() != bTag->color() ||
aTag->aniDir() != bTag->aniDir()) {
diff.anything = diff.frameTags = true;
diff.anything = diff.tags = true;
}
}
}

View File

@ -16,7 +16,7 @@ namespace app {
bool canvas : 1;
bool totalFrames : 1;
bool frameDuration : 1;
bool frameTags : 1;
bool tags : 1;
bool palettes : 1;
bool layers : 1;
bool cels : 1;
@ -28,7 +28,7 @@ namespace app {
canvas(false),
totalFrames(false),
frameDuration(false),
frameTags(false),
tags(false),
palettes(false),
layers(false),
cels(false),

View File

@ -14,80 +14,78 @@
namespace doc {
class Cel;
class FrameTag;
class Image;
class Layer;
class LayerImage;
class Slice;
class Sprite;
class Tag;
}
namespace app {
class Doc;
using namespace doc;
class DocEvent {
public:
DocEvent(Doc* document)
: m_document(document)
, m_sprite(NULL)
, m_layer(NULL)
, m_cel(NULL)
, m_image(NULL)
DocEvent(Doc* doc)
: m_doc(doc)
, m_sprite(nullptr)
, m_layer(nullptr)
, m_cel(nullptr)
, m_image(nullptr)
, m_imageIndex(-1)
, m_frame(0)
, m_frameTag(nullptr)
, m_tag(nullptr)
, m_slice(nullptr)
, m_targetLayer(NULL)
, m_targetLayer(nullptr)
, m_targetFrame(0) {
}
// Source of the event.
Doc* 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; }
Doc* document() const { return m_doc; }
doc::Sprite* sprite() const { return m_sprite; }
doc::Layer* layer() const { return m_layer; }
doc::Cel* cel() const { return m_cel; }
doc::Image* image() const { return m_image; }
int imageIndex() const { return m_imageIndex; }
frame_t frame() const { return m_frame; }
FrameTag* frameTag() const { return m_frameTag; }
Slice* slice() const { return m_slice; }
doc::frame_t frame() const { return m_frame; }
doc::Tag* tag() const { return m_tag; }
doc::Slice* slice() const { return m_slice; }
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 sprite(doc::Sprite* sprite) { m_sprite = sprite; }
void layer(doc::Layer* layer) { m_layer = layer; }
void cel(doc::Cel* cel) { m_cel = cel; }
void image(doc::Image* image) { m_image = image; }
void imageIndex(int imageIndex) { m_imageIndex = imageIndex; }
void frame(frame_t frame) { m_frame = frame; }
void frameTag(FrameTag* frameTag) { m_frameTag = frameTag; }
void slice(Slice* slice) { m_slice = slice; }
void frame(doc::frame_t frame) { m_frame = frame; }
void tag(doc::Tag* tag) { m_tag = tag; }
void slice(doc::Slice* slice) { m_slice = slice; }
void region(const gfx::Region& rgn) { m_region = rgn; }
// Destination of the operation.
Layer* targetLayer() const { return m_targetLayer; }
frame_t targetFrame() const { return m_targetFrame; }
doc::Layer* targetLayer() const { return m_targetLayer; }
doc::frame_t targetFrame() const { return m_targetFrame; }
void targetLayer(Layer* layer) { m_targetLayer = layer; }
void targetFrame(frame_t frame) { m_targetFrame = frame; }
void targetLayer(doc::Layer* layer) { m_targetLayer = layer; }
void targetFrame(doc::frame_t frame) { m_targetFrame = frame; }
private:
Doc* m_document;
Sprite* m_sprite;
Layer* m_layer;
Cel* m_cel;
Image* m_image;
Doc* m_doc;
doc::Sprite* m_sprite;
doc::Layer* m_layer;
doc::Cel* m_cel;
doc::Image* m_image;
int m_imageIndex;
frame_t m_frame;
FrameTag* m_frameTag;
Slice* m_slice;
doc::frame_t m_frame;
doc::Tag* m_tag;
doc::Slice* m_slice;
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;
frame_t m_targetFrame;
doc::Layer* m_targetLayer;
doc::frame_t m_targetFrame;
};
} // namespace app

View File

@ -27,7 +27,6 @@
#include "base/string.h"
#include "doc/algorithm/shrink_bounds.h"
#include "doc/cel.h"
#include "doc/frame_tag.h"
#include "doc/image.h"
#include "doc/layer.h"
#include "doc/palette.h"
@ -36,6 +35,7 @@
#include "doc/selected_layers.h"
#include "doc/slice.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "gfx/packing_rects.h"
#include "gfx/size.h"
#include "render/dithering.h"
@ -114,11 +114,11 @@ private:
typedef std::shared_ptr<SampleBounds> SampleBoundsPtr;
DocExporter::Item::Item(Doc* doc,
doc::FrameTag* frameTag,
doc::SelectedLayers* selLayers,
doc::SelectedFrames* selFrames)
doc::Tag* tag,
doc::SelectedLayers* selLayers,
doc::SelectedFrames* selFrames)
: doc(doc)
, frameTag(frameTag)
, tag(tag)
, selLayers(selLayers ? new doc::SelectedLayers(*selLayers): nullptr)
, selFrames(selFrames ? new doc::SelectedFrames(*selFrames): nullptr)
{
@ -126,7 +126,7 @@ DocExporter::Item::Item(Doc* doc,
DocExporter::Item::Item(Item&& other)
: doc(other.doc)
, frameTag(other.frameTag)
, tag(other.tag)
, selLayers(other.selLayers)
, selFrames(other.selFrames)
{
@ -144,8 +144,8 @@ int DocExporter::Item::frames() const
{
if (selFrames)
return selFrames->size();
else if (frameTag) {
int result = frameTag->toFrame() - frameTag->fromFrame() + 1;
else if (tag) {
int result = tag->toFrame() - tag->fromFrame() + 1;
return MID(1, result, doc->sprite()->totalFrames());
}
else
@ -158,9 +158,9 @@ doc::SelectedFrames DocExporter::Item::getSelectedFrames() const
return *selFrames;
doc::SelectedFrames frames;
if (frameTag) {
frames.insert(MID(0, frameTag->fromFrame(), doc->sprite()->lastFrame()),
MID(0, frameTag->toFrame(), doc->sprite()->lastFrame()));
if (tag) {
frames.insert(MID(0, tag->fromFrame(), doc->sprite()->lastFrame()),
MID(0, tag->toFrame(), doc->sprite()->lastFrame()));
}
else {
frames.insert(0, doc->sprite()->lastFrame());
@ -398,7 +398,7 @@ DocExporter::DocExporter()
, m_trimCels(false)
, m_trimByGrid(false)
, m_extrude(false)
, m_listFrameTags(false)
, m_listTags(false)
, m_listLayers(false)
, m_listSlices(false)
{
@ -487,7 +487,7 @@ void DocExporter::captureSamples(Samples& samples)
Sprite* sprite = doc->sprite();
Layer* layer = (item.selLayers && item.selLayers->size() == 1 ?
*item.selLayers->begin(): nullptr);
FrameTag* frameTag = item.frameTag;
Tag* tag = item.tag;
int frames = item.frames();
std::string format = m_filenameFormat;
@ -496,13 +496,13 @@ void DocExporter::captureSamples(Samples& samples)
doc->filename(),
(frames > 1), // Has frames
(layer != nullptr), // Has layer
(frameTag != nullptr)); // Has frame tag
(tag != nullptr)); // Has tag
}
frame_t outputFrame = 0;
for (frame_t frame : item.getSelectedFrames()) {
FrameTag* innerTag = (frameTag ? frameTag: sprite->frameTags().innerTag(frame));
FrameTag* outerTag = sprite->frameTags().outerTag(frame);
Tag* innerTag = (tag ? tag: sprite->tags().innerTag(frame));
Tag* outerTag = sprite->tags().outerTag(frame);
FilenameInfo fnInfo;
fnInfo
.filename(doc->filename())
@ -543,7 +543,7 @@ void DocExporter::captureSamples(Samples& samples)
}
// "done" variable can be false here, e.g. when we export a
// frame tag and the first linked cel is outside the tag range.
ASSERT(done || (!done && frameTag));
ASSERT(done || (!done && tag));
}
if (!done && (m_ignoreEmptyCels || m_trimCels)) {
@ -586,7 +586,7 @@ void DocExporter::captureSamples(Samples& samples)
// Should we ignore this empty frame? (i.e. don't include
// the frame in the sprite sheet)
if (m_ignoreEmptyCels) {
for (FrameTag* tag : sprite->frameTags()) {
for (Tag* tag : sprite->tags()) {
auto& delta = m_tagDelta[tag->id()];
if (frame < tag->fromFrame()) --delta.first;
@ -852,16 +852,16 @@ void DocExporter::createDataFile(const Samples& samples, std::ostream& os, Image
<< " \"scale\": \"1\"";
// meta.frameTags
if (m_listFrameTags) {
if (m_listTags) {
os << ",\n"
<< " \"frameTags\": [";
<< " \"frameTags\": ["; // TODO rename this someday in the future
bool firstTag = true;
for (auto& item : m_documents) {
Doc* doc = item.doc;
Sprite* sprite = doc->sprite();
for (FrameTag* tag : sprite->frameTags()) {
for (Tag* tag : sprite->tags()) {
if (firstTag)
firstTag = false;
else

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -22,10 +23,10 @@
#include <vector>
namespace doc {
class FrameTag;
class Image;
class SelectedLayers;
class SelectedFrames;
class SelectedLayers;
class Tag;
}
namespace app {
@ -57,7 +58,7 @@ namespace app {
bool trimByGrid() const { return m_trimByGrid; }
bool extrude() const { return m_extrude; }
const std::string& filenameFormat() const { return m_filenameFormat; }
bool listFrameTags() const { return m_listFrameTags; }
bool listTags() const { return m_listTags; }
bool listLayers() const { return m_listLayers; }
void setDataFormat(DataFormat format) { m_dataFormat = format; }
@ -74,12 +75,12 @@ namespace app {
void setTrimByGrid(bool trimByGrid) { m_trimByGrid = trimByGrid; }
void setExtrude(bool extrude) { m_extrude = extrude; }
void setFilenameFormat(const std::string& format) { m_filenameFormat = format; }
void setListFrameTags(bool value) { m_listFrameTags = value; }
void setListTags(bool value) { m_listTags = value; }
void setListLayers(bool value) { m_listLayers = value; }
void setListSlices(bool value) { m_listSlices = value; }
void addDocument(Doc* document,
doc::FrameTag* tag,
doc::Tag* tag,
doc::SelectedLayers* selLayers,
doc::SelectedFrames* selFrames) {
m_documents.push_back(Item(document, tag, selLayers, selFrames));
@ -106,12 +107,12 @@ namespace app {
class Item {
public:
Doc* doc;
doc::FrameTag* frameTag;
doc::Tag* tag;
doc::SelectedLayers* selLayers;
doc::SelectedFrames* selFrames;
Item(Doc* doc,
doc::FrameTag* frameTag,
doc::Tag* tag,
doc::SelectedLayers* selLayers,
doc::SelectedFrames* selFrames);
Item(Item&& other);
@ -142,7 +143,7 @@ namespace app {
Items m_documents;
std::string m_filenameFormat;
doc::ImageBufferPtr m_sampleRenderBuf;
bool m_listFrameTags;
bool m_listTags;
bool m_listLayers;
bool m_listSlices;

View File

@ -31,7 +31,7 @@ namespace app {
virtual void onAddFrame(DocEvent& ev) { }
virtual void onAddCel(DocEvent& ev) { }
virtual void onAddSlice(DocEvent& ev) { }
virtual void onAddFrameTag(DocEvent& ev) { }
virtual void onAddTag(DocEvent& ev) { }
virtual void onBeforeRemoveLayer(DocEvent& ev) { }
virtual void onAfterRemoveLayer(DocEvent& ev) { }
@ -39,7 +39,7 @@ namespace app {
// 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(DocEvent& ev) { }
virtual void onRemoveFrameTag(DocEvent& ev) { }
virtual void onRemoveTag(DocEvent& ev) { }
virtual void onRemoveCel(DocEvent& ev) { }
virtual void onRemoveSlice(DocEvent& ev) { }

View File

@ -264,7 +264,7 @@ static DocRange drop_range_op(
(place == kDocRangeBefore && to.firstFrame() == from.lastFrame()+1) ||
(place == kDocRangeAfter && to.lastFrame() == from.firstFrame()-1)) &&
// If there are tags, this might not be a no-op
(sprite->frameTags().empty() ||
(sprite->tags().empty() ||
tagsHandling == kDontAdjustTags)) {
return from;
}

View File

@ -1285,10 +1285,10 @@ TEST(DocRangeOps2, DropInsideBugs) {
}
TEST_F(DocRangeOps, MoveRangeWithTags) {
FrameTag* a = new FrameTag(0, 2);
FrameTag* b = new FrameTag(3, 5);
sprite->frameTags().add(a);
sprite->frameTags().add(b);
auto a = new Tag(0, 2);
auto b = new Tag(3, 5);
sprite->tags().add(a);
sprite->tags().add(b);
EXPECT_EQ(0, a->fromFrame());
EXPECT_EQ(2, a->toFrame());
@ -1467,10 +1467,10 @@ TEST_F(DocRangeOps, MoveRangeWithTags) {
}
TEST_F(DocRangeOps, CopyRangeWithTags) {
FrameTag* a = new FrameTag(0, 2);
FrameTag* b = new FrameTag(3, 5);
sprite->frameTags().add(a);
sprite->frameTags().add(b);
auto a = new Tag(0, 2);
auto b = new Tag(3, 5);
sprite->tags().add(a);
sprite->tags().add(b);
EXPECT_EQ(0, a->fromFrame());
EXPECT_EQ(2, a->toFrame());

View File

@ -120,7 +120,7 @@ static void ase_file_write_color_profile(FILE* f,
#if 0
static void ase_file_write_mask_chunk(FILE* f, dio::AsepriteFrameHeader* frame_header, Mask* mask);
#endif
static void ase_file_write_tags_chunk(FILE* f, dio::AsepriteFrameHeader* frame_header, const FrameTags* frameTags,
static void ase_file_write_tags_chunk(FILE* f, dio::AsepriteFrameHeader* frame_header, const Tags* tags,
const frame_t fromFrame, const frame_t toFrame);
static void ase_file_write_slice_chunks(FILE* f, dio::AsepriteFrameHeader* frame_header, const Slices& slices,
const frame_t fromFrame, const frame_t toFrame);
@ -172,7 +172,7 @@ class AseFormat : public FileFormat {
FILE_SUPPORT_LAYERS |
FILE_SUPPORT_FRAMES |
FILE_SUPPORT_PALETTES |
FILE_SUPPORT_FRAME_TAGS |
FILE_SUPPORT_TAGS |
FILE_SUPPORT_BIG_PALETTES |
FILE_SUPPORT_PALETTE_WITH_ALPHA;
}
@ -304,8 +304,8 @@ bool AseFormat::onSave(FileOp* fop)
ase_file_write_layers(f, &frame_header, child, 0);
// Writer frame tags
if (sprite->frameTags().size() > 0)
ase_file_write_tags_chunk(f, &frame_header, &sprite->frameTags(),
if (sprite->tags().size() > 0)
ase_file_write_tags_chunk(f, &frame_header, &sprite->tags(),
fop->roi().fromFrame(),
fop->roi().toFrame());
@ -921,25 +921,28 @@ static void ase_file_write_mask_chunk(FILE* f, dio::AsepriteFrameHeader* frame_h
}
#endif
static void ase_file_write_tags_chunk(FILE* f, dio::AsepriteFrameHeader* frame_header, const FrameTags* frameTags,
const frame_t fromFrame, const frame_t toFrame)
static void ase_file_write_tags_chunk(FILE* f,
dio::AsepriteFrameHeader* frame_header,
const Tags* tags,
const frame_t fromFrame,
const frame_t toFrame)
{
ChunkWriter chunk(f, frame_header, ASE_FILE_CHUNK_TAGS);
int tags = 0;
for (const FrameTag* tag : *frameTags) {
int ntags = 0;
for (const Tag* tag : *tags) {
// Skip tags that are outside of the given ROI
if (tag->fromFrame() > toFrame ||
tag->toFrame() < fromFrame)
continue;
++tags;
++ntags;
}
fputw(tags, f);
fputw(ntags, f);
fputl(0, f); // 8 reserved bytes
fputl(0, f);
for (const FrameTag* tag : *frameTags) {
for (const Tag* tag : *tags) {
if (tag->fromFrame() > toFrame ||
tag->toFrame() < fromFrame)
continue;

View File

@ -138,18 +138,18 @@ bool is_static_image_format(const std::string& filename)
FileOpROI::FileOpROI()
: m_document(nullptr)
, m_slice(nullptr)
, m_frameTag(nullptr)
, m_tag(nullptr)
{
}
FileOpROI::FileOpROI(const Doc* doc,
const std::string& sliceName,
const std::string& frameTagName,
const std::string& tagName,
const doc::SelectedFrames& selFrames,
const bool adjustByFrameTag)
const bool adjustByTag)
: m_document(doc)
, m_slice(nullptr)
, m_frameTag(nullptr)
, m_tag(nullptr)
, m_selFrames(selFrames)
{
if (doc) {
@ -157,18 +157,18 @@ FileOpROI::FileOpROI(const Doc* doc,
m_slice = doc->sprite()->slices().getByName(sliceName);
// Don't allow exporting frame tags with empty names
if (!frameTagName.empty())
m_frameTag = doc->sprite()->frameTags().getByName(frameTagName);
if (!tagName.empty())
m_tag = doc->sprite()->tags().getByName(tagName);
if (m_frameTag) {
if (m_tag) {
if (m_selFrames.empty())
m_selFrames.insert(m_frameTag->fromFrame(), m_frameTag->toFrame());
else if (adjustByFrameTag)
m_selFrames.displace(m_frameTag->fromFrame());
m_selFrames.insert(m_tag->fromFrame(), m_tag->toFrame());
else if (adjustByTag)
m_selFrames.displace(m_tag->fromFrame());
m_selFrames =
m_selFrames.filter(MAX(0, m_frameTag->fromFrame()),
MIN(m_frameTag->toFrame(), doc->sprite()->lastFrame()));
m_selFrames.filter(MAX(0, m_tag->fromFrame()),
MIN(m_tag->toFrame(), doc->sprite()->lastFrame()));
}
// All frames if selected frames is empty
else if (m_selFrames.empty())
@ -424,9 +424,9 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
}
// Check frames support
if (!fop->m_document->sprite()->frameTags().empty()) {
if (!fop->m_format->support(FILE_SUPPORT_FRAME_TAGS)) {
warnings += "<<- " + Strings::alerts_file_format_frame_tags();
if (!fop->m_document->sprite()->tags().empty()) {
if (!fop->m_format->support(FILE_SUPPORT_TAGS)) {
warnings += "<<- " + Strings::alerts_file_format_tags();
}
}
@ -507,8 +507,8 @@ FileOp* FileOp::createSaveDocumentOperation(const Context* context,
frame_t outputFrame = 0;
for (frame_t frame : fop->m_roi.selectedFrames()) {
FrameTag* innerTag = (fop->m_roi.frameTag() ? fop->m_roi.frameTag(): spr->frameTags().innerTag(frame));
FrameTag* outerTag = (fop->m_roi.frameTag() ? fop->m_roi.frameTag(): spr->frameTags().outerTag(frame));
Tag* innerTag = (fop->m_roi.tag() ? fop->m_roi.tag(): spr->tags().innerTag(frame));
Tag* outerTag = (fop->m_roi.tag() ? fop->m_roi.tag(): spr->tags().outerTag(frame));
FilenameInfo fnInfo;
fnInfo
.filename(fn)

View File

@ -35,7 +35,7 @@
#define FILE_LOAD_CREATE_PALETTE 0x00000040
namespace doc {
class FrameTag;
class Tag;
}
namespace doc {
@ -72,13 +72,13 @@ namespace app {
FileOpROI();
FileOpROI(const Doc* doc,
const std::string& sliceName,
const std::string& frameTagName,
const std::string& tagName,
const doc::SelectedFrames& selFrames,
const bool adjustByFrameTag);
const bool adjustByTag);
const Doc* document() const { return m_document; }
doc::Slice* slice() const { return m_slice; }
doc::FrameTag* frameTag() const { return m_frameTag; }
doc::Tag* tag() const { return m_tag; }
doc::frame_t fromFrame() const { return m_selFrames.firstFrame(); }
doc::frame_t toFrame() const { return m_selFrames.lastFrame(); }
const doc::SelectedFrames& selectedFrames() const { return m_selFrames; }
@ -90,7 +90,7 @@ namespace app {
private:
const Doc* m_document;
doc::Slice* m_slice;
doc::FrameTag* m_frameTag;
doc::Tag* m_tag;
doc::SelectedFrames m_selFrames;
};

View File

@ -27,7 +27,7 @@
#define FILE_SUPPORT_PALETTES 0x00000200
#define FILE_SUPPORT_SEQUENCES 0x00000400
#define FILE_SUPPORT_GET_FORMAT_OPTIONS 0x00000800
#define FILE_SUPPORT_FRAME_TAGS 0x00001000
#define FILE_SUPPORT_TAGS 0x00001000
#define FILE_SUPPORT_BIG_PALETTES 0x00002000 // Palettes w/more than 256 colors
#define FILE_SUPPORT_PALETTE_WITH_ALPHA 0x00004000

View File

@ -129,7 +129,7 @@ std::string get_default_filename_format(
const bool withPath,
const bool hasFrames,
const bool hasLayer,
const bool hasFrameTag)
const bool hasTag)
{
std::string format;
@ -141,7 +141,7 @@ std::string get_default_filename_format(
if (hasLayer)
format += " ({layer})";
if (hasFrameTag)
if (hasTag)
format += " #{tag}";
if (hasFrames && is_static_image_format(filename) &&
@ -149,7 +149,7 @@ std::string get_default_filename_format(
filename.find("{tagframe") == std::string::npos) {
const bool autoFrameFromLastDigit =
(!hasLayer &&
!hasFrameTag);
!hasTag);
// Check if we already have a frame number at the end of the
// filename (e.g. output01.png)
@ -161,7 +161,7 @@ std::string get_default_filename_format(
std::vector<char> buf(32);
std::sprintf(&buf[0], "{frame%0*d}", frameWidth, frameBase);
if (hasLayer || hasFrameTag)
if (hasLayer || hasTag)
format += " ";
format += &buf[0];
@ -174,7 +174,7 @@ std::string get_default_filename_format(
// Do nothing
}
else {
if (hasLayer || hasFrameTag)
if (hasLayer || hasTag)
format += " {frame}";
else
format += "{frame1}";
@ -189,14 +189,14 @@ std::string get_default_filename_format_for_sheet(
const std::string& filename,
const bool hasFrames,
const bool hasLayer,
const bool hasFrameTag)
const bool hasTag)
{
std::string format = "{title}";
if (hasLayer)
format += " ({layer})";
if (hasFrameTag)
if (hasTag)
format += " #{tag}";
if (hasFrames) {

View File

@ -100,13 +100,13 @@ namespace app {
const bool withPath,
const bool hasFrames,
const bool hasLayer,
const bool hasFrameTag);
const bool hasTag);
std::string get_default_filename_format_for_sheet(
const std::string& filename,
const bool hasFrames,
const bool hasLayer,
const bool hasFrameTag);
const bool hasTag);
} // namespace app

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -11,30 +12,30 @@
#include "app/loop_tag.h"
#include "doc/sprite.h"
#include "doc/frame_tag.h"
#include "doc/tag.h"
namespace app {
const char* kLoopTagName = "Loop";
doc::FrameTag* get_animation_tag(const doc::Sprite* sprite, doc::frame_t frame)
doc::Tag* get_animation_tag(const doc::Sprite* sprite, doc::frame_t frame)
{
return sprite->frameTags().innerTag(frame);
return sprite->tags().innerTag(frame);
}
doc::FrameTag* get_loop_tag(const doc::Sprite* sprite)
doc::Tag* get_loop_tag(const doc::Sprite* sprite)
{
// Get tag with special "Loop" name
for (doc::FrameTag* tag : sprite->frameTags())
for (doc::Tag* tag : sprite->tags())
if (tag->name() == kLoopTagName)
return tag;
return nullptr;
}
doc::FrameTag* create_loop_tag(doc::frame_t from, doc::frame_t to)
doc::Tag* create_loop_tag(doc::frame_t from, doc::frame_t to)
{
doc::FrameTag* tag = new doc::FrameTag(from, to);
doc::Tag* tag = new doc::Tag(from, to);
tag->setName(kLoopTagName);
return tag;
}

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -11,22 +12,22 @@
#include "doc/frame.h"
namespace doc {
class FrameTag;
class Sprite;
class Tag;
}
namespace app {
class FrameTagProvider {
class TagProvider {
public:
virtual ~FrameTagProvider() { }
virtual doc::FrameTag* getFrameTagByFrame(const doc::frame_t frame,
const bool getLoopTagIfNone) = 0;
virtual ~TagProvider() { }
virtual doc::Tag* getTagByFrame(const doc::frame_t frame,
const bool getLoopTagIfNone) = 0;
};
doc::FrameTag* get_animation_tag(const doc::Sprite* sprite, doc::frame_t frame);
doc::FrameTag* get_loop_tag(const doc::Sprite* sprite);
doc::FrameTag* create_loop_tag(doc::frame_t from, doc::frame_t to);
doc::Tag* get_animation_tag(const doc::Sprite* sprite, doc::frame_t frame);
doc::Tag* get_loop_tag(const doc::Sprite* sprite);
doc::Tag* create_loop_tag(doc::frame_t from, doc::frame_t to);
} // namespace app

View File

@ -39,9 +39,9 @@
#include "base/fs.h"
#include "base/replace_string.h"
#include "base/version.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "doc/primitives.h"
#include "doc/tag.h"
#include "render/render.h"
#include "ui/alert.h"
@ -403,14 +403,14 @@ int App_get_activeImage(lua_State* L)
int App_get_activeTag(lua_State* L)
{
FrameTag* tag = nullptr;
Tag* tag = nullptr;
app::Context* ctx = App::instance()->context();
Site site = ctx->activeSite();
if (site.sprite()) {
#ifdef ENABLE_UI
if (App::instance()->timeline()) {
tag = App::instance()->timeline()->getFrameTagByFrame(site.frame(), false);
tag = App::instance()->timeline()->getTagByFrame(site.frame(), false);
}
else
#endif

View File

@ -36,13 +36,13 @@ namespace gfx {
namespace doc {
class Cel;
class FrameTag;
class Image;
class Layer;
class LayerGroup;
class Mask;
class Palette;
class Sprite;
class Tag;
class WithUserData;
}

View File

@ -15,9 +15,9 @@
#include "app/cmd/clear_cel.h"
#include "app/cmd/convert_color_profile.h"
#include "app/cmd/flatten_layers.h"
#include "app/cmd/remove_frame_tag.h"
#include "app/cmd/remove_layer.h"
#include "app/cmd/remove_slice.h"
#include "app/cmd/remove_tag.h"
#include "app/cmd/set_mask.h"
#include "app/cmd/set_sprite_size.h"
#include "app/cmd/set_transparent_color.h"
@ -40,12 +40,12 @@
#include "app/ui/doc_view.h"
#include "base/convert_to.h"
#include "base/fs.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "doc/mask.h"
#include "doc/palette.h"
#include "doc/slice.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include <algorithm>
@ -502,10 +502,10 @@ int Sprite_newTag(lua_State* L)
auto sprite = get_docobj<Sprite>(L, 1);
auto from = get_frame_number_from_arg(L, 2);
auto to = get_frame_number_from_arg(L, 3);
auto tag = new doc::FrameTag(from, to);
auto tag = new doc::Tag(from, to);
Tx tx;
tx(new cmd::AddFrameTag(sprite, tag));
tx(new cmd::AddTag(sprite, tag));
tx.commit();
push_docobj(L, tag);
@ -515,15 +515,15 @@ int Sprite_newTag(lua_State* L)
int Sprite_deleteTag(lua_State* L)
{
auto sprite = get_docobj<Sprite>(L, 1);
auto tag = may_get_docobj<FrameTag>(L, 2);
auto tag = may_get_docobj<Tag>(L, 2);
if (!tag && lua_isstring(L, 2)) {
const char* tagName = lua_tostring(L, 2);
if (tagName)
tag = sprite->frameTags().getByName(tagName);
tag = sprite->tags().getByName(tagName);
}
if (tag) {
Tx tx;
tx(new cmd::RemoveFrameTag(sprite, tag));
tx(new cmd::RemoveTag(sprite, tag));
tx.commit();
return 0;
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
@ -9,15 +9,15 @@
#include "config.h"
#endif
#include "app/cmd/set_frame_tag_anidir.h"
#include "app/cmd/set_frame_tag_name.h"
#include "app/cmd/set_frame_tag_range.h"
#include "app/cmd/set_tag_anidir.h"
#include "app/cmd/set_tag_name.h"
#include "app/cmd/set_tag_range.h"
#include "app/script/docobj.h"
#include "app/script/engine.h"
#include "app/script/luacpp.h"
#include "app/tx.h"
#include "doc/frame_tag.h"
#include "doc/sprite.h"
#include "doc/tag.h"
namespace app {
namespace script {
@ -28,22 +28,22 @@ namespace {
int Tag_eq(lua_State* L)
{
const auto a = get_docobj<FrameTag>(L, 1);
const auto b = get_docobj<FrameTag>(L, 2);
const auto a = get_docobj<Tag>(L, 1);
const auto b = get_docobj<Tag>(L, 2);
lua_pushboolean(L, a->id() == b->id());
return 1;
}
int Tag_get_sprite(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
push_docobj(L, tag->owner()->sprite());
return 1;
}
int Tag_get_fromFrame(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
if (tag->owner()->sprite())
push_sprite_frame(L, tag->owner()->sprite(), tag->fromFrame());
else
@ -53,7 +53,7 @@ int Tag_get_fromFrame(lua_State* L)
int Tag_get_toFrame(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
if (tag->owner()->sprite())
push_sprite_frame(L, tag->owner()->sprite(), tag->toFrame());
else
@ -63,42 +63,42 @@ int Tag_get_toFrame(lua_State* L)
int Tag_get_frames(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
lua_pushinteger(L, tag->frames());
return 1;
}
int Tag_get_name(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
lua_pushstring(L, tag->name().c_str());
return 1;
}
int Tag_get_aniDir(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
lua_pushinteger(L, (int)tag->aniDir());
return 1;
}
int Tag_set_fromFrame(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
const auto fromFrame = get_frame_number_from_arg(L, 2);
Tx tx;
tx(new cmd::SetFrameTagRange(tag, fromFrame,
std::max(fromFrame, tag->toFrame())));
tx(new cmd::SetTagRange(tag, fromFrame,
std::max(fromFrame, tag->toFrame())));
tx.commit();
return 0;
}
int Tag_set_toFrame(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
const auto toFrame = get_frame_number_from_arg(L, 2);
Tx tx;
tx(new cmd::SetFrameTagRange(tag,
tx(new cmd::SetTagRange(tag,
std::min(tag->fromFrame(), toFrame),
toFrame));
tx.commit();
@ -107,11 +107,11 @@ int Tag_set_toFrame(lua_State* L)
int Tag_set_name(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
const char* name = lua_tostring(L, 2);
if (name) {
Tx tx;
tx(new cmd::SetFrameTagName(tag, name));
tx(new cmd::SetTagName(tag, name));
tx.commit();
}
return 0;
@ -119,10 +119,10 @@ int Tag_set_name(lua_State* L)
int Tag_set_aniDir(lua_State* L)
{
auto tag = get_docobj<FrameTag>(L, 1);
auto tag = get_docobj<Tag>(L, 1);
const int aniDir = lua_tointeger(L, 2);
Tx tx;
tx(new cmd::SetFrameTagAniDir(tag, (doc::AniDir)aniDir));
tx(new cmd::SetTagAniDir(tag, (doc::AniDir)aniDir));
tx.commit();
return 0;
}
@ -144,11 +144,11 @@ const Property Tag_properties[] = {
} // anonymous namespace
DEF_MTNAME(FrameTag);
DEF_MTNAME(Tag);
void register_tag_class(lua_State* L)
{
using Tag = doc::FrameTag;
using Tag = doc::Tag;
REG_CLASS(L, Tag);
REG_CLASS_PROPERTIES(L, Tag);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This program is distributed under the terms of
@ -12,8 +12,8 @@
#include "app/script/docobj.h"
#include "app/script/engine.h"
#include "app/script/luacpp.h"
#include "doc/frame_tag.h"
#include "doc/sprite.h"
#include "doc/tag.h"
namespace app {
namespace script {
@ -42,14 +42,14 @@ int Tags_gc(lua_State* L)
int Tags_len(lua_State* L)
{
auto obj = get_obj<TagsObj>(L, 1);
lua_pushinteger(L, obj->sprite(L)->frameTags().size());
lua_pushinteger(L, obj->sprite(L)->tags().size());
return 1;
}
int Tags_index(lua_State* L)
{
auto obj = get_obj<TagsObj>(L, 1);
auto& tags = obj->sprite(L)->frameTags();
auto& tags = obj->sprite(L)->tags();
const int i = lua_tonumber(L, 2);
if (i >= 1 && i <= int(tags.size()))
push_docobj(L, *(tags.begin()+i-1));

View File

@ -104,7 +104,7 @@ public:
return KeyboardShortcuts::instance()->getCurrentActionModifiers(context);
}
FrameTagProvider* getFrameTagProvider() override {
TagProvider* getTagProvider() override {
return App::instance()->mainWindow()->getTimeline();
}
@ -187,7 +187,7 @@ public:
return KeyAction::None;
}
FrameTagProvider* getFrameTagProvider() override {
TagProvider* getTagProvider() override {
return App::instance()->mainWindow()->getTimeline();
}
};

View File

@ -631,9 +631,9 @@ void Editor::drawOneSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& sprite
opts.opacityStep(m_docPref.onionskin.opacityStep());
opts.layer(m_docPref.onionskin.currentLayer() ? m_layer: nullptr);
FrameTag* tag = nullptr;
Tag* tag = nullptr;
if (m_docPref.onionskin.loopTag())
tag = m_sprite->frameTags().innerTag(m_frame);
tag = m_sprite->tags().innerTag(m_frame);
opts.loopTag(tag);
m_renderEngine->setOnionskin(opts);
@ -2127,16 +2127,16 @@ void Editor::onRemoveCel(DocEvent& ev)
m_showGuidesThisCel = nullptr;
}
void Editor::onAddFrameTag(DocEvent& ev)
void Editor::onAddTag(DocEvent& ev)
{
m_tagFocusBand = -1;
}
void Editor::onRemoveFrameTag(DocEvent& ev)
void Editor::onRemoveTag(DocEvent& ev)
{
m_tagFocusBand = -1;
if (m_state)
m_state->onRemoveFrameTag(this, ev.frameTag());
m_state->onRemoveTag(this, ev.tag());
}
void Editor::onRemoveSlice(DocEvent& ev)

View File

@ -320,8 +320,8 @@ namespace app {
void onSpritePixelRatioChanged(DocEvent& ev) override;
void onBeforeRemoveLayer(DocEvent& ev) override;
void onRemoveCel(DocEvent& ev) override;
void onAddFrameTag(DocEvent& ev) override;
void onRemoveFrameTag(DocEvent& ev) override;
void onAddTag(DocEvent& ev) override;
void onRemoveTag(DocEvent& ev) override;
void onRemoveSlice(DocEvent& ev) override;
// ActiveToolObserver impl

View File

@ -16,7 +16,7 @@ namespace tools {
namespace app {
class Editor;
class FrameTagProvider;
class TagProvider;
class EditorCustomizationDelegate {
public:
@ -32,7 +32,7 @@ namespace app {
virtual KeyAction getPressedKeyAction(KeyContext context) = 0;
// Returns the provider of active frame tag (it's the timeline).
virtual FrameTagProvider* getFrameTagProvider() = 0;
virtual TagProvider* getTagProvider() = 0;
};
} // namespace app

View File

@ -25,7 +25,7 @@ namespace ui {
}
namespace doc {
class FrameTag;
class Tag;
}
namespace app {
@ -130,7 +130,7 @@ namespace app {
virtual tools::Ink* getStateInk() const { return nullptr; }
// Called when a tag is deleted.
virtual void onRemoveFrameTag(Editor* editor, doc::FrameTag* tag) { }
virtual void onRemoveTag(Editor* editor, doc::Tag* tag) { }
private:
DISABLE_COPYING(EditorState);

View File

@ -20,8 +20,8 @@
#include "app/ui/editor/scrolling_state.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui_context.h"
#include "doc/frame_tag.h"
#include "doc/handle_anidir.h"
#include "doc/tag.h"
#include "ui/manager.h"
#include "ui/message.h"
#include "ui/system.h"
@ -63,8 +63,8 @@ void PlayState::onEnterState(Editor* editor)
if (!m_playAll)
m_tag = m_editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(m_refFrame, true);
->getTagProvider()
->getTagByFrame(m_refFrame, true);
// Go to the first frame of the animation or active frame tag
if (m_playOnce) {
@ -167,7 +167,7 @@ bool PlayState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
return true;
}
void PlayState::onRemoveFrameTag(Editor* editor, doc::FrameTag* tag)
void PlayState::onRemoveTag(Editor* editor, doc::Tag* tag)
{
if (m_tag == tag)
m_tag = nullptr;

View File

@ -15,7 +15,7 @@
#include "ui/timer.h"
namespace doc {
class FrameTag;
class Tag;
}
namespace app {
@ -35,7 +35,7 @@ namespace app {
bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
bool onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos) override;
void onRemoveFrameTag(Editor* editor, doc::FrameTag* tag) override;
void onRemoveTag(Editor* editor, doc::Tag* tag) override;
private:
void onPlaybackTick();
@ -58,7 +58,7 @@ namespace app {
bool m_pingPongForward;
doc::frame_t m_refFrame;
doc::FrameTag* m_tag;
doc::Tag* m_tag;
obs::scoped_connection m_ctxConn;
};

View File

@ -21,8 +21,8 @@
#include "base/convert_to.h"
#include "base/fs.h"
#include "base/string.h"
#include "doc/frame_tag.h"
#include "doc/selected_frames.h"
#include "doc/tag.h"
#include "fmt/format.h"
#include "ui/alert.h"
@ -170,10 +170,10 @@ void ExportFileWindow::updateAniDir()
framesValue != kAllFrames &&
framesValue != kSelectedFrames) {
SelectedFrames selFrames;
FrameTag* frameTag = calculate_selected_frames(
Tag* tag = calculate_selected_frames(
UIContext::instance()->activeSite(), framesValue, selFrames);
if (frameTag)
anidir()->setSelectedItemIndex(int(frameTag->aniDir()));
if (tag)
anidir()->setSelectedItemIndex(int(tag->aniDir()));
}
else
anidir()->setSelectedItemIndex(int(doc::AniDir::FORWARD));

View File

@ -13,11 +13,11 @@
#include "app/restore_visible_layers.h"
#include "app/site.h"
#include "doc/anidir.h"
#include "doc/frame_tag.h"
#include "doc/layer.h"
#include "doc/selected_frames.h"
#include "doc/selected_layers.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "ui/combobox.h"
namespace app {
@ -49,7 +49,7 @@ std::string LayerListItem::buildName(const doc::Layer* layer)
return name;
}
FrameListItem::FrameListItem(doc::FrameTag* tag)
FrameListItem::FrameListItem(doc::Tag* tag)
: ListItem("Tag: " + tag->name())
, m_tag(tag)
{
@ -85,7 +85,7 @@ void fill_frames_combobox(const doc::Sprite* sprite, ui::ComboBox* frames, const
if (defFrame == kSelectedFrames)
frames->setSelectedItemIndex(i);
for (auto tag : sprite->frameTags()) {
for (auto tag : sprite->tags()) {
// Don't allow to select empty frame tags
if (tag->name().empty())
continue;
@ -134,11 +134,11 @@ void calculate_visible_layers(Site& site,
}
}
doc::FrameTag* calculate_selected_frames(const Site& site,
const std::string& framesValue,
doc::SelectedFrames& selFrames)
doc::Tag* calculate_selected_frames(const Site& site,
const std::string& framesValue,
doc::SelectedFrames& selFrames)
{
doc::FrameTag* frameTag = nullptr;
doc::Tag* tag = nullptr;
if (framesValue == kSelectedFrames) {
if (!site.selectedFrames().empty()) {
@ -149,17 +149,17 @@ doc::FrameTag* calculate_selected_frames(const Site& site,
}
}
else if (framesValue != kAllFrames) {
frameTag = site.sprite()->frameTags().getByName(framesValue);
if (frameTag)
selFrames.insert(frameTag->fromFrame(),
frameTag->toFrame());
tag = site.sprite()->tags().getByName(framesValue);
if (tag)
selFrames.insert(tag->fromFrame(),
tag->toFrame());
else
selFrames.insert(0, site.sprite()->lastFrame());
}
else
selFrames.insert(0, site.sprite()->lastFrame());
return frameTag;
return tag;
}
} // namespace app

View File

@ -14,11 +14,11 @@
#include <string>
namespace doc {
class FrameTag;
class Layer;
class SelectedFrames;
class SelectedLayers;
class Sprite;
class Tag;
}
namespace ui {
@ -45,10 +45,10 @@ namespace app {
class FrameListItem : public ui::ListItem {
public:
FrameListItem(doc::FrameTag* tag);
doc::FrameTag* tag() const { return m_tag; }
FrameListItem(doc::Tag* tag);
doc::Tag* tag() const { return m_tag; }
private:
doc::FrameTag* m_tag;
doc::Tag* m_tag;
};
void fill_layers_combobox(const doc::Sprite* sprite, ui::ComboBox* layers, const std::string& defLayer);
@ -59,9 +59,9 @@ namespace app {
const std::string& layersValue,
RestoreVisibleLayers& layersVisibility);
doc::FrameTag* calculate_selected_frames(const Site& site,
const std::string& framesValue,
doc::SelectedFrames& selFrames);
doc::Tag* calculate_selected_frames(const Site& site,
const std::string& framesValue,
doc::SelectedFrames& selFrames);
} // namespace app

View File

@ -35,7 +35,7 @@
#include "ui/message.h"
#include "ui/system.h"
#include "doc/frame_tag.h"
#include "doc/tag.h"
namespace app {
@ -397,15 +397,15 @@ void PreviewEditorWindow::updateUsingEditor(Editor* editor)
}
else {
if (miniEditor->isPlaying()) {
doc::FrameTag* tag = editor
doc::Tag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(editor->frame(), true);
->getTagProvider()
->getTagByFrame(editor->frame(), true);
doc::FrameTag* playingTag = editor
doc::Tag* playingTag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(m_refFrame, true);
->getTagProvider()
->getTagByFrame(m_refFrame, true);
if (tag == playingTag)
return;

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
@ -8,44 +9,44 @@
#include "config.h"
#endif
#include "app/ui/frame_tag_window.h"
#include "app/ui/tag_window.h"
#include "app/doc.h"
#include "app/pref/preferences.h"
#include "app/ui/layer_frame_comboboxes.h"
#include "doc/frame_tag.h"
#include "doc/sprite.h"
#include "doc/tag.h"
namespace app {
FrameTagWindow::FrameTagWindow(const doc::Sprite* sprite, const doc::FrameTag* frameTag)
TagWindow::TagWindow(const doc::Sprite* sprite, const doc::Tag* tag)
: m_sprite(sprite)
, m_base(Preferences::instance().document(
static_cast<Doc*>(sprite->document())).timeline.firstFrame())
{
name()->setText(frameTag->name());
from()->setTextf("%d", frameTag->fromFrame()+m_base);
to()->setTextf("%d", frameTag->toFrame()+m_base);
name()->setText(tag->name());
from()->setTextf("%d", tag->fromFrame()+m_base);
to()->setTextf("%d", tag->toFrame()+m_base);
color()->setColor(app::Color::fromRgb(
doc::rgba_getr(frameTag->color()),
doc::rgba_getg(frameTag->color()),
doc::rgba_getb(frameTag->color())));
doc::rgba_getr(tag->color()),
doc::rgba_getg(tag->color()),
doc::rgba_getb(tag->color())));
fill_anidir_combobox(anidir(), frameTag->aniDir());
fill_anidir_combobox(anidir(), tag->aniDir());
}
bool FrameTagWindow::show()
bool TagWindow::show()
{
openWindowInForeground();
return (closer() == ok());
}
std::string FrameTagWindow::nameValue()
std::string TagWindow::nameValue()
{
return name()->text();
}
void FrameTagWindow::rangeValue(doc::frame_t& from, doc::frame_t& to)
void TagWindow::rangeValue(doc::frame_t& from, doc::frame_t& to)
{
doc::frame_t first = 0;
doc::frame_t last = m_sprite->lastFrame();
@ -56,13 +57,13 @@ void FrameTagWindow::rangeValue(doc::frame_t& from, doc::frame_t& to)
to = MID(from, to, last);
}
doc::color_t FrameTagWindow::colorValue()
doc::color_t TagWindow::colorValue()
{
app::Color color = this->color()->getColor();
return doc::rgba(color.getRed(), color.getGreen(), color.getBlue(), 255);
}
doc::AniDir FrameTagWindow::aniDirValue()
doc::AniDir TagWindow::aniDirValue()
{
return (doc::AniDir)anidir()->getSelectedItemIndex();
}

View File

@ -1,29 +1,30 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_UI_FRAME_TAG_WINDOW_H_INCLUDED
#define APP_UI_FRAME_TAG_WINDOW_H_INCLUDED
#ifndef APP_UI_TAG_WINDOW_H_INCLUDED
#define APP_UI_TAG_WINDOW_H_INCLUDED
#pragma once
#include "app/ui/color_button.h"
#include "doc/anidir.h"
#include "doc/frame.h"
#include "frame_tag_properties.xml.h"
#include "tag_properties.xml.h"
namespace doc {
class FrameTag;
class Sprite;
class Tag;
}
namespace app {
class FrameTagWindow : protected app::gen::FrameTagProperties {
class TagWindow : protected app::gen::TagProperties {
public:
FrameTagWindow(const doc::Sprite* sprite, const doc::FrameTag* frameTag);
TagWindow(const doc::Sprite* sprite, const doc::Tag* tag);
bool show();

View File

@ -49,7 +49,6 @@
#include "base/memory.h"
#include "base/scoped_value.h"
#include "doc/doc.h"
#include "doc/frame_tag.h"
#include "gfx/point.h"
#include "gfx/rect.h"
#include "os/font.h"
@ -87,11 +86,11 @@ enum {
PART_ROW_TEXT,
PART_CEL,
PART_RANGE_OUTLINE,
PART_FRAME_TAG,
PART_FRAME_TAGS,
PART_FRAME_TAG_BAND,
PART_FRAME_TAG_SWITCH_BUTTONS,
PART_FRAME_TAG_SWITCH_BAND_BUTTON,
PART_TAG,
PART_TAGS,
PART_TAG_BAND,
PART_TAG_SWITCH_BUTTONS,
PART_TAG_SWITCH_BAND_BUTTON,
};
struct Timeline::DrawCelData {
@ -162,12 +161,12 @@ namespace {
Timeline::Hit::Hit(int part,
layer_t layer,
frame_t frame,
ObjectId frameTag,
ObjectId tag,
int band)
: part(part),
layer(layer),
frame(frame),
frameTag(frameTag),
tag(tag),
veryBottom(false),
band(band)
{
@ -179,13 +178,13 @@ bool Timeline::Hit::operator!=(const Hit& other) const
part != other.part ||
layer != other.layer ||
frame != other.frame ||
frameTag != other.frameTag ||
tag != other.tag ||
band != other.band;
}
FrameTag* Timeline::Hit::getFrameTag() const
Tag* Timeline::Hit::getTag() const
{
return get<FrameTag>(frameTag);
return get<Tag>(tag);
}
Timeline::DropTarget::DropTarget()
@ -564,24 +563,24 @@ void Timeline::activateClipboardRange()
invalidate();
}
FrameTag* Timeline::getFrameTagByFrame(const frame_t frame,
Tag* Timeline::getTagByFrame(const frame_t frame,
const bool getLoopTagIfNone)
{
if (!m_sprite)
return nullptr;
if (m_tagFocusBand < 0) {
FrameTag* tag = get_animation_tag(m_sprite, frame);
Tag* tag = get_animation_tag(m_sprite, frame);
if (!tag && getLoopTagIfNone)
tag = get_loop_tag(m_sprite);
return tag;
}
for (FrameTag* frameTag : m_sprite->frameTags()) {
if (frame >= frameTag->fromFrame() &&
frame <= frameTag->toFrame() &&
m_tagBand[frameTag] == m_tagFocusBand) {
return frameTag;
for (Tag* tag : m_sprite->tags()) {
if (frame >= tag->fromFrame() &&
frame <= tag->toFrame() &&
m_tagBand[tag] == m_tagFocusBand) {
return tag;
}
}
@ -1252,20 +1251,20 @@ bool Timeline::onProcessMessage(Message* msg)
break;
}
case PART_FRAME_TAG: {
FrameTag* frameTag = m_clk.getFrameTag();
if (frameTag) {
case PART_TAG: {
Tag* tag = m_clk.getTag();
if (tag) {
Params params;
params.set("id", base::convert_to<std::string>(frameTag->id()).c_str());
params.set("id", base::convert_to<std::string>(tag->id()).c_str());
// As the m_clk.frameTag can be deleted with
// RemoveFrameTag command, we've to clean all references
// As the m_clk.tag can be deleted with
// RemoveTag command, we've to clean all references
// to it from Hit() structures.
cleanClk();
m_hot = m_clk;
if (mouseMsg->right()) {
Menu* popupMenu = AppMenus::instance()->getFrameTagPopupMenu();
Menu* popupMenu = AppMenus::instance()->getTagPopupMenu();
if (popupMenu) {
AppMenuItem::setContextParams(params);
popupMenu->showPopup(mouseMsg->position());
@ -1284,7 +1283,7 @@ bool Timeline::onProcessMessage(Message* msg)
break;
}
case PART_FRAME_TAG_SWITCH_BAND_BUTTON:
case PART_TAG_SWITCH_BAND_BUTTON:
if (m_clk.band >= 0) {
focusTagBand(m_clk.band);
regenRows = true;
@ -1355,7 +1354,7 @@ bool Timeline::onProcessMessage(Message* msg)
return true;
}
case PART_FRAME_TAG_BAND:
case PART_TAG_BAND:
if (m_hot.band >= 0) {
focusTagBand(m_hot.band);
regenerateRows();
@ -1663,7 +1662,7 @@ void Timeline::onPaint(ui::PaintEvent& ev)
}
drawPaddings(g);
drawFrameTags(g);
drawTags(g);
drawRangeOutline(g);
drawClipboardRange(g);
drawCelOverlay(g);
@ -1803,7 +1802,7 @@ void Timeline::onLayerNameChange(DocEvent& ev)
invalidate();
}
void Timeline::onAddFrameTag(DocEvent& ev)
void Timeline::onAddTag(DocEvent& ev)
{
if (m_tagFocusBand >= 0) {
m_tagFocusBand = -1;
@ -1812,9 +1811,9 @@ void Timeline::onAddFrameTag(DocEvent& ev)
}
}
void Timeline::onRemoveFrameTag(DocEvent& ev)
void Timeline::onRemoveTag(DocEvent& ev)
{
onAddFrameTag(ev);
onAddTag(ev);
}
void Timeline::onStateChanged(Editor* editor)
@ -1884,7 +1883,7 @@ void Timeline::setCursor(ui::Message* msg, const Hit& hit)
else if (hit.part == PART_SEPARATOR) {
ui::set_mouse_cursor(kSizeWECursor);
}
else if (hit.part == PART_FRAME_TAG) {
else if (hit.part == PART_TAG) {
ui::set_mouse_cursor(kHandCursor);
}
else {
@ -2380,9 +2379,9 @@ void Timeline::drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& bounds,
if (style2) drawPart(g, bounds, nullptr, style2, is_active, is_hover);
}
void Timeline::drawFrameTags(ui::Graphics* g)
void Timeline::drawTags(ui::Graphics* g)
{
IntersectClip clip(g, getPartBounds(Hit(PART_FRAME_TAGS)));
IntersectClip clip(g, getPartBounds(Hit(PART_TAGS)));
if (!clip)
return;
@ -2400,17 +2399,17 @@ void Timeline::drawFrameTags(ui::Graphics* g)
m_tagBands > 1 &&
m_tagFocusBand < 0) {
gfx::Rect bandBounds =
getPartBounds(Hit(PART_FRAME_TAG_BAND, -1, 0,
getPartBounds(Hit(PART_TAG_BAND, -1, 0,
doc::NullId, m_hot.band));
g->fillRect(theme->colors.timelineBandHighlight(), bandBounds);
}
int passes = (m_tagFocusBand >= 0 ? 2: 1);
for (int pass=0; pass<passes; ++pass) {
for (FrameTag* frameTag : m_sprite->frameTags()) {
for (Tag* tag : m_sprite->tags()) {
int band = -1;
if (m_tagFocusBand >= 0) {
auto it = m_tagBand.find(frameTag);
auto it = m_tagBand.find(tag);
if (it != m_tagBand.end()) {
band = it->second;
if ((pass == 0 && band == m_tagFocusBand) ||
@ -2419,12 +2418,12 @@ void Timeline::drawFrameTags(ui::Graphics* g)
}
}
gfx::Rect bounds1 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), frameTag->fromFrame()));
gfx::Rect bounds2 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), frameTag->toFrame()));
gfx::Rect bounds1 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), tag->fromFrame()));
gfx::Rect bounds2 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), tag->toFrame()));
gfx::Rect bounds = bounds1.createUnion(bounds2);
gfx::Rect frameTagBounds = getPartBounds(Hit(PART_FRAME_TAG, 0, 0, frameTag->id()));
bounds.h = bounds.y2() - frameTagBounds.y2();
bounds.y = frameTagBounds.y2();
gfx::Rect tagBounds = getPartBounds(Hit(PART_TAG, 0, 0, tag->id()));
bounds.h = bounds.y2() - tagBounds.y2();
bounds.y = tagBounds.y2();
int dx = 0, dw = 0;
if (m_dropTarget.outside &&
@ -2432,19 +2431,19 @@ void Timeline::drawFrameTags(ui::Graphics* g)
m_dropRange.type() == DocRange::kFrames) {
switch (m_dropTarget.hhit) {
case DropTarget::Before:
if (m_dropRange.firstFrame() == frameTag->fromFrame()) {
if (m_dropRange.firstFrame() == tag->fromFrame()) {
dx = +frameBoxWidth()/4;
dw = -frameBoxWidth()/4;
}
else if (m_dropRange.firstFrame()-1 == frameTag->toFrame()) {
else if (m_dropRange.firstFrame()-1 == tag->toFrame()) {
dw = -frameBoxWidth()/4;
}
break;
case DropTarget::After:
if (m_dropRange.lastFrame() == frameTag->toFrame()) {
if (m_dropRange.lastFrame() == tag->toFrame()) {
dw = -frameBoxWidth()/4;
}
else if (m_dropRange.lastFrame()+1 == frameTag->fromFrame()) {
else if (m_dropRange.lastFrame()+1 == tag->fromFrame()) {
dx = +frameBoxWidth()/4;
dw = -frameBoxWidth()/4;
}
@ -2453,11 +2452,11 @@ void Timeline::drawFrameTags(ui::Graphics* g)
}
bounds.x += dx;
bounds.w += dw;
frameTagBounds.x += dx;
tagBounds.x += dx;
gfx::Color bg =
(m_tagFocusBand < 0 || pass == 1) ?
frameTag->color(): theme->colors.timelineBandBg();
tag->color(): theme->colors.timelineBandBg();
{
IntersectClip clip(g, bounds);
if (clip) {
@ -2473,12 +2472,12 @@ void Timeline::drawFrameTags(ui::Graphics* g)
}
if (m_tagFocusBand < 0 || pass == 1) {
bounds = frameTagBounds;
bounds = tagBounds;
if (m_clk.part == PART_FRAME_TAG && m_clk.frameTag == frameTag->id()) {
if (m_clk.part == PART_TAG && m_clk.tag == tag->id()) {
bg = color_utils::blackandwhite_neg(bg);
}
else if (m_hot.part == PART_FRAME_TAG && m_hot.frameTag == frameTag->id()) {
else if (m_hot.part == PART_TAG && m_hot.tag == tag->id()) {
int r, g, b;
r = gfx::getr(bg)+32;
g = gfx::getg(bg)+32;
@ -2493,7 +2492,7 @@ void Timeline::drawFrameTags(ui::Graphics* g)
bounds.y += 2*ui::guiscale();
bounds.x += 2*ui::guiscale();
g->drawText(
frameTag->name(),
tag->name(),
color_utils::blackandwhite_neg(bg),
gfx::ColorNone,
bounds.origin());
@ -2504,10 +2503,10 @@ void Timeline::drawFrameTags(ui::Graphics* g)
// Draw button to expand/collapse the active band
if (m_hot.band >= 0 && m_tagBands > 1) {
gfx::Rect butBounds =
getPartBounds(Hit(PART_FRAME_TAG_SWITCH_BAND_BUTTON, -1, 0,
getPartBounds(Hit(PART_TAG_SWITCH_BAND_BUTTON, -1, 0,
doc::NullId, m_hot.band));
PaintWidgetPartInfo info;
if (m_hot.part == PART_FRAME_TAG_SWITCH_BAND_BUTTON) {
if (m_hot.part == PART_TAG_SWITCH_BAND_BUTTON) {
info.styleFlags |= ui::Style::Layer::kMouse;
if (hasCapture())
info.styleFlags |= ui::Style::Layer::kSelected;
@ -2775,22 +2774,22 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const
return rc;
}
case PART_FRAME_TAG: {
FrameTag* frameTag = hit.getFrameTag();
if (frameTag) {
gfx::Rect bounds1 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), frameTag->fromFrame()));
gfx::Rect bounds2 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), frameTag->toFrame()));
case PART_TAG: {
Tag* tag = hit.getTag();
if (tag) {
gfx::Rect bounds1 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), tag->fromFrame()));
gfx::Rect bounds2 = getPartBounds(Hit(PART_HEADER_FRAME, firstLayer(), tag->toFrame()));
gfx::Rect bounds = bounds1.createUnion(bounds2);
bounds.y -= skinTheme()->dimensions.timelineTagsAreaHeight();
int textHeight = font()->height();
bounds.y -= textHeight + 2*ui::guiscale();
bounds.x += 3*ui::guiscale();
bounds.w = font()->textLength(frameTag->name().c_str()) + 4*ui::guiscale();
bounds.w = font()->textLength(tag->name().c_str()) + 4*ui::guiscale();
bounds.h = font()->height() + 2*ui::guiscale();
if (m_tagFocusBand < 0) {
auto it = m_tagBand.find(frameTag);
auto it = m_tagBand.find(tag);
if (it != m_tagBand.end()) {
int dy = (m_tagBands-it->second-1)*oneTagHeight();
bounds.y -= dy;
@ -2802,13 +2801,13 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const
break;
}
case PART_FRAME_TAGS:
case PART_TAGS:
return gfx::Rect(
bounds.x + m_separator_x + m_separator_w - 1,
bounds.y,
bounds.w - m_separator_x - m_separator_w + 1, y);
case PART_FRAME_TAG_BAND:
case PART_TAG_BAND:
return gfx::Rect(
bounds.x + m_separator_x + m_separator_w - 1,
bounds.y
@ -2816,7 +2815,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const
bounds.w - m_separator_x - m_separator_w + 1,
oneTagHeight());
case PART_FRAME_TAG_SWITCH_BUTTONS: {
case PART_TAG_SWITCH_BUTTONS: {
gfx::Size sz = theme()->calcSizeHint(
this, skinTheme()->styles.timelineSwitchBandButton());
@ -2826,7 +2825,7 @@ gfx::Rect Timeline::getPartBounds(const Hit& hit) const
sz.w, y);
}
case PART_FRAME_TAG_SWITCH_BAND_BUTTON: {
case PART_TAG_SWITCH_BAND_BUTTON: {
gfx::Size sz = theme()->calcSizeHint(
this, skinTheme()->styles.timelineSwitchBandButton());
@ -2887,7 +2886,7 @@ void Timeline::invalidateHit(const Hit& hit)
{
if (hit.band >= 0) {
Hit hit2 = hit;
hit2.part = PART_FRAME_TAG_BAND;
hit2.part = PART_TAG_BAND;
invalidateRect(getPartBounds(hit2).offset(origin()));
}
@ -2962,24 +2961,24 @@ void Timeline::regenerateTagBands()
{
// TODO improve this implementation
std::vector<unsigned char> tagsPerFrame(m_sprite->totalFrames(), 0);
std::vector<FrameTag*> bands(4, nullptr);
std::vector<Tag*> bands(4, nullptr);
m_tagBand.clear();
for (FrameTag* frameTag : m_sprite->frameTags()) {
frame_t f = frameTag->fromFrame();
for (Tag* tag : m_sprite->tags()) {
frame_t f = tag->fromFrame();
int b=0;
for (; b<int(bands.size()); ++b) {
if (!bands[b] ||
frameTag->fromFrame() > calcTagVisibleToFrame(bands[b])) {
bands[b] = frameTag;
m_tagBand[frameTag] = b;
tag->fromFrame() > calcTagVisibleToFrame(bands[b])) {
bands[b] = tag;
m_tagBand[tag] = b;
break;
}
}
if (b == int(bands.size()))
m_tagBand[frameTag] = tagsPerFrame[f];
m_tagBand[tag] = tagsPerFrame[f];
frame_t toFrame = calcTagVisibleToFrame(frameTag);
frame_t toFrame = calcTagVisibleToFrame(tag);
if (toFrame >= frame_t(tagsPerFrame.size()))
tagsPerFrame.resize(toFrame+1, 0);
for (; f<=toFrame; ++f) {
@ -3081,16 +3080,16 @@ Timeline::Hit Timeline::hitTest(ui::Message* msg, const gfx::Point& mousePos)
hit.part = PART_SEPARATOR;
}
// Is the mouse on the frame tags area?
else if (getPartBounds(Hit(PART_FRAME_TAGS)).contains(mousePos)) {
else if (getPartBounds(Hit(PART_TAGS)).contains(mousePos)) {
// Mouse in switch band button
if (hit.part == PART_NOTHING) {
if (m_tagFocusBand < 0) {
for (int band=0; band<m_tagBands; ++band) {
gfx::Rect bounds = getPartBounds(
Hit(PART_FRAME_TAG_SWITCH_BAND_BUTTON, 0, 0,
Hit(PART_TAG_SWITCH_BAND_BUTTON, 0, 0,
doc::NullId, band));
if (bounds.contains(mousePos)) {
hit.part = PART_FRAME_TAG_SWITCH_BAND_BUTTON;
hit.part = PART_TAG_SWITCH_BAND_BUTTON;
hit.band = band;
break;
}
@ -3098,10 +3097,10 @@ Timeline::Hit Timeline::hitTest(ui::Message* msg, const gfx::Point& mousePos)
}
else {
gfx::Rect bounds = getPartBounds(
Hit(PART_FRAME_TAG_SWITCH_BAND_BUTTON, 0, 0,
Hit(PART_TAG_SWITCH_BAND_BUTTON, 0, 0,
doc::NullId, m_tagFocusBand));
if (bounds.contains(mousePos)) {
hit.part = PART_FRAME_TAG_SWITCH_BAND_BUTTON;
hit.part = PART_TAG_SWITCH_BAND_BUTTON;
hit.band = m_tagFocusBand;
}
}
@ -3109,16 +3108,16 @@ Timeline::Hit Timeline::hitTest(ui::Message* msg, const gfx::Point& mousePos)
// Mouse in frame tags
if (hit.part == PART_NOTHING) {
for (FrameTag* frameTag : m_sprite->frameTags()) {
gfx::Rect bounds = getPartBounds(Hit(PART_FRAME_TAG, 0, 0, frameTag->id()));
for (Tag* tag : m_sprite->tags()) {
gfx::Rect bounds = getPartBounds(Hit(PART_TAG, 0, 0, tag->id()));
if (bounds.contains(mousePos)) {
const int band = m_tagBand[frameTag];
const int band = m_tagBand[tag];
if (m_tagFocusBand >= 0 &&
m_tagFocusBand != band)
continue;
hit.part = PART_FRAME_TAG;
hit.frameTag = frameTag->id();
hit.part = PART_TAG;
hit.tag = tag->id();
hit.band = band;
break;
}
@ -3130,10 +3129,10 @@ Timeline::Hit Timeline::hitTest(ui::Message* msg, const gfx::Point& mousePos)
if (m_tagFocusBand < 0) {
for (int band=0; band<m_tagBands; ++band) {
gfx::Rect bounds = getPartBounds(
Hit(PART_FRAME_TAG_BAND, 0, 0,
Hit(PART_TAG_BAND, 0, 0,
doc::NullId, band));
if (bounds.contains(mousePos)) {
hit.part = PART_FRAME_TAG_BAND;
hit.part = PART_TAG_BAND;
hit.band = band;
break;
}
@ -3141,10 +3140,10 @@ Timeline::Hit Timeline::hitTest(ui::Message* msg, const gfx::Point& mousePos)
}
else {
gfx::Rect bounds = getPartBounds(
Hit(PART_FRAME_TAG_BAND, 0, 0,
Hit(PART_TAG_BAND, 0, 0,
doc::NullId, m_tagFocusBand));
if (bounds.contains(mousePos)) {
hit.part = PART_FRAME_TAG_BAND;
hit.part = PART_TAG_BAND;
hit.band = m_tagFocusBand;
}
}
@ -3383,14 +3382,14 @@ void Timeline::updateStatusBar(ui::Message* msg)
case PART_HEADER_FRAME:
case PART_CEL:
case PART_FRAME_TAG: {
case PART_TAG: {
frame_t frame = m_frame;
if (validFrame(m_hot.frame))
frame = m_hot.frame;
updateStatusBarForFrame(
frame,
m_hot.getFrameTag(),
m_hot.getTag(),
(layer ? layer->cel(frame) : nullptr));
return;
}
@ -3401,7 +3400,7 @@ void Timeline::updateStatusBar(ui::Message* msg)
}
void Timeline::updateStatusBarForFrame(const frame_t frame,
const FrameTag* frameTag,
const Tag* tag,
const Cel* cel)
{
if (!m_sprite)
@ -3412,9 +3411,9 @@ void Timeline::updateStatusBarForFrame(const frame_t frame,
frame_t firstFrame = frame;
frame_t lastFrame = frame;
if (frameTag) {
firstFrame = frameTag->fromFrame();
lastFrame = frameTag->toFrame();
if (tag) {
firstFrame = tag->fromFrame();
lastFrame = tag->toFrame();
}
else if (m_range.enabled() &&
m_range.frames() > 1) {
@ -3438,8 +3437,8 @@ void Timeline::updateStatusBarForFrame(const frame_t frame,
if (firstFrame != lastFrame) {
std::sprintf(
buf+std::strlen(buf), " [%s]",
frameTag ?
human_readable_time(tagFramesDuration(frameTag)).c_str():
tag ?
human_readable_time(tagFramesDuration(tag)).c_str():
human_readable_time(selectedFramesDuration()).c_str());
}
if (m_sprite->totalFrames() > 1)
@ -3713,7 +3712,7 @@ void Timeline::dropRange(DropOp op)
if (m_range.type() == Range::kFrames &&
m_sprite &&
!m_sprite->frameTags().empty()) {
!m_sprite->tags().empty()) {
invalidateRect(getFrameHeadersBounds().offset(origin()));
}
@ -3756,7 +3755,7 @@ void Timeline::setViewScroll(const gfx::Point& pt)
if (newScroll != oldScroll) {
gfx::Rect rc;
if (m_tagBands > 0)
rc |= getPartBounds(Hit(PART_FRAME_TAG_BAND));
rc |= getPartBounds(Hit(PART_TAG_BAND));
rc |= getFrameHeadersBounds();
rc |= getCelsBounds();
rc.offset(origin());
@ -3930,12 +3929,12 @@ double Timeline::zoom() const
// Returns the last frame where the frame tag (or frame tag label)
// is visible in the timeline.
int Timeline::calcTagVisibleToFrame(FrameTag* frameTag) const
int Timeline::calcTagVisibleToFrame(Tag* tag) const
{
return
MAX(frameTag->toFrame(),
frameTag->fromFrame() +
font()->textLength(frameTag->name())/frameBoxWidth());
MAX(tag->toFrame(),
tag->fromFrame() +
font()->textLength(tag->name())/frameBoxWidth());
}
int Timeline::topHeight() const
@ -4065,14 +4064,14 @@ void Timeline::onCancel(Context* ctx)
invalidate();
}
int Timeline::tagFramesDuration(const FrameTag* frameTag) const
int Timeline::tagFramesDuration(const Tag* tag) const
{
ASSERT(m_sprite);
ASSERT(frameTag);
ASSERT(tag);
int duration = 0;
for (frame_t f=frameTag->fromFrame();
f<frameTag->toFrame(); ++f) {
for (frame_t f=tag->fromFrame();
f<tag->toFrame(); ++f) {
duration += m_sprite->frameDuration(f);
}
return duration;

View File

@ -62,7 +62,7 @@ namespace app {
public DocObserver,
public EditorObserver,
public InputChainElement,
public FrameTagProvider {
public TagProvider {
public:
typedef DocRange Range;
@ -115,12 +115,12 @@ namespace app {
// called from popup menus.
void dropRange(DropOp op);
// FrameTagProvider impl
// TagProvider impl
// Returns the active frame tag depending on the timeline status
// E.g. if other frame tags are collapsed, the focused band has
// priority and tags in other bands are ignored.
FrameTag* getFrameTagByFrame(const frame_t frame,
const bool getLoopTagIfNone) override;
Tag* getTagByFrame(const frame_t frame,
const bool getLoopTagIfNone) override;
// ScrollableViewDelegate impl
gfx::Size visibleSize() const override;
@ -148,8 +148,8 @@ namespace app {
void onAddFrame(DocEvent& ev) override;
void onRemoveFrame(DocEvent& ev) override;
void onLayerNameChange(DocEvent& ev) override;
void onAddFrameTag(DocEvent& ev) override;
void onRemoveFrameTag(DocEvent& ev) override;
void onAddTag(DocEvent& ev) override;
void onRemoveTag(DocEvent& ev) override;
// app::Context slots.
void onAfterCommandExecution(CommandExecutionEvent& ev);
@ -186,17 +186,17 @@ namespace app {
int part;
layer_t layer;
frame_t frame;
ObjectId frameTag;
ObjectId tag;
bool veryBottom;
int band;
Hit(int part = 0,
layer_t layer = -1,
frame_t frame = 0,
ObjectId frameTag = NullId,
ObjectId tag = NullId,
int band = -1);
bool operator!=(const Hit& other) const;
FrameTag* getFrameTag() const;
Tag* getTag() const;
};
struct DropTarget {
@ -272,7 +272,7 @@ namespace app {
void drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& bounds,
Cel* cel, frame_t frame, bool is_active, bool is_hover,
DrawCelData* data);
void drawFrameTags(ui::Graphics* g);
void drawTags(ui::Graphics* g);
void drawRangeOutline(ui::Graphics* g);
void drawPaddings(ui::Graphics* g);
bool drawPart(ui::Graphics* g, int part, layer_t layer, frame_t frame);
@ -309,7 +309,7 @@ namespace app {
bool isCelLooselyActive(const layer_t layerIdx, const frame_t frame) const;
void updateStatusBar(ui::Message* msg);
void updateStatusBarForFrame(const frame_t frame,
const FrameTag* frameTag,
const Tag* tag,
const Cel* cel);
void updateDropRange(const gfx::Point& pt);
void clearClipboardRange();
@ -338,7 +338,7 @@ namespace app {
int frameBoxWidth() const;
int outlineWidth() const;
int oneTagHeight() const;
int calcTagVisibleToFrame(FrameTag* frameTag) const;
int calcTagVisibleToFrame(Tag* tag) const;
void updateCelOverlayBounds(const Hit& hit);
void drawCelOverlay(ui::Graphics* g);
@ -348,7 +348,7 @@ namespace app {
const bool updatePref);
double zoom() const;
int tagFramesDuration(const FrameTag* frameTag) const;
int tagFramesDuration(const Tag* tag) const;
// Calculate the duration of the selected range of frames
int selectedFramesDuration() const;
@ -379,7 +379,7 @@ namespace app {
// Data used to display frame tags
int m_tagBands;
int m_tagFocusBand;
std::map<FrameTag*, int> m_tagBand;
std::map<Tag*, int> m_tagBand;
int m_separator_x;
int m_separator_w;

View File

@ -173,7 +173,7 @@ bool AsepriteDecoder::decode()
break;
case ASE_FILE_CHUNK_TAGS:
readTagsChunk(&sprite->frameTags());
readTagsChunk(&sprite->tags());
break;
case ASE_FILE_CHUNK_SLICES: {
@ -809,14 +809,14 @@ doc::Mask* AsepriteDecoder::readMaskChunk()
return mask;
}
void AsepriteDecoder::readTagsChunk(doc::FrameTags* frameTags)
void AsepriteDecoder::readTagsChunk(doc::Tags* tags)
{
size_t tags = read16();
size_t ntags = read16();
read32(); // 8 reserved bytes
read32();
for (size_t c=0; c<tags; ++c) {
for (size_t c=0; c<ntags; ++c) {
doc::frame_t from = read16();
doc::frame_t to = read16();
int aniDir = read8();
@ -836,11 +836,11 @@ void AsepriteDecoder::readTagsChunk(doc::FrameTags* frameTags)
std::string name = readString();
doc::FrameTag* tag = new doc::FrameTag(from, to);
auto tag = new doc::Tag(from, to);
tag->setColor(doc::rgba(r, g, b, 255));
tag->setName(name);
tag->setAniDir((doc::AniDir)aniDir);
frameTags->add(tag);
tags->add(tag);
}
}

View File

@ -11,10 +11,10 @@
#include "dio/decoder.h"
#include "doc/frame.h"
#include "doc/frame_tags.h"
#include "doc/layer_list.h"
#include "doc/pixel_format.h"
#include "doc/slices.h"
#include "doc/tags.h"
#include <string>
@ -55,7 +55,7 @@ private:
void readCelExtraChunk(doc::Cel* cel);
void readColorProfile(doc::Sprite* sprite);
doc::Mask* readMaskChunk();
void readTagsChunk(doc::FrameTags* frameTags);
void readTagsChunk(doc::Tags* tags);
void readSlicesChunk(doc::Slices& slices);
doc::Slice* readSliceChunk(doc::Slices& slices);
void readUserDataChunk(doc::UserData* userData);

View File

@ -36,9 +36,6 @@ add_library(doc-lib
file/gpl_file.cpp
file/hex_file.cpp
file/pal_file.cpp
frame_tag.cpp
frame_tag_io.cpp
frame_tags.cpp
handle_anidir.cpp
image.cpp
image_impl.cpp
@ -66,6 +63,9 @@ add_library(doc-lib
sprites.cpp
string_io.cpp
subobjects_io.cpp
tag.cpp
tag_io.cpp
tags.cpp
user_data_io.cpp)
# TODO Remove 'os' as dependency and move conversion_to_surface.cpp/h files

View File

@ -1,5 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2001-2018 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -17,8 +18,6 @@
#include "doc/color_scales.h"
#include "doc/document.h"
#include "doc/frame.h"
#include "doc/frame_tag.h"
#include "doc/frame_tags.h"
#include "doc/image.h"
#include "doc/image_impl.h"
#include "doc/image_ref.h"
@ -36,5 +35,7 @@
#include "doc/slice.h"
#include "doc/slices.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "doc/tags.h"
#endif

View File

@ -1,22 +0,0 @@
// Aseprite Document Library
// Copyright (c) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_FRAME_TAG_IO_H_INCLUDED
#define DOC_FRAME_TAG_IO_H_INCLUDED
#pragma once
#include <iosfwd>
namespace doc {
class FrameTag;
void write_frame_tag(std::ostream& os, const FrameTag* tag);
FrameTag* read_frame_tag(std::istream& is, bool setId = true);
} // namespace doc
#endif

View File

@ -1,5 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2001-2016 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -12,8 +13,8 @@
#include "base/base.h"
#include "doc/frame.h"
#include "doc/frame_tag.h"
#include "doc/sprite.h"
#include "doc/tag.h"
namespace doc {
@ -21,7 +22,7 @@ frame_t calculate_next_frame(
const Sprite* sprite,
frame_t frame,
frame_t frameDelta,
const FrameTag* tag,
const Tag* tag,
bool& pingPongForward)
{
if (frameDelta == 0)

View File

@ -1,5 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2001-2015 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -12,14 +13,14 @@
namespace doc {
class FrameTag;
class Sprite;
class Tag;
frame_t calculate_next_frame(
const Sprite* sprite,
frame_t frame,
frame_t frameDelta,
const FrameTag* tag,
const Tag* tag,
bool& pingPongForward);
} // namespace doc

View File

@ -1,5 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2001-2017 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -23,7 +24,7 @@ namespace doc {
LayerGroup,
Sprite,
Document,
FrameTag,
Tag,
Slice,
};

View File

@ -1,6 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2018-2019 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -16,13 +16,13 @@
#include "base/remove_from_container.h"
#include "doc/cel.h"
#include "doc/cels_range.h"
#include "doc/frame_tag.h"
#include "doc/image_impl.h"
#include "doc/layer.h"
#include "doc/palette.h"
#include "doc/primitives.h"
#include "doc/remap.h"
#include "doc/rgbmap.h"
#include "doc/tag.h"
#include <algorithm>
#include <cstring>
@ -44,7 +44,7 @@ Sprite::Sprite(const ImageSpec& spec,
, m_frlens(1, 100) // First frame with 100 msecs of duration
, m_root(new LayerGroup(this))
, m_rgbMap(nullptr) // Initial RGB map
, m_frameTags(this)
, m_tags(this)
, m_slices(this)
{
// Generate palette

View File

@ -1,6 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2018-2019 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -14,7 +14,6 @@
#include "doc/cel_list.h"
#include "doc/color.h"
#include "doc/frame.h"
#include "doc/frame_tags.h"
#include "doc/image_ref.h"
#include "doc/image_spec.h"
#include "doc/layer_list.h"
@ -22,6 +21,7 @@
#include "doc/pixel_format.h"
#include "doc/pixel_ratio.h"
#include "doc/slices.h"
#include "doc/tags.h"
#include "gfx/rect.h"
#include <vector>
@ -142,8 +142,8 @@ namespace doc {
void setFrameRangeDuration(frame_t from, frame_t to, int msecs);
void setDurationForAllFrames(int msecs);
const FrameTags& frameTags() const { return m_frameTags; }
FrameTags& frameTags() { return m_frameTags; }
const Tags& tags() const { return m_tags; }
Tags& tags() { return m_tags; }
const Slices& slices() const { return m_slices; }
Slices& slices() { return m_slices; }
@ -192,7 +192,7 @@ namespace doc {
// Current rgb map
mutable RgbMap* m_rgbMap;
FrameTags m_frameTags;
Tags m_tags;
Slices m_slices;
// Disable default constructor and copying

View File

@ -1,5 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2001-2016 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -8,15 +9,15 @@
#include "config.h"
#endif
#include "doc/frame_tag.h"
#include "doc/tag.h"
#include "base/debug.h"
#include "doc/frame_tags.h"
#include "doc/tags.h"
namespace doc {
FrameTag::FrameTag(frame_t from, frame_t to)
: Object(ObjectType::FrameTag)
Tag::Tag(frame_t from, frame_t to)
: Object(ObjectType::Tag)
, m_owner(nullptr)
, m_from(from)
, m_to(to)
@ -26,8 +27,8 @@ FrameTag::FrameTag(frame_t from, frame_t to)
{
}
FrameTag::FrameTag(const FrameTag& other)
: Object(ObjectType::FrameTag)
Tag::Tag(const Tag& other)
: Object(ObjectType::Tag)
, m_owner(nullptr)
, m_from(other.m_from)
, m_to(other.m_to)
@ -37,19 +38,19 @@ FrameTag::FrameTag(const FrameTag& other)
{
}
FrameTag::~FrameTag()
Tag::~Tag()
{
ASSERT(!m_owner);
}
void FrameTag::setOwner(FrameTags* owner)
void Tag::setOwner(Tags* owner)
{
m_owner = owner;
}
void FrameTag::setFrameRange(frame_t from, frame_t to)
void Tag::setFrameRange(frame_t from, frame_t to)
{
FrameTags* owner = m_owner;
Tags* owner = m_owner;
if (owner)
owner->remove(this);
@ -60,17 +61,17 @@ void FrameTag::setFrameRange(frame_t from, frame_t to)
owner->add(this); // Re-add the tag, so it's added in the correct place
}
void FrameTag::setName(const std::string& name)
void Tag::setName(const std::string& name)
{
m_name = name;
}
void FrameTag::setColor(color_t color)
void Tag::setColor(color_t color)
{
m_color = color;
}
void FrameTag::setAniDir(AniDir aniDir)
void Tag::setAniDir(AniDir aniDir)
{
ASSERT(m_aniDir == AniDir::FORWARD ||
m_aniDir == AniDir::REVERSE ||

View File

@ -1,11 +1,12 @@
// Aseprite Document Library
// Copyright (c) 2001-2016 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_FRAME_TAG_H_INCLUDED
#define DOC_FRAME_TAG_H_INCLUDED
#ifndef DOC_TAG_H_INCLUDED
#define DOC_TAG_H_INCLUDED
#pragma once
#include "base/disable_copying.h"
@ -17,15 +18,15 @@
#include <string>
namespace doc {
class FrameTags;
class Tags;
class FrameTag : public Object {
class Tag : public Object {
public:
FrameTag(frame_t from, frame_t to);
FrameTag(const FrameTag& other);
~FrameTag();
Tag(frame_t from, frame_t to);
Tag(const Tag& other);
~Tag();
FrameTags* owner() const { return m_owner; }
Tags* owner() const { return m_owner; }
frame_t fromFrame() const { return m_from; }
frame_t toFrame() const { return m_to; }
frame_t frames() const { return m_to - m_from + 1; }
@ -38,17 +39,17 @@ namespace doc {
void setColor(color_t color);
void setAniDir(AniDir aniDir);
void setOwner(FrameTags* owner);
void setOwner(Tags* owner);
public:
FrameTags* m_owner;
Tags* m_owner;
frame_t m_from, m_to;
color_t m_color;
std::string m_name;
AniDir m_aniDir;
// Disable operator=
FrameTag& operator=(FrameTag&);
Tag& operator=(Tag&);
};
} // namespace doc

View File

@ -1,5 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2001-2018 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -8,11 +9,11 @@
#include "config.h"
#endif
#include "doc/frame_tag_io.h"
#include "doc/tag_io.h"
#include "base/serialization.h"
#include "doc/frame_tag.h"
#include "doc/string_io.h"
#include "doc/tag.h"
#include <iostream>
#include <memory>
@ -22,7 +23,7 @@ namespace doc {
using namespace base::serialization;
using namespace base::serialization::little_endian;
void write_frame_tag(std::ostream& os, const FrameTag* tag)
void write_tag(std::ostream& os, const Tag* tag)
{
std::string name = tag->name();
@ -34,7 +35,7 @@ void write_frame_tag(std::ostream& os, const FrameTag* tag)
write_string(os, tag->name());
}
FrameTag* read_frame_tag(std::istream& is, bool setId)
Tag* read_tag(std::istream& is, bool setId)
{
ObjectId id = read32(is);
frame_t from = read32(is);
@ -43,7 +44,7 @@ FrameTag* read_frame_tag(std::istream& is, bool setId)
AniDir aniDir = (AniDir)read8(is);
std::string name = read_string(is);
std::unique_ptr<FrameTag> tag(new FrameTag(from, to));
std::unique_ptr<Tag> tag(new Tag(from, to));
tag->setColor(color);
tag->setAniDir(aniDir);
tag->setName(name);

23
src/doc/tag_io.h Normal file
View File

@ -0,0 +1,23 @@
// Aseprite Document Library
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_TAG_IO_H_INCLUDED
#define DOC_TAG_IO_H_INCLUDED
#pragma once
#include <iosfwd>
namespace doc {
class Tag;
void write_tag(std::ostream& os, const Tag* tag);
Tag* read_tag(std::istream& is, bool setId = true);
} // namespace doc
#endif

View File

@ -1,5 +1,6 @@
// Aseprite Document Library
// Copyright (c) 2001-2016 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -8,29 +9,29 @@
#include "config.h"
#endif
#include "doc/frame_tags.h"
#include "doc/tags.h"
#include "base/debug.h"
#include "doc/frame_tag.h"
#include "doc/tag.h"
#include <algorithm>
namespace doc {
FrameTags::FrameTags(Sprite* sprite)
Tags::Tags(Sprite* sprite)
: m_sprite(sprite)
{
}
FrameTags::~FrameTags()
Tags::~Tags()
{
for (FrameTag* tag : m_tags) {
for (Tag* tag : m_tags) {
tag->setOwner(nullptr);
delete tag;
}
}
void FrameTags::add(FrameTag* tag)
void Tags::add(Tag* tag)
{
auto it = begin(), end = this->end();
for (; it != end; ++it) {
@ -43,7 +44,7 @@ void FrameTags::add(FrameTag* tag)
tag->setOwner(this);
}
void FrameTags::remove(FrameTag* tag)
void Tags::remove(Tag* tag)
{
auto it = std::find(m_tags.begin(), m_tags.end(), tag);
ASSERT(it != m_tags.end());
@ -53,28 +54,28 @@ void FrameTags::remove(FrameTag* tag)
tag->setOwner(nullptr);
}
FrameTag* FrameTags::getByName(const std::string& name) const
Tag* Tags::getByName(const std::string& name) const
{
for (FrameTag* tag : *this) {
for (Tag* tag : *this) {
if (tag->name() == name)
return tag;
}
return nullptr;
}
FrameTag* FrameTags::getById(ObjectId id) const
Tag* Tags::getById(ObjectId id) const
{
for (FrameTag* tag : *this) {
for (Tag* tag : *this) {
if (tag->id() == id)
return tag;
}
return nullptr;
}
FrameTag* FrameTags::innerTag(frame_t frame) const
Tag* Tags::innerTag(const frame_t frame) const
{
const FrameTag* found = nullptr;
for (const FrameTag* tag : *this) {
const Tag* found = nullptr;
for (const Tag* tag : *this) {
if (frame >= tag->fromFrame() &&
frame <= tag->toFrame()) {
if (!found ||
@ -83,13 +84,13 @@ FrameTag* FrameTags::innerTag(frame_t frame) const
}
}
}
return const_cast<FrameTag*>(found);
return const_cast<Tag*>(found);
}
FrameTag* FrameTags::outerTag(frame_t frame) const
Tag* Tags::outerTag(const frame_t frame) const
{
const FrameTag* found = nullptr;
for (const FrameTag* tag : *this) {
const Tag* found = nullptr;
for (const Tag* tag : *this) {
if (frame >= tag->fromFrame() &&
frame <= tag->toFrame()) {
if (!found ||
@ -98,7 +99,7 @@ FrameTag* FrameTags::outerTag(frame_t frame) const
}
}
}
return const_cast<FrameTag*>(found);
return const_cast<Tag*>(found);
}
} // namespace doc

View File

@ -1,11 +1,12 @@
// Aseprite Document Library
// Copyright (c) 2001-2015 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_FRAME_TAGS_H_INCLUDED
#define DOC_FRAME_TAGS_H_INCLUDED
#ifndef DOC_TAGS_H_INCLUDED
#define DOC_TAGS_H_INCLUDED
#pragma once
#include "base/disable_copying.h"
@ -17,26 +18,26 @@
namespace doc {
class FrameTag;
class Tag;
class Sprite;
class FrameTags {
typedef std::vector<FrameTag*> List;
class Tags {
typedef std::vector<Tag*> List;
public:
typedef List::iterator iterator;
typedef List::const_iterator const_iterator;
FrameTags(Sprite* sprite);
~FrameTags();
Tags(Sprite* sprite);
~Tags();
Sprite* sprite() { return m_sprite; }
void add(FrameTag* tag);
void remove(FrameTag* tag);
void add(Tag* tag);
void remove(Tag* tag);
FrameTag* getByName(const std::string& name) const;
FrameTag* getById(const ObjectId id) const;
Tag* getByName(const std::string& name) const;
Tag* getById(const ObjectId id) const;
iterator begin() { return m_tags.begin(); }
iterator end() { return m_tags.end(); }
@ -46,14 +47,14 @@ namespace doc {
std::size_t size() const { return m_tags.size(); }
bool empty() const { return m_tags.empty(); }
FrameTag* innerTag(frame_t frame) const;
FrameTag* outerTag(frame_t frame) const;
Tag* innerTag(const frame_t frame) const;
Tag* outerTag(const frame_t frame) const;
private:
Sprite* m_sprite;
List m_tags;
DISABLE_COPYING(FrameTags);
DISABLE_COPYING(Tags);
};
} // namespace doc

View File

@ -1,5 +1,6 @@
// Aseprite Render Library
// Copyright (c) 2018 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -12,8 +13,8 @@
#include "render/onionskin_type.h"
namespace doc {
class FrameTag;
class Layer;
class Tag;
}
namespace render {
@ -37,7 +38,7 @@ namespace render {
int nextFrames() const { return m_nextFrames; }
int opacityBase() const { return m_opacityBase; }
int opacityStep() const { return m_opacityStep; }
doc::FrameTag* loopTag() const { return m_loopTag; }
doc::Tag* loopTag() const { return m_loopTag; }
doc::Layer* layer() const { return m_layer; }
void type(OnionskinType type) { m_type = type; }
@ -46,7 +47,7 @@ namespace render {
void nextFrames(int nextFrames) { m_nextFrames = nextFrames; }
void opacityBase(int base) { m_opacityBase = base; }
void opacityStep(int step) { m_opacityStep = step; }
void loopTag(doc::FrameTag* loopTag) { m_loopTag = loopTag; }
void loopTag(doc::Tag* loopTag) { m_loopTag = loopTag; }
void layer(doc::Layer* layer) { m_layer = layer; }
private:
@ -56,7 +57,7 @@ namespace render {
int m_nextFrames;
int m_opacityBase;
int m_opacityStep;
doc::FrameTag* m_loopTag;
doc::Tag* m_loopTag;
doc::Layer* m_layer;
};

View File

@ -1,6 +1,6 @@
// Aseprite Render Library
// Copyright (c) 2019 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -849,7 +849,7 @@ void Render::renderOnionskin(
// Onion-skin feature: Draw previous/next frames with different
// opacity (<255)
if (m_onionskin.type() != OnionskinType::NONE) {
FrameTag* loop = m_onionskin.loopTag();
Tag* loop = m_onionskin.loopTag();
Layer* onionLayer = (m_onionskin.layer() ? m_onionskin.layer():
m_sprite->root());
frame_t frameIn;

View File

@ -25,7 +25,6 @@
namespace doc {
class Cel;
class FrameTag;
class Image;
class Layer;
class Palette;