Skip to content

Commit

Permalink
Merge pull request #97 from kas-gui/work2
Browse files Browse the repository at this point in the history
Any, Menu, MenuBar improvements
  • Loading branch information
dhardy authored Apr 29, 2020
2 parents d9577d8 + d56162e commit 4c7fd34
Show file tree
Hide file tree
Showing 24 changed files with 860 additions and 548 deletions.
3 changes: 3 additions & 0 deletions kas-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ pub fn derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
impl #impl_generics kas::WidgetCore
for #name #ty_generics #where_clause
{
fn as_any(&self) -> &dyn std::any::Any { self }
fn as_any_mut(&mut self) -> &mut dyn std::any::Any { self }

fn core_data(&self) -> &kas::CoreData {
&self.#core_data
}
Expand Down
2 changes: 1 addition & 1 deletion kas-theme/src/col.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl ThemeColours {
}
}

/// Get colour of a [text] area, depending on state
/// Get colour of a text area, depending on state
pub fn bg_col(&self, state: InputState) -> Colour {
if state.disabled {
self.bg_disabled
Expand Down
4 changes: 2 additions & 2 deletions kas-wgpu/examples/gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

use kas::class::HasText;
use kas::event::{Manager, Response, UpdateHandle, VoidMsg, VoidResponse};
use kas::macros::{make_widget, VoidMsg};
use kas::prelude::*;
use kas::widget::*;
use kas::{Right, TkAction, Widget, WidgetId};
use kas::Right;

#[derive(Clone, Debug, VoidMsg)]
enum Item {
Expand Down
4 changes: 2 additions & 2 deletions kas-wgpu/src/draw/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ pub trait CustomPipe {
/// Per-window state for a custom draw pipe
///
/// One instance is constructed per window. Since the [`CustomPipe`] is not
/// accessible during a widget's [`Layout::draw`] calls, this struct must batch
/// per-frame draw data.
/// accessible during a widget's [`kas::Layout::draw`] calls, this struct must
/// batch per-frame draw data.
pub trait CustomWindow {
/// User parameter type
type Param;
Expand Down
2 changes: 1 addition & 1 deletion src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl CompleteAlignment {
///
/// Using a generic `<D: Directional>` over [`Direction`] allows compile-time
/// substitution via the [`Right`], [`Down`], [`Left`] and [`Up`] instantiations.
pub trait Directional: Copy + Sized + std::fmt::Debug {
pub trait Directional: Copy + Sized + std::fmt::Debug + 'static {
/// Direction flipped over diagonal (i.e. Down ↔ Right)
type Flipped: Directional;

Expand Down
12 changes: 1 addition & 11 deletions src/event/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! Event handling: events

#[allow(unused)]
use super::Manager; // for doc-links
use super::{Manager, Response}; // for doc-links
use super::{MouseButton, UpdateHandle, VirtualKeyCode};

use crate::geom::{Coord, DVec2};
Expand Down Expand Up @@ -122,16 +122,6 @@ pub enum Event {
/// A user-defined payload is passed. Interpretation of this payload is
/// user-defined and unfortunately not type safe.
HandleUpdate { handle: UpdateHandle, payload: u64 },
/// Open popup / menu
///
/// This is a specific command from a parent, e.g. [`kas::widget::MenuBar`].
/// Most widgets can ignore this, even if they have a pop-up.
OpenPopup,
/// Close popup / menu
///
/// This is a specific command from a parent, e.g. [`kas::widget::MenuBar`].
/// Most widgets can ignore this, even if they have a pop-up.
ClosePopup,
/// Notification that a new popup has been created
///
/// This is sent to the parent of each open popup when a new popup is
Expand Down
4 changes: 2 additions & 2 deletions src/event/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub trait SendEvent: Handler {
/// disabled widgets should not forward any events.
///
/// The following logic is recommended for routing events:
/// ```norun
/// ```no_test
/// if self.is_disabled() {
/// return Response::Unhandled(event);
/// }
Expand All @@ -83,7 +83,7 @@ pub trait SendEvent: Handler {
/// }
/// ```
/// Parents which don't handle any events themselves may simplify this:
/// ```norun
/// ```no_test
/// if !self.is_disabled() && id <= self.w.id() {
/// return self.w.send(mgr, id, event);
/// }
Expand Down
4 changes: 2 additions & 2 deletions src/event/manager/mgr_pub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ impl<'a> Manager<'a> {
/// [`Event::Activate`].)
///
/// Only one widget can be a fallback, and the *first* to set itself wins.
/// This is primarily used to allow [`ScrollRegion`] to respond to
/// navigation keys when no widget has focus.
/// This is primarily used to allow [`kas::widget::ScrollRegion`] to
/// respond to navigation keys when no widget has focus.
pub fn register_nav_fallback(&mut self, id: WidgetId) {
if self.mgr.nav_fallback.is_none() {
debug!("Manager: nav_fallback = {}", id);
Expand Down
2 changes: 1 addition & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub use kas::geom::{Coord, Rect, Size};
pub use kas::macros::*;
pub use kas::{class, draw, event, geom, layout, widget};
pub use kas::{Align, AlignHints, Direction, Directional, WidgetId};
pub use kas::{Boxed, TkAction, TkWindow};
pub use kas::{CloneTo, Layout, ThemeApi, Widget, WidgetChildren, WidgetConfig, WidgetCore};
pub use kas::{CoreData, LayoutData};
pub use kas::{CowString, CowStringL};
pub use kas::{TkAction, TkWindow};
Loading

0 comments on commit 4c7fd34

Please sign in to comment.