1extern crate pushrod;
2extern crate sdl2;
3
4use pushrod::render::engine::Engine;
5use pushrod::render::widget::Widget;
6use pushrod::render::widget_config::{
7 CONFIG_BORDER_WIDTH, CONFIG_COLOR_BASE, CONFIG_COLOR_BORDER, CONFIG_COLOR_HOVER,
8 CONFIG_COLOR_SECONDARY,
9};
10use pushrod::render::{make_points, make_size};
11use pushrod::widgets::list_widget::*;
12use pushrod::widgets::tab_bar_widget::TabBarWidget;
13use sdl2::pixels::Color;
14
15pub fn main() {
16 let sdl_context = sdl2::init().unwrap();
17 let video_subsystem = sdl_context.video().unwrap();
18 let window = video_subsystem
19 .window("pushrod-render tab bar demo", 400, 300)
20 .position_centered()
21 .opengl()
22 .build()
23 .unwrap();
24 let mut engine = Engine::new(400, 300, 60);
25 let mut widget1 = TabBarWidget::new(
26 make_points(20, 20),
27 make_size(360, 30),
28 vec![
29 String::from("First"),
30 String::from("Second"),
31 String::from("Third"),
32 ],
33 );
34
35 widget1.set_color(CONFIG_COLOR_BASE, Color::RGB(255, 255, 255));
36 widget1.set_color(CONFIG_COLOR_HOVER, Color::RGB(192, 192, 255));
37 widget1.on_tab_selected(|_, _, _, selected_tab| {
38 eprintln!("Selected tab: {}", selected_tab);
39 });
40
41 engine.add_widget(Box::new(widget1), String::from("widget1"));
42
43 engine.run(sdl_context, window);
44}