[aseprite] 261/308: Show grayscale colors in color buttons when we're editing a grayscale image
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:45:18 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 c09dfa89f0887ef482869f787ce257086e6a0c0c
Author: David Capello <davidcapello at gmail.com>
Date: Wed Feb 24 19:37:20 2016 -0300
Show grayscale colors in color buttons when we're editing a grayscale image
---
src/app/modules/gfx.cpp | 38 +++++++++++++++++++++++++++-----------
src/app/modules/gfx.h | 14 ++++++++++----
src/app/ui/color_button.cpp | 6 ++++--
src/app/ui/context_bar.cpp | 3 ++-
src/app/ui/palette_view.cpp | 2 +-
src/app/ui/status_bar.cpp | 11 +++++++----
6 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/src/app/modules/gfx.cpp b/src/app/modules/gfx.cpp
index 848430e..738ac20 100644
--- a/src/app/modules/gfx.cpp
+++ b/src/app/modules/gfx.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -62,12 +62,16 @@ static void rectgrid(ui::Graphics* g, const gfx::Rect& rc, const gfx::Size& tile
}
}
-void draw_color(ui::Graphics* g, const Rect& rc, const app::Color& color)
+void draw_color(ui::Graphics* g,
+ const Rect& rc,
+ const app::Color& _color,
+ const doc::ColorMode colorMode)
{
if (rc.w < 1 || rc.h < 1)
return;
- app::Color::Type type = color.getType();
+ app::Color color = _color;
+
int alpha = color.getAlpha();
if (alpha < 255) {
@@ -78,7 +82,13 @@ void draw_color(ui::Graphics* g, const Rect& rc, const app::Color& color)
}
if (alpha > 0) {
- if (type == app::Color::IndexType) {
+ if (colorMode == doc::ColorMode::GRAYSCALE) {
+ color = app::Color::fromGray(
+ color.getGray(),
+ color.getAlpha());
+ }
+
+ if (color.getType() == app::Color::IndexType) {
int index = color.getIndex();
if (index >= 0 && index < get_current_palette()->size()) {
@@ -91,24 +101,30 @@ void draw_color(ui::Graphics* g, const Rect& rc, const app::Color& color)
gfx::Point(rc.x+1, rc.y+rc.h-2));
}
}
- else
+ else {
g->fillRect(color_utils::color_for_ui(color), rc);
+ }
}
}
void draw_color_button(ui::Graphics* g,
- const Rect& rc, const app::Color& color,
- bool hot, bool drag)
+ const Rect& rc,
+ const app::Color& color,
+ const doc::ColorMode colorMode,
+ const bool hot,
+ const bool drag)
{
SkinTheme* theme = SkinTheme::instance();
int scale = ui::guiscale();
// Draw background (the color)
draw_color(g,
- Rect(rc.x+1*scale,
- rc.y+1*scale,
- rc.w-2*scale,
- rc.h-2*scale), color);
+ Rect(rc.x+1*scale,
+ rc.y+1*scale,
+ rc.w-2*scale,
+ rc.h-2*scale),
+ color,
+ colorMode);
// Draw opaque border
theme->drawRect(
diff --git a/src/app/modules/gfx.h b/src/app/modules/gfx.h
index afc060d..b9a465a 100644
--- a/src/app/modules/gfx.h
+++ b/src/app/modules/gfx.h
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -10,6 +10,7 @@
#pragma once
#include "app/color.h"
+#include "doc/color_mode.h"
#include "gfx/color.h"
#include "gfx/rect.h"
#include "ui/base.h"
@@ -19,11 +20,16 @@ namespace app {
using namespace doc;
void draw_color(ui::Graphics* g,
- const gfx::Rect& rc, const app::Color& color);
+ const gfx::Rect& rc,
+ const app::Color& color,
+ const doc::ColorMode colorMode);
void draw_color_button(ui::Graphics* g,
- const gfx::Rect& rc, const app::Color& color,
- bool hot, bool drag);
+ const gfx::Rect& rc,
+ const app::Color& color,
+ const doc::ColorMode colorMode,
+ const bool hot,
+ const bool drag);
} // namespace app
diff --git a/src/app/ui/color_button.cpp b/src/app/ui/color_button.cpp
index a48f2a7..cdaa429 100644
--- a/src/app/ui/color_button.cpp
+++ b/src/app/ui/color_button.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -209,7 +209,9 @@ void ColorButton::onPaint(PaintEvent& ev)
}
draw_color_button(g, rc,
- color, hasMouseOver(), false);
+ color,
+ (doc::ColorMode)m_pixelFormat,
+ hasMouseOver(), false);
// Draw text
std::string str = m_color.toHumanReadableString(m_pixelFormat,
diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp
index 53ef26d..7367157 100644
--- a/src/app/ui/context_bar.cpp
+++ b/src/app/ui/context_bar.cpp
@@ -609,7 +609,8 @@ class ContextBar::InkShadesField : public HBox {
color = app::Color::fromMask();
}
- draw_color(g, box, color);
+ draw_color(g, box, color,
+ (doc::ColorMode)app_get_current_pixel_format());
if (m_hotIndex == i)
hotBounds = box;
diff --git a/src/app/ui/palette_view.cpp b/src/app/ui/palette_view.cpp
index 16f035c..7a8a0d2 100644
--- a/src/app/ui/palette_view.cpp
+++ b/src/app/ui/palette_view.cpp
@@ -992,7 +992,7 @@ gfx::Color PaletteView::drawEntry(ui::Graphics* g, const gfx::Rect& box, int pal
rgba_geta(palColor));
g->drawRect(gfx::rgba(0, 0, 0), gfx::Rect(box).enlarge(guiscale()));
- draw_color(g, box, appColor);
+ draw_color(g, box, appColor, doc::ColorMode::RGB);
return gfxColor;
}
diff --git a/src/app/ui/status_bar.cpp b/src/app/ui/status_bar.cpp
index e82349a..6795925 100644
--- a/src/app/ui/status_bar.cpp
+++ b/src/app/ui/status_bar.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -435,13 +435,16 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
}
// Draw color
- draw_color_button(g, gfx::Rect(x, rc.y, 32*guiscale(), rc.h),
- m_color, false, false);
+ draw_color_button(
+ g, gfx::Rect(x, rc.y, 32*guiscale(), rc.h),
+ m_color,
+ (doc::ColorMode)app_get_current_pixel_format(), false, false);
x += (32+4)*guiscale();
// Draw color description
- std::string str = m_color.toHumanReadableString(app_get_current_pixel_format(),
+ std::string str = m_color.toHumanReadableString(
+ app_get_current_pixel_format(),
app::Color::LongHumanReadableString);
if (m_color.getAlpha() < 255) {
char buf[256];
--
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