diff --git a/examples/example1/res/mdpi/tx_fabric.jpg b/examples/example1/res/mdpi/tx_fabric.jpg new file mode 100644 index 00000000..6c33894a Binary files /dev/null and b/examples/example1/res/mdpi/tx_fabric.jpg differ diff --git a/examples/example1/src/main.d b/examples/example1/src/main.d index 15f947a1..58fd8931 100644 --- a/examples/example1/src/main.d +++ b/examples/example1/src/main.d @@ -28,6 +28,7 @@ class SampleAnimationWidget : Widget { ulong animationProgress; this(string ID) { super(ID); + backgroundImageId = "tx_fabric.tiled"; // tx_fabric.jpg tiled } /// returns true is widget is being animated - need to call animate() and redraw @property override bool animating() { return true; } diff --git a/src/dlangui/graphics/resources.d b/src/dlangui/graphics/resources.d index fe84524a..fe6ed560 100644 --- a/src/dlangui/graphics/resources.d +++ b/src/dlangui/graphics/resources.d @@ -289,7 +289,17 @@ class ImageDrawable : Drawable { } } else if (_tiled) { // tiled - } else { + int imgdx = _image.width; + int imgdy = _image.height; + tilex0 %= imgdx; + if (tilex0 < 0) + tilex0 += imgdx; + tiley0 %= imgdy; + if (tiley0 < 0) + tiley0 += imgdy; + + buf.drawRescaled(rc, _image.get, Rect(0, 0, _image.width, _image.height)); + } else { // rescaled or normal if (rc.width != _image.width || rc.height != _image.height) buf.drawRescaled(rc, _image.get, Rect(0, 0, _image.width, _image.height)); diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index abc2d789..f3686987 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -330,6 +330,23 @@ class Widget { invalidate(); return this; } + + /// background image id + @property string backgroundImageId() const { + return style.backgroundImageId; + } + + /// background image id + @property Widget backgroundImageId(string imageId) { + ownStyle.backgroundImageId = imageId; + return this; + } + + /// background drawable + @property DrawableRef backgroundDrawable() const { + return style.backgroundDrawable; + } + /// widget drawing alpha value (0=opaque .. 255=transparent) @property uint alpha() const { return stateStyle.alpha; } /// set widget drawing alpha value (0=opaque .. 255=transparent)