mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Draw thumbnails inside cel box (item in #1271)
This commit is contained in:
parent
b24fccb76a
commit
534458a2c1
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@ -277,19 +277,19 @@
|
||||
<part id="timeline_closed_group_active" x="288" y="60" w="12" h="12" />
|
||||
<part id="timeline_open_group_normal" x="276" y="72" w="12" h="12" />
|
||||
<part id="timeline_open_group_active" x="288" y="72" w="12" h="12" />
|
||||
<part id="timeline_empty_frame_normal" x="240" y="60" w="12" h="12" />
|
||||
<part id="timeline_empty_frame_active" x="252" y="60" w="12" h="12" />
|
||||
<part id="timeline_keyframe_normal" x="240" y="72" w="12" h="12" />
|
||||
<part id="timeline_keyframe_active" x="252" y="72" w="12" h="12" />
|
||||
<part id="timeline_from_left_normal" x="240" y="84" w="12" h="12" />
|
||||
<part id="timeline_from_left_active" x="252" y="84" w="12" h="12" />
|
||||
<part id="timeline_from_right_normal" x="240" y="96" w="12" h="12" />
|
||||
<part id="timeline_from_right_active" x="252" y="96" w="12" h="12" />
|
||||
<part id="timeline_from_both_normal" x="240" y="108" w="12" h="12" />
|
||||
<part id="timeline_from_both_active" x="252" y="108" w="12" h="12" />
|
||||
<part id="timeline_left_link_active" x="264" y="84" w="12" h="12" />
|
||||
<part id="timeline_both_links_active" x="264" y="96" w="12" h="12" />
|
||||
<part id="timeline_right_link_active" x="264" y="108" w="12" h="12" />
|
||||
<part id="timeline_empty_frame_normal" x="240" y="60" w1="5" w2="3" w3="4" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_empty_frame_active" x="252" y="60" w1="5" w2="3" w3="4" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_keyframe_normal" x="240" y="72" w1="5" w2="3" w3="4" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_keyframe_active" x="252" y="72" w1="5" w2="3" w3="4" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_from_left_normal" x="240" y="84" w1="0" w2="8" w3="4" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_from_left_active" x="252" y="84" w1="0" w2="8" w3="4" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_from_right_normal" x="240" y="96" w1="5" w2="7" w3="0" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_from_right_active" x="252" y="96" w1="5" w2="7" w3="0" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_from_both_normal" x="240" y="108" w1="0" w2="12" w3="0" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_from_both_active" x="252" y="108" w1="0" w2="12" w3="0" h1="5" h2="3" h3="4" />
|
||||
<part id="timeline_left_link_active" x="264" y="84" w1="3" w2="9" w3="0" h1="4" h2="1" h3="7" />
|
||||
<part id="timeline_both_links_active" x="264" y="96" w1="0" w2="12" w3="0" h1="4" h2="1" h3="7" />
|
||||
<part id="timeline_right_link_active" x="264" y="108" w1="0" w2="9" w3="3" h1="4" h2="1" h3="7" />
|
||||
<part id="timeline_gear" x="264" y="12" w="12" h="12" />
|
||||
<part id="timeline_gear_active" x="264" y="24" w="12" h="12" />
|
||||
<part id="timeline_onionskin" x="264" y="36" w="12" h="12" />
|
||||
@ -805,33 +805,33 @@
|
||||
<text color="timeline_clicked_text" />
|
||||
</style>
|
||||
<style id="timeline_empty_frame">
|
||||
<icon part="timeline_empty_frame_normal" />
|
||||
<icon part="timeline_empty_frame_active" state="focus" />
|
||||
<background part="timeline_empty_frame_normal" />
|
||||
<background part="timeline_empty_frame_active" state="focus" />
|
||||
</style>
|
||||
<style id="timeline_keyframe">
|
||||
<icon part="timeline_keyframe_normal" />
|
||||
<icon part="timeline_keyframe_active" state="focus" />
|
||||
<background part="timeline_keyframe_normal" />
|
||||
<background part="timeline_keyframe_active" state="focus" />
|
||||
</style>
|
||||
<style id="timeline_from_left">
|
||||
<icon part="timeline_from_left_normal" />
|
||||
<icon part="timeline_from_left_active" state="focus" />
|
||||
<background part="timeline_from_left_normal" />
|
||||
<background part="timeline_from_left_active" state="focus" />
|
||||
</style>
|
||||
<style id="timeline_from_right">
|
||||
<icon part="timeline_from_right_normal" />
|
||||
<icon part="timeline_from_right_active" state="focus" />
|
||||
<background part="timeline_from_right_normal" />
|
||||
<background part="timeline_from_right_active" state="focus" />
|
||||
</style>
|
||||
<style id="timeline_from_both">
|
||||
<icon part="timeline_from_both_normal" />
|
||||
<icon part="timeline_from_both_active" state="focus" />
|
||||
<background part="timeline_from_both_normal" />
|
||||
<background part="timeline_from_both_active" state="focus" />
|
||||
</style>
|
||||
<style id="timeline_left_link">
|
||||
<icon part="timeline_left_link_active" />
|
||||
<background part="timeline_left_link_active" />
|
||||
</style>
|
||||
<style id="timeline_right_link">
|
||||
<icon part="timeline_right_link_active" />
|
||||
<background part="timeline_right_link_active" />
|
||||
</style>
|
||||
<style id="timeline_both_links">
|
||||
<icon part="timeline_both_links_active" />
|
||||
<background part="timeline_both_links_active" />
|
||||
</style>
|
||||
<style id="timeline_gear" extends="timeline_box">
|
||||
<icon part="timeline_gear" />
|
||||
|
@ -1912,88 +1912,78 @@ void Timeline::drawCel(ui::Graphics* g, layer_t layerIndex, frame_t frame, Cel*
|
||||
if (!clip)
|
||||
return;
|
||||
|
||||
if (layer == m_layer && frame == m_frame)
|
||||
// Draw background
|
||||
if (layer == m_layer &&
|
||||
frame == m_frame)
|
||||
drawPart(g, bounds, nullptr, styles.timelineSelectedCel(), false, false, true);
|
||||
else
|
||||
drawPart(g, bounds, nullptr, styles.timelineBox(), is_active, is_hover);
|
||||
|
||||
// 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) {
|
||||
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),
|
||||
doc::rgba_geta(celColor)),
|
||||
b2);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw keyframe shape
|
||||
|
||||
ui::Style* style = nullptr;
|
||||
bool fromLeft = false;
|
||||
bool fromRight = false;
|
||||
if (is_empty || !data) {
|
||||
style = styles.timelineEmptyFrame();
|
||||
}
|
||||
else {
|
||||
// Calculate which cel is next to this one (in previous and next
|
||||
// frame).
|
||||
Cel* left = (data->prevIt != data->end ? *data->prevIt: nullptr);
|
||||
Cel* right = (data->nextIt != data->end ? *data->nextIt: nullptr);
|
||||
if (left && left->frame() != frame-1) left = nullptr;
|
||||
if (right && right->frame() != frame+1) right = nullptr;
|
||||
|
||||
ObjectId leftImg = (left ? left->image()->id(): 0);
|
||||
ObjectId rightImg = (right ? right->image()->id(): 0);
|
||||
fromLeft = (leftImg == cel->image()->id());
|
||||
fromRight = (rightImg == cel->image()->id());
|
||||
|
||||
if (fromLeft && fromRight)
|
||||
style = styles.timelineFromBoth();
|
||||
else if (fromLeft)
|
||||
style = styles.timelineFromLeft();
|
||||
else if (fromRight)
|
||||
style = styles.timelineFromRight();
|
||||
else
|
||||
style = styles.timelineKeyframe();
|
||||
}
|
||||
|
||||
drawPart(g, bounds, nullptr, style, is_active, is_hover);
|
||||
|
||||
// Draw thumbnail
|
||||
if ((docPref().thumbnails.enabled() || m_zoom > 1) && image) {
|
||||
gfx::Rect thumb_bounds = gfx::Rect(bounds).shrink(guiscale()).inflate(guiscale(), guiscale());
|
||||
if(m_zoom > 1)
|
||||
thumb_bounds.inflate(0, -headerBoxHeight()).offset(0, headerBoxHeight());
|
||||
gfx::Rect thumb_bounds =
|
||||
gfx::Rect(bounds).shrink(
|
||||
skinTheme()->calcBorder(this, style));
|
||||
|
||||
if(!thumb_bounds.isEmpty()) {
|
||||
if (!thumb_bounds.isEmpty()) {
|
||||
she::Surface* thumb_surf = thumb::get_cel_thumbnail(cel, thumb_bounds.size());
|
||||
|
||||
g->drawRgbaSurface(thumb_surf, thumb_bounds.x, thumb_bounds.y);
|
||||
|
||||
thumb_surf->dispose();
|
||||
if (thumb_surf) {
|
||||
g->drawRgbaSurface(thumb_surf, thumb_bounds.x, thumb_bounds.y);
|
||||
thumb_surf->dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!docPref().thumbnails.enabled() || m_zoom > 1 || !image) {
|
||||
bounds.h = headerBoxHeight();
|
||||
|
||||
// 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) {
|
||||
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),
|
||||
doc::rgba_geta(celColor)),
|
||||
b2);
|
||||
}
|
||||
}
|
||||
|
||||
bounds.w = headerBoxWidth();
|
||||
|
||||
ui::Style* style = nullptr;
|
||||
bool fromLeft = false;
|
||||
bool fromRight = false;
|
||||
if (is_empty || !data) {
|
||||
style = styles.timelineEmptyFrame();
|
||||
}
|
||||
else {
|
||||
// Calculate which cel is next to this one (in previous and next
|
||||
// frame).
|
||||
Cel* left = (data->prevIt != data->end ? *data->prevIt: nullptr);
|
||||
Cel* right = (data->nextIt != data->end ? *data->nextIt: nullptr);
|
||||
if (left && left->frame() != frame-1) left = nullptr;
|
||||
if (right && right->frame() != frame+1) right = nullptr;
|
||||
|
||||
ObjectId leftImg = (left ? left->image()->id(): 0);
|
||||
ObjectId rightImg = (right ? right->image()->id(): 0);
|
||||
fromLeft = (leftImg == cel->image()->id());
|
||||
fromRight = (rightImg == cel->image()->id());
|
||||
|
||||
if (fromLeft && fromRight)
|
||||
style = styles.timelineFromBoth();
|
||||
else if (fromLeft)
|
||||
style = styles.timelineFromLeft();
|
||||
else if (fromRight)
|
||||
style = styles.timelineFromRight();
|
||||
else
|
||||
style = styles.timelineKeyframe();
|
||||
}
|
||||
drawPart(g, bounds, nullptr, style, is_active, is_hover);
|
||||
|
||||
if (m_zoom > 1) {
|
||||
if (style == styles.timelineFromBoth() ||
|
||||
style == styles.timelineFromRight()) {
|
||||
style = styles.timelineFromBoth();
|
||||
while ((bounds.x += bounds.w) < full_bounds.x + full_bounds.w) {
|
||||
drawPart(g, bounds, nullptr, style, is_active, is_hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw decorators to link the activeCel with its links.
|
||||
if (data && data->activeIt != data->end)
|
||||
drawCelLinkDecorators(g, full_bounds, cel, frame, is_active, is_hover, data);
|
||||
}
|
||||
// Draw decorators to link the activeCel with its links.
|
||||
if (data && data->activeIt != data->end)
|
||||
drawCelLinkDecorators(g, full_bounds, cel, frame, is_active, is_hover, data);
|
||||
}
|
||||
|
||||
void Timeline::updateCelOverlayBounds(const Hit& hit)
|
||||
@ -2102,15 +2092,15 @@ void Timeline::drawCelOverlay(ui::Graphics* g)
|
||||
overlay_surf->dispose();
|
||||
}
|
||||
|
||||
void Timeline::drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& full_bounds,
|
||||
void Timeline::drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& bounds,
|
||||
Cel* cel, frame_t frame, bool is_active, bool is_hover,
|
||||
DrawCelData* data)
|
||||
{
|
||||
auto& styles = skinTheme()->styles;
|
||||
ObjectId imageId = (*data->activeIt)->image()->id();
|
||||
|
||||
gfx::Rect bounds = gfx::Rect(full_bounds).setSize(gfx::Size(headerBoxWidth(), headerBoxHeight()));
|
||||
ui::Style* style = NULL;
|
||||
ui::Style* style1 = nullptr;
|
||||
ui::Style* style2 = nullptr;
|
||||
|
||||
// Links at the left or right side
|
||||
bool left = (data->firstLink != data->end ? frame > (*data->firstLink)->frame(): false);
|
||||
@ -2120,29 +2110,21 @@ void Timeline::drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& full_boun
|
||||
if (left) {
|
||||
Cel* prevCel = m_layer->cel(cel->frame()-1);
|
||||
if (!prevCel || prevCel->image()->id() != imageId)
|
||||
style = styles.timelineLeftLink();
|
||||
style1 = styles.timelineLeftLink();
|
||||
}
|
||||
if (right) {
|
||||
Cel* nextCel = m_layer->cel(cel->frame()+1);
|
||||
if (!nextCel || nextCel->image()->id() != imageId)
|
||||
style = styles.timelineRightLink();
|
||||
style2 = styles.timelineRightLink();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (left && right)
|
||||
style = styles.timelineBothLinks();
|
||||
style1 = styles.timelineBothLinks();
|
||||
}
|
||||
|
||||
if (style) {
|
||||
drawPart(g, bounds, nullptr, style, is_active, is_hover);
|
||||
|
||||
if (m_zoom > 1 && (style == styles.timelineBothLinks() || style == styles.timelineRightLink())) {
|
||||
style = styles.timelineBothLinks();
|
||||
while ((bounds.x += bounds.w) < full_bounds.x + full_bounds.w) {
|
||||
drawPart(g, bounds, nullptr, style, is_active, is_hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (style1) drawPart(g, bounds, nullptr, style1, is_active, is_hover);
|
||||
if (style2) drawPart(g, bounds, nullptr, style2, is_active, is_hover);
|
||||
}
|
||||
|
||||
void Timeline::drawFrameTags(ui::Graphics* g)
|
||||
|
Loading…
x
Reference in New Issue
Block a user