mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 15:47:26 +00:00
C++: Api changes in the WindowAdapter
- s/physical_size/size/ (consistant with the slint::Window API) - remove const of virtual function (they don't need to be const and make implementation potentially easier) - Move the WindowProperties in it
This commit is contained in:
parent
465fe20478
commit
c47e6cd029
5 changed files with 83 additions and 87 deletions
|
@ -62,7 +62,7 @@ struct MyWindowAdapter : public slint::platform::WindowAdapter
|
|||
|
||||
slint::platform::AbstractRenderer &renderer() override { return m_renderer.value(); }
|
||||
|
||||
slint::PhysicalSize physical_size() const override
|
||||
slint::PhysicalSize size() override
|
||||
{
|
||||
RECT r;
|
||||
GetWindowRect(hwnd, &r);
|
||||
|
|
|
@ -198,7 +198,7 @@ public:
|
|||
MyWindow(QWindow *parentWindow = nullptr) : QWindow(parentWindow)
|
||||
{
|
||||
resize(640, 480);
|
||||
m_renderer.emplace(window_handle_for_qt_window(this), physical_size());
|
||||
m_renderer.emplace(window_handle_for_qt_window(this), size());
|
||||
}
|
||||
|
||||
slint::platform::AbstractRenderer &renderer() override { return m_renderer.value(); }
|
||||
|
@ -256,13 +256,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void set_physical_size(slint::PhysicalSize size) override
|
||||
void set_size(slint::PhysicalSize size) override
|
||||
{
|
||||
float scale_factor = devicePixelRatio();
|
||||
resize(size.width / scale_factor, size.height / scale_factor);
|
||||
}
|
||||
|
||||
slint::PhysicalSize physical_size() const override
|
||||
slint::PhysicalSize size() override
|
||||
{
|
||||
auto windowSize = slint::LogicalSize({ float(width()), float(height()) });
|
||||
float scale_factor = devicePixelRatio();
|
||||
|
@ -276,7 +276,7 @@ public:
|
|||
setFramePosition(QPointF(position.x / scale_factor, position.y / scale_factor).toPoint());
|
||||
}
|
||||
|
||||
std::optional<slint::PhysicalPosition> position() const override
|
||||
std::optional<slint::PhysicalPosition> position() override
|
||||
{
|
||||
auto pos = framePosition();
|
||||
float scale_factor = devicePixelRatio();
|
||||
|
@ -286,7 +286,7 @@ public:
|
|||
|
||||
void request_redraw() override { requestUpdate(); }
|
||||
|
||||
void update_window_properties(const slint::platform::WindowProperties &props) override
|
||||
void update_window_properties(const WindowProperties &props) override
|
||||
{
|
||||
QWindow::setTitle(QString::fromUtf8(props.title().data()));
|
||||
auto c = props.layout_constraints();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue