mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-10 03:10:41 +00:00
Deprecate ScrollBase
This commit is contained in:
parent
c7c5f7955f
commit
801fa8e54b
@ -111,6 +111,7 @@ pub use self::nameable::Nameable;
|
||||
pub use self::position::{Offset, Position};
|
||||
pub use self::resizable::Resizable;
|
||||
pub use self::scroll::ScrollStrategy;
|
||||
#[allow(deprecated)]
|
||||
pub use self::scroll_base::ScrollBase;
|
||||
pub use self::scrollable::Scrollable;
|
||||
pub use self::size_cache::SizeCache;
|
||||
|
@ -6,9 +6,15 @@ use std::cmp::{max, min};
|
||||
|
||||
/// Provide scrolling functionalities to a view.
|
||||
///
|
||||
/// You're not supposed to use this directly,
|
||||
/// but it can be helpful if you create your own Views.
|
||||
/// This is a legacy helper utility to define scrollable views.
|
||||
///
|
||||
/// The [`scroll`] module is the preferred way to achieve that.
|
||||
///
|
||||
/// [`scroll`]: ./scroll/index.html
|
||||
#[derive(Default, Debug)]
|
||||
#[deprecated(
|
||||
note = "`ScrollBase` is being deprecated in favor of the view::scroll module."
|
||||
)]
|
||||
pub struct ScrollBase {
|
||||
/// First line visible
|
||||
pub start_line: usize,
|
||||
@ -35,6 +41,7 @@ pub struct ScrollBase {
|
||||
pub thumb_grab: Option<usize>,
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl ScrollBase {
|
||||
/// Creates a new, uninitialized scrollbar.
|
||||
pub fn new() -> Self {
|
||||
|
@ -3,6 +3,7 @@ use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent};
|
||||
use crate::rect::Rect;
|
||||
use crate::theme::{ColorStyle, Effect};
|
||||
use crate::utils::lines::simple::{prefix, simple_prefix, LinesIterator, Row};
|
||||
#[allow(deprecated)]
|
||||
use crate::view::{ScrollBase, SizeCache, View};
|
||||
use crate::Vec2;
|
||||
use crate::{Printer, With, XY};
|
||||
@ -42,6 +43,7 @@ pub struct TextArea {
|
||||
enabled: bool,
|
||||
|
||||
/// Base for scrolling features
|
||||
#[allow(deprecated)]
|
||||
scrollbase: ScrollBase,
|
||||
|
||||
/// Cache to avoid re-computing layout on no-op events
|
||||
@ -63,6 +65,7 @@ new_default!(TextArea);
|
||||
impl TextArea {
|
||||
/// Creates a new, empty TextArea.
|
||||
pub fn new() -> Self {
|
||||
#[allow(deprecated)]
|
||||
TextArea {
|
||||
content: String::new(),
|
||||
rows: Vec::new(),
|
||||
@ -614,6 +617,7 @@ impl View for TextArea {
|
||||
&& position.fits_in_rect(offset, self.last_size) =>
|
||||
{
|
||||
if let Some(position) = position.checked_sub(offset) {
|
||||
#[allow(deprecated)]
|
||||
let y = position.y + self.scrollbase.start_line;
|
||||
let y = min(y, self.rows.len() - 1);
|
||||
let x = position.x;
|
||||
|
Loading…
Reference in New Issue
Block a user