Skip to content

Commit

Permalink
Mandlebrot/Clippy/doc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed May 12, 2022
1 parent 732b45a commit 8d12489
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/kas-core/src/event/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Event {
Event::Activate => f(mgr),
Event::Command(cmd, _) if cmd.is_activate() => f(mgr),
Event::PressStart { source, coord, .. } if source.is_primary() => {
mgr.grab_press(id.clone(), source, coord, GrabMode::Grab, None);
mgr.grab_press(id, source, coord, GrabMode::Grab, None);
Response::Used
}
Event::PressMove { source, cur_id, .. } => {
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-core/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl RootWidget {

/// Add a pop-up as a layer in the current window
///
/// Each [`Popup`] is assigned a [`WindowId`]; both are passed.
/// Each [`crate::Popup`] is assigned a [`WindowId`]; both are passed.
pub fn add_popup(&mut self, mgr: &mut EventMgr, id: WindowId, popup: kas::Popup) {
let index = self.popups.len();
self.popups.push((id, popup));
Expand Down
6 changes: 2 additions & 4 deletions crates/kas-widgets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

//! KAS widget library
//!
//! ## Dialogs
//! ## Dialogs / pre-made windows
//!
//! - [`MessageBox`]: a simple window with a message and an "Ok" button
//! See [`dialog`] module.
//!
//! ## Container widgets
//!
Expand All @@ -16,8 +16,6 @@
//! - [`Stack`]: a stack of widgets in the same rect (TODO: `TabbedStack`)
//! - [`List`]: a dynamic row / column of children
//! - [`Splitter`]: similar to [`List`] but with resizing handles
//! - [`Window`] is usually the root widget and has special handling for
//! pop-ups and callbacks
//!
//! ## Menus
//!
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/view/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Driver<String> for DefaultEdit {
EditBox::new("".to_string())
}
fn set(&self, widget: &mut Self::Widget, data: String) -> TkAction {
widget.set_string(data.to_string())
widget.set_string(data)
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/kas-widgets/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
//!
//! The user may implement a [`Driver`] or may use a standard one:
//!
//! - [`driver::Default`] constructs a default view widget over various data types
//! - [`driver::DefaultView`] constructs a default view widget over various data types
//! - [`driver::DefaultEdit`] chooses a widget allowing editing of the shared data
//! - [`driver::DefaultNav`] is a variant of the above, ensuring items support
//! keyboard navigation (e.g. useful to allow selection of static items)
//! - [`driver::CheckBox`] and [`driver::RadioBox`] support the `bool` type
Expand Down
14 changes: 8 additions & 6 deletions examples/mandlebrot/mandlebrot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use kas::prelude::*;
use kas::shell::draw::{CustomPipe, CustomPipeBuilder, CustomWindow, DrawCustom, DrawPipe};
use kas::shell::Options;
use kas::widgets::adapter::ReserveP;
use kas::widgets::{Label, Slider, Window};
use kas::widgets::{Label, Slider};

#[cfg(not(feature = "shader64"))]
type ShaderVec2 = Vec2;
Expand Down Expand Up @@ -445,19 +445,18 @@ impl_scope! {
}

impl MandlebrotWindow {
fn new_window() -> Window<MandlebrotWindow> {
fn new() -> MandlebrotWindow {
let slider = Slider::new(0, 256, 1).with_value(64);
let mbrot = Mandlebrot::new();
let w = MandlebrotWindow {
MandlebrotWindow {
core: Default::default(),
label: Label::new(mbrot.loc()),
iters: ReserveP::new(Label::from("64"), |size_mgr, axis| {
Label::new("000").size_rules(size_mgr, axis)
}),
slider,
mbrot,
};
Window::new("Mandlebrot", w)
}
}
}
impl Widget for Self {
Expand All @@ -471,6 +470,9 @@ impl_scope! {
}
}
}
impl Window for Self {
fn title(&self) -> &str { "Mandlebrot" }
}
}

fn main() -> kas::shell::Result<()> {
Expand All @@ -479,6 +481,6 @@ fn main() -> kas::shell::Result<()> {
let theme = kas::theme::FlatTheme::new().with_colours("dark");

kas::shell::Toolkit::new_custom(PipeBuilder, theme, Options::from_env())?
.with(MandlebrotWindow::new_window())?
.with(MandlebrotWindow::new())?
.run()
}

0 comments on commit 8d12489

Please sign in to comment.