mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 11:42:47 +00:00
Add text-color to Label widget.
This commit is contained in:
parent
96095159bb
commit
d1baef1555
@ -13,9 +13,21 @@
|
|||||||
Label::Label(const char *text)
|
Label::Label(const char *text)
|
||||||
: Widget(JI_LABEL)
|
: Widget(JI_LABEL)
|
||||||
{
|
{
|
||||||
this->setAlign(JI_LEFT | JI_MIDDLE);
|
setAlign(JI_LEFT | JI_MIDDLE);
|
||||||
this->setText(text);
|
setText(text);
|
||||||
initTheme();
|
initTheme();
|
||||||
|
|
||||||
|
m_textColor = ji_color_foreground();
|
||||||
|
}
|
||||||
|
|
||||||
|
int Label::getTextColor() const
|
||||||
|
{
|
||||||
|
return m_textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setTextColor(int color)
|
||||||
|
{
|
||||||
|
m_textColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Label::onProcessMessage(JMessage msg)
|
bool Label::onProcessMessage(JMessage msg)
|
||||||
|
@ -14,10 +14,15 @@ class Label : public Widget
|
|||||||
public:
|
public:
|
||||||
Label(const char *text);
|
Label(const char *text);
|
||||||
|
|
||||||
|
int getTextColor() const;
|
||||||
|
void setTextColor(int color);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onProcessMessage(JMessage msg);
|
bool onProcessMessage(JMessage msg);
|
||||||
void onPaint(PaintEvent& ev);
|
void onPaint(PaintEvent& ev);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_textColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,8 +27,6 @@
|
|||||||
#include "gfx/point.h"
|
#include "gfx/point.h"
|
||||||
#include "gfx/rect.h"
|
#include "gfx/rect.h"
|
||||||
#include "gfx/size.h"
|
#include "gfx/size.h"
|
||||||
#include "gui/paint_event.h"
|
|
||||||
#include "gui/graphics.h"
|
|
||||||
#include "gui/gui.h"
|
#include "gui/gui.h"
|
||||||
#include "gui/intern.h"
|
#include "gui/intern.h"
|
||||||
#include "loadpng.h"
|
#include "loadpng.h"
|
||||||
@ -842,12 +840,21 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
|||||||
|
|
||||||
void SkinTheme::paintLabel(PaintEvent& ev)
|
void SkinTheme::paintLabel(PaintEvent& ev)
|
||||||
{
|
{
|
||||||
Widget* widget = static_cast<Widget*>(ev.getSource());
|
Graphics* g = ev.getGraphics();
|
||||||
|
Label* widget = static_cast<Label*>(ev.getSource());
|
||||||
|
struct jrect text;
|
||||||
int bg = BGCOLOR;
|
int bg = BGCOLOR;
|
||||||
|
int fg = widget->getTextColor();
|
||||||
|
gfx::Rect rc = widget->getClientBounds();
|
||||||
|
|
||||||
jdraw_rectfill(widget->rc, bg);
|
g->fillRect(bg, rc);
|
||||||
|
rc.shrink(widget->getBorder());
|
||||||
|
|
||||||
draw_textstring(NULL, -1, bg, false, widget, widget->rc, 0);
|
jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0);
|
||||||
|
|
||||||
|
g->drawString(widget->getText(), fg, bg, false,
|
||||||
|
// TODO "text" coordinates are absolute and we are drawing on client area
|
||||||
|
gfx::Point(text.x1, text.y1) - gfx::Point(widget->rc->x1, widget->rc->y1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinTheme::paintLinkLabel(PaintEvent& ev)
|
void SkinTheme::paintLinkLabel(PaintEvent& ev)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user