Display last access date under files
This commit is contained in:
parent
87f5f74c86
commit
032db7f444
9 changed files with 86 additions and 22 deletions
|
|
@ -1,16 +1,18 @@
|
|||
#include "ImageDisplay.hpp"
|
||||
#include "../GUIManager.hpp"
|
||||
#include <include/codec/SkJpegDecoder.h>
|
||||
#include <include/core/SkRRect.h>
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
ImageDisplay::ImageDisplay(GUIManager& gui): Element(gui) {}
|
||||
|
||||
void ImageDisplay::layout(const Clay_ElementId& id, const std::filesystem::path& imgPath) {
|
||||
if(imgPath != oldImgPath) {
|
||||
void ImageDisplay::layout(const Clay_ElementId& id, const Data& data) {
|
||||
if(data != d) {
|
||||
d = data;
|
||||
std::string imgData;
|
||||
try {
|
||||
imgData = read_file_to_string(imgPath);
|
||||
imgData = read_file_to_string(data.imgPath);
|
||||
auto codec = SkCodec::MakeFromData(SkData::MakeWithoutCopy(imgData.c_str(), imgData.size()), {
|
||||
SkJpegDecoder::Decoder()
|
||||
});
|
||||
|
|
@ -30,12 +32,23 @@ void ImageDisplay::layout(const Clay_ElementId& id, const std::filesystem::path&
|
|||
|
||||
void ImageDisplay::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {
|
||||
if(img) {
|
||||
canvas->drawImageRect(img, boundingBox.value().get_sk_rect(), {SkFilterMode::kLinear, SkMipmapMode::kNone});
|
||||
SkPaint p;
|
||||
p.setAntiAlias(skiaAA);
|
||||
if(d.radius != 0.0f) {
|
||||
canvas->save();
|
||||
SkRRect r = SkRRect::MakeRectXY(boundingBox.value().get_sk_rect(), d.radius, d.radius);
|
||||
canvas->clipRRect(r, skiaAA);
|
||||
canvas->drawImageRect(img, boundingBox.value().get_sk_rect(), {SkFilterMode::kLinear, SkMipmapMode::kNone}, &p);
|
||||
canvas->restore();
|
||||
}
|
||||
else
|
||||
canvas->drawImageRect(img, boundingBox.value().get_sk_rect(), {SkFilterMode::kLinear, SkMipmapMode::kNone}, &p);
|
||||
}
|
||||
else {
|
||||
SkPaint p{io.theme->frontColor1};
|
||||
p.setAntiAlias(skiaAA);
|
||||
canvas->drawRect(boundingBox.value().get_sk_rect(), p);
|
||||
SkRRect r = SkRRect::MakeRectXY(boundingBox.value().get_sk_rect(), d.radius, d.radius);
|
||||
canvas->drawRRect(r, p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,16 @@ namespace GUIStuff {
|
|||
class ImageDisplay : public Element {
|
||||
public:
|
||||
ImageDisplay(GUIManager& gui);
|
||||
void layout(const Clay_ElementId& id, const std::filesystem::path& imgPath);
|
||||
struct Data {
|
||||
std::filesystem::path imgPath;
|
||||
float radius = 0.0f;
|
||||
bool operator==(const Data& d) const = default;
|
||||
};
|
||||
void layout(const Clay_ElementId& id, const Data& data);
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override;
|
||||
|
||||
private:
|
||||
std::filesystem::path oldImgPath;
|
||||
Data d;
|
||||
sk_sp<SkImage> img;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue