From 40df0f6e0c465e10c1d181c3dfdea350e2e70bd9 Mon Sep 17 00:00:00 2001 From: nedko Date: Mon, 15 Dec 2025 17:07:44 +0200 Subject: [PATCH] Added info to README for WidgetImage --- README.md | 21 ++++++++++++++++++++- Widgets/WidgetImage.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f1eea6..baf8183 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,12 @@ Controls vertical alignment of elements. **String** type. Has several options: * center - Align objects to be centered * bottom - Align objects to the bottom +### ImageResize +Controls image resizing. **String** type. Has several options: +* none - Image is not resized and is only clipped by the bounding box +* fit - Image is uniformly scaled to fit inside the box +* stretch - Image is scaled (with possible stretching) to fully fill the box + ### TextFit Controls automatic change the text size depending on contents. **String** type. Has several options: * none - Text is not changed in any way @@ -70,6 +76,20 @@ Controls automatic change the text size depending on contents. **String** type. * auto - Renders text with desired size and enlarges/shrinks it to fit if contents are too small/large # List of Widgets and their parameters +### image +Renders an image with optional scaling +| Name | Type | Required | Default | Description | +| ---: | :--: | :------: | ------: | :---------- | +| x | int | | 0 | Horizontal position in pixels (from left to right) | +| y | int | | 0 | Vertical position in pixels (from top to bottom) | +| width | int | REQ | | Width in pixels | +| height | int | REQ | | Height in pixels | +| filename | string | | | Filename of the image to render | +| resize_type | ImageResize | | fit | Whether to resize the image and how to do so | +| bg_color | color | | 255, 255, 255, 0 (Transparent WHITE) | The background color to fill around the image if it is not fully in the box | +| halign | HAlign | | center | Horizontal alignment of the image | +| valign | VAlign | | center | Vertical alignment of the image | + ### rect Renders a rectangle with optional rounded corners using either fill or internal stroke. | Name | Type | Required | Default | Description | @@ -84,7 +104,6 @@ Renders a rectangle with optional rounded corners using either fill or internal ### text Renders text within a specified box - | Name | Type | Required | Default | Description | | ---: | :--: | :------: | ------: | :---------- | | x | int | | 0 | Horizontal position in pixels (from left to right) | diff --git a/Widgets/WidgetImage.h b/Widgets/WidgetImage.h index 8b84c11..5921efc 100644 --- a/Widgets/WidgetImage.h +++ b/Widgets/WidgetImage.h @@ -7,6 +7,7 @@ #include "../sdl_helpers.h" +// Renders an image with optional scaling class WidgetImage : public Widget { protected: