Draw layers and cels in Timeline w/user-defined color in UserData

This commit is contained in:
David Capello 2015-12-11 19:37:19 -03:00
parent addddf78a5
commit 868376380f

View File

@ -1350,8 +1350,10 @@ void Timeline::drawLayer(ui::Graphics* g, LayerIndex layerIdx)
(hotlayer && m_hot.part == PART_LAYER_CONTINUOUS_ICON),
(clklayer && m_clk.part == PART_LAYER_CONTINUOUS_ICON));
// Draw the layer's name.
// Get the layer's name bounds.
bounds = getPartBounds(Hit(PART_LAYER_TEXT, layerIdx));
// Draw layer name.
drawPart(g, bounds, layer->name().c_str(), styles.timelineLayer(),
is_active,
(hotlayer && m_hot.part == PART_LAYER_TEXT),
@ -1368,6 +1370,18 @@ void Timeline::drawLayer(ui::Graphics* g, LayerIndex layerIdx)
font()->textLength(layer->name().c_str()), s));
}
// Fill with an user-defined custom color.
doc::color_t layerColor = layer->userData().color();
if (doc::rgba_geta(layerColor) > 0) {
int alpha = doc::rgba_geta(layerColor) * 3 / 4;
auto b2 = bounds;
b2.shrink(1*guiscale()).inflate(1*guiscale());
g->fillRect(gfx::rgba(doc::rgba_getr(layerColor),
doc::rgba_getg(layerColor),
doc::rgba_getb(layerColor), alpha),
b2);
}
// If this layer wasn't clicked but there are another layer clicked,
// we have to draw some indicators to show that the user can move
// layers.
@ -1432,6 +1446,20 @@ void Timeline::drawCel(ui::Graphics* g, LayerIndex layerIndex, frame_t frame, Ce
// Draw decorators to link the activeCel with its links.
if (data->activeIt != data->end)
drawCelLinkDecorators(g, bounds, cel, frame, is_active, is_hover, data);
// Fill with an user-defined custom color.
if (cel && cel->data()) {
doc::color_t celColor = cel->data()->userData().color();
if (doc::rgba_geta(celColor) > 0) {
int alpha = doc::rgba_geta(celColor) * 3 / 4;
auto b2 = bounds;
b2.shrink(1*guiscale()).inflate(1*guiscale());
g->fillRect(gfx::rgba(doc::rgba_getr(celColor),
doc::rgba_getg(celColor),
doc::rgba_getb(celColor), alpha),
b2);
}
}
}
void Timeline::drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& bounds,