Added info to README for WidgetImage

This commit is contained in:
nedko 2025-12-15 17:07:44 +02:00
parent 17f73211a9
commit 40df0f6e0c
2 changed files with 21 additions and 1 deletions

View File

@ -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) |

View File

@ -7,6 +7,7 @@
#include "../sdl_helpers.h"
// Renders an image with optional scaling
class WidgetImage : public Widget
{
protected: