Skip to main content

WatchlistPanel

Struct WatchlistPanel 

Source
pub struct WatchlistPanel { /* private fields */ }
Expand description

Watchlists fed by host quotes.

With a Quotes service attached through set_service, the panel subscribes to the symbols of the active list and the selected symbol, and subscribes again whenever they change; call poll each frame, even while the panel is hidden. Without one, set quotes with set_quote. Either way quote reads them back, so the selected symbol’s quote can feed the symbol details panel, the symbol header and the order ticket. Keep the chart symbol selected with set_selected. The list name in the header opens the list menu; beside it, the add button returns WatchlistAction::AddSymbol, the advanced view button WatchlistAction::AdvancedView, and the more button opens the actions on the active list. Clicking a symbol, or moving through the list with the up and down arrow keys after a click, returns WatchlistAction::SelectSymbol. Column headers cycle through ascending, descending and list order; sorting keeps symbols inside their section. Clicking a section collapses or expands its symbols. Unsorted rows are dragged to reorder, and rows are right-clicked to flag, rename or remove. The host persists lists and handles file intents.

Implementations§

Source§

impl WatchlistPanel

Source

pub fn new(lists: Vec<Watchlist>) -> Self

A panel showing the first of lists, or one empty list when there are none.

Source

pub fn set_columns( &mut self, columns: impl IntoIterator<Item = WatchlistColumn>, )

Shows these columns after the symbol, in order; the default is WatchlistColumn::DEFAULT. A quote without a column’s figure shows a dash, apart from a symbol without a quote, which shows nothing. A sort by a column no longer shown is dropped.

Source

pub fn flag_filter(&self) -> Option<WatchlistFlag>

The flag whose symbols the panel shows across every list, if any.

Source

pub fn set_flag_filter(&mut self, flag: Option<WatchlistFlag>)

Shows the symbols flagged flag in any list, each once, instead of the active list; None returns to the active list. The view follows flag changes in the lists.

Source

pub fn lists(&self) -> &[Watchlist]

Every list, for the host to persist.

Source

pub fn symbols(&self) -> impl Iterator<Item = &str>

The symbols the panel shows, which need quotes: those of the active list, or with a flag filter the flagged ones of every list, each once.

Source

pub fn set_quote(&mut self, symbol: &str, quote: Quote)

Sets the latest quote of symbol, ignoring older timestamps and non-finite prices or supplied numeric fields. Equal timestamps can correct the current quote.

Source

pub fn quote(&self, symbol: &str) -> Option<&Quote>

The latest quote of symbol, if the panel holds one.

Source

pub fn set_price_decimals(&mut self, symbol: &str, decimals: u8)

Shows the prices of symbol with decimals, as Instrument::price_decimals. Without them, the decimals follow the size of the last price.

Source

pub fn set_mark(&mut self, symbol: &str, mark: ImageSource<'static>)

Shows mark, such as the issuer’s logo, in a circle before symbol. Without one, or while it loads or cannot be read, the row shows the symbol’s first letter or digit on a neutral disc.

Source

pub fn set_service(&mut self, service: Arc<dyn Quotes>)

Takes quotes from service from the next poll on.

Source

pub fn set_sharing(&mut self, sharing: Arc<dyn Sharing>)

Offers copy-link and save-a-copy on the active list, as sharing reports them for ShareKind::Watchlist. A saved copy is added to the lists under the name the host answers. poll receives the answers.

Source

pub fn poll(&mut self, ctx: &Context)

Subscribes again when the symbols to quote changed or the stream lagged, and applies the quotes the service pushed. The quotes of symbols no longer subscribed are dropped.

Source

pub fn set_selected(&mut self, symbol: &str)

Marks symbol selected, such as the symbol the chart shows.

Source

pub fn add_symbol(&mut self, symbol: &str) -> bool

Appends symbol to the active list as Watchlist::add_symbol does, such as the symbol picked after WatchlistAction::AddSymbol. Returns false when the list is unchanged.

Source

pub fn add_symbol_to(&mut self, list: usize, symbol: &str) -> bool

Appends symbol to the list at list in lists as Watchlist::add_symbol does, such as for ContextMenuAction::AddToWatchlist. Returns false when there is no such list or it is unchanged.

Source

pub fn import(&mut self, name: impl Into<String>, text: &str)

Adds a list read with Watchlist::from_text and shows it.

Source

pub fn show(&mut self, ui: &mut Ui) -> WatchlistAction

Render the active list and return the host action.

Source

pub fn show_wide( &mut self, ui: &mut Ui, details: &WatchlistDetails, ) -> WatchlistAction

Render the active list in the wide view: the table with every WatchlistColumn::WIDE column, and tabs for the earnings, dividends and news of details, which the host fills for the symbols shown. The sections list the rows of the selected symbol, or of every shown symbol while none of them is selected. Selection, sorting, the active list and the flag filter are those of show, so switching views keeps them. Returns WatchlistAction::CompactView from its view button.

Trait Implementations§

Source§

impl Default for WatchlistPanel

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.