Hasty Badger
Small UI library (a branch of Turbo Badger)
|
TBSkin contains a list of TBSkinElement. More...
#include <tb_skin.h>
Public Member Functions | |
void | SetListener (TBSkinListener *listener) |
Set the listener for this skin. More... | |
TBSkinListener * | GetListener () const |
bool | Load (const TBStr &skin_file, const TBStr &override_skin_file=TBStr()) |
Load the skin file and the bitmaps it refers to. More... | |
bool | Write (const TBStr &skin_file) |
Write the current skin to a file. | |
void | UnloadBitmaps () |
Unload all bitmaps used in this skin. More... | |
bool | ReloadBitmaps () |
Reload all bitmaps used in this skin. More... | |
const TBDimensionConverter * | GetDimensionConverter () const |
Get the dimension converter used for the current skin. More... | |
TBSkinElement * | GetSkinElement (const TBID &skin_id) const |
Get the skin element with the given id. More... | |
TBSkinElement * | GetSkinElementStrongOverride (const TBID &skin_id, SKIN_STATE state, TBSkinConditionContext &context) const |
Get the skin element with the given id and state. More... | |
TBColor | GetDefaultTextColor () const |
Get the default text color for all skin elements. | |
void | SetDefaultTextColor (TBColor color) |
Set the default text color for all skin elements. | |
float | GetDefaultDisabledOpacity () const |
Get the default disabled opacity for all skin elements. | |
float | GetDefaultPlaceholderOpacity () const |
Get the default placeholder opacity for all skin elements. | |
int | GetDefaultSpacing () const |
Get the default layout spacing in pixels. More... | |
TBSkinElement * | PaintSkin (const TBRect &dst_rect, const TBID &skin_id, SKIN_STATE state, TBSkinConditionContext &context) |
Paint the skin at dst_rect. More... | |
TBSkinElement * | PaintSkin (const TBRect &dst_rect, TBSkinElement *element, SKIN_STATE state, TBSkinConditionContext &context) |
Paint the skin at dst_rect. More... | |
void | PaintSkinOverlay (const TBRect &dst_rect, TBSkinElement *element, SKIN_STATE state, TBSkinConditionContext &context) |
Paint the overlay elements for the given skin element and state. More... | |
void | PaintRect (const TBRect &dst_rect, const TBColor &color, int thickness) |
Paint a rectangle outline inside dst_rect with the given thickness and color. More... | |
void | PaintRectFill (const TBRect &dst_rect, const TBColor &color) |
Paint a filled rectangle with the given color. More... | |
TBBitmapFragmentManager * | GetFragmentManager () |
Get the fragment manager. More... | |
virtual void | OnContextLost () |
Called when the context has been lost and all TBBitmaps need to be deleted. More... | |
virtual void | OnContextRestored () |
Called when the context has been restored again, and new TBBitmaps can be created again. More... | |
Friends | |
class | TBSkinElement |
TBSkin contains a list of TBSkinElement.
|
inline |
Get the default layout spacing in pixels.
|
inline |
Get the dimension converter used for the current skin.
This dimension converter converts to px by the same factor as the skin (based on the skin DPI settings).
|
inline |
Get the fragment manager.
TBSkinElement * tb::TBSkin::GetSkinElement | ( | const TBID & | skin_id | ) | const |
Get the skin element with the given id.
Returns nullptr if there's no match.
TBSkinElement * tb::TBSkin::GetSkinElementStrongOverride | ( | const TBID & | skin_id, |
SKIN_STATE | state, | ||
TBSkinConditionContext & | context | ||
) | const |
Get the skin element with the given id and state.
This is like calling GetSkinElement and also following any strong overrides that match the current state (if any). See details about strong overrides in PaintSkin. Returns nullptr if there's no match.
Load the skin file and the bitmaps it refers to.
If override_skin_file is specified, it will also be loaded into this skin after loading skin_file. Elements using the same name will override any previosly read data for the same element. Known limitation: Clone can currently only clone elements in the same file!
Returns true on success, and all bitmaps referred to also loaded successfully.
|
virtual |
Called when the context has been lost and all TBBitmaps need to be deleted.
NOTE: Only do cleanup here. It's not safe to do work on any bitmap since the context is already lost.
Implements tb::TBRendererListener.
|
virtual |
Called when the context has been restored again, and new TBBitmaps can be created again.
Implements tb::TBRendererListener.
Paint a rectangle outline inside dst_rect with the given thickness and color.
Paint a filled rectangle with the given color.
TBSkinElement * tb::TBSkin::PaintSkin | ( | const TBRect & | dst_rect, |
const TBID & | skin_id, | ||
SKIN_STATE | state, | ||
TBSkinConditionContext & | context | ||
) |
Paint the skin at dst_rect.
Strong override elements: -Strong override elements are like override elements, but they don't only apply when painting. They also override padding and other things that might affect the layout of the widget having the skin set.
Override elements: -If there is a override element with the exact matching state, it will paint the override instead if the base skin. If no exact match was found, it will check for a partial match and paint that instead of the base skin.
Child elements: -It will paint all child elements that match the current state ("all" can be specified as state so it will always be painted). The elements are painted in the order they are specified in the skin.
Special elements: -There's some special generic skin elements used by TBWidget (see TBWidget::SetSkinBg)
Overlay elements: -Overlay elements are painted separately, from PaintSkinOverlay (when all sibling widgets has been painted). As with child elements, all overlay elements that match the current state will be painted in the order they are specified in the skin.
Return the skin element used (after following override elements), or nullptr if no skin element was found matching the skin_id.
TBSkinElement * tb::TBSkin::PaintSkin | ( | const TBRect & | dst_rect, |
TBSkinElement * | element, | ||
SKIN_STATE | state, | ||
TBSkinConditionContext & | context | ||
) |
Paint the skin at dst_rect.
Just like the PaintSkin above, but takes a specific skin element instead of looking it up from the id.
void tb::TBSkin::PaintSkinOverlay | ( | const TBRect & | dst_rect, |
TBSkinElement * | element, | ||
SKIN_STATE | state, | ||
TBSkinConditionContext & | context | ||
) |
Paint the overlay elements for the given skin element and state.
bool tb::TBSkin::ReloadBitmaps | ( | ) |
Reload all bitmaps used in this skin.
Calls UnloadBitmaps first to ensure no bitmaps are loaded before loading new ones.
|
inline |
Set the listener for this skin.
void tb::TBSkin::UnloadBitmaps | ( | ) |
Unload all bitmaps used in this skin.