Skip to content

Commit

Permalink
Merge branch 'lapce:main' into fix-signal-from-tokio-channel
Browse files Browse the repository at this point in the history
  • Loading branch information
anishsinha-io authored Jan 14, 2025
2 parents 8edbb0c + 33779de commit 3bfe992
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/app_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,15 @@ impl ApplicationHandle {
if let Some(val) = mac.titlebar_hidden {
window_attributes = window_attributes.with_titlebar_hidden(val);
}
if let Some(val) = mac.title_hidden {
window_attributes = window_attributes.with_title_hidden(val);
}
if let Some(val) = mac.full_size_content_view {
window_attributes = window_attributes.with_fullsize_content_view(val);
}
if let Some(val) = mac.unified_titlebar {
window_attributes = window_attributes.with_unified_titlebar(val);
}
if let Some(val) = mac.movable {
window_attributes = window_attributes.with_movable_by_window_background(val);
}
Expand All @@ -423,6 +429,9 @@ impl ApplicationHandle {
if let Some(hide) = mac.titlebar_buttons_hidden {
window_attributes = window_attributes.with_titlebar_buttons_hidden(hide)
}
if let Some(panel) = mac.panel {
window_attributes = window_attributes.with_panel(panel)
}
}

let Ok(window) = event_loop.create_window(window_attributes) else {
Expand Down
19 changes: 17 additions & 2 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use taffy::{
geometry::{MinMax, Size},
prelude::{GridPlacement, Line, Rect},
style::{
LengthPercentage, MaxTrackSizingFunction, MinTrackSizingFunction, Style as TaffyStyle,
TrackSizingFunction,
LengthPercentage, MaxTrackSizingFunction, MinTrackSizingFunction, Overflow,
Style as TaffyStyle, TrackSizingFunction,
},
};

Expand Down Expand Up @@ -74,6 +74,7 @@ impl StylePropValue for f64 {
Some(*self * (1.0 - value) + *other * value)
}
}
impl StylePropValue for Overflow {}
impl StylePropValue for Display {}
impl StylePropValue for Position {}
impl StylePropValue for FlexDirection {}
Expand Down Expand Up @@ -1674,6 +1675,16 @@ define_builtin_props!(
Rotation rotate: Px {} = Px(0.),
);

prop!(
/// How children overflowing their container in Y axis should affect layout
pub(crate) OverflowX: Overflow {} = Overflow::default()
);

prop!(
/// How children overflowing their container in X axis should affect layout
pub(crate) OverflowY: Overflow {} = Overflow::default()
);

prop_extractor! {
pub FontProps {
pub size: FontSize,
Expand Down Expand Up @@ -2357,6 +2368,10 @@ impl Style {
let style = self.builtin();
TaffyStyle {
display: style.display(),
overflow: taffy::Point {
x: self.get(OverflowX),
y: self.get(OverflowY),
},
position: style.position(),
size: taffy::prelude::Size {
width: style.width().into(),
Expand Down
9 changes: 7 additions & 2 deletions src/views/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use floem_reactive::create_effect;
use peniko::kurbo::{Point, Rect, Size, Stroke, Vec2};
use peniko::{Brush, Color};

use crate::style::CustomStylable;
use crate::style::{CustomStylable, OverflowX, OverflowY};
use crate::unit::PxPct;
use crate::{
app_state::AppState,
Expand Down Expand Up @@ -733,7 +733,12 @@ impl View for Scroll {
}

fn view_style(&self) -> Option<Style> {
Some(Style::new().items_start())
Some(
Style::new()
.items_start()
.set(OverflowX, taffy::Overflow::Scroll)
.set(OverflowY, taffy::Overflow::Scroll),
)
}

fn update(&mut self, cx: &mut crate::context::UpdateCx, state: Box<dyn std::any::Any>) {
Expand Down
21 changes: 21 additions & 0 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,18 @@ pub struct MacOSWindowConfig {
pub(crate) movable_by_window_background: Option<bool>,
pub(crate) titlebar_transparent: Option<bool>,
pub(crate) titlebar_hidden: Option<bool>,
pub(crate) title_hidden: Option<bool>,
pub(crate) titlebar_buttons_hidden: Option<bool>,
pub(crate) full_size_content_view: Option<bool>,
pub(crate) unified_titlebar: Option<bool>,
pub(crate) movable: Option<bool>,
pub(crate) traffic_lights_offset: Option<(f64, f64)>,
pub(crate) accepts_first_mouse: Option<bool>,
pub(crate) tabbing_identifier: Option<String>,
pub(crate) option_as_alt: Option<MacOsOptionAsAlt>,
pub(crate) has_shadow: Option<bool>,
pub(crate) disallow_high_dpi: Option<bool>,
pub(crate) panel: Option<bool>,
}

impl MacOSWindowConfig {
Expand All @@ -282,6 +285,12 @@ impl MacOSWindowConfig {
self
}

/// Hides the title.
pub fn hide_title(mut self, val: bool) -> Self {
self.title_hidden = Some(val);
self
}

/// Hides the title bar buttons.
pub fn hide_titlebar_buttons(mut self, val: bool) -> Self {
self.titlebar_buttons_hidden = Some(val);
Expand All @@ -294,6 +303,12 @@ impl MacOSWindowConfig {
self
}

/// unify the titlebar
pub fn unified_titlebar(mut self, val: bool) -> Self {
self.unified_titlebar = Some(val);
self
}

/// Allow the window to be moved or not.
pub fn movable(mut self, val: bool) -> Self {
self.movable = Some(val);
Expand Down Expand Up @@ -341,6 +356,12 @@ impl MacOSWindowConfig {
self.disallow_high_dpi = Some(val);
self
}

/// Set whether the window is a panel
pub fn panel(mut self, val: bool) -> Self {
self.panel = Some(val);
self
}
}

/// macOS specific configuration for how the Option key is treated
Expand Down

0 comments on commit 3bfe992

Please sign in to comment.