mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
Improved color indicators in status bar (StatusBar::showColor()).
This commit is contained in:
parent
21a979874b
commit
f2265b2034
@ -677,17 +677,15 @@ void color_to_formalstring(int imgtype, color_t color,
|
|||||||
case COLOR_TYPE_RGB:
|
case COLOR_TYPE_RGB:
|
||||||
data = GET_COLOR_DATA_RGB(color);
|
data = GET_COLOR_DATA_RGB(color);
|
||||||
if (imgtype == IMAGE_GRAYSCALE) {
|
if (imgtype == IMAGE_GRAYSCALE) {
|
||||||
uszprintf(buf, size, "%s %d",
|
uszprintf(buf, size, "Gray %d",
|
||||||
_("Gray"),
|
|
||||||
_graya_getv(get_color_for_image(imgtype, color)));
|
_graya_getv(get_color_for_image(imgtype, color)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uszprintf(buf, size, "%s %d %d %d",
|
uszprintf(buf, size, "RGB %d %d %d",
|
||||||
_("RGB"),
|
|
||||||
GET_DATA_C1(data),
|
GET_DATA_C1(data),
|
||||||
GET_DATA_C2(data),
|
GET_DATA_C2(data),
|
||||||
GET_DATA_C3(data));
|
GET_DATA_C3(data));
|
||||||
|
|
||||||
if (imgtype == IMAGE_INDEXED)
|
if (imgtype == IMAGE_INDEXED)
|
||||||
uszprintf(buf+ustrlen(buf), size, " %s %d",
|
uszprintf(buf+ustrlen(buf), size, " %s %d",
|
||||||
_("Index"), get_color_for_image(imgtype, color));
|
_("Index"), get_color_for_image(imgtype, color));
|
||||||
@ -697,34 +695,32 @@ void color_to_formalstring(int imgtype, color_t color,
|
|||||||
case COLOR_TYPE_HSV:
|
case COLOR_TYPE_HSV:
|
||||||
data = GET_COLOR_DATA_HSV(color);
|
data = GET_COLOR_DATA_HSV(color);
|
||||||
if (imgtype == IMAGE_GRAYSCALE) {
|
if (imgtype == IMAGE_GRAYSCALE) {
|
||||||
uszprintf(buf, size, "%s %d",
|
uszprintf(buf, size, "Gray %d",
|
||||||
_("Gray"), GET_DATA_C3(data));
|
GET_DATA_C3(data));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uszprintf(buf, size, "%s %d %d %d",
|
uszprintf(buf, size, "HSV %d %d %d",
|
||||||
_("HSV"),
|
|
||||||
GET_DATA_C1(data),
|
GET_DATA_C1(data),
|
||||||
GET_DATA_C2(data),
|
GET_DATA_C2(data),
|
||||||
GET_DATA_C3(data));
|
GET_DATA_C3(data));
|
||||||
|
|
||||||
if (imgtype == IMAGE_INDEXED)
|
if (imgtype == IMAGE_INDEXED)
|
||||||
uszprintf(buf+ustrlen(buf), size, " %s %d",
|
uszprintf(buf+ustrlen(buf), size, " Index %d",
|
||||||
_("Index"), get_color_for_image(imgtype, color));
|
get_color_for_image(imgtype, color));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_TYPE_GRAY:
|
case COLOR_TYPE_GRAY:
|
||||||
data = GET_COLOR_DATA_GRAY(color);
|
data = GET_COLOR_DATA_GRAY(color);
|
||||||
uszprintf(buf, size, "%s %d",
|
uszprintf(buf, size, "Gray %d",
|
||||||
_("Gray"), data);
|
data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COLOR_TYPE_INDEX: {
|
case COLOR_TYPE_INDEX: {
|
||||||
ase_uint32 _c;
|
ase_uint32 _c;
|
||||||
data = GET_COLOR_DATA_INDEX(color);
|
data = GET_COLOR_DATA_INDEX(color);
|
||||||
_c = get_current_palette()->getEntry(data & 0xff);
|
_c = get_current_palette()->getEntry(data & 0xff);
|
||||||
uszprintf(buf, size, "%s %d (RGB %d %d %d)",
|
uszprintf(buf, size, "Index %d (RGB %d %d %d)",
|
||||||
_("Index"),
|
|
||||||
data & 0xff,
|
data & 0xff,
|
||||||
_rgba_getr(_c),
|
_rgba_getr(_c),
|
||||||
_rgba_getg(_c),
|
_rgba_getg(_c),
|
||||||
|
@ -562,5 +562,5 @@ Rect ColorBar::getBgBounds() const
|
|||||||
void ColorBar::updateStatusBar(color_t color, int msecs)
|
void ColorBar::updateStatusBar(color_t color, int msecs)
|
||||||
{
|
{
|
||||||
app_get_statusbar()
|
app_get_statusbar()
|
||||||
->showColor(msecs, app_get_current_image_type(), color);
|
->showColor(msecs, "", color, 255);
|
||||||
}
|
}
|
||||||
|
@ -628,42 +628,34 @@ void Editor::hide_drawing_cursor()
|
|||||||
|
|
||||||
void Editor::editor_update_statusbar_for_standby()
|
void Editor::editor_update_statusbar_for_standby()
|
||||||
{
|
{
|
||||||
char buf[256];
|
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
screen_to_editor(jmouse_x(0), jmouse_y(0), &x, &y);
|
screen_to_editor(jmouse_x(0), jmouse_y(0), &x, &y);
|
||||||
|
|
||||||
/* for eye-dropper */
|
// For eye-dropper
|
||||||
if (m_alt_pressed) {
|
if (m_alt_pressed) {
|
||||||
color_t color = color_from_image(m_sprite->getImgType(),
|
int imgtype = m_sprite->getImgType();
|
||||||
m_sprite->getPixel(x, y));
|
ase_uint32 pixel = m_sprite->getPixel(x, y);
|
||||||
if (color_type(color) != COLOR_TYPE_MASK) {
|
color_t color = color_from_image(imgtype, pixel);
|
||||||
usprintf(buf, "%s ", _("Color"));
|
|
||||||
color_to_formalstring(m_sprite->getImgType(),
|
int alpha = 255;
|
||||||
color,
|
switch (imgtype) {
|
||||||
buf+ustrlen(buf),
|
case IMAGE_RGB: alpha = _rgba_geta(pixel); break;
|
||||||
sizeof(buf)-ustrlen(buf), true);
|
case IMAGE_GRAYSCALE: alpha = _graya_geta(pixel); break;
|
||||||
}
|
|
||||||
else {
|
|
||||||
usprintf(buf, "%s", _("Transparent"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char buf[256];
|
||||||
|
usprintf(buf, "- Pos %d %d", x, y);
|
||||||
|
|
||||||
|
app_get_statusbar()->showColor(0, buf, color, alpha);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ustrcpy(buf, empty_string);
|
app_get_statusbar()->setStatusText
|
||||||
|
(0, "Pos %d %d, Size %d %d, Frame %d",
|
||||||
|
x, y,
|
||||||
|
((m_sprite->getMask()->bitmap)? m_sprite->getMask()->w: m_sprite->getWidth()),
|
||||||
|
((m_sprite->getMask()->bitmap)? m_sprite->getMask()->h: m_sprite->getHeight()),
|
||||||
|
m_sprite->getCurrentFrame()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
app_get_statusbar()->setStatusText
|
|
||||||
(0, "%s %3d %3d (%s %3d %3d) [%s %d] %s",
|
|
||||||
_("Pos"), x, y,
|
|
||||||
_("Size"),
|
|
||||||
((m_sprite->getMask()->bitmap)?
|
|
||||||
m_sprite->getMask()->w:
|
|
||||||
m_sprite->getWidth()),
|
|
||||||
((m_sprite->getMask()->bitmap)?
|
|
||||||
m_sprite->getMask()->h:
|
|
||||||
m_sprite->getHeight()),
|
|
||||||
_("Frame"), m_sprite->getCurrentFrame()+1,
|
|
||||||
buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::editor_refresh_region()
|
void Editor::editor_refresh_region()
|
||||||
|
@ -87,6 +87,7 @@ StatusBar::StatusBar()
|
|||||||
jwidget_focusrest(this, true);
|
jwidget_focusrest(this, true);
|
||||||
|
|
||||||
m_timeout = 0;
|
m_timeout = 0;
|
||||||
|
m_state = SHOW_TEXT;
|
||||||
m_progress = jlist_new();
|
m_progress = jlist_new();
|
||||||
m_tipwindow = NULL;
|
m_tipwindow = NULL;
|
||||||
m_hot_layer = -1;
|
m_hot_layer = -1;
|
||||||
@ -151,7 +152,7 @@ void StatusBar::onCurrentToolChange()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::setStatusText(int msecs, const char *format, ...)
|
bool StatusBar::setStatusText(int msecs, const char *format, ...)
|
||||||
{
|
{
|
||||||
if ((ji_clock > m_timeout) || (msecs > 0)) {
|
if ((ji_clock > m_timeout) || (msecs > 0)) {
|
||||||
char buf[256]; // TODO warning buffer overflow
|
char buf[256]; // TODO warning buffer overflow
|
||||||
@ -162,9 +163,15 @@ void StatusBar::setStatusText(int msecs, const char *format, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
m_timeout = ji_clock + msecs;
|
m_timeout = ji_clock + msecs;
|
||||||
|
m_state = SHOW_TEXT;
|
||||||
|
|
||||||
this->setText(buf);
|
this->setText(buf);
|
||||||
this->dirty();
|
this->dirty();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::showTip(int msecs, const char *format, ...)
|
void StatusBar::showTip(int msecs, const char *format, ...)
|
||||||
@ -207,11 +214,13 @@ void StatusBar::showTip(int msecs, const char *format, ...)
|
|||||||
this->dirty();
|
this->dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::showColor(int msecs, int imgtype, color_t color)
|
void StatusBar::showColor(int msecs, const char* text, color_t color, int alpha)
|
||||||
{
|
{
|
||||||
char buf[128]; // TODO warning buffer overflow
|
if (setStatusText(msecs, text)) {
|
||||||
color_to_formalstring(imgtype, color, buf, sizeof(buf), true);
|
m_state = SHOW_COLOR;
|
||||||
setStatusText(msecs, "%s %s", _("Color"), buf);
|
m_color = color;
|
||||||
|
m_alpha = alpha;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@ -309,12 +318,50 @@ bool StatusBar::msg_proc(JMessage msg)
|
|||||||
rc->x2 -= 2*jguiscale();
|
rc->x2 -= 2*jguiscale();
|
||||||
rc->y2 -= 2*jguiscale();
|
rc->y2 -= 2*jguiscale();
|
||||||
|
|
||||||
|
int x = rc->x1+4*jguiscale();
|
||||||
|
|
||||||
|
// Color
|
||||||
|
if (m_state == SHOW_COLOR) {
|
||||||
|
// Draw eyedropper icon
|
||||||
|
BITMAP* icon = theme->get_toolicon("eyedropper");
|
||||||
|
if (icon) {
|
||||||
|
set_alpha_blender();
|
||||||
|
draw_trans_sprite(doublebuffer, icon,
|
||||||
|
x, (rc->y1+rc->y2)/2-icon->h/2);
|
||||||
|
|
||||||
|
x += icon->w + 4*jguiscale();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw color
|
||||||
|
draw_color_button(doublebuffer, Rect(x, rc->y1, 32*jguiscale(), rc->y2-rc->y1),
|
||||||
|
true, true, true, true,
|
||||||
|
true, true, true, true,
|
||||||
|
app_get_current_image_type(), m_color,
|
||||||
|
false, false);
|
||||||
|
|
||||||
|
x += (32+4)*jguiscale();
|
||||||
|
|
||||||
|
// Draw color description
|
||||||
|
char buf[256]; // TODO warning buffer overflow
|
||||||
|
color_to_formalstring(app_get_current_image_type(),
|
||||||
|
m_color, buf, sizeof(buf), true);
|
||||||
|
|
||||||
|
textout_ex(doublebuffer, this->getFont(), buf,
|
||||||
|
x, (rc->y1+rc->y2)/2-text_height(this->getFont())/2,
|
||||||
|
text_color, -1);
|
||||||
|
|
||||||
|
x += ji_font_text_len(this->getFont(), buf) + 4*jguiscale();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Status bar text
|
// Status bar text
|
||||||
if (this->getText()) {
|
if (this->getTextSize() > 0) {
|
||||||
textout_ex(doublebuffer, this->getFont(), this->getText(),
|
textout_ex(doublebuffer, this->getFont(), this->getText(),
|
||||||
rc->x1+4*jguiscale(),
|
x,
|
||||||
(rc->y1+rc->y2)/2-text_height(this->getFont())/2,
|
(rc->y1+rc->y2)/2-text_height(this->getFont())/2,
|
||||||
text_color, -1);
|
text_color, -1);
|
||||||
|
|
||||||
|
x += ji_font_text_len(this->getFont(), this->getText()) + 4*jguiscale();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw progress bar
|
// Draw progress bar
|
||||||
|
@ -49,9 +49,9 @@ public:
|
|||||||
StatusBar();
|
StatusBar();
|
||||||
~StatusBar();
|
~StatusBar();
|
||||||
|
|
||||||
void setStatusText(int msecs, const char *format, ...);
|
bool setStatusText(int msecs, const char *format, ...);
|
||||||
void showTip(int msecs, const char *format, ...);
|
void showTip(int msecs, const char *format, ...);
|
||||||
void showColor(int msecs, int imgtype, color_t color);
|
void showColor(int msecs, const char* text, color_t color, int alpha);
|
||||||
|
|
||||||
Progress* addProgress();
|
Progress* addProgress();
|
||||||
void removeProgress(Progress* progress);
|
void removeProgress(Progress* progress);
|
||||||
@ -63,7 +63,14 @@ private:
|
|||||||
void onCurrentToolChange();
|
void onCurrentToolChange();
|
||||||
void updateFromLayer();
|
void updateFromLayer();
|
||||||
|
|
||||||
|
enum State { SHOW_TEXT, SHOW_COLOR };
|
||||||
|
|
||||||
int m_timeout;
|
int m_timeout;
|
||||||
|
State m_state;
|
||||||
|
|
||||||
|
// Showing a color
|
||||||
|
color_t m_color;
|
||||||
|
int m_alpha;
|
||||||
|
|
||||||
// Progress bar
|
// Progress bar
|
||||||
JList m_progress;
|
JList m_progress;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user