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
impl WatchlistPanel
Sourcepub fn new(lists: Vec<Watchlist>) -> Self
pub fn new(lists: Vec<Watchlist>) -> Self
A panel showing the first of lists, or one empty list when there are none.
Sourcepub fn set_columns(
&mut self,
columns: impl IntoIterator<Item = WatchlistColumn>,
)
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.
Sourcepub fn flag_filter(&self) -> Option<WatchlistFlag>
pub fn flag_filter(&self) -> Option<WatchlistFlag>
The flag whose symbols the panel shows across every list, if any.
Sourcepub fn set_flag_filter(&mut self, flag: Option<WatchlistFlag>)
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.
Sourcepub fn symbols(&self) -> impl Iterator<Item = &str>
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.
Sourcepub fn set_quote(&mut self, symbol: &str, quote: Quote)
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.
Sourcepub fn quote(&self, symbol: &str) -> Option<&Quote>
pub fn quote(&self, symbol: &str) -> Option<&Quote>
The latest quote of symbol, if the panel holds one.
Sourcepub fn set_price_decimals(&mut self, symbol: &str, decimals: u8)
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.
Sourcepub fn set_mark(&mut self, symbol: &str, mark: ImageSource<'static>)
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.
Sourcepub fn set_service(&mut self, service: Arc<dyn Quotes>)
pub fn set_service(&mut self, service: Arc<dyn Quotes>)
Takes quotes from service from the next poll on.
Sourcepub fn set_sharing(&mut self, sharing: Arc<dyn Sharing>)
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.
Sourcepub fn poll(&mut self, ctx: &Context)
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.
Sourcepub fn set_selected(&mut self, symbol: &str)
pub fn set_selected(&mut self, symbol: &str)
Marks symbol selected, such as the symbol the chart shows.
Sourcepub fn add_symbol(&mut self, symbol: &str) -> bool
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.
Sourcepub fn add_symbol_to(&mut self, list: usize, symbol: &str) -> bool
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.
Sourcepub fn import(&mut self, name: impl Into<String>, text: &str)
pub fn import(&mut self, name: impl Into<String>, text: &str)
Adds a list read with Watchlist::from_text and shows it.
Sourcepub fn show(&mut self, ui: &mut Ui) -> WatchlistAction
pub fn show(&mut self, ui: &mut Ui) -> WatchlistAction
Render the active list and return the host action.
Sourcepub fn show_wide(
&mut self,
ui: &mut Ui,
details: &WatchlistDetails,
) -> WatchlistAction
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§
Auto Trait Implementations§
impl !RefUnwindSafe for WatchlistPanel
impl !UnwindSafe for WatchlistPanel
impl Freeze for WatchlistPanel
impl Send for WatchlistPanel
impl Sync for WatchlistPanel
impl Unpin for WatchlistPanel
impl UnsafeUnpin for WatchlistPanel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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