From 792cbd9d355c740ccf78cb07ebfb460b9fdcd2dc Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 15 Dec 2013 17:26:29 -0300 Subject: [PATCH] Timeline: Add proper clip to frames header and cels area --- src/app/ui/timeline.cpp | 51 +++++++++++++++++++++++++++++++++++++---- src/app/ui/timeline.h | 3 +++ 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/app/ui/timeline.cpp b/src/app/ui/timeline.cpp index b89d0609e..2dd752a18 100644 --- a/src/app/ui/timeline.cpp +++ b/src/app/ui/timeline.cpp @@ -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(); diff --git a/src/app/ui/timeline.h b/src/app/ui/timeline.h index 70e5fa2e5..bf796c6d4 100644 --- a/src/app/ui/timeline.h +++ b/src/app/ui/timeline.h @@ -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();