mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 05:42:32 +00:00
Timeline: Add proper clip to frames header and cels area
This commit is contained in:
parent
ad6f18c11c
commit
792cbd9d35
@ -752,12 +752,21 @@ void Timeline::onPaint(ui::PaintEvent& ev)
|
|||||||
drawHeader(g);
|
drawHeader(g);
|
||||||
|
|
||||||
// Draw the header for each visible frame.
|
// 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.
|
// Draw each visible layer.
|
||||||
for (layer=first_layer; layer<=last_layer; 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)
|
// Get the first CelIterator to be drawn (it is the first cel with cel->frame >= first_frame)
|
||||||
CelIterator it, end;
|
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.
|
// Draw every visible cel for each layer.
|
||||||
for (frame=first_frame; frame<=last_frame; ++frame) {
|
for (frame=first_frame; frame<=last_frame; ++frame) {
|
||||||
Cel* cel = (layerPtr->isImage() && it != end && (*it)->getFrame() == frame ? *it: NULL);
|
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)
|
void Timeline::getDrawableLayers(ui::Graphics* g, int* first_layer, int* last_layer)
|
||||||
{
|
{
|
||||||
*first_layer = m_scroll_y / LAYSIZE;
|
*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 = *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)
|
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);
|
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
|
gfx::Rect Timeline::getPartBounds(int part, int layer, FrameNumber frame) const
|
||||||
{
|
{
|
||||||
const gfx::Rect bounds = getBounds();
|
const gfx::Rect bounds = getBounds();
|
||||||
|
@ -115,6 +115,9 @@ namespace app {
|
|||||||
void drawCel(ui::Graphics* g, int layer_index, FrameNumber frame, Cel* cel);
|
void drawCel(ui::Graphics* g, int layer_index, FrameNumber frame, Cel* cel);
|
||||||
void drawPaddings(ui::Graphics* g);
|
void drawPaddings(ui::Graphics* g);
|
||||||
bool drawPart(ui::Graphics* g, int part, int layer, FrameNumber frame);
|
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;
|
gfx::Rect getPartBounds(int part, int layer = 0, FrameNumber frame = FrameNumber(0)) const;
|
||||||
void invalidatePart(int part, int layer, FrameNumber frame);
|
void invalidatePart(int part, int layer, FrameNumber frame);
|
||||||
void regenerateLayers();
|
void regenerateLayers();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user