Timeline: Add proper clip to frames header and cels area

This commit is contained in:
David Capello 2013-12-15 17:26:29 -03:00
parent ad6f18c11c
commit 792cbd9d35
2 changed files with 49 additions and 5 deletions

View File

@ -752,12 +752,21 @@ void Timeline::onPaint(ui::PaintEvent& ev)
drawHeader(g);
// Draw the header for each visible frame.
for (frame=first_frame; frame<=last_frame; ++frame)
drawHeaderFrame(g, frame);
{
IntersectClip clip(g, getFrameHeadersBounds());
if (clip) {
for (frame=first_frame; frame<=last_frame; ++frame)
drawHeaderFrame(g, frame);
}
}
// Draw each visible layer.
for (layer=first_layer; layer<=last_layer; layer++) {
drawLayer(g, layer);
{
IntersectClip clip(g, getLayerHeadersBounds());
if (clip)
drawLayer(g, layer);
}
// Get the first CelIterator to be drawn (it is the first cel with cel->frame >= first_frame)
CelIterator it, end;
@ -769,6 +778,10 @@ void Timeline::onPaint(ui::PaintEvent& ev)
;
}
IntersectClip clip(g, getCelsBounds());
if (!clip)
continue;
// Draw every visible cel for each layer.
for (frame=first_frame; frame<=last_frame; ++frame) {
Cel* cel = (layerPtr->isImage() && it != end && (*it)->getFrame() == frame ? *it: NULL);
@ -931,9 +944,9 @@ void Timeline::setCursor(int x, int y)
void Timeline::getDrawableLayers(ui::Graphics* g, int* first_layer, int* last_layer)
{
*first_layer = m_scroll_y / LAYSIZE;
*first_layer = MID(0, *first_layer, m_layers.size()-1);
*first_layer = MID(0, *first_layer, (int)m_layers.size()-1);
*last_layer = *first_layer + (getClientBounds().h - HDRSIZE) / LAYSIZE;
*last_layer = MID(0, *last_layer, m_layers.size()-1);
*last_layer = MID(0, *last_layer, (int)m_layers.size()-1);
}
void Timeline::getDrawableFrames(ui::Graphics* g, FrameNumber* first_frame, FrameNumber* last_frame)
@ -1109,6 +1122,34 @@ void Timeline::drawPaddings(ui::Graphics* g)
NULL, m_timelinePaddingBrStyle);
}
gfx::Rect Timeline::getLayerHeadersBounds() const
{
gfx::Rect rc = getClientBounds();
rc.w = m_separator_x;
rc.y += HDRSIZE;
rc.h -= HDRSIZE;
return rc;
}
gfx::Rect Timeline::getFrameHeadersBounds() const
{
gfx::Rect rc = getClientBounds();
rc.x += m_separator_x;
rc.w -= m_separator_x;
rc.h = HDRSIZE;
return rc;
}
gfx::Rect Timeline::getCelsBounds() const
{
gfx::Rect rc = getClientBounds();
rc.x += m_separator_x;
rc.w -= m_separator_x;
rc.y += HDRSIZE;
rc.h -= HDRSIZE;
return rc;
}
gfx::Rect Timeline::getPartBounds(int part, int layer, FrameNumber frame) const
{
const gfx::Rect bounds = getBounds();

View File

@ -115,6 +115,9 @@ namespace app {
void drawCel(ui::Graphics* g, int layer_index, FrameNumber frame, Cel* cel);
void drawPaddings(ui::Graphics* g);
bool drawPart(ui::Graphics* g, int part, int layer, FrameNumber frame);
gfx::Rect getLayerHeadersBounds() const;
gfx::Rect getFrameHeadersBounds() const;
gfx::Rect getCelsBounds() const;
gfx::Rect getPartBounds(int part, int layer = 0, FrameNumber frame = FrameNumber(0)) const;
void invalidatePart(int part, int layer, FrameNumber frame);
void regenerateLayers();