Commit 2609f213 authored by Florian Blasius's avatar Florian Blasius 🤘

[prelude] add and use prelude file to orbtk

parent 8a06ddb3
use orbtk::*;
use orbtk::prelude::*;
widget!(MainView);
......
use orbtk::*;
use orbtk::prelude::*;
fn main() {
let mut application = Application::default();
......
use std::cell::Cell;
use orbtk::*;
use orbtk::prelude::*;
#[derive(Default)]
pub struct MainViewState {
......
use orbtk::*;
use orbtk::prelude::*;
fn main() {
let mut application = Application::default();
......
use std::cell::Cell;
use orbtk::*;
use orbtk::prelude::*;
#[derive(Default)]
pub struct MainViewState {
......
......@@ -37,3 +37,4 @@ pub mod styling;
pub mod systems;
pub mod theme;
pub mod widgets;
pub mod prelude;
......@@ -2,9 +2,6 @@
#[macro_export]
macro_rules! property {
($(#[$property_doc:meta])* $property:ident($type:ty)) => {
use dces::prelude::{Entity, EntityComponentManager};
use crate::properties::{PropertySource, get_property};
#[derive(Default, Debug, Clone, PartialEq)]
$(#[$property_doc])*
pub struct $property(pub $type);
......@@ -40,16 +37,6 @@ macro_rules! property {
#[macro_export]
macro_rules! widget {
( $(#[$widget_doc:meta])* $widget:ident $(<$state:ident>)* $(: $( $handler:ident ),*)* $( { $($(#[$prop_doc:meta])* $property:ident: $property_type:tt ),* } )* ) => {
#[allow(dead_code)]
use std::{ any::TypeId, rc::Rc, collections::HashMap, cell::RefCell, fmt::Debug };
use dces::prelude::{Component, ComponentBox, SharedComponentBox };
use crate::{event::EventHandler,
properties::{PropertySource, Bounds, Constraint, VerticalAlignment, HorizontalAlignment, Visibility, Name},
widgets::{Widget, BuildContext},
structs::Point};
$(#[$widget_doc])*
#[derive(Default)]
pub struct $widget {
......
pub use std::{
any::{Any, TypeId},
cell::RefCell,
collections::HashMap,
rc::Rc,
fmt::Debug,
};
pub use dces::prelude::*;
pub use crate::{
application::*,
event::*,
enums::*,
layout::*,
properties::*,
render_object::*,
structs::*,
styling::*,
theme::*,
widgets::*,
widget,
property
};
\ No newline at end of file
use crate::structs::{Position, Rect, Size};
use crate::prelude::*;
property!(
/// `Bounds` describes the actual bounds (position and size) of a widget.
......
use std::slice::{Iter, IterMut};
use crate::prelude::*;
/// Used to build a column, specifying additional details.
#[derive(Default)]
pub struct ColumnBuilder {
......
use crate::prelude::*;
property!(
/// `ColumnSpan` describes the column span of a widget on the `Grid`.
ColumnSpan(usize)
......
use std::f64;
use crate::prelude::*;
/// Used to build a constraint, specifying additional details.
#[derive(Default)]
pub struct ConstraintBuilder {
......
use crate::prelude::*;
property!(
/// `GridColumn` describes the column position of a widget on the `Grid`.
GridColumn(usize)
......
use crate::prelude::*;
property!(
/// `GridRow` describes the row position of a widget on the `Grid`.
GridRow(usize)
......
use super::Margin;
use crate::{enums::Alignment, structs::Spacer};
use crate::prelude::*;
property!(
/// `HorizontalAlignment` describes the vertical alignment of a widget.
......
use crate::structs::{Spacer, Thickness};
use crate::prelude::*;
property!(
/// `Margin` describes the outer widget space.
......
use crate::prelude::*;
property!(
/// `Offset` describes the x- and y-axis offset of a widget.
Offset((f64, f64))
......
use crate::prelude::*;
/// Is used to control the orientation of the `Stack`.
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum OrientationValue {
......
use crate::structs::{Spacer, Thickness};
use crate::prelude::*;
property!(
/// `Padding` describes the inner widget space.
......
use std::slice::{Iter, IterMut};
use crate::prelude::*;
/// Used to build a row, specifying additional details.
#[derive(Default)]
pub struct RowBuilder {
......
use crate::prelude::*;
property!(
/// `RowSpan` describes the row span of a widget on the `Grid`.
RowSpan(usize)
......
use crate::prelude::*;
/// The `ScrollMode` defines the mode of a scroll direction.
#[derive(Copy, Debug, Clone, PartialEq)]
pub enum ScrollMode {
......
use super::ScrollMode;
use crate::prelude::*;
/// `ScrollViewerMode` describes the vertical and horizontal scroll behavior of the `ScrollViewer`.
#[derive(Debug, Copy, Clone, PartialEq)]
......
use super::Margin;
use crate::{enums::Alignment, structs::Spacer};
use crate::prelude::*;
property!(
/// `VerticalAlignment` describes the vertical alignment of a widget.
......
use crate::prelude::*;
property!(
/// `Enabled` describes the enabled / disabled state of a widget.
Enabled(bool)
......
use crate::prelude::*;
property!(
/// `Focused` describes the focused (keyboard focus) state of a widget.
Focused(bool)
......
use crate::prelude::*;
property!(
/// `MouseOver` describes the mouse over state of a widget.
MouseOver(bool)
......
use crate::prelude::*;
property!(
/// `Pressed` describes the pressed (touch / mouse) state of a widget.
Pressed(bool)
......
use crate::prelude::*;
property!(
/// `Selected` describes the selected state of a widget.
Selected(bool)
......
use crate::prelude::*;
/// Is used to control the visibility of a widget
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum VisibilityValue {
......
use crate::
structs::{Brush, Color};
use crate::prelude::*;
property!(
/// `Background` describes the background brush of a visual element.
......
use crate::
structs::{Brush, Color};
use crate::prelude::*;
property!(
/// `BorderBrush` describes the border brush.
......
use crate::prelude::*;
property!(
/// `IconSize` describes the degree to which the corners of a Border are rounded.
BorderRadius(f64)
......
use crate::structs::{Spacer, Thickness};
use crate::prelude::*;
property!(
/// `BorderThickness` describes the relative thickness of a border.
......
......@@ -2,7 +2,7 @@ use std::fmt;
use orbfont::Font as OrbFont;
use crate::styling::fonts;
use crate::prelude::*;
#[derive(Clone)]
pub struct InnerFont(pub OrbFont);
......
use crate::prelude::*;
property!(
/// `FontSize` describes the font size of a text element.
FontSize(f64)
......
use crate::
structs::{Brush, Color};
use crate::prelude::*;
property!(
/// `Foreground` describes the foreground brush of a visual element.
......
use crate::
structs::{Brush, Color};
use crate::prelude::*;
property!(
/// `IconBrush` describes the icon brush of a visual element.
......
use orbfont::Font as OrbFont;
use super::InnerFont;
use crate::prelude::*;
property!(
/// `IconFont` describes the icon font of a widget.
......
use crate::prelude::*;
property!(
/// `IconSize` describes the icon size of a text element.
IconSize(f64)
......
use crate::prelude::*;
property!(
/// `Opacity` describes the opacity of a widget.
Opacity(f64)
......
......@@ -2,6 +2,8 @@ use std::{collections::HashSet, ops::Add};
use std::fmt;
use crate::prelude::*;
#[derive(Clone, Debug)]
pub enum SelectorRelation {
Ancestor(SelectorValue),
......
use crate::prelude::*;
property!(
/// `FontIcon` describes the font icon of a widget.
FontIcon(String)
......
use std::fmt;
use orbclient::Color;
use orbclient::Renderer;
use orbimage::Image as OrbImage;
use crate::prelude::*;
#[derive(Clone)]
pub struct InnerImage(pub OrbImage);
......
use crate::prelude::*;
property!(
/// `Name` is use for debugging purposes.
Name(String)
......
use crate::prelude::*;
property!(
/// `Text` describes the text of a widget.
Text(String)
......
use crate::prelude::*;
/// Is used to mark the selection of a text.
#[derive(Copy, Clone, Default, Debug, PartialEq)]
pub struct TextSelectionValue {
......
use crate::prelude::*;
property!(
/// `WaterMark` describes a placeholder text.
WaterMark(String)
......
use dces::prelude::Entity;
use crate::{
event::ClickHandler,
properties::*,
styling::{colors, fonts},
widgets::{Container, FontIconBlock, Stack, Template, TextBlock},
};
use crate::prelude::*;
widget!(
/// The `Button` widget can be clicked by user. It's used to perform an action.
......
use dces::prelude::Entity;
use crate::{
event::ClickHandler,
material_font_icons,
properties::*,
styling::{colors, fonts},
widgets::{Container, FontIconBlock, Stack, Template, TextBlock},
};
use crate::prelude::*;
widget!(
/// The `CheckBox` widget can be switch its selected state. It contains a selection box and a text.
......
use dces::prelude::Entity;
use crate::{properties::*, widgets::Template, render_object::{RenderObject, RectangleRenderObject}, layout::{Layout, PaddingLayout}};
use crate::prelude::*;
widget!(
/// The `Container` layout widget surrounds its child with a padding. Draws a box around the child.
......
use dces::prelude::Entity;
use crate::{
layout::{TextSelectionLayout, Layout},
properties::*,
render_object::{RenderObject, RectangleRenderObject},
styling::fonts,
widgets::{Template, State, Context, add_selector_to_widget, remove_selector_from_widget},
};
use crate::prelude::*;
// Default state of the `Cursor` widget.
#[derive(Default)]
......
use dces::prelude::Entity;
use crate::{
layout::{FixedSizeLayout, Layout},
properties::*,
render_object::{FontIconRenderObject, RenderObject},
styling::{colors, fonts},
widgets::Template,
};
use crate::prelude::*;
widget!(
/// The `FontIconBlock` widget is used to draw text. It is not interactive.
......
use dces::prelude::Entity;
use crate::{
layout::{GridLayout, Layout},
properties::*,
render_object::{RenderObject, RectangleRenderObject},
widgets::Template,
};
use crate::prelude::*;
widget!(
/// The `Grid` defines a flexible grid area that consists of columns and rows.
......
use dces::prelude::Entity;
use crate::{
layout::{FixedSizeLayout, Layout},
properties::*,
render_object::{RenderObject, ImageRenderObject},
widgets::Template,
};
use crate::prelude::*;
widget!(
/// The `ImageWidget` widget is used to draw an image. It is not interactive.
......
use dces::prelude::Entity;
use crate::{
layout::{Layout, ScrollLayout},
properties::*,
widgets::Template,
};
use crate::prelude::*;
widget!(
/// The `ScrollViewer` defines a layout that is used to stack its children on the z-axis.
......
use dces::prelude::Entity;
use crate::{
layout::{Layout, StackLayout},
properties::*,
widgets::Template,
};
use crate::prelude::*;
widget!(
/// The `Stack` defines a layout that is used to stack its children on the z-axis.
......
use dces::prelude::Entity;
use crate::{
properties::*,
styling::colors,
widgets::{Container, Grid, Template, State, Context},
};
use crate::prelude::*;
/// State to handle the position of switch toggle.
#[derive(Default)]
......
use dces::prelude::Entity;
use crate::{
layout::{FixedSizeLayout, Layout},
properties::*,
render_object::{RenderObject, TextRenderObject},
styling::{colors, fonts},
widgets::Template,
};
use crate::prelude::*;
widget!(
/// The `TextBlock` widget is used to draw text. It is not interactive.
......
use dces::prelude::Entity;
use std::cell::Cell;
use crate::{
event::{Key, KeyDownHandler},
properties::*,
structs::*,
styling::{colors, fonts},
widgets::*,
};
use crate::prelude::*;
/// The `TextBoxState` handles the text processing of the `TextBox` widget.
#[derive(Default)]
......
use dces::prelude::Entity;
use crate::{
event::ClickHandler,
properties::*,
styling::{colors, fonts},
widgets::{Container, FontIconBlock, Stack, Template, TextBlock},
};
use crate::prelude::*;
widget!(
/// The `ToggleButton` widget can be clicked by user and could switch between selected / not selected.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment