TinyMaterialDesign
Loading...
Searching...
No Matches
Divider.h
Go to the documentation of this file.
1#pragma once
2#include "TinyGPU/Color/RGB565.h"
3#include "TinyGPU/Color/RGB666.h"
4#include "TinyGPU/Color/RGB888.h"
5#include "TinyMaterialDesign/Core/Widget.h"
6
7namespace tinymd {
8
9/// @brief A themed hairline. Orientation follows the bounds' aspect ratio: wider
10/// than tall draws horizontal (centered vertically), taller draws vertical
11/// (centered horizontally).
12template <typename RGB_T = TINYMD_DEFAULT_RGB_T>
13class Divider : public Widget<RGB_T> {
14 public:
15 Divider() = default;
16 explicit Divider(Bounds bounds) { this->bounds = bounds; }
17
18 void draw(tinygpu::ISurface<RGB_T>& target) override {
19 const RGB_T color = this->theme().colors.outline;
20 if (this->bounds.w >= this->bounds.h) {
21 const int32_t y = this->bounds.centerY();
22 target.drawLine(toPx(this->bounds.x), toPx(y), toPx(this->bounds.right() - 1), toPx(y),
23 color);
24 } else {
25 const int32_t x = this->bounds.centerX();
26 target.drawLine(toPx(x), toPx(this->bounds.y), toPx(x), toPx(this->bounds.bottom() - 1),
27 color);
28 }
29 }
30};
31
35
36} // namespace tinymd
A themed hairline. Orientation follows the bounds' aspect ratio: wider than tall draws horizontal (ce...
Definition: Divider.h:13
Divider()=default
Divider(Bounds bounds)
Definition: Divider.h:16
void draw(tinygpu::ISurface< RGB_T > &target) override
Definition: Divider.h:18
Base class every TinyMaterialDesign widget derives from.
Definition: Widget.h:58
Definition: AnchorLayout.h:4
Axis-aligned pixel rectangle used for widget bounds and hit-testing.
Definition: Bounds.h:21