Deprecate ScrollBase

This commit is contained in:
Alexandre Bury 2020-10-06 09:37:53 -07:00
parent c7c5f7955f
commit 801fa8e54b
3 changed files with 14 additions and 2 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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;