MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / layout

Method layout

src/GUIStuff/Elements/ImageDisplay.cpp:28–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26ImageDisplay::ImageDisplay(GUIManager& gui): Element(gui) {}
27
28void ImageDisplay::layout(const Clay_ElementId& id, const Data& data) {
29 if(data != d) {
30 d = data;
31 std::string imgData;
32 try {
33 imgData = read_file_to_string(data.imgPath);
34 auto codec = SkCodec::MakeFromData(SkData::MakeWithoutCopy(imgData.c_str(), imgData.size()), {
35 SkJpegDecoder::Decoder()
36 });
37 img = std::get<0>(codec->getImage());
38 } catch(...) {
39 img = nullptr;
40 }
41 gui.invalidate_draw_element(this);
42 }
43
44 CLAY(id, {
45 .layout = {.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}},
46 .custom = {.customData = this}
47 }) {
48 }
49}
50
51void ImageDisplay::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {
52 if(img) {

Callers

nothing calls this directly

Calls 4

read_file_to_stringFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected