pushrod/render/mod.rs
1// Pushrod Rendering Library
2// Core Rendering Module
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16use sdl2::pixels::Color;
17
18/// This is a type that defines two points: X and Y coordinates.
19pub type Points = Vec<i32>;
20
21/// Quick reference in `Points` `Vec` for X position.
22pub const POINT_X: usize = 0;
23
24/// Quick reference in `Points` `Vec` for Y position.
25pub const POINT_Y: usize = 1;
26
27/// This is a type that defines two size: width and height.
28pub type Size = Vec<u32>;
29
30/// Quick reference in `Size` `Vec` for width.
31pub const SIZE_WIDTH: usize = 0;
32
33/// Quick reference in `Size` `Vec` for height.
34pub const SIZE_HEIGHT: usize = 1;
35
36/// Convenience method to create a `Points` type.
37pub fn make_points(x: i32, y: i32) -> Points {
38 vec![x, y]
39}
40
41/// Convenience method to create a `Points` type at origin coordinates (0, 0)
42pub fn make_points_origin() -> Points {
43 vec![0, 0]
44}
45
46/// Convenience method to create a `Size` type.
47pub fn make_size(w: u32, h: u32) -> Size {
48 vec![w, h]
49}
50
51/// Calculates the inverse of a color.
52pub fn inverse_color(color: Color) -> Color {
53 Color::RGBA(255 - color.r, 255 - color.g, 255 - color.b, color.a)
54}
55
56/// This is a store used by `Widget`s for drawing against. Once the drawing is complete, the
57/// `Texture` stored within is used for blitting to the screen.
58pub mod texture_store;
59
60/// This is the `Engine` that is used to dispatch events from the screen to a corresponding list
61/// of `Widget`s in a `Window`. This is the main event loop.
62pub mod engine;
63
64/// This is the `CanvasHelper` trait that is used to help draw against a `Canvas`.
65pub mod canvas_helper;
66
67/// This is the `Callbacks` mechanism for each `Widget`, providing a way to perform a function when
68/// an action is intercepted (ie. mouse enter, exit, move, etc.)
69pub mod callbacks;
70
71/// This is the `Widget` and `BaseWidget` definitions for `Widget` objects to be defined by the
72/// `pushrod` project, and other crates that may define or create their own `Widget`s.
73pub mod widget;
74
75/// This is a configuration object that stores information about `Widget`s.
76pub mod widget_config;
77
78/// This is the caching object that stores a list of `Widget`s that the Pushrod engine manages.
79pub mod widget_cache;
80
81/// This is a layout manager description module, describing rules for `Layout` managers to be used
82/// in the system, and having `Widget`s added to them.
83pub mod layout;
84
85/// This is a caching object that stores a container of `Layout` objects, managed by the Pushrod
86/// engine.
87pub mod layout_cache;
88
89/// This is a caching object that stores Textures for fonts and images.
90pub mod texture_cache;