# Widget class

## Widget:

The [`Widget`](https://github.com/V-Fast/DynamicHUD/blob/master/src/main/java/com/tanishisherewith/dynamichud/widget/Widget.java) class represents a widget that can be rendered on the screen. It is an abstract class that must be extended by concrete widget classes.

## Fields

* `textGenerators`: A map of text generators for different labels.
* `client`: The Minecraft client instance.
* `enabled`: Whether the widget is enabled.
* `isDraggable`: Whether the widget is draggable.
* `xPercent`: The x position of the widget as a percentage of the screen width.
* `yPercent`: The y position of the widget as a percentage of the screen height.
* `label`: The label of the widget.

## Constructors

* `Widget(MinecraftClient client)`: Constructs a Widget object with the given Minecraft client instance.

## Methods

* `addTextGenerator(String label, TextGenerator textGenerator)`: Adds a text generator for the given label.
* `setTextGeneratorFromLabel()`: Sets the text generator for this widget based on its label.
* `getWidgetBox()`: Gets the box around the widget for some purpose.
* `setDraggable(boolean draggable)`: Sets whether the widget is draggable.
* `isOverlapping(List<Widget> other)`: Returns whether this widget is overlapping with any of the widgets in the given list.
* `isOverlapping(Widget other)`: Returns whether this widget is overlapping with the given widget.
* `render(DrawContext drawContext)`: Renders the widget on the screen.
* `isEnabled()`: Returns whether the widget is enabled.
* `getX()`: Returns the x position of the widget in pixels.
* `setX(int x)`: Sets the x position of the widget in pixels.
* `getY()`: Returns the y position of the widget in pixels.
* `setY(int y)`: Sets the y position of the widget in pixels.
* `getHeight()`: Returns the font height from TextRenderer.
* `readFromTag(NbtCompound tag)`: Reads the state of this widget from the given NBT tag.
* `writeToTag(NbtCompound tag)`: Writes the state of this widget to the given NBT tag.
