Rework theme API
This commit adds support for theming on macOS and also unifies the system theme handling across platforms.
This commit is contained in:
parent
4f06cfcf5b
commit
92fdf5ba85
20 changed files with 256 additions and 60 deletions
29
src/platform_impl/macos/appkit/appearance.rs
Normal file
29
src/platform_impl/macos/appkit/appearance.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use objc2::foundation::{NSArray, NSObject, NSString};
|
||||
use objc2::rc::{Id, Shared};
|
||||
use objc2::{extern_class, extern_methods, msg_send_id, ClassType};
|
||||
|
||||
extern_class!(
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub(crate) struct NSAppearance;
|
||||
|
||||
unsafe impl ClassType for NSAppearance {
|
||||
type Super = NSObject;
|
||||
}
|
||||
);
|
||||
|
||||
type NSAppearanceName = NSString;
|
||||
|
||||
extern_methods!(
|
||||
unsafe impl NSAppearance {
|
||||
pub fn appearanceNamed(name: &NSAppearanceName) -> Id<Self, Shared> {
|
||||
unsafe { msg_send_id![Self::class(), appearanceNamed: name] }
|
||||
}
|
||||
|
||||
pub fn bestMatchFromAppearancesWithNames(
|
||||
&self,
|
||||
appearances: &NSArray<NSAppearanceName>,
|
||||
) -> Id<NSAppearanceName, Shared> {
|
||||
unsafe { msg_send_id![self, bestMatchFromAppearancesWithNames: appearances,] }
|
||||
}
|
||||
}
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue