Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/tb/tb_skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ void TBSkin::PaintSkinOverlay(const TBRect &dst_rect, TBSkinElement *element, SK

void TBSkin::PaintElement(const TBRect &dst_rect, TBSkinElement *element)
{
PaintElementBorderColor(dst_rect, element);
PaintElementBGColor(dst_rect, element);
if (!element->bitmap)
return;
Expand Down Expand Up @@ -435,6 +436,13 @@ TBRect TBSkin::GetFlippedRect(const TBRect &src_rect, TBSkinElement *element) co
return tmp_rect;
}

void TBSkin::PaintElementBorderColor(const TBRect &dst_rect, TBSkinElement *element)
{
if (element->border_width == 0)
return;
g_renderer->DrawRectFill(dst_rect.Expand(element->border_width, element->border_width), element->border_color);
}

void TBSkin::PaintElementBGColor(const TBRect &dst_rect, TBSkinElement *element)
{
if (element->bg_color == 0)
Expand Down Expand Up @@ -553,6 +561,7 @@ TBSkinElement::TBSkinElement()
, pref_width(SKIN_VALUE_NOT_SPECIFIED), pref_height(SKIN_VALUE_NOT_SPECIFIED)
, min_width(SKIN_VALUE_NOT_SPECIFIED), min_height(SKIN_VALUE_NOT_SPECIFIED)
, max_width(SKIN_VALUE_NOT_SPECIFIED), max_height(SKIN_VALUE_NOT_SPECIFIED)
, border_width(0)
, spacing(SKIN_VALUE_NOT_SPECIFIED)
, content_ofs_x(0), content_ofs_y(0)
, img_ofs_x(0), img_ofs_y(0)
Expand Down Expand Up @@ -686,6 +695,7 @@ void TBSkinElement::Load(TBNode *n, TBSkin *skin, const char *skin_path)
min_height = skin->GetPxFromNode(n->GetNode("min-height"), min_height);
max_width = skin->GetPxFromNode(n->GetNode("max-width"), max_width);
max_height = skin->GetPxFromNode(n->GetNode("max-height"), max_height);
border_width = skin->GetPxFromNode(n->GetNode("border-width"), border_width);
spacing = skin->GetPxFromNode(n->GetNode("spacing"), spacing);
content_ofs_x = skin->GetPxFromNode(n->GetNode("content-ofs-x"), content_ofs_x);
content_ofs_y = skin->GetPxFromNode(n->GetNode("content-ofs-y"), content_ofs_y);
Expand All @@ -703,6 +713,9 @@ void TBSkinElement::Load(TBNode *n, TBSkin *skin, const char *skin_path)
if (const char *color = n->GetValueString("background-color", nullptr))
bg_color.SetFromString(color, strlen(color));

if (const char *color = n->GetValueString("border-color", nullptr))
border_color.SetFromString(color, strlen(color));

if (const char *type_str = n->GetValueString("type", nullptr))
type = StringToType(type_str);

Expand Down
3 changes: 3 additions & 0 deletions src/tb/tb_skin.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class TBSkinElement
int16 min_height; ///< Minimum height or SKIN_VALUE_NOT_SPECIFIED
int16 max_width; ///< Maximum width or SKIN_VALUE_NOT_SPECIFIED
int16 max_height; ///< Maximum height or SKIN_VALUE_NOT_SPECIFIED
int16 border_width; ///< How thick the border should be for the element
int16 spacing; ///< Spacing used on layout or SKIN_VALUE_NOT_SPECIFIED.
int16 content_ofs_x; ///< X offset of the content in the widget.
int16 content_ofs_y; ///< Y offset of the content in the widget.
Expand All @@ -205,6 +206,7 @@ class TBSkinElement
float opacity; ///< Opacity that should be used for the whole widget (0.f - 1.f).
TBColor text_color; ///< Color of the text in the widget.
TBColor bg_color; ///< Color of the background in the widget.
TBColor border_color; ///< Color of the border in the widget.
int16 bitmap_dpi; ///< The DPI of the bitmap that was loaded.
TBValue tag; ///< This value is free to use for anything. It's not used internally.

Expand Down Expand Up @@ -393,6 +395,7 @@ class TBSkin : private TBRendererListener
bool LoadInternal(const char *skin_file);
bool ReloadBitmapsInternal();
void PaintElement(const TBRect &dst_rect, TBSkinElement *element);
void PaintElementBorderColor(const TBRect &dst_rect, TBSkinElement *element);
void PaintElementBGColor(const TBRect &dst_rect, TBSkinElement *element);
void PaintElementImage(const TBRect &dst_rect, TBSkinElement *element);
void PaintElementTile(const TBRect &dst_rect, TBSkinElement *element);
Expand Down