[aseprite] 157/308: Modify style of colored layers and cels in Timeline
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 7b5827a1514737e773726554ca2fd40e8b645e34
Author: David Capello <davidcapello at gmail.com>
Date: Wed Dec 23 19:57:31 2015 -0300
Modify style of colored layers and cels in Timeline
Now colored layers/cels are filled with the user-defined color as
background and the text in the foreground.
---
data/skins/default/sheet.png | Bin 14067 -> 14192 bytes
data/skins/default/skin.xml | 12 +++++++
src/app/ui/skin/skin_theme.cpp | 14 ++++++--
src/app/ui/timeline.cpp | 71 ++++++++++++++++++++++++-----------------
4 files changed, 64 insertions(+), 33 deletions(-)
diff --git a/data/skins/default/sheet.png b/data/skins/default/sheet.png
index 7b796bc..5df7474 100644
Binary files a/data/skins/default/sheet.png and b/data/skins/default/sheet.png differ
diff --git a/data/skins/default/skin.xml b/data/skins/default/skin.xml
index 5cbca26..0b715ab 100644
--- a/data/skins/default/skin.xml
+++ b/data/skins/default/skin.xml
@@ -564,6 +564,18 @@
<style id="timeline_layer" base="timeline_box">
<text align="left" valign="middle" padding-left="4" />
</style>
+ <style id="timeline_layer_text_only" base="timeline_layer">
+ <background color="none" part="none" repeat="none" />
+ </style>
+ <style id="timeline_layer_text_only:hover" base="timeline_layer">
+ <background color="none" part="none" repeat="none" />
+ </style>
+ <style id="timeline_layer_text_only:active" base="timeline_layer">
+ <background color="none" part="none" repeat="none" />
+ </style>
+ <style id="timeline_layer_text_only:active:hover" base="timeline_layer">
+ <background color="none" part="none" repeat="none" />
+ </style>
<!-- timeline_selected_cel -->
<style id="timeline_selected_cel">
diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp
index 572bc06..0e62a25 100644
--- a/src/app/ui/skin/skin_theme.cpp
+++ b/src/app/ui/skin/skin_theme.cpp
@@ -135,6 +135,14 @@ static const char* cursor_names[kCursorTypes] = {
"magnifier" // kMagnifierCursor
};
+static css::Value value_or_none(const char* valueStr)
+{
+ if (strcmp(valueStr, "none") == 0)
+ return css::Value();
+ else
+ return css::Value(valueStr);
+}
+
// static
SkinTheme* SkinTheme::instance()
{
@@ -445,9 +453,9 @@ void SkinTheme::loadXml(const std::string& skinId)
if (ruleName == "background") {
const char* repeat_id = xmlRule->Attribute("repeat");
- if (color_id) (*style)[StyleSheet::backgroundColorRule()] = css::Value(color_id);
- if (part_id) (*style)[StyleSheet::backgroundPartRule()] = css::Value(part_id);
- if (repeat_id) (*style)[StyleSheet::backgroundRepeatRule()] = css::Value(repeat_id);
+ if (color_id) (*style)[StyleSheet::backgroundColorRule()] = value_or_none(color_id);
+ if (part_id) (*style)[StyleSheet::backgroundPartRule()] = value_or_none(part_id);
+ if (repeat_id) (*style)[StyleSheet::backgroundRepeatRule()] = value_or_none(repeat_id);
}
else if (ruleName == "icon") {
if (align) (*style)[StyleSheet::iconAlignRule()] = css::Value(align);
diff --git a/src/app/ui/timeline.cpp b/src/app/ui/timeline.cpp
index de3ac5e..30d266f 100644
--- a/src/app/ui/timeline.cpp
+++ b/src/app/ui/timeline.cpp
@@ -1354,10 +1354,33 @@ void Timeline::drawLayer(ui::Graphics* g, LayerIndex layerIdx)
bounds = getPartBounds(Hit(PART_LAYER_TEXT, layerIdx));
// Draw layer name.
- drawPart(g, bounds, layer->name().c_str(), styles.timelineLayer(),
- is_active,
- (hotlayer && m_hot.part == PART_LAYER_TEXT),
- (clklayer && m_clk.part == PART_LAYER_TEXT));
+ doc::color_t layerColor = layer->userData().color();
+ if (doc::rgba_geta(layerColor) > 0) {
+ drawPart(g, bounds, nullptr, styles.timelineLayer(),
+ is_active,
+ (hotlayer && m_hot.part == PART_LAYER_TEXT),
+ (clklayer && m_clk.part == PART_LAYER_TEXT));
+
+ // Fill with an user-defined custom color.
+ auto b2 = bounds;
+ b2.shrink(1*guiscale()).inflate(1*guiscale());
+ g->fillRect(gfx::rgba(doc::rgba_getr(layerColor),
+ doc::rgba_getg(layerColor),
+ doc::rgba_getb(layerColor),
+ doc::rgba_geta(layerColor)),
+ b2);
+
+ drawPart(g, bounds, layer->name().c_str(), styles.timelineLayerTextOnly(),
+ is_active,
+ (hotlayer && m_hot.part == PART_LAYER_TEXT),
+ (clklayer && m_clk.part == PART_LAYER_TEXT));
+ }
+ else {
+ drawPart(g, bounds, layer->name().c_str(), styles.timelineLayer(),
+ is_active,
+ (hotlayer && m_hot.part == PART_LAYER_TEXT),
+ (clklayer && m_clk.part == PART_LAYER_TEXT));
+ }
if (layer->isBackground()) {
int s = ui::guiscale();
@@ -1370,18 +1393,6 @@ void Timeline::drawLayer(ui::Graphics* g, LayerIndex layerIdx)
font()->textLength(layer->name().c_str()), s));
}
- // Fill with an user-defined custom color.
- doc::color_t layerColor = layer->userData().color();
- if (doc::rgba_geta(layerColor) > 0) {
- int alpha = doc::rgba_geta(layerColor) * 3 / 4;
- auto b2 = bounds;
- b2.shrink(1*guiscale()).inflate(1*guiscale());
- g->fillRect(gfx::rgba(doc::rgba_getr(layerColor),
- doc::rgba_getg(layerColor),
- doc::rgba_getb(layerColor), alpha),
- b2);
- }
-
// If this layer wasn't clicked but there are another layer clicked,
// we have to draw some indicators to show that the user can move
// layers.
@@ -1413,6 +1424,20 @@ void Timeline::drawCel(ui::Graphics* g, LayerIndex layerIndex, frame_t frame, Ce
else
drawPart(g, bounds, NULL, 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);
+ }
+ }
+
skin::Style* style;
bool fromLeft = false;
bool fromRight = false;
@@ -1446,20 +1471,6 @@ void Timeline::drawCel(ui::Graphics* g, LayerIndex layerIndex, frame_t frame, Ce
// Draw decorators to link the activeCel with its links.
if (data->activeIt != data->end)
drawCelLinkDecorators(g, bounds, cel, frame, is_active, is_hover, data);
-
- // 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) {
- int alpha = doc::rgba_geta(celColor) * 3 / 4;
- 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), alpha),
- b2);
- }
- }
}
void Timeline::drawCelLinkDecorators(ui::Graphics* g, const gfx::Rect& bounds,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list