mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00
C++: minimize/maximize/fullscreen API on Window
This commit is contained in:
parent
be8fdd15d5
commit
9f0c3c94a9
5 changed files with 109 additions and 3 deletions
|
@ -527,6 +527,12 @@ fn gen_corelib(
|
||||||
"slint_windowrc_dispatch_pointer_event",
|
"slint_windowrc_dispatch_pointer_event",
|
||||||
"slint_windowrc_dispatch_key_event",
|
"slint_windowrc_dispatch_key_event",
|
||||||
"slint_windowrc_dispatch_event",
|
"slint_windowrc_dispatch_event",
|
||||||
|
"slint_windowrc_set_fullscreen",
|
||||||
|
"slint_windowrc_set_minimized",
|
||||||
|
"slint_windowrc_set_maximized",
|
||||||
|
"slint_windowrc_is_fullscreen",
|
||||||
|
"slint_windowrc_is_minimized",
|
||||||
|
"slint_windowrc_is_maximized",
|
||||||
"slint_new_path_elements",
|
"slint_new_path_elements",
|
||||||
"slint_new_path_events",
|
"slint_new_path_events",
|
||||||
"slint_color_brighter",
|
"slint_color_brighter",
|
||||||
|
|
|
@ -243,20 +243,26 @@ public:
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \deprecated Use is_fullscreen() instead
|
||||||
|
[[deprecated("Renamed is_fullscreen()")]] bool fullscreen() const
|
||||||
|
{
|
||||||
|
return is_fullscreen();
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the window should be shown fullscreen; false otherwise.
|
/// Returns true if the window should be shown fullscreen; false otherwise.
|
||||||
bool fullscreen() const
|
bool is_fullscreen() const
|
||||||
{
|
{
|
||||||
return cbindgen_private::slint_window_properties_get_fullscreen(inner());
|
return cbindgen_private::slint_window_properties_get_fullscreen(inner());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the window should be minimized; false otherwise
|
/// Returns true if the window should be minimized; false otherwise
|
||||||
bool minimized() const
|
bool is_minimized() const
|
||||||
{
|
{
|
||||||
return cbindgen_private::slint_window_properties_get_minimized(inner());
|
return cbindgen_private::slint_window_properties_get_minimized(inner());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the window should be maximized; false otherwise
|
/// Returns true if the window should be maximized; false otherwise
|
||||||
bool maximized() const
|
bool is_maximized() const
|
||||||
{
|
{
|
||||||
return cbindgen_private::slint_window_properties_get_maximized(inner());
|
return cbindgen_private::slint_window_properties_get_maximized(inner());
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,6 +320,39 @@ public:
|
||||||
/// physical pixels.
|
/// physical pixels.
|
||||||
float scale_factor() const { return inner.scale_factor(); }
|
float scale_factor() const { return inner.scale_factor(); }
|
||||||
|
|
||||||
|
/// Returns if the window is currently fullscreen
|
||||||
|
bool is_fullscreen() const
|
||||||
|
{
|
||||||
|
return cbindgen_private::slint_windowrc_is_fullscreen(&inner.handle());
|
||||||
|
}
|
||||||
|
/// Set or unset the window to display fullscreen.
|
||||||
|
void set_fullscreen(bool fullscreen)
|
||||||
|
{
|
||||||
|
cbindgen_private::slint_windowrc_set_fullscreen(&inner.handle(), fullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns if the window is currently maximized
|
||||||
|
bool is_maximized() const
|
||||||
|
{
|
||||||
|
return cbindgen_private::slint_windowrc_is_maximized(&inner.handle());
|
||||||
|
}
|
||||||
|
/// Maximize or unmaximize the window.
|
||||||
|
void set_maximized(bool maximized)
|
||||||
|
{
|
||||||
|
cbindgen_private::slint_windowrc_set_maximized(&inner.handle(), maximized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns if the window is currently minimized
|
||||||
|
bool is_minimized() const
|
||||||
|
{
|
||||||
|
return cbindgen_private::slint_windowrc_is_minimized(&inner.handle());
|
||||||
|
}
|
||||||
|
/// Minimize or unminimze the window.
|
||||||
|
void set_minimized(bool minimized)
|
||||||
|
{
|
||||||
|
cbindgen_private::slint_windowrc_set_minimized(&inner.handle(), minimized);
|
||||||
|
}
|
||||||
|
|
||||||
/// Dispatch a key press event to the scene.
|
/// Dispatch a key press event to the scene.
|
||||||
///
|
///
|
||||||
/// Use this when you're implementing your own backend and want to forward user input events.
|
/// Use this when you're implementing your own backend and want to forward user input events.
|
||||||
|
|
|
@ -297,6 +297,15 @@ public:
|
||||||
QWindow::setMaximumSize(c.max ? QSize(c.max->width, c.max->height)
|
QWindow::setMaximumSize(c.max ? QSize(c.max->width, c.max->height)
|
||||||
: QSize(1 << 15, 1 << 15));
|
: QSize(1 << 15, 1 << 15));
|
||||||
QWindow::setMinimumSize(c.min ? QSize(c.min->width, c.min->height) : QSize());
|
QWindow::setMinimumSize(c.min ? QSize(c.min->width, c.min->height) : QSize());
|
||||||
|
|
||||||
|
Qt::WindowStates states = windowState() & Qt::WindowActive;
|
||||||
|
if (props.is_fullscreen())
|
||||||
|
states |= Qt::WindowFullScreen;
|
||||||
|
if (props.is_minimized())
|
||||||
|
states |= Qt::WindowMinimized;
|
||||||
|
if (props.is_maximized())
|
||||||
|
states |= Qt::WindowMaximized;
|
||||||
|
setWindowStates(states);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent *ev) override
|
void resizeEvent(QResizeEvent *ev) override
|
||||||
|
|
|
@ -1110,6 +1110,7 @@ pub type WindowAdapterRc = Rc<dyn WindowAdapter>;
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
#![allow(clippy::missing_safety_doc)]
|
#![allow(clippy::missing_safety_doc)]
|
||||||
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::api::{RenderingNotifier, RenderingState, SetRenderingNotifierError};
|
use crate::api::{RenderingNotifier, RenderingState, SetRenderingNotifierError};
|
||||||
|
@ -1472,6 +1473,57 @@ pub mod ffi {
|
||||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||||
window_adapter.window().dispatch_event(event.clone());
|
window_adapter.window().dispatch_event(event.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn slint_windowrc_is_fullscreen(
|
||||||
|
handle: *const WindowAdapterRcOpaque,
|
||||||
|
) -> bool {
|
||||||
|
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||||
|
window_adapter.window().is_fullscreen()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn slint_windowrc_is_minimized(
|
||||||
|
handle: *const WindowAdapterRcOpaque,
|
||||||
|
) -> bool {
|
||||||
|
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||||
|
window_adapter.window().is_minimized()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn slint_windowrc_is_maximized(
|
||||||
|
handle: *const WindowAdapterRcOpaque,
|
||||||
|
) -> bool {
|
||||||
|
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||||
|
window_adapter.window().is_maximized()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn slint_windowrc_set_fullscreen(
|
||||||
|
handle: *const WindowAdapterRcOpaque,
|
||||||
|
value: bool,
|
||||||
|
) {
|
||||||
|
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||||
|
window_adapter.window().set_fullscreen(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn slint_windowrc_set_minimized(
|
||||||
|
handle: *const WindowAdapterRcOpaque,
|
||||||
|
value: bool,
|
||||||
|
) {
|
||||||
|
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||||
|
window_adapter.window().set_minimized(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn slint_windowrc_set_maximized(
|
||||||
|
handle: *const WindowAdapterRcOpaque,
|
||||||
|
value: bool,
|
||||||
|
) {
|
||||||
|
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||||
|
window_adapter.window().set_maximized(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "software-renderer")]
|
#[cfg(feature = "software-renderer")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue