-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextPanel.cpp
More file actions
40 lines (38 loc) · 1.02 KB
/
Copy pathTextPanel.cpp
File metadata and controls
40 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* This file is part of the Eclipse2024 project. It is subject to the GPLv3
* license terms in the LICENSE file found in the top-level directory of this
* distribution and at
* https://github.com/jjackowski/eclipse2024/blob/master/LICENSE.
* No part of the Eclipse2024 project, including this file, may be copied,
* modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*
* Copyright (C) 2024 Jeff Jackowski
*/
#include "TextPanel.hpp"
void TextPanel::text(const std::string &t) {
if (t != txt) {
txt = t;
img.reset();
}
}
const duds::ui::graphics::BppImage *TextPanel::render(
duds::ui::graphics::ImageLocation &offset,
duds::ui::graphics::ImageDimensions &dim,
duds::ui::graphics::PanelMargins &margin,
int sizeStep
) {
if (txt.empty()) {
return nullptr;
}
if (!img) {
img = strcache->text(txt);
}
std::int16_t w = img->dimensions().w;
dim = img->dimensions().minExtent(dim);
if (dim.w == w) {
// trim last pixel; usually empty
--dim.w;
}
return img.get();
}