mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-27 12:29:41 +00:00
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
/* LICENSE BEGIN
|
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
|
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
|
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
|
|
|
SPDX-License-Identifier: GPL-3.0-only
|
|
This file is also available under commercial licensing terms.
|
|
Please contact info@sixtyfps.io for more information.
|
|
LICENSE END */
|
|
#pragma once
|
|
#include <string_view>
|
|
#include "sixtyfps_properties_internal.h"
|
|
|
|
namespace sixtyfps {
|
|
|
|
// template<typename... Args>
|
|
struct Signal
|
|
{
|
|
Signal() { cbindgen_private::sixtyfps_signal_init(&inner); }
|
|
~Signal() { cbindgen_private::sixtyfps_signal_drop(&inner); }
|
|
Signal(const Signal &) = delete;
|
|
Signal(Signal &&) = delete;
|
|
Signal &operator=(const Signal &) = delete;
|
|
|
|
template<typename F>
|
|
void set_handler(F binding)
|
|
{
|
|
cbindgen_private::sixtyfps_signal_set_handler(
|
|
&inner,
|
|
[](void *user_data) {
|
|
(*reinterpret_cast<F *>(user_data))();
|
|
},
|
|
new F(std::move(binding)), [](void *user_data) { delete reinterpret_cast<F *>(user_data); });
|
|
}
|
|
|
|
void emit() const
|
|
{
|
|
cbindgen_private::sixtyfps_signal_emit(&inner);
|
|
}
|
|
|
|
private:
|
|
cbindgen_private::SignalOpaque inner;
|
|
};
|
|
}
|