mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Fix issue 426: The user should not be able to change cel opacity in Indexed images
This commit is contained in:
parent
ff493552aa
commit
a5d6af7d87
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2014 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -112,9 +112,16 @@ void CelPropertiesCommand::onExecute(Context* context)
|
||||
if (layer->isBackground()) {
|
||||
slider_opacity->setEnabled(false);
|
||||
tooltipManager->addTooltipFor(slider_opacity,
|
||||
"The `Background' layer is opaque,\n"
|
||||
"you can't change its opacity.",
|
||||
JI_LEFT);
|
||||
"The `Background' layer is opaque,\n"
|
||||
"its opacity can't be changed.",
|
||||
JI_LEFT);
|
||||
}
|
||||
else if (sprite->pixelFormat() == IMAGE_INDEXED) {
|
||||
slider_opacity->setEnabled(false);
|
||||
tooltipManager->addTooltipFor(slider_opacity,
|
||||
"Cel opacity of Indexed images\n"
|
||||
"cannot be changed.",
|
||||
JI_LEFT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2014 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -195,6 +195,17 @@ void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, Ditherin
|
||||
replaceStockImage(sprite, c, new_image);
|
||||
}
|
||||
|
||||
// Set all cels opacity to 100% if we are converting to indexed.
|
||||
if (newFormat == IMAGE_INDEXED) {
|
||||
CelList cels;
|
||||
sprite->getCels(cels);
|
||||
for (CelIterator it = cels.begin(), end = cels.end(); it != end; ++it) {
|
||||
Cel* cel = *it;
|
||||
if (cel->opacity() < 255)
|
||||
setCelOpacity(sprite, *it, 255);
|
||||
}
|
||||
}
|
||||
|
||||
// Change sprite's pixel format.
|
||||
if (undoEnabled())
|
||||
m_undoers->pushUndoer(new undoers::SetSpritePixelFormat(getObjects(), sprite));
|
||||
@ -576,6 +587,7 @@ void DocumentApi::setCelPosition(Sprite* sprite, Cel* cel, int x, int y)
|
||||
void DocumentApi::setCelOpacity(Sprite* sprite, Cel* cel, int newOpacity)
|
||||
{
|
||||
ASSERT(cel);
|
||||
ASSERT(sprite->supportAlpha());
|
||||
|
||||
if (undoEnabled())
|
||||
m_undoers->pushUndoer(new undoers::SetCelOpacity(getObjects(), cel));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
* Copyright (C) 2001-2014 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -432,8 +432,10 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
updateSubwidgetsVisibility();
|
||||
|
||||
const Document* document = UIContext::instance()->activeDocument();
|
||||
if (document != NULL)
|
||||
if (document != NULL) {
|
||||
updateFromLayer();
|
||||
updateCurrentFrame();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -610,7 +612,9 @@ void StatusBar::updateFromLayer()
|
||||
const Cel* cel;
|
||||
|
||||
// Opacity layer
|
||||
if (reader.layer() &&
|
||||
if (reader.sprite() &&
|
||||
reader.sprite()->supportAlpha() &&
|
||||
reader.layer() &&
|
||||
reader.layer()->isImage() &&
|
||||
!reader.layer()->isBackground() &&
|
||||
(cel = reader.cel())) {
|
||||
|
@ -174,6 +174,16 @@ bool Sprite::needAlpha() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Sprite::supportAlpha() const
|
||||
{
|
||||
switch (m_format) {
|
||||
case IMAGE_RGB:
|
||||
case IMAGE_GRAYSCALE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sprite::setTransparentColor(color_t color)
|
||||
{
|
||||
m_transparentColor = color;
|
||||
|
@ -71,6 +71,7 @@ namespace raster {
|
||||
// than 255. Only RGBA and Grayscale images without background needs
|
||||
// alpha channel in the render.
|
||||
bool needAlpha() const;
|
||||
bool supportAlpha() const;
|
||||
|
||||
color_t transparentColor() const { return m_transparentColor; }
|
||||
void setTransparentColor(color_t color);
|
||||
|
Loading…
x
Reference in New Issue
Block a user