Add zwidget
This commit is contained in:
parent
e7285cd6d9
commit
113fdc5fcc
54 changed files with 9321 additions and 0 deletions
32
libraries/ZWidget/src/widgets/imagebox/imagebox.cpp
Normal file
32
libraries/ZWidget/src/widgets/imagebox/imagebox.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
#include "widgets/imagebox/imagebox.h"
|
||||
|
||||
ImageBox::ImageBox(Widget* parent) : Widget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
double ImageBox::GetPreferredHeight() const
|
||||
{
|
||||
if (image)
|
||||
return (double)image->GetHeight();
|
||||
else
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void ImageBox::SetImage(std::shared_ptr<Image> newImage)
|
||||
{
|
||||
if (image != newImage)
|
||||
{
|
||||
image = newImage;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
void ImageBox::OnPaint(Canvas* canvas)
|
||||
{
|
||||
canvas->fillRect(Rect::xywh(0.0, 0.0, GetWidth(), GetHeight()), Colorf::fromRgba8(0, 0, 0));
|
||||
if (image)
|
||||
{
|
||||
canvas->drawImage(image, Point((GetWidth() - (double)image->GetWidth()) * 0.5, (GetHeight() - (double)image->GetHeight()) * 0.5));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue