Color frame tag lines (related to #920)

This commit is contained in:
David Capello 2017-03-27 12:32:39 -03:00
parent 054d3b139a
commit 043489e532
7 changed files with 133 additions and 81 deletions

View File

@ -254,6 +254,7 @@
<part id="drop_down_button_right_selected" x="71" y="48" w1="2" w2="2" w3="3" h1="4" h2="6" h3="6" />
<part id="transformation_handle" x="208" y="144" w="5" h="5" />
<part id="pivot_handle" x="224" y="144" w="9" h="9" />
<part id="timeline_none" x="228" y="0" w1="2" w2="8" w3="2" h1="2" h2="8" h3="2" />
<part id="timeline_normal" x="240" y="0" w1="2" w2="8" w3="2" h1="2" h2="8" h3="2" />
<part id="timeline_active" x="252" y="0" w1="2" w2="8" w3="2" h1="2" h2="8" h3="2" />
<part id="timeline_hover" x="264" y="0" w1="2" w2="8" w3="2" h1="2" h2="8" h3="2" />
@ -497,9 +498,11 @@
<text color="disabled" state="disabled" />
</style>
<style id="check_box" border="2">
<background part="check_focus" color="check_hot_face" state="mouse focus" />
<background part="check_focus" color="check_focus_face" state="focus" />
<background color="check_hot_face" state="mouse focus" />
<background color="check_focus_face" state="focus" />
<background color="check_hot_face" state="mouse" />
<newlayer />
<background part="check_focus" state="focus" />
<text color="text" align="left middle" x="14" />
<text color="disabled" align="left middle" x="14" state="disabled" />
<icon part="check_normal" align="left middle" x="2" />
@ -507,9 +510,11 @@
<icon part="check_disabled" align="left middle" x="2" state="disabled" />
</style>
<style id="radio_button" border="2">
<background part="radio_focus" color="radio_hot_face" state="mouse focus" />
<background part="radio_focus" color="radio_focus_face" state="focus" />
<background color="radio_hot_face" state="mouse focus" />
<background color="radio_focus_face" state="focus" />
<background color="radio_hot_face" state="mouse" />
<newlayer />
<background part="radio_focus" state="focus" />
<text color="text" align="left middle" x="14" />
<text color="disabled" align="left middle" x="14" state="disabled" />
<icon part="radio_normal" align="left middle" x="2" />
@ -581,12 +586,14 @@
<background color="workspace" />
</style>
<style id="horizontal_separator" border-left="2" border-top="4" border-right="2" border-bottom="0">
<background-border part="separator_horz" color="window_face" align="middle" />
<background color="window_face" />
<background-border part="separator_horz" align="middle" />
<text color="separator_label" x="4" align="left middle" />
</style>
<style id="menu_separator" extends="horizontal_separator" />
<style id="separator_in_view" extends="horizontal_separator">
<background-border part="separator_horz" color="background" align="middle" />
<background color="background" />
<background-border part="separator_horz" align="middle" />
</style>
<style id="vertical_separator" border-left="4" border-top="2" border-right="1" border-bottom="2">
<background-border part="separator_vert" align="center" />
@ -652,8 +659,10 @@
<text color="tab_active_text" align="left middle" x="4" y="1" state="focus" />
</style>
<style id="tab_bottom">
<background color="tab_active_face" state="focus" />
<newlayer />
<background part="tab_bottom_normal" align="middle" />
<background part="tab_bottom_active" color="tab_active_face" state="focus" />
<background part="tab_bottom_active" state="focus" />
</style>
<style id="tab_filler">
<background part="tab_filler" align="middle" />
@ -677,9 +686,13 @@
<icon part="tab_home_icon_active" align="left middle" x="4" y="1" state="focus" />
</style>
<style id="flag">
<background part="flag_normal" color="flag_normal" />
<background part="flag_highlight" color="flag_active" state="focus" />
<background part="flag_highlight" color="flag_clicked" state="selected" />
<background color="flag_normal" />
<background color="flag_active" state="focus" />
<background color="flag_clicked" state="selected" />
<newlayer />
<background part="flag_normal" />
<background part="flag_highlight" state="focus" />
<background part="flag_highlight" state="selected" />
</style>
<style id="warning_box" padding-left="2" padding-right="2">
<background color="workspace" />
@ -687,14 +700,14 @@
<icon part="warning_box" align="center middle" />
</style>
<style id="timeline">
<background color="timeline_normal" part="timeline_normal" />
<background part="timeline_normal" />
</style>
<style id="timeline_box">
<background-border color="timeline_normal" part="timeline_normal" />
<background-border color="timeline_hover" part="timeline_hover" state="mouse" />
<background-border color="timeline_active" part="timeline_active" state="focus" />
<background-border color="timeline_active_hover" part="timeline_active_hover" state="focus mouse" />
<background-border color="timeline_clicked" part="timeline_clicked" state="selected" />
<background-border part="timeline_normal" />
<background-border part="timeline_hover" state="mouse" />
<background-border part="timeline_active" state="focus" />
<background-border part="timeline_active_hover" state="focus mouse" />
<background-border part="timeline_clicked" state="selected" />
</style>
<style id="timeline_open_eye" extends="timeline_box">
<icon part="timeline_open_eye_normal" />
@ -748,10 +761,11 @@
<text color="timeline_clicked_text" align="left middle" x="2" state="selected" />
</style>
<style id="timeline_layer_text_only" extends="timeline_layer">
<background color="none" part="none" repeat="none" />
<background color="none" part="none" repeat="none" state="mouse" />
<background color="none" part="none" repeat="none" state="focus" />
<background color="none" part="none" repeat="none" state="focus mouse" />
<background-border part="timeline_none" />
<background-border part="timeline_none" state="mouse" />
<background-border part="timeline_none" state="focus" />
<background-border part="timeline_none" state="focus mouse" />
<background-border part="timeline_none" state="selected" />
</style>
<style id="timeline_header_frame" extends="timeline_box" font="mini">
<text color="timeline_normal_text" />
@ -761,7 +775,7 @@
<text color="timeline_clicked_text" state="selected" />
</style>
<style id="timeline_selected_cel">
<background color="timeline_clicked" part="timeline_clicked" />
<background part="timeline_clicked" />
<text color="timeline_clicked_text" />
</style>
<style id="timeline_empty_frame">
@ -807,16 +821,16 @@
<background part="timeline_onionskin_range" />
</style>
<style id="timeline_padding">
<background color="timeline_normal" part="timeline_padding" />
<background part="timeline_padding" />
</style>
<style id="timeline_padding_tr">
<background color="timeline_normal" part="timeline_padding_tr" />
<background part="timeline_padding_tr" />
</style>
<style id="timeline_padding_bl">
<background color="timeline_normal" part="timeline_padding_bl" />
<background part="timeline_padding_bl" />
</style>
<style id="timeline_padding_br">
<background color="timeline_normal" part="timeline_padding_br" />
<background part="timeline_padding_br" />
</style>
<style id="timeline_range_outline">
<background part="colorbar_selection" state="focus" />

View File

@ -1538,7 +1538,9 @@ void SkinTheme::drawRect(ui::Graphics* g, const gfx::Rect& rc,
{
Theme::drawSlices(g, m_sheet, rc,
skinPart->spriteBounds(),
skinPart->slicesBounds(), drawCenter);
skinPart->slicesBounds(),
gfx::ColorNone,
drawCenter);
}
void SkinTheme::drawRect2(Graphics* g, const Rect& rc, int x_mid,

View File

@ -2023,16 +2023,24 @@ void Timeline::drawFrameTags(ui::Graphics* g)
bounds.h = bounds.y2() - frameTagBounds.y2();
bounds.y = frameTagBounds.y2();
gfx::Color bg = frameTag->color();
{
IntersectClip clip(g, bounds);
if (clip)
if (clip) {
for (auto& layer : styles.timelineLoopRange()->layers()) {
if (layer.type() == Style::Layer::Type::kBackground ||
layer.type() == Style::Layer::Type::kBackgroundBorder ||
layer.type() == Style::Layer::Type::kBorder) {
const_cast<Style::Layer*>(&layer)->setColor(bg);
}
}
drawPart(g, bounds, nullptr, styles.timelineLoopRange());
}
}
{
bounds = frameTagBounds;
gfx::Color bg = frameTag->color();
if (m_clk.part == PART_FRAME_TAG && m_clk.frameTag == frameTag->id()) {
bg = color_utils::blackandwhite_neg(bg);
}

View File

@ -200,6 +200,17 @@ void Graphics::drawColoredRgbaSurface(she::Surface* surface, gfx::Color color, i
gfx::Clip(m_dx+x, m_dy+y, 0, 0, surface->width(), surface->height()));
}
void Graphics::drawColoredRgbaSurface(she::Surface* surface, gfx::Color color,
int srcx, int srcy, int dstx, int dsty, int w, int h)
{
dirty(gfx::Rect(m_dx+dstx, m_dy+dsty, w, h));
she::SurfaceLock lockSrc(surface);
she::SurfaceLock lockDst(m_surface);
m_surface->drawColoredRgbaSurface(surface, color, gfx::ColorNone,
gfx::Clip(m_dx+dstx, m_dy+dsty, srcx, srcy, w, h));
}
void Graphics::blit(she::Surface* srcSurface, int srcx, int srcy, int dstx, int dsty, int w, int h)
{
dirty(gfx::Rect(m_dx+dstx, m_dy+dsty, w, h));

View File

@ -74,6 +74,7 @@ namespace ui {
void drawRgbaSurface(she::Surface* surface, int x, int y);
void drawRgbaSurface(she::Surface* surface, int srcx, int srcy, int dstx, int dsty, int w, int h);
void drawColoredRgbaSurface(she::Surface* surface, gfx::Color color, int x, int y);
void drawColoredRgbaSurface(she::Surface* surface, gfx::Color color, int srcx, int srcy, int dstx, int dsty, int w, int h);
void blit(she::Surface* src, int srcx, int srcy, int dstx, int dsty, int w, int h);

View File

@ -75,6 +75,19 @@ void for_each_layer(const Widget* widget,
callback);
}
std::function<void(int srcx, int srcy, int dstx, int dsty, int w, int h)>
getDrawSurfaceFunction(Graphics* g, she::Surface* sheet, gfx::Color color)
{
if (color != gfx::ColorNone)
return [g, sheet, color](int srcx, int srcy, int dstx, int dsty, int w, int h) {
g->drawColoredRgbaSurface(sheet, color, srcx, srcy, dstx, dsty, w, h);
};
else
return [g, sheet](int srcx, int srcy, int dstx, int dsty, int w, int h) {
g->drawRgbaSurface(sheet, srcx, srcy, dstx, dsty, w, h);
};
}
} // anonymous namespace
PaintWidgetPartInfo::PaintWidgetPartInfo()
@ -296,17 +309,13 @@ void Theme::paintLayer(Graphics* g,
case Style::Layer::Type::kBackground:
case Style::Layer::Type::kBackgroundBorder:
if (layer.color() != gfx::ColorNone) {
bgColor = layer.color();
g->fillRect(layer.color(), rc);
}
if (layer.spriteSheet() &&
!layer.spriteBounds().isEmpty()) {
if (!layer.slicesBounds().isEmpty()) {
Theme::drawSlices(g, layer.spriteSheet(), rc,
layer.spriteBounds(),
layer.slicesBounds(), true);
layer.slicesBounds(),
layer.color(), true);
if (layer.type() == Style::Layer::Type::kBackgroundBorder) {
rc.x += layer.slicesBounds().x;
@ -319,78 +328,81 @@ void Theme::paintLayer(Graphics* g,
else {
IntersectClip clip(g, rc);
if (clip) {
auto draw = getDrawSurfaceFunction(
g, layer.spriteSheet(), layer.color());
switch (layer.align()) {
// Horizontal line
case MIDDLE:
for (int x=rc.x; x<rc.x2(); x+=layer.spriteBounds().w) {
g->drawRgbaSurface(layer.spriteSheet(),
layer.spriteBounds().x,
layer.spriteBounds().y,
x, rc.y+rc.h/2-layer.spriteBounds().h/2,
layer.spriteBounds().w,
layer.spriteBounds().h);
draw(layer.spriteBounds().x,
layer.spriteBounds().y,
x, rc.y+rc.h/2-layer.spriteBounds().h/2,
layer.spriteBounds().w,
layer.spriteBounds().h);
}
break;
// Vertical line
case CENTER:
for (int y=rc.y; y<rc.y2(); y+=layer.spriteBounds().h) {
g->drawRgbaSurface(layer.spriteSheet(),
layer.spriteBounds().x,
layer.spriteBounds().y,
rc.x+rc.w/2-layer.spriteBounds().w/2, y,
layer.spriteBounds().w,
layer.spriteBounds().h);
draw(layer.spriteBounds().x,
layer.spriteBounds().y,
rc.x+rc.w/2-layer.spriteBounds().w/2, y,
layer.spriteBounds().w,
layer.spriteBounds().h);
}
break;
// One instance
case CENTER | MIDDLE:
g->drawRgbaSurface(layer.spriteSheet(),
layer.spriteBounds().x,
layer.spriteBounds().y,
rc.x+rc.w/2-layer.spriteBounds().w/2,
rc.y+rc.h/2-layer.spriteBounds().h/2,
layer.spriteBounds().w,
layer.spriteBounds().h);
draw(layer.spriteBounds().x,
layer.spriteBounds().y,
rc.x+rc.w/2-layer.spriteBounds().w/2,
rc.y+rc.h/2-layer.spriteBounds().h/2,
layer.spriteBounds().w,
layer.spriteBounds().h);
break;
// Pattern
case 0:
for (int y=rc.y; y<rc.y2(); y+=layer.spriteBounds().h) {
for (int x=rc.x; x<rc.x2(); x+=layer.spriteBounds().w)
g->drawRgbaSurface(layer.spriteSheet(),
layer.spriteBounds().x,
layer.spriteBounds().y,
x, y,
layer.spriteBounds().w,
layer.spriteBounds().h);
draw(layer.spriteBounds().x,
layer.spriteBounds().y,
x, y,
layer.spriteBounds().w,
layer.spriteBounds().h);
}
break;
}
}
}
}
else if (layer.color() != gfx::ColorNone) {
bgColor = layer.color();
g->fillRect(layer.color(), rc);
}
break;
case Style::Layer::Type::kBorder:
if (layer.color() != gfx::ColorNone) {
g->drawRect(layer.color(), rc);
}
if (layer.spriteSheet() &&
!layer.spriteBounds().isEmpty() &&
!layer.slicesBounds().isEmpty()) {
Theme::drawSlices(g, layer.spriteSheet(), rc,
layer.spriteBounds(),
layer.slicesBounds(), false);
layer.slicesBounds(),
layer.color(), false);
rc.x += layer.slicesBounds().x;
rc.y += layer.slicesBounds().y;
rc.w -= layer.spriteBounds().w - layer.slicesBounds().w;
rc.h -= layer.spriteBounds().h - layer.slicesBounds().h;
}
else if (layer.color() != gfx::ColorNone) {
g->drawRect(layer.color(), rc);
}
break;
case Style::Layer::Type::kText:
@ -672,6 +684,7 @@ void Theme::drawSlices(Graphics* g, she::Surface* sheet,
const gfx::Rect& rc,
const gfx::Rect& sprite,
const gfx::Rect& slices,
const gfx::Color color,
const bool drawCenter)
{
const int w1 = slices.x;
@ -682,51 +695,52 @@ void Theme::drawSlices(Graphics* g, she::Surface* sheet,
const int h3 = sprite.h-h1-h2;
const int x2 = rc.x2()-w3;
const int y2 = rc.y2()-h3;
auto draw = getDrawSurfaceFunction(g, sheet, color);
// Top
int x = rc.x;
int y = rc.y;
g->drawRgbaSurface(sheet, sprite.x, sprite.y,
x, y, w1, h1);
draw(sprite.x, sprite.y,
x, y, w1, h1);
{
IntersectClip clip(g, gfx::Rect(rc.x+w1, rc.y, rc.w-w1-w3, h1));
if (clip) {
for (x+=w1; x<x2; x+=w2) {
g->drawRgbaSurface(sheet, sprite.x+w1, sprite.y,
x, y, w2, h1);
draw(sprite.x+w1, sprite.y,
x, y, w2, h1);
}
}
}
g->drawRgbaSurface(sheet, sprite.x+w1+w2, sprite.y,
x2, y, w3, h1);
draw(sprite.x+w1+w2, sprite.y,
x2, y, w3, h1);
// Bottom
x = rc.x;
y = y2;
g->drawRgbaSurface(sheet, sprite.x, sprite.y+h1+h2,
x, y, w1, h3);
draw(sprite.x, sprite.y+h1+h2,
x, y, w1, h3);
{
IntersectClip clip(g, gfx::Rect(rc.x+w1, y2, rc.w-w1-w3, h3));
if (clip) {
for (x+=w1; x<x2; x+=w2) {
g->drawRgbaSurface(sheet, sprite.x+w1, sprite.y+h1+h2,
x, y2, w2, h3);
draw(sprite.x+w1, sprite.y+h1+h2,
x, y2, w2, h3);
}
}
}
g->drawRgbaSurface(sheet, sprite.x+w1+w2, sprite.y+h1+h2,
x2, y2, w3, h3);
draw(sprite.x+w1+w2, sprite.y+h1+h2,
x2, y2, w3, h3);
// Left & Right
IntersectClip clip(g, gfx::Rect(rc.x, rc.y+h1, rc.w, rc.h-h1-h3));
if (clip) {
for (y=rc.y+h1; y<y2; y+=h2) {
// Left
g->drawRgbaSurface(sheet, sprite.x, sprite.y+h1,
rc.x, y, w1, h2);
draw(sprite.x, sprite.y+h1,
rc.x, y, w1, h2);
// Right
g->drawRgbaSurface(sheet, sprite.x+w1+w2, sprite.y+h1,
x2, y, w3, h2);
draw(sprite.x+w1+w2, sprite.y+h1,
x2, y, w3, h2);
}
}
@ -736,7 +750,8 @@ void Theme::drawSlices(Graphics* g, she::Surface* sheet,
if (clip) {
for (y=rc.y+h1; y<y2; y+=h2) {
for (x=rc.x+w1; x<x2; x+=w2)
g->drawRgbaSurface(sheet, sprite.x+w1, sprite.y+h1, x, y, w2, h2);
draw(sprite.x+w1, sprite.y+h1,
x, y, w2, h2);
}
}
}

View File

@ -118,6 +118,7 @@ namespace ui {
const gfx::Rect& rc,
const gfx::Rect& sprite,
const gfx::Rect& slices,
const gfx::Color color,
const bool drawCenter = true);
static void drawTextBox(Graphics* g, Widget* textbox,