mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-30 23:27:22 +00:00
Add support for set_position(), position(), and set_physical_size() to the C++ WindowAdapter (#3367)
Closes #3349
This commit is contained in:
parent
d3b89df095
commit
d160eb7a31
5 changed files with 137 additions and 2 deletions
|
@ -256,6 +256,12 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void set_physical_size(slint::PhysicalSize size) override
|
||||
{
|
||||
float scale_factor = devicePixelRatio();
|
||||
resize(size.width / scale_factor, size.height / scale_factor);
|
||||
}
|
||||
|
||||
slint::PhysicalSize physical_size() const override
|
||||
{
|
||||
auto windowSize = slint::LogicalSize({ float(width()), float(height()) });
|
||||
|
@ -264,6 +270,20 @@ public:
|
|||
uint32_t(windowSize.height * scale_factor) });
|
||||
}
|
||||
|
||||
void set_position(slint::PhysicalPosition position) override
|
||||
{
|
||||
float scale_factor = devicePixelRatio();
|
||||
setFramePosition(QPointF(position.x / scale_factor, position.y / scale_factor).toPoint());
|
||||
}
|
||||
|
||||
std::optional<slint::PhysicalPosition> position() const override
|
||||
{
|
||||
auto pos = framePosition();
|
||||
float scale_factor = devicePixelRatio();
|
||||
return { slint::PhysicalPosition(
|
||||
{ int32_t(pos.x() * scale_factor), int32_t(pos.y() * scale_factor) }) };
|
||||
}
|
||||
|
||||
void request_redraw() override { requestUpdate(); }
|
||||
|
||||
void update_window_properties(const slint::platform::WindowProperties &props) override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue