mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 12:39:57 +00:00
Removed color functions from tag related code, fix backward compatibilty and added default color in tag constructor (before this, tests were failing)
This commit is contained in:
parent
1cd584413d
commit
f630714547
@ -103,10 +103,6 @@ void FrameTagPropertiesCommand::onExecute(Context* context)
|
||||
tx(new cmd::SetTagRange(tag, from, to));
|
||||
}
|
||||
|
||||
doc::color_t docColor = window.colorValue();
|
||||
if (tag->color() != docColor)
|
||||
tx(new cmd::SetTagColor(tag, docColor));
|
||||
|
||||
doc::AniDir anidir = window.aniDirValue();
|
||||
if (tag->aniDir() != anidir)
|
||||
tx(new cmd::SetTagAniDir(tag, anidir));
|
||||
|
@ -68,7 +68,6 @@ void NewFrameTagCommand::onExecute(Context* context)
|
||||
window.rangeValue(from, to);
|
||||
tag->setFrameRange(from, to);
|
||||
tag->setName(window.nameValue());
|
||||
tag->setColor(window.colorValue());
|
||||
tag->setAniDir(window.aniDirValue());
|
||||
tag->setUserData(window.userDataValue());
|
||||
|
||||
|
@ -61,15 +61,6 @@ void TagWindow::rangeValue(doc::frame_t& from, doc::frame_t& to)
|
||||
to = base::clamp(to, from, last);
|
||||
}
|
||||
|
||||
doc::color_t TagWindow::colorValue()
|
||||
{
|
||||
app::Color color = this->color()->getColor();
|
||||
m_userData.setColor(doc::rgba(color.getRed(),
|
||||
color.getGreen(),
|
||||
color.getBlue(), 255));
|
||||
return doc::rgba(color.getRed(), color.getGreen(), color.getBlue(), 255);
|
||||
}
|
||||
|
||||
doc::AniDir TagWindow::aniDirValue()
|
||||
{
|
||||
return (doc::AniDir)anidir()->getSelectedItemIndex();
|
||||
@ -77,14 +68,14 @@ doc::AniDir TagWindow::aniDirValue()
|
||||
|
||||
void TagWindow::onPopupUserData()
|
||||
{
|
||||
if (m_userData.color() != colorValue())
|
||||
m_userData.setColor(colorValue());
|
||||
show_user_data_popup(userData()->bounds(), m_userData);
|
||||
color_t color = m_userData.color();
|
||||
app::Color c;
|
||||
this->color()->setColor(c.fromRgb(int(rgba_getr(color)),
|
||||
int(rgba_getg(color)),
|
||||
int(rgba_getb(color)), 255));
|
||||
if (show_user_data_popup(userData()->bounds(), m_userData)) {
|
||||
color_t color = m_userData.color();
|
||||
// Paint the tag properties color picker
|
||||
app::Color c;
|
||||
this->color()->setColor(c.fromRgb(int(rgba_getr(color)),
|
||||
int(rgba_getg(color)),
|
||||
int(rgba_getb(color)), 255));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -31,7 +31,6 @@ namespace app {
|
||||
|
||||
std::string nameValue();
|
||||
void rangeValue(doc::frame_t& from, doc::frame_t& to);
|
||||
doc::color_t colorValue();
|
||||
doc::AniDir aniDirValue();
|
||||
const doc::UserData& userDataValue() { return m_userData; }
|
||||
|
||||
|
@ -227,7 +227,9 @@ bool AsepriteDecoder::decode()
|
||||
if (tagsInProcess) {
|
||||
// Tag user data:
|
||||
doc::Tag* tag = *tag_it;
|
||||
doc::color_t c = tag->color();// this line is for backward compatibility
|
||||
tag->setUserData(userData);
|
||||
tag->setColor(c);// this line is for backward compatibility
|
||||
tag_it++;
|
||||
if (tag_it == tag_end)
|
||||
tagsInProcess = false;
|
||||
@ -946,7 +948,7 @@ void AsepriteDecoder::readTagsChunk(doc::Tags* tags)
|
||||
std::string name = readString();
|
||||
|
||||
auto tag = new doc::Tag(from, to);
|
||||
tag->setColor(doc::rgba(r, g, b, 255));
|
||||
tag->setColor(doc::rgba(r, g, b, 255));// this line is for backward compatibility
|
||||
tag->setName(name);
|
||||
tag->setAniDir((doc::AniDir)aniDir);
|
||||
tags->add(tag);
|
||||
|
@ -24,6 +24,8 @@ Tag::Tag(frame_t from, frame_t to)
|
||||
, m_name("Tag")
|
||||
, m_aniDir(AniDir::FORWARD)
|
||||
{
|
||||
color_t defaultColor = rgba_a_mask;// black color with full opacity.
|
||||
userData().setColor(defaultColor);
|
||||
}
|
||||
|
||||
Tag::Tag(const Tag& other)
|
||||
|
@ -31,7 +31,6 @@ void write_tag(std::ostream& os, const Tag* tag)
|
||||
write32(os, tag->id());
|
||||
write32(os, tag->fromFrame());
|
||||
write32(os, tag->toFrame());
|
||||
write32(os, tag->color());
|
||||
write8(os, (int)tag->aniDir());
|
||||
write_string(os, tag->name());
|
||||
write_user_data(os, tag->userData());
|
||||
@ -42,13 +41,11 @@ Tag* read_tag(std::istream& is, bool setId)
|
||||
ObjectId id = read32(is);
|
||||
frame_t from = read32(is);
|
||||
frame_t to = read32(is);
|
||||
color_t color = read32(is);
|
||||
AniDir aniDir = (AniDir)read8(is);
|
||||
std::string name = read_string(is);
|
||||
UserData userData = read_user_data(is);
|
||||
|
||||
std::unique_ptr<Tag> tag(new Tag(from, to));
|
||||
tag->setColor(color);
|
||||
tag->setAniDir(aniDir);
|
||||
tag->setName(name);
|
||||
tag->setUserData(userData);
|
||||
|
Loading…
x
Reference in New Issue
Block a user