Add #[must_use] to all widgets
This commit is contained in:
parent
99808d2df8
commit
dd2f50e8ed
3 changed files with 9 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ImageButton {
|
pub struct ImageButton {
|
||||||
image: widgets::Image,
|
image: widgets::Image,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
texture_id: TextureId,
|
texture_id: TextureId,
|
||||||
|
|
|
@ -22,6 +22,7 @@ use paint::*;
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Anything implementing Widget can be added to a Ui with `Ui::add`
|
/// Anything implementing Widget can be added to a Ui with `Ui::add`
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
pub trait Widget {
|
pub trait Widget {
|
||||||
fn ui(self, ui: &mut Ui) -> Response;
|
fn ui(self, ui: &mut Ui) -> Response;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,7 @@ pub trait Widget {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Static text.
|
/// Static text.
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
pub struct Label {
|
pub struct Label {
|
||||||
// TODO: not pub
|
// TODO: not pub
|
||||||
pub(crate) text: String,
|
pub(crate) text: String,
|
||||||
|
@ -213,6 +215,7 @@ impl Into<Label> for String {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// A clickable hyperlink, e.g. to `"https://github.com/emilk/egui"`.
|
/// A clickable hyperlink, e.g. to `"https://github.com/emilk/egui"`.
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
pub struct Hyperlink {
|
pub struct Hyperlink {
|
||||||
// TODO: wrap Label
|
// TODO: wrap Label
|
||||||
url: String,
|
url: String,
|
||||||
|
@ -296,6 +299,7 @@ impl Widget for Hyperlink {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Clickable button with text
|
/// Clickable button with text
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
pub struct Button {
|
pub struct Button {
|
||||||
text: String,
|
text: String,
|
||||||
text_color: Option<Srgba>,
|
text_color: Option<Srgba>,
|
||||||
|
@ -532,6 +536,7 @@ impl<'a> Widget for Checkbox<'a> {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// One out of several alternatives, either selected or not.
|
/// One out of several alternatives, either selected or not.
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RadioButton {
|
pub struct RadioButton {
|
||||||
checked: bool,
|
checked: bool,
|
||||||
|
@ -628,6 +633,7 @@ impl Widget for RadioButton {
|
||||||
/// One out of several alternatives, either selected or not.
|
/// One out of several alternatives, either selected or not.
|
||||||
/// Will mark selected items with a different background color
|
/// Will mark selected items with a different background color
|
||||||
/// An alternative to `RadioButton` and `Checkbox`.
|
/// An alternative to `RadioButton` and `Checkbox`.
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct SelectableLabel {
|
pub struct SelectableLabel {
|
||||||
selected: bool,
|
selected: bool,
|
||||||
|
@ -693,6 +699,7 @@ impl Widget for SelectableLabel {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// A visual separator. A horizontal or vertical line (depending on `Layout`).
|
/// A visual separator. A horizontal or vertical line (depending on `Layout`).
|
||||||
|
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
|
||||||
pub struct Separator {
|
pub struct Separator {
|
||||||
spacing: f32,
|
spacing: f32,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue