Merge branch 'master' into feature/panes-widget

This commit is contained in:
Héctor Ramón Jiménez 2020-03-17 03:23:10 +01:00
commit c7583f1227
9 changed files with 49 additions and 24 deletions

View file

@ -10,7 +10,7 @@ use iced_wgpu::{
use iced_winit::{winit, Cache, Clipboard, MouseCursor, Size, UserInterface}; use iced_winit::{winit, Cache, Clipboard, MouseCursor, Size, UserInterface};
use winit::{ use winit::{
event::{DeviceEvent, Event, ModifiersState, WindowEvent}, event::{Event, ModifiersState, WindowEvent},
event_loop::{ControlFlow, EventLoop}, event_loop::{ControlFlow, EventLoop},
}; };
@ -66,14 +66,11 @@ pub fn main() {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;
match event { match event {
Event::DeviceEvent {
event: DeviceEvent::ModifiersChanged(new_modifiers),
..
} => {
modifiers = new_modifiers;
}
Event::WindowEvent { event, .. } => { Event::WindowEvent { event, .. } => {
match event { match event {
WindowEvent::ModifiersChanged(new_modifiers) => {
modifiers = new_modifiers;
}
WindowEvent::Resized(new_size) => { WindowEvent::Resized(new_size) => {
logical_size = logical_size =
new_size.to_logical(window.scale_factor()); new_size.to_logical(window.scale_factor());
@ -82,6 +79,7 @@ pub fn main() {
WindowEvent::CloseRequested => { WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit;
} }
_ => {} _ => {}
} }

View file

@ -93,6 +93,7 @@ impl Sandbox for Styling {
ProgressBar::new(0.0..=100.0, self.slider_value).style(self.theme); ProgressBar::new(0.0..=100.0, self.slider_value).style(self.theme);
let scrollable = Scrollable::new(&mut self.scroll) let scrollable = Scrollable::new(&mut self.scroll)
.width(Length::Fill)
.height(Length::Units(100)) .height(Length::Units(100))
.style(self.theme) .style(self.theme)
.push(Text::new("Scroll me!")) .push(Text::new("Scroll me!"))

View file

@ -30,6 +30,15 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
/// ///
/// [`Column`]: struct.Column.html /// [`Column`]: struct.Column.html
pub fn new() -> Self { pub fn new() -> Self {
Self::with_children(Vec::new())
}
/// Creates a [`Column`] with the given elements.
///
/// [`Column`]: struct.Column.html
pub fn with_children(
children: Vec<Element<'a, Message, Renderer>>,
) -> Self {
Column { Column {
spacing: 0, spacing: 0,
padding: 0, padding: 0,
@ -38,7 +47,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> {
max_width: u32::MAX, max_width: u32::MAX,
max_height: u32::MAX, max_height: u32::MAX,
align_items: Align::Start, align_items: Align::Start,
children: Vec::new(), children,
} }
} }

View file

@ -30,6 +30,15 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
/// ///
/// [`Row`]: struct.Row.html /// [`Row`]: struct.Row.html
pub fn new() -> Self { pub fn new() -> Self {
Self::with_children(Vec::new())
}
/// Creates a [`Row`] with the given elements.
///
/// [`Row`]: struct.Row.html
pub fn with_children(
children: Vec<Element<'a, Message, Renderer>>,
) -> Self {
Row { Row {
spacing: 0, spacing: 0,
padding: 0, padding: 0,
@ -38,7 +47,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> {
max_width: u32::MAX, max_width: u32::MAX,
max_height: u32::MAX, max_height: u32::MAX,
align_items: Align::Start, align_items: Align::Start,
children: Vec::new(), children,
} }
} }

View file

@ -118,7 +118,7 @@ where
Renderer: 'static + self::Renderer + column::Renderer, Renderer: 'static + self::Renderer + column::Renderer,
{ {
fn width(&self) -> Length { fn width(&self) -> Length {
Length::Fill Widget::<Message, Renderer>::width(&self.content)
} }
fn height(&self) -> Length { fn height(&self) -> Length {
@ -132,7 +132,7 @@ where
) -> layout::Node { ) -> layout::Node {
let limits = limits let limits = limits
.max_height(self.max_height) .max_height(self.max_height)
.width(Length::Fill) .width(Widget::<Message, Renderer>::width(&self.content))
.height(self.height); .height(self.height);
let child_limits = layout::Limits::new( let child_limits = layout::Limits::new(

View file

@ -25,6 +25,13 @@ impl<'a, Message> Column<'a, Message> {
/// ///
/// [`Column`]: struct.Column.html /// [`Column`]: struct.Column.html
pub fn new() -> Self { pub fn new() -> Self {
Self::with_children(Vec::new())
}
/// Creates a [`Column`] with the given elements.
///
/// [`Column`]: struct.Column.html
pub fn with_children(children: Vec<Element<'a, Message>>) -> Self {
Column { Column {
spacing: 0, spacing: 0,
padding: 0, padding: 0,
@ -33,7 +40,7 @@ impl<'a, Message> Column<'a, Message> {
max_width: u32::MAX, max_width: u32::MAX,
max_height: u32::MAX, max_height: u32::MAX,
align_items: Align::Start, align_items: Align::Start,
children: Vec::new(), children,
} }
} }

View file

@ -25,6 +25,13 @@ impl<'a, Message> Row<'a, Message> {
/// ///
/// [`Row`]: struct.Row.html /// [`Row`]: struct.Row.html
pub fn new() -> Self { pub fn new() -> Self {
Self::with_children(Vec::new())
}
/// Creates a [`Row`] with the given elements.
///
/// [`Row`]: struct.Row.html
pub fn with_children(children: Vec<Element<'a, Message>>) -> Self {
Row { Row {
spacing: 0, spacing: 0,
padding: 0, padding: 0,
@ -33,7 +40,7 @@ impl<'a, Message> Row<'a, Message> {
max_width: u32::MAX, max_width: u32::MAX,
max_height: u32::MAX, max_height: u32::MAX,
align_items: Align::Start, align_items: Align::Start,
children: Vec::new(), children,
} }
} }

View file

@ -14,16 +14,13 @@ categories = ["gui"]
debug = [] debug = []
[dependencies] [dependencies]
winit = "0.21" winit = "0.22"
window_clipboard = "0.1"
log = "0.4" log = "0.4"
[dependencies.iced_native] [dependencies.iced_native]
version = "0.1.0-alpha" version = "0.1.0-alpha"
path = "../native" path = "../native"
[dependencies.window_clipboard]
git = "https://github.com/hecrj/window_clipboard"
rev = "22c6dd6c04cd05d528029b50a30c56417cd4bebf"
[target.'cfg(target_os = "windows")'.dependencies.winapi] [target.'cfg(target_os = "windows")'.dependencies.winapi]
version = "0.3.6" version = "0.3.6"

View file

@ -347,6 +347,9 @@ pub trait Application: Sized {
WindowEvent::CloseRequested => { WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit;
} }
WindowEvent::ModifiersChanged(new_modifiers) => {
modifiers = new_modifiers;
}
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
input: input:
@ -382,12 +385,6 @@ pub trait Application: Sized {
events.push(event); events.push(event);
} }
} }
event::Event::DeviceEvent {
event: event::DeviceEvent::ModifiersChanged(new_modifiers),
..
} => {
modifiers = new_modifiers;
}
_ => { _ => {
*control_flow = ControlFlow::Wait; *control_flow = ControlFlow::Wait;
} }