Go to the documentation of this file.
29 void UIWidget::initImage()
34 void UIWidget::parseImageStyle(
const OTMLNodePtr& styleNode)
37 if(node->tag() ==
"image-source")
39 else if(node->tag() ==
"image-offset-x")
41 else if(node->tag() ==
"image-offset-y")
43 else if(node->tag() ==
"image-offset")
45 else if(node->tag() ==
"image-width")
47 else if(node->tag() ==
"image-height")
49 else if(node->tag() ==
"image-size")
51 else if(node->tag() ==
"image-rect")
53 else if(node->tag() ==
"image-clip")
55 else if(node->tag() ==
"image-fixed-ratio")
57 else if(node->tag() ==
"image-repeated")
59 else if(node->tag() ==
"image-smooth")
61 else if(node->tag() ==
"image-color")
63 else if(node->tag() ==
"image-border-top")
65 else if(node->tag() ==
"image-border-right")
67 else if(node->tag() ==
"image-border-bottom")
69 else if(node->tag() ==
"image-border-left")
71 else if(node->tag() ==
"image-border")
73 else if(node->tag() ==
"image-auto-resize")
84 if(m_imageCachedScreenCoords != screenCoords || m_imageMustRecache) {
85 m_imageCoordsBuffer.
clear();
86 m_imageCachedScreenCoords = screenCoords;
87 m_imageMustRecache =
false;
89 Rect drawRect = screenCoords;
96 if(!m_imageBordered) {
100 Size textureClipSize = drawRect.
size();
103 Point texCoordsOffset;
105 texCoordsOffset.
y = (textureSize.
height() - textureClipSize.
height())/2;
106 else if(textureSize.
width() > textureClipSize.
width())
107 texCoordsOffset.
x = (textureSize.
width() - textureClipSize.
width())/2;
109 Rect textureClipRect(texCoordsOffset, textureClipSize);
111 m_imageCoordsBuffer.
addRect(drawRect, textureClipRect);
116 m_imageCoordsBuffer.
addRect(drawRect, clipRect);
125 const Rect clip = clipRect;
126 Rect leftBorder(clip.
left(), clip.
top() + top, left, clip.
height() - top - bottom);
127 Rect rightBorder(clip.
right() - right + 1, clip.
top() + top, right, clip.
height() - top - bottom);
128 Rect topBorder(clip.
left() + left, clip.
top(), clip.
width() - right - left, top);
129 Rect bottomBorder(clip.
left() + left, clip.
bottom() - bottom + 1, clip.
width() - right - left, bottom);
130 Rect topLeftCorner(clip.
left(), clip.
top(), left, top);
131 Rect topRightCorner(clip.
right() - right + 1, clip.
top(), right, top);
132 Rect bottomLeftCorner(clip.
left(), clip.
bottom() - bottom + 1, left, bottom);
133 Rect bottomRightCorner(clip.
right() - right + 1, clip.
bottom() - bottom + 1, right, bottom);
134 Rect center(clip.
left() + left, clip.
top() + top, clip.
width() - right - left, clip.
height() - top - bottom);
136 Size centerSize = drawRect.
size() - bordersSize;
140 if(centerSize.
area() > 0) {
195 m_imageMustRecache =
true;
void addRepeatedRects(const Rect &dest, const Rect &src)
virtual void setColor(const Color &color)
void resize(const TSize< T > &size)
void scale(const TSize< T > &s, Fw::AspectRatioMode mode)
void enableHardwareCaching(HardwareBuffer::UsagePattern usagePattern=HardwareBuffer::DynamicDraw)
TPoint< T > topLeft() const
std::string resolve_path(const std::string &filePath, std::string sourcePath)
Resolve a file path by combining sourcePath with filePath.
TexturePtr getTexture(const std::string &fileName)
void addRect(const Rect &dest)
TextureManager g_textures
virtual void drawTextureCoords(CoordsBuffer &coordsBuffer, const TexturePtr &texture)=0