mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 03:15:07 +00:00
Cargo fmt
This commit is contained in:
parent
35eb1ec5a2
commit
14fe6f3b36
@ -19,11 +19,7 @@ use cursive::{Cursive, Printer};
|
||||
fn main() {
|
||||
let mut siv = Cursive::default();
|
||||
|
||||
siv.add_layer(
|
||||
Canvas::new(())
|
||||
.with_draw(draw)
|
||||
.fixed_size((20, 10)),
|
||||
);
|
||||
siv.add_layer(Canvas::new(()).with_draw(draw).fixed_size((20, 10)));
|
||||
|
||||
siv.add_global_callback('q', |s| s.quit());
|
||||
|
||||
|
@ -9,11 +9,7 @@ use cursive::{Cursive, Printer};
|
||||
|
||||
fn main() {
|
||||
let mut siv = Cursive::default();
|
||||
siv.add_layer(
|
||||
KeyCodeView::new(10)
|
||||
.full_width()
|
||||
.fixed_height(10),
|
||||
);
|
||||
siv.add_layer(KeyCodeView::new(10).full_width().fixed_height(10));
|
||||
|
||||
siv.run();
|
||||
}
|
||||
|
@ -87,11 +87,8 @@ impl View for BufferView {
|
||||
|
||||
fn draw(&self, printer: &Printer) {
|
||||
// Print the end of the buffer
|
||||
for (i, line) in self.buffer
|
||||
.iter()
|
||||
.rev()
|
||||
.take(printer.size.y)
|
||||
.enumerate()
|
||||
for (i, line) in
|
||||
self.buffer.iter().rev().take(printer.size.y).enumerate()
|
||||
{
|
||||
printer.print((0, printer.size.y - 1 - i), line);
|
||||
}
|
||||
|
@ -12,10 +12,7 @@ fn main() {
|
||||
let mut siv = Cursive::default();
|
||||
|
||||
let mut styled = StyledString::plain("Isn't ");
|
||||
styled.append(StyledString::styled(
|
||||
"that ",
|
||||
Color::Dark(BaseColor::Red),
|
||||
));
|
||||
styled.append(StyledString::styled("that ", Color::Dark(BaseColor::Red)));
|
||||
styled.append(StyledString::styled(
|
||||
"cool?",
|
||||
Style::from(Color::Light(BaseColor::Blue)).combine(Effect::Bold),
|
||||
|
@ -64,8 +64,7 @@ impl Board {
|
||||
}
|
||||
|
||||
fn get_mut(&mut self, pos: Vec2) -> Option<&mut Cell> {
|
||||
self.cell_id(pos)
|
||||
.map(move |i| &mut self.cells[i])
|
||||
self.cell_id(pos).map(move |i| &mut self.cells[i])
|
||||
}
|
||||
|
||||
pub fn cell_id(&self, pos: Vec2) -> Option<usize> {
|
||||
|
@ -189,9 +189,7 @@ impl cursive::view::View for BoardView {
|
||||
Cell::Unknown => "[]",
|
||||
Cell::Flag => "()",
|
||||
Cell::Visible(n) => {
|
||||
[
|
||||
" ", " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8"
|
||||
][n]
|
||||
[" ", " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8"][n]
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -87,11 +87,7 @@ fn phase_2(s: &mut Cursive) {
|
||||
// Let's prepare the progress bars...
|
||||
let mut linear = LinearLayout::vertical();
|
||||
for c in &counters {
|
||||
linear.add_child(
|
||||
ProgressBar::new()
|
||||
.max(n_max)
|
||||
.with_value(c.clone()),
|
||||
);
|
||||
linear.add_child(ProgressBar::new().max(n_max).with_value(c.clone()));
|
||||
}
|
||||
|
||||
s.pop_layer();
|
||||
|
@ -38,10 +38,6 @@ fn on_edit(siv: &mut Cursive, _content: &str, _cursor: usize) {
|
||||
let matches = edit_1.get_content() == edit_2.get_content();
|
||||
|
||||
siv.call_on_id("match", |v: &mut TextView| {
|
||||
v.set_content(if matches {
|
||||
"match"
|
||||
} else {
|
||||
"no match"
|
||||
})
|
||||
v.set_content(if matches { "match" } else { "no match" })
|
||||
});
|
||||
}
|
||||
|
@ -19,9 +19,7 @@ fn main() {
|
||||
);
|
||||
|
||||
// We'll add a find feature!
|
||||
siv.add_layer(Dialog::info(
|
||||
"Hint: press Ctrl-F to find in text!",
|
||||
));
|
||||
siv.add_layer(Dialog::info("Hint: press Ctrl-F to find in text!"));
|
||||
|
||||
siv.add_global_callback(Event::CtrlChar('f'), |s| {
|
||||
// When Ctrl-F is pressed, show the Find popup.
|
||||
|
@ -6,8 +6,7 @@ use cursive::Cursive;
|
||||
fn main() {
|
||||
let mut siv = Cursive::default();
|
||||
// You can load a theme from a file at runtime for fast development.
|
||||
siv.load_theme_file("assets/style.toml")
|
||||
.unwrap();
|
||||
siv.load_theme_file("assets/style.toml").unwrap();
|
||||
|
||||
// Or you can directly load it from a string for easy deployment.
|
||||
// siv.load_theme(include_str!("../assets/style.toml")).unwrap();
|
||||
|
@ -8,9 +8,7 @@ fn main() {
|
||||
let mut siv = Cursive::default();
|
||||
|
||||
let layout = LinearLayout::vertical()
|
||||
.child(TextView::new(
|
||||
"This is a dynamic theme example!",
|
||||
))
|
||||
.child(TextView::new("This is a dynamic theme example!"))
|
||||
.child(EditView::new().content("Woo! colors!").style(
|
||||
ColorStyle::new(
|
||||
Color::Rgb(200, 150, 150),
|
||||
|
@ -11,12 +11,12 @@ use self::bear_lib_terminal::terminal::{
|
||||
};
|
||||
use self::bear_lib_terminal::Color as BltColor;
|
||||
use backend;
|
||||
use chan;
|
||||
use event::{Event, Key, MouseButton, MouseEvent};
|
||||
use std::collections::HashSet;
|
||||
use std::time::{Duration, Instant};
|
||||
use theme::{BaseColor, Color, ColorPair, Effect};
|
||||
use vec::Vec2;
|
||||
use chan;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
enum ColorRole {
|
||||
Foreground,
|
||||
@ -52,7 +52,6 @@ impl Backend {
|
||||
}
|
||||
|
||||
fn parse_next(&mut self) -> Option<Event> {
|
||||
|
||||
// TODO: we could add backend-specific controls here.
|
||||
// Ex: ctrl+mouse wheel cause window cellsize to change
|
||||
terminal::read_event().map(|ev| {
|
||||
@ -99,7 +98,7 @@ impl Backend {
|
||||
offset: Vec2::zero(),
|
||||
}
|
||||
})
|
||||
.unwrap_or(Event::Unknown(vec![]))
|
||||
.unwrap_or(Event::Unknown(vec![]))
|
||||
}
|
||||
BltEvent::ShiftReleased | BltEvent::ControlReleased => {
|
||||
Event::Refresh
|
||||
@ -306,7 +305,9 @@ impl backend::Backend for Backend {
|
||||
terminal::print_xy(pos.x as i32, pos.y as i32, text);
|
||||
}
|
||||
|
||||
fn prepare_input(&mut self, event_sink: &chan::Sender<Event>, timeout: Duration) {
|
||||
fn prepare_input(
|
||||
&mut self, event_sink: &chan::Sender<Event>, timeout: Duration,
|
||||
) {
|
||||
// Wait for up to `timeout_ms`.
|
||||
let start = Instant::now();
|
||||
while start.elapsed() < timeout {
|
||||
|
@ -13,11 +13,11 @@ use std::collections::HashMap;
|
||||
use std::ffi::CString;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::{Write};
|
||||
use std::io::Write;
|
||||
use std::thread;
|
||||
|
||||
use libc;
|
||||
use chan;
|
||||
use libc;
|
||||
|
||||
pub struct Backend {
|
||||
current_style: Cell<ColorPair>,
|
||||
@ -88,7 +88,8 @@ impl InputParser {
|
||||
let _alt = (mevent.bstate & ncurses::BUTTON_ALT as mmask_t) != 0;
|
||||
let _ctrl = (mevent.bstate & ncurses::BUTTON_CTRL as mmask_t) != 0;
|
||||
|
||||
mevent.bstate &= !(ncurses::BUTTON_SHIFT | ncurses::BUTTON_ALT
|
||||
mevent.bstate &= !(ncurses::BUTTON_SHIFT
|
||||
| ncurses::BUTTON_ALT
|
||||
| ncurses::BUTTON_CTRL)
|
||||
as mmask_t;
|
||||
|
||||
@ -248,7 +249,6 @@ impl Backend {
|
||||
let style = ncurses::COLOR_PAIR(i);
|
||||
ncurses::attron(style);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl backend::Backend for Backend {
|
||||
@ -263,7 +263,10 @@ impl backend::Backend for Backend {
|
||||
ncurses::has_colors()
|
||||
}
|
||||
|
||||
fn start_input_thread(&mut self, event_sink: chan::Sender<Event>, stops: chan::Receiver<bool>) {
|
||||
fn start_input_thread(
|
||||
&mut self, event_sink: chan::Sender<Event>,
|
||||
stops: chan::Receiver<bool>,
|
||||
) {
|
||||
let mut parser = InputParser::new(event_sink);
|
||||
|
||||
// Start an input thread
|
||||
|
@ -3,15 +3,15 @@ extern crate pancurses;
|
||||
use self::super::split_i32;
|
||||
use self::pancurses::mmask_t;
|
||||
use backend;
|
||||
use chan;
|
||||
use event::{Event, Key, MouseButton, MouseEvent};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashMap;
|
||||
use std::io::{stdout, Write};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use theme::{Color, ColorPair, Effect};
|
||||
use vec::Vec2;
|
||||
use std::sync::Arc;
|
||||
use chan;
|
||||
use std::thread;
|
||||
|
||||
pub struct Backend {
|
||||
// Used
|
||||
@ -36,7 +36,9 @@ struct InputParser {
|
||||
unsafe impl Send for InputParser {}
|
||||
|
||||
impl InputParser {
|
||||
fn new(event_sink: chan::Sender<Event>, window: Arc<pancurses::Window>) -> Self {
|
||||
fn new(
|
||||
event_sink: chan::Sender<Event>, window: Arc<pancurses::Window>,
|
||||
) -> Self {
|
||||
InputParser {
|
||||
key_codes: initialize_keymap(),
|
||||
last_mouse_button: None,
|
||||
@ -48,21 +50,15 @@ impl InputParser {
|
||||
fn parse_next(&mut self) {
|
||||
let event = if let Some(ev) = self.window.getch() {
|
||||
match ev {
|
||||
pancurses::Input::Character('\n') => {
|
||||
Event::Key(Key::Enter)
|
||||
}
|
||||
pancurses::Input::Character('\n') => Event::Key(Key::Enter),
|
||||
// TODO: wait for a very short delay. If more keys are
|
||||
// pipelined, it may be an escape sequence.
|
||||
pancurses::Input::Character('\u{7f}')
|
||||
| pancurses::Input::Character('\u{8}') => {
|
||||
Event::Key(Key::Backspace)
|
||||
}
|
||||
pancurses::Input::Character('\u{9}') => {
|
||||
Event::Key(Key::Tab)
|
||||
}
|
||||
pancurses::Input::Character('\u{1b}') => {
|
||||
Event::Key(Key::Esc)
|
||||
| pancurses::Input::Character('\u{8}') => {
|
||||
Event::Key(Key::Backspace)
|
||||
}
|
||||
pancurses::Input::Character('\u{9}') => Event::Key(Key::Tab),
|
||||
pancurses::Input::Character('\u{1b}') => Event::Key(Key::Esc),
|
||||
pancurses::Input::Character(c) if (c as u32) <= 26 => {
|
||||
Event::CtrlChar((b'a' - 1 + c as u8) as char)
|
||||
}
|
||||
@ -85,9 +81,7 @@ impl InputParser {
|
||||
pancurses::Input::KeyLeft => Event::Key(Key::Left),
|
||||
pancurses::Input::KeyRight => Event::Key(Key::Right),
|
||||
pancurses::Input::KeyHome => Event::Key(Key::Home),
|
||||
pancurses::Input::KeyBackspace => {
|
||||
Event::Key(Key::Backspace)
|
||||
}
|
||||
pancurses::Input::KeyBackspace => Event::Key(Key::Backspace),
|
||||
pancurses::Input::KeyF0 => Event::Key(Key::F0),
|
||||
pancurses::Input::KeyF1 => Event::Key(Key::F1),
|
||||
pancurses::Input::KeyF2 => Event::Key(Key::F2),
|
||||
@ -171,9 +165,7 @@ impl InputParser {
|
||||
pancurses::Input::KeySMove => Event::Refresh,
|
||||
pancurses::Input::KeySNext => Event::Shift(Key::PageDown),
|
||||
pancurses::Input::KeySOptions => Event::Refresh,
|
||||
pancurses::Input::KeySPrevious => {
|
||||
Event::Shift(Key::PageUp)
|
||||
}
|
||||
pancurses::Input::KeySPrevious => Event::Shift(Key::PageUp),
|
||||
pancurses::Input::KeySPrint => Event::Refresh,
|
||||
pancurses::Input::KeySRedo => Event::Refresh,
|
||||
pancurses::Input::KeySReplace => Event::Refresh,
|
||||
@ -219,7 +211,8 @@ impl InputParser {
|
||||
let _alt = (mevent.bstate & pancurses::BUTTON_ALT as mmask_t) != 0;
|
||||
let _ctrl = (mevent.bstate & pancurses::BUTTON_CTRL as mmask_t) != 0;
|
||||
|
||||
mevent.bstate &= !(pancurses::BUTTON_SHIFT | pancurses::BUTTON_ALT
|
||||
mevent.bstate &= !(pancurses::BUTTON_SHIFT
|
||||
| pancurses::BUTTON_ALT
|
||||
| pancurses::BUTTON_CTRL) as mmask_t;
|
||||
|
||||
let make_event = |event| Event::Mouse {
|
||||
@ -348,7 +341,6 @@ impl Backend {
|
||||
let style = pancurses::COLOR_PAIR(i as pancurses::chtype);
|
||||
self.window.attron(style);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl backend::Backend for Backend {
|
||||
@ -417,8 +409,12 @@ impl backend::Backend for Backend {
|
||||
self.window.mvaddstr(pos.y as i32, pos.x as i32, text);
|
||||
}
|
||||
|
||||
fn start_input_thread(&mut self, event_sink: chan::Sender<Event>, stops: chan::Receiver<bool>) {
|
||||
let mut input_parser = InputParser::new(event_sink, Arc::clone(&self.window));
|
||||
fn start_input_thread(
|
||||
&mut self, event_sink: chan::Sender<Event>,
|
||||
stops: chan::Receiver<bool>,
|
||||
) {
|
||||
let mut input_parser =
|
||||
InputParser::new(event_sink, Arc::clone(&self.window));
|
||||
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
@ -430,7 +426,6 @@ impl backend::Backend for Backend {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,9 @@ impl backend::Backend for Backend {
|
||||
(1, 1).into()
|
||||
}
|
||||
|
||||
fn prepare_input(&mut self, event_sink: &chan::Sender<event::Event>, _timeout: Duration) {
|
||||
fn prepare_input(
|
||||
&mut self, event_sink: &chan::Sender<event::Event>, _timeout: Duration,
|
||||
) {
|
||||
event_sink.send(event::Event::Exit)
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,9 @@ pub trait Backend {
|
||||
fn finish(&mut self);
|
||||
|
||||
/// Starts a thread to collect input and send it to the given channel.
|
||||
fn start_input_thread(&mut self, event_sink: Sender<event::Event>, running: Receiver<bool>) {
|
||||
fn start_input_thread(
|
||||
&mut self, event_sink: Sender<event::Event>, running: Receiver<bool>,
|
||||
) {
|
||||
// Dummy implementation for some backends.
|
||||
let _ = event_sink;
|
||||
let _ = running;
|
||||
@ -42,7 +44,9 @@ pub trait Backend {
|
||||
///
|
||||
/// This is only required for non-thread-safe backends like BearLibTerminal
|
||||
/// where we cannot collect input in a separate thread.
|
||||
fn prepare_input(&mut self, event_sink: &Sender<event::Event>, timeout: Duration) {
|
||||
fn prepare_input(
|
||||
&mut self, event_sink: &Sender<event::Event>, timeout: Duration,
|
||||
) {
|
||||
// Dummy implementation for most backends.
|
||||
// Little trick to avoid unused variables.
|
||||
let _ = event_sink;
|
||||
|
@ -184,13 +184,11 @@ impl Backend {
|
||||
pub fn init() -> Box<Self> {
|
||||
print!("{}", termion::cursor::Hide);
|
||||
|
||||
|
||||
// TODO: lock stdout
|
||||
let terminal = AlternateScreen::from(MouseTerminal::from(
|
||||
::std::io::stdout().into_raw_mode().unwrap(),
|
||||
));
|
||||
|
||||
|
||||
let c = Backend {
|
||||
terminal: terminal,
|
||||
current_style: Cell::new(theme::ColorPair::from_256colors(0, 0)),
|
||||
@ -265,7 +263,10 @@ impl backend::Backend for Backend {
|
||||
);
|
||||
}
|
||||
|
||||
fn start_input_thread(&mut self, event_sink: chan::Sender<Event>, stops: chan::Receiver<bool>) {
|
||||
fn start_input_thread(
|
||||
&mut self, event_sink: chan::Sender<Event>,
|
||||
stops: chan::Receiver<bool>,
|
||||
) {
|
||||
let mut parser = InputParser::new(event_sink);
|
||||
thread::spawn(move || {
|
||||
loop {
|
||||
|
@ -5,8 +5,8 @@ use event::{Callback, Event, EventResult};
|
||||
use printer::Printer;
|
||||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
use std::time::Duration;
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
use theme;
|
||||
use vec::Vec2;
|
||||
use view::{self, Finder, IntoBoxedView, Position, View};
|
||||
@ -582,10 +582,11 @@ impl Cursive {
|
||||
let input_channel = &self.event_source;
|
||||
let cb_channel = &self.cb_source;
|
||||
|
||||
self.backend.prepare_input(&self.event_sink, Duration::from_millis(30));
|
||||
self.backend
|
||||
.prepare_input(&self.event_sink, Duration::from_millis(30));
|
||||
|
||||
if self.fps > 0 {
|
||||
let timeout = 1000 / self.fps;
|
||||
let timeout = 1000 / self.fps;
|
||||
let timeout = chan::after_ms(timeout);
|
||||
chan_select! {
|
||||
input_channel.recv() -> input => {
|
||||
@ -726,7 +727,8 @@ impl Cursive {
|
||||
event, position, ..
|
||||
} = event
|
||||
{
|
||||
if event.grabs_focus() && !self.menubar.autohide
|
||||
if event.grabs_focus()
|
||||
&& !self.menubar.autohide
|
||||
&& !self.menubar.has_submenu()
|
||||
&& position.y == 0
|
||||
{
|
||||
@ -743,7 +745,8 @@ impl Cursive {
|
||||
self.menubar.on_event(event).process(self);
|
||||
} else {
|
||||
let offset = if self.menubar.autohide { 0 } else { 1 };
|
||||
match self.screen_mut()
|
||||
match self
|
||||
.screen_mut()
|
||||
.on_event(event.relativized((0, offset)))
|
||||
{
|
||||
// If the event was ignored,
|
||||
@ -757,12 +760,11 @@ impl Cursive {
|
||||
// Ok, we processed the event.
|
||||
// Now tell the backend whether he sould keep receiving.
|
||||
self.stop_sink.send(!self.running);
|
||||
},
|
||||
}
|
||||
Interruption::Callback(cb) => {
|
||||
cb.call_box(self);
|
||||
},
|
||||
Interruption::Timeout => {
|
||||
}
|
||||
Interruption::Timeout => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,10 +368,12 @@ impl Dialog {
|
||||
// Add some special effect to the focused button
|
||||
let position = Vec2::new(offset, y);
|
||||
button.offset.set(position);
|
||||
button.button.draw(&printer
|
||||
.offset(position)
|
||||
.cropped(size)
|
||||
.focused(self.focus == DialogFocus::Button(i)));
|
||||
button.button.draw(
|
||||
&printer
|
||||
.offset(position)
|
||||
.cropped(size)
|
||||
.focused(self.focus == DialogFocus::Button(i)),
|
||||
);
|
||||
// Keep 1 blank between two buttons
|
||||
offset += size.x + 1;
|
||||
// Also keep 1 blank above the buttons
|
||||
@ -392,10 +394,12 @@ impl Dialog {
|
||||
None => return,
|
||||
};
|
||||
|
||||
self.content.draw(&printer
|
||||
.offset(self.borders.top_left() + self.padding.top_left())
|
||||
.cropped(inner_size)
|
||||
.focused(self.focus == DialogFocus::Content));
|
||||
self.content.draw(
|
||||
&printer
|
||||
.offset(self.borders.top_left() + self.padding.top_left())
|
||||
.cropped(inner_size)
|
||||
.focused(self.focus == DialogFocus::Content),
|
||||
);
|
||||
}
|
||||
|
||||
fn draw_title(&self, printer: &Printer) {
|
||||
@ -575,6 +579,7 @@ impl View for Dialog {
|
||||
|
||||
fn important_area(&self, _: Vec2) -> Rect {
|
||||
self.content.important_area(self.content.size)
|
||||
+ self.borders.top_left() + self.padding.top_left()
|
||||
+ self.borders.top_left()
|
||||
+ self.padding.top_left()
|
||||
}
|
||||
}
|
||||
|
@ -273,9 +273,9 @@ impl View for ListView {
|
||||
.draw(printer, |printer, i| match self.children[i] {
|
||||
ListChild::Row(ref label, ref view) => {
|
||||
printer.print((0, 0), label);
|
||||
view.draw(&printer
|
||||
.offset((offset, 0))
|
||||
.focused(i == self.focus));
|
||||
view.draw(
|
||||
&printer.offset((offset, 0)).focused(i == self.focus),
|
||||
);
|
||||
}
|
||||
ListChild::Delimiter => (),
|
||||
});
|
||||
@ -407,14 +407,10 @@ impl View for ListView {
|
||||
Event::Key(Key::PageDown) => {
|
||||
self.move_focus(10, direction::Direction::up())
|
||||
}
|
||||
Event::Key(Key::Home) | Event::Ctrl(Key::Home) => self.move_focus(
|
||||
usize::max_value(),
|
||||
direction::Direction::back(),
|
||||
),
|
||||
Event::Key(Key::End) | Event::Ctrl(Key::End) => self.move_focus(
|
||||
usize::max_value(),
|
||||
direction::Direction::front(),
|
||||
),
|
||||
Event::Key(Key::Home) | Event::Ctrl(Key::Home) => self
|
||||
.move_focus(usize::max_value(), direction::Direction::back()),
|
||||
Event::Key(Key::End) | Event::Ctrl(Key::End) => self
|
||||
.move_focus(usize::max_value(), direction::Direction::front()),
|
||||
Event::Key(Key::Tab) => {
|
||||
self.move_focus(1, direction::Direction::front())
|
||||
}
|
||||
|
@ -107,26 +107,26 @@ impl<V> ScrollView<V> {
|
||||
pub fn scroll_x(self, enabled: bool) -> Self {
|
||||
self.with(|s| s.set_scroll_x(enabled))
|
||||
}
|
||||
|
||||
|
||||
/// Programmatically scroll to the top of the view.
|
||||
pub fn scroll_to_top(&mut self) {
|
||||
let curr_x = self.offset.x;
|
||||
self.set_offset((curr_x,0));
|
||||
self.set_offset((curr_x, 0));
|
||||
}
|
||||
|
||||
|
||||
/// Programmatically scroll to the bottom of the view.
|
||||
pub fn scroll_to_bottom(&mut self) {
|
||||
let max_y = self.inner_size.saturating_sub(self.available_size()).y;
|
||||
let curr_x = self.offset.x;
|
||||
let curr_x = self.offset.x;
|
||||
self.set_offset((curr_x, max_y));
|
||||
}
|
||||
|
||||
|
||||
/// Programmatically scroll to the leftmost side of the view.
|
||||
pub fn scroll_to_left(&mut self) {
|
||||
let curr_y = self.offset.y;
|
||||
self.set_offset((0, curr_y));
|
||||
}
|
||||
|
||||
|
||||
/// Programmatically scroll to the rightmost side of the view.
|
||||
pub fn scroll_to_right(&mut self) {
|
||||
let max_x = self.inner_size.saturating_sub(self.available_size()).x;
|
||||
|
@ -459,10 +459,12 @@ impl StackView {
|
||||
StackPositionIterator::new(self.layers.iter(), printer.size)
|
||||
.enumerate()
|
||||
{
|
||||
v.view.draw(&printer
|
||||
.offset(offset)
|
||||
.cropped(v.size)
|
||||
.focused(i + 1 == last));
|
||||
v.view.draw(
|
||||
&printer
|
||||
.offset(offset)
|
||||
.cropped(v.size)
|
||||
.focused(i + 1 == last),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user