-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from hecrj/feature/panes-widget
Pane grid widget
- Loading branch information
Showing
36 changed files
with
1,915 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//! Reuse basic keyboard types. | ||
mod key_code; | ||
mod modifiers_state; | ||
|
||
pub use key_code::KeyCode; | ||
pub use modifiers_state::ModifiersState; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// The current state of the keyboard modifiers. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] | ||
pub struct ModifiersState { | ||
/// Whether a shift key is pressed | ||
pub shift: bool, | ||
|
||
/// Whether a control key is pressed | ||
pub control: bool, | ||
|
||
/// Whether an alt key is pressed | ||
pub alt: bool, | ||
|
||
/// Whether a logo key is pressed (e.g. windows key, command key...) | ||
pub logo: bool, | ||
} | ||
|
||
impl ModifiersState { | ||
/// Returns true if the current [`ModifiersState`] has at least the same | ||
/// modifiers enabled as the given value, and false otherwise. | ||
/// | ||
/// [`ModifiersState`]: struct.ModifiersState.html | ||
pub fn matches(&self, modifiers: ModifiersState) -> bool { | ||
let shift = !modifiers.shift || self.shift; | ||
let control = !modifiers.control || self.control; | ||
let alt = !modifiers.alt || self.alt; | ||
let logo = !modifiers.logo || self.logo; | ||
|
||
shift && control && alt && logo | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "pane_grid" | ||
version = "0.1.0" | ||
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"] | ||
edition = "2018" | ||
publish = false | ||
|
||
[dependencies] | ||
iced = { path = "../.." } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Pane grid | ||
|
||
A grid of panes that can be split, resized, and reorganized. | ||
|
||
This example showcases the `PaneGrid` widget, which features: | ||
|
||
* Vertical and horizontal splits | ||
* Tracking of the last active pane | ||
* Mouse-based resizing | ||
* Drag and drop to reorganize panes | ||
* Hotkey support | ||
* Configurable modifier keys | ||
* API to perform actions programmatically (`split`, `swap`, `resize`, etc.) | ||
|
||
The __[`main`]__ file contains all the code of the example. | ||
|
||
<div align="center"> | ||
<a href="https://gfycat.com/mixedflatjellyfish"> | ||
<img src="https://thumbs.gfycat.com/MixedFlatJellyfish-small.gif"> | ||
</a> | ||
</div> | ||
|
||
You can run it with `cargo run`: | ||
``` | ||
cargo run --package pane_grid | ||
``` | ||
|
||
[`main`]: src/main.rs |
Oops, something went wrong.