Move towards a new reconciler model, undo a lot of the weird stretch integrations I had done, separate out Layout and Appearance concepts, introduce ComponentKey and constructor lifecycle for components

This commit is contained in:
Ryan McGrath 2019-05-27 00:22:33 -07:00
parent 6fd3f79099
commit 91266cc841
No known key found for this signature in database
GPG key ID: 811674B62B666830
31 changed files with 820 additions and 941 deletions

View file

@ -13,9 +13,7 @@ use cocoa::foundation::{NSRect, NSPoint, NSSize, NSString};
use crate::color::IntoNSColor;
use alchemy_styles::color::Color;
use alchemy_styles::styles::Style;
use alchemy_styles::result::Layout;
use alchemy_styles::{Color, Layout, Appearance};
use alchemy_lifecycle::traits::PlatformSpecificNodeType;
@ -74,15 +72,15 @@ impl Text {
/// Given a `&Style`, will set the frame, background color, borders and so forth. It then
/// calls `setNeedsDisplay:YES` on the Objective-C side, so that Cocoa will re-render this
/// view.
pub fn apply_styles(&mut self, layout: &Layout, style: &Style) {
pub fn apply_styles(&mut self, appearance: &Appearance, layout: &Layout) {
unsafe {
let rect = NSRect::new(
NSPoint::new(layout.location.x.into(), layout.location.y.into()),
NSSize::new(layout.size.width.into(), layout.size.height.into())
);
self.background_color = style.background_color.into_nscolor();
self.text_color = style.text_color.into_nscolor();
self.background_color = appearance.background_color.into_nscolor();
self.text_color = appearance.text_color.into_nscolor();
msg_send![&*self.inner_mut, setFrame:rect];
msg_send![&*self.inner_mut, setBackgroundColor:&*self.background_color];

View file

@ -13,9 +13,7 @@ use cocoa::foundation::{NSRect, NSPoint, NSSize};
use crate::color::IntoNSColor;
use alchemy_styles::color::Color;
use alchemy_styles::styles::Style;
use alchemy_styles::result::Layout;
use alchemy_styles::{Appearance, Color, Layout};
use alchemy_lifecycle::traits::PlatformSpecificNodeType;
@ -70,14 +68,14 @@ impl View {
/// Given a `&Style`, will set the frame, background color, borders and so forth. It then
/// calls `setNeedsDisplay:YES` on the Objective-C side, so that Cocoa will re-render this
/// view.
pub fn apply_styles(&mut self, layout: &Layout, style: &Style) {
pub fn apply_styles(&mut self, appearance: &Appearance, layout: &Layout) {
unsafe {
let rect = NSRect::new(
NSPoint::new(layout.location.x.into(), layout.location.y.into()),
NSSize::new(layout.size.width.into(), layout.size.height.into())
);
self.background_color = style.background_color.into_nscolor();
self.background_color = appearance.background_color.into_nscolor();
self.inner_mut.set_ivar(BACKGROUND_COLOR, &*self.background_color);
msg_send![&*self.inner_mut, setFrame:rect];