1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
use pax_lang::*;
use pax_lang::api::*;
use pax_std::primitives::{Frame, Group, Rectangle, Text, Image};
use pax_std::types::{Color, Fill, LinearGradient, StackerDirection};
use pax_std::components::{Stacker, Sidebar};
const ROUTE_COUNT : usize = 5;
//noinspection RsMainFunctionNotFound
#[derive(Pax)]
#[main]
// #[inlined(
// <Frame width=100% height=100% @key_press=modulate >
// if current_route == 2 {
// <Grids />
// }
// if current_route == 1 {
// <Fireworks />
// }
// if current_route == 0 {
// <Words />
// }
// if current_route == 3 {
// <Camera />
// }
// if current_route == 4 {
// <HelloRGB />
// }
// </Frame>
// )]
#[file("lib.pax")]
pub struct Example {
pub scroll_position: Property<f64>,
pub panels: Property<Vec<Panel>>,
pub sizes: Property<Vec<Option<Size>>>,
}
impl Example {
pub fn handle_container_scroll(&mut self, ctx: RuntimeContext, args: ArgsScroll) {
let mut scroll_position = *self.scroll_position.get();
scroll_position = scroll_position - args.delta_y;
scroll_position = scroll_position.min(0.0);
scroll_position = scroll_position.max(-4000.0);
self.scroll_position.set(scroll_position);
}
pub fn handle_container_key_down(&mut self, ctx: RuntimeContext, args: ArgsKeyDown) {
let mut scroll_position = *self.scroll_position.get();
if args.keyboard.key == "ArrowDown".to_string() || args.keyboard.key == "Down".to_string() {
scroll_position = scroll_position - 20.0;
scroll_position = scroll_position.min(0.0);
scroll_position = scroll_position.max(-4000.0);
}
if args.keyboard.key == "ArrowUp".to_string() || args.keyboard.key == "Up".to_string() {
scroll_position = scroll_position + 20.0;
scroll_position = scroll_position.min(0.0);
scroll_position = scroll_position.max(-4000.0);
}
if args.keyboard.key == "ArrowLeft".to_string() || args.keyboard.key == "Left".to_string() {
scroll_position = scroll_position + 1000.0;
scroll_position = scroll_position.min(0.0);
scroll_position = scroll_position.max(-4000.0);
}
if args.keyboard.key == "ArrowRight".to_string() || args.keyboard.key == "Right".to_string() {
scroll_position = scroll_position - 1000.0;
scroll_position = scroll_position.min(0.0);
scroll_position = scroll_position.max(-4000.0);
}
self.scroll_position.set(scroll_position);
}
pub fn handle_did_mount(&mut self, ctx: RuntimeContext) {
self.sizes.set(vec![
Some(Size::Percent(70.0.into())),
None
]);
// self.panels.set(vec![
// Panel{
// fill: Fill::LinearGradient(
// LinearGradient {
// start: (Size::Percent(0.0.into()),Size::Percent(0.0.into())),
// end: (Size::Percent(100.0.into()),Size::Percent(100.0.into())),
// stops: (
// Color::rgb(Numeric::from(1.0), Numeric::from(1.0), Numeric::from(0.0)),
// Color::rgb(Numeric::from(1.0), Numeric::from(0.0), Numeric::from(1.0))
// ),
// }
// )
// },
// Panel{
// fill: Fill::LinearGradient(
// LinearGradient {
// start: (Size::Percent(0.0.into()),Size::Percent(0.0.into())),
// end: (Size::Percent(100.0.into()),Size::Percent(100.0.into())),
// stops: (
// Color::rgb(Numeric::from(0.0), Numeric::from(1.0), Numeric::from(1.0)),
// Color::rgb(Numeric::from(0.0), Numeric::from(1.0), Numeric::from(0.0))
// ),
// }
// )
// },
// Panel{
// fill: Fill::LinearGradient(
// LinearGradient {
// start: (Size::Percent(0.0.into()),Size::Percent(0.0.into())),
// end: (Size::Percent(100.0.into()),Size::Percent(100.0.into())),
// stops: (
// Color::rgb(Numeric::from(1.0), Numeric::from(0.0), Numeric::from(0.0)),
// Color::rgb(Numeric::from(0.0), Numeric::from(1.0), Numeric::from(1.0))
// ),
// }
// )
// },
// Panel{
// fill: Fill::LinearGradient(
// LinearGradient {
// start: (Size::Percent(0.0.into()),Size::Percent(0.0.into())),
// end: (Size::Percent(100.0.into()),Size::Percent(100.0.into())),
// stops: (
// Color::rgb(Numeric::from(1.0), Numeric::from(0.0), Numeric::from(1.0)),
// Color::rgb(Numeric::from(0.0), Numeric::from(1.0), Numeric::from(0.0))
// ),
// }
// )
// },
// Panel{
// fill: Fill::LinearGradient(
// LinearGradient {
// start: (Size::Percent(0.0.into()),Size::Percent(0.0.into())),
// end: (Size::Percent(100.0.into()),Size::Percent(100.0.into())),
// stops: (
// Color::rgb(Numeric::from(0.0), Numeric::from(0.0), Numeric::from(1.0)),
// Color::rgb(Numeric::from(1.0), Numeric::from(1.0), Numeric::from(0.0))
// ),
// }
// )
// },
// ])
}
}
#[derive(Pax)]
#[custom(Imports)]
pub struct Panel {
pub fill: Fill,
}