4 //! An easy-to-use, immediate-mode, 2D GUI library featuring a range of useful widgets.
6 //! If you are new to Conrod, we recommend checking out [The Guide](./guide/index.html).
8 #![deny(missing_copy_implementations)]
13 extern crate graphics;
20 pub use widget::primitive::line::Line;
21 pub use widget::primitive::image::Image;
22 pub use widget::primitive::point_path::PointPath;
23 pub use widget::primitive::shape::circle::Circle;
24 pub use widget::primitive::shape::framed_rectangle::FramedRectangle;
25 pub use widget::primitive::shape::polygon::Polygon;
26 pub use widget::primitive::shape::oval::Oval;
27 pub use widget::primitive::shape::rectangle::Rectangle;
28 pub use widget::primitive::text::{Text, Wrap as TextWrap};
30 pub use widget::button::Button;
31 pub use widget::dbutton::DButton;
32 pub use widget::canvas::Canvas;
33 pub use widget::drop_down_list::DropDownList;
34 pub use widget::envelope_editor::EnvelopeEditor;
35 pub use widget::envelope_editor::EnvelopePoint;
36 pub use widget::matrix::Matrix as WidgetMatrix;
37 pub use widget::number_dialer::NumberDialer;
38 pub use widget::slider::Slider;
39 pub use widget::tabs::Tabs;
40 pub use widget::text_box::TextBox;
41 pub use widget::title_bar::TitleBar;
42 pub use widget::toggle::Toggle;
43 pub use widget::xy_pad::XYPad;
46 pub use widget::primitive::line::Style as LineStyle;
47 pub use widget::primitive::image::Style as ImageStyle;
48 pub use widget::primitive::shape::Style as ShapeStyle;
49 pub use widget::primitive::shape::framed_rectangle::Style as FramedRectangleStyle;
50 pub use widget::primitive::text::Style as TextStyle;
52 pub use widget::button::Style as ButtonStyle;
53 pub use widget::canvas::Style as CanvasStyle;
54 pub use widget::drop_down_list::Style as DropDownListStyle;
55 pub use widget::envelope_editor::Style as EnvelopeEditorStyle;
56 pub use widget::number_dialer::Style as NumberDialerStyle;
57 pub use widget::slider::Style as SliderStyle;
58 pub use widget::tabs::Style as TabsStyle;
59 pub use widget::text_box::Style as TextBoxStyle;
60 pub use widget::title_bar::Style as TitleBarStyle;
61 pub use widget::toggle::Style as ToggleStyle;
62 pub use widget::xy_pad::Style as XYPadStyle;
65 pub use backend::{Backend, CharacterCache, Graphics};
66 pub use background::Background;
67 pub use color::{Color, Colorable};
68 pub use frame::{Framing, Frameable};
69 pub use glyph_cache::{GlyphCache, LineBreak};
70 pub use graph::NodeIndex;
71 pub use label::{FontSize, Labelable};
73 pub use mouse::ButtonState as MouseButtonState;
74 pub use mouse::ButtonPosition as MouseButtonPosition;
75 pub use mouse::Scroll as MouseScroll;
76 pub use position::{Align, Axis, Corner, Depth, Direction, Dimension, Dimensions, Edge, Margin,
77 Padding, Place, Point, Position, Positionable, Range, Rect, Scalar, Sizeable};
78 //pub use position::Matrix as PositionMatrix;
80 pub use ui::{Ui, UiCell, UserInput};
81 pub use widget::{default_x_dimension, default_y_dimension};
82 pub use widget::{drag, scroll};
83 pub use widget::{CommonBuilder, CommonState, CommonStyle, Floating, IndexSlot, MaybeParent,
85 pub use widget::{KidArea, KidAreaArgs};
86 pub use widget::CommonState as WidgetCommonState;
87 pub use widget::Id as WidgetId;
88 pub use widget::Index as WidgetIndex;
89 pub use widget::Kind as WidgetKind;
90 pub use widget::State as WidgetState;
116 /// Generate a list of unique IDs given a list of identifiers.
118 /// This is the recommended way of generating `WidgetId`s as it greatly lessens the chances of
119 /// making errors when adding or removing widget ids.
121 /// Each Widget must have its own unique identifier so that the `Ui` can keep track of its state
124 /// To make this easier, we provide the `widget_ids` macro, which generates a unique `WidgetId` for
125 /// each identifier given in the list.
127 /// The `with n` syntax reserves `n` number of `WidgetId`s for that identifier rather than just one.
129 /// This is often useful in the case that you need to set multiple Widgets in a loop or when using
130 /// the `widget::Matrix`.
132 /// Note: Make sure when that you remember to `#[macro_use]` if you want to use this macro - i.e.
134 /// `#[macro_use] extern crate conrod;`
136 /// Also, if your list has a large number of identifiers (~64 or more) you may find this macro
137 /// hitting rustc's recursion limit (this will show as a compile error). To fix this you can try
138 /// adding the following to your crate root.
140 /// `#![recursion_limit="512"]`
142 /// This will raise the recursion limit from the default (~64) to 512. You should be able to set it
143 /// to a higher number if you find it necessary.
146 macro_rules! widget_ids {
148 // Handle the first ID.
149 ( $widget_id:ident , $($rest:tt)* ) => (
150 const $widget_id: $crate::WidgetId = $crate::WidgetId(0);
151 widget_ids!($widget_id.0 => $($rest)*);
154 // Handle the first ID with some given step between it and the next ID.
155 ( $widget_id:ident with $step:expr , $($rest:tt)* ) => (
156 const $widget_id: $crate::WidgetId = $crate::WidgetId(0);
157 widget_ids!($widget_id.0 + $step => $($rest)*);
160 // Handle some consecutive ID.
161 ( $prev_id:expr => $widget_id:ident , $($rest:tt)* ) => (
162 const $widget_id: $crate::WidgetId = $crate::WidgetId($prev_id + 1);
163 widget_ids!($widget_id.0 => $($rest)*);
166 // Handle some consecutive ID with some given step between it and the next ID.
167 ( $prev_id:expr => $widget_id:ident with $step:expr , $($rest:tt)* ) => (
168 const $widget_id: $crate::WidgetId = $crate::WidgetId($prev_id + 1);
169 widget_ids!($widget_id.0 + $step => $($rest)*);
173 ///// End cases. /////
176 // Handle the final ID.
179 // Handle the final ID.
180 ( $prev_id:expr => ) => ();
183 ///// Handle end cases that don't have a trailing comma. /////
186 // Handle a single ID without a trailing comma.
187 ( $widget_id:ident ) => (
188 const $widget_id: $crate::WidgetId = $crate::WidgetId(0);
191 // Handle a single ID with some given step without a trailing comma.
192 ( $widget_id:ident with $step:expr ) => (
193 const $widget_id: $crate::WidgetId = $crate::WidgetId(0);
196 // Handle the last ID without a trailing comma.
197 ( $prev_id:expr => $widget_id:ident ) => (
198 const $widget_id: $crate::WidgetId = $crate::WidgetId($prev_id + 1);
201 // Handle the last ID with some given step without a trailing comma.
202 ( $prev_id:expr => $widget_id:ident with $step:expr ) => (
203 const $widget_id: $crate::WidgetId = $crate::WidgetId($prev_id + 1);
218 assert_eq!(A, WidgetId(0));
219 assert_eq!(B, WidgetId(1));
220 assert_eq!(C, WidgetId(66));
221 assert_eq!(D, WidgetId(99));
222 assert_eq!(E, WidgetId(100));