#![feature(proc_macro)]
extern crate gtk;
#[macro_use]
extern crate relm;
extern crate relm_attributes;
#[macro_use]
extern crate relm_derive;
use gtk::{
BoxExt,
ButtonExt,
Inhibit,
LabelExt,
OrientableExt,
WidgetExt,
};
use gtk::Orientation::{Horizontal, Vertical};
use relm::Widget;
use relm_attributes::widget;
use self::Msg::*;
#[widget]
impl Widget for MyFrame {
fn model() -> () {
}
fn update(&mut self, _msg: ()) {
}
view! {
#[container]
gtk::Frame {
}
}
}
#[widget]
impl Widget for CenterButton {
fn model() -> () {
}
fn update(&mut self, _msg: ()) {
}
view! {
#[parent="center"]
gtk::Button {
label: "-",
},
}
}
#[widget]
impl Widget for Button {
fn model() -> () {
}
fn update(&mut self, _msg: ()) {
}
view! {
#[parent="right"]
gtk::Button {
label: "+",
},
}
}
#[widget]
impl Widget for SplitBox {
fn model() -> () {
()
}
fn update(&mut self, _event: Msg) {
}
view! {
gtk::Box {
orientation: Horizontal,
#[container]
gtk::Box {
orientation: Vertical,
},
#[container="center"]
gtk::Frame {
},
#[container="right"]
MyFrame {
packing: {
padding: 10,
},
}
}
}
}
pub struct Model {
counter: i32,
}
#[derive(Msg)]
pub enum Msg {
Decrement,
Increment,
Quit,
}
#[widget]
impl Widget for Win {
fn model() -> Model {
Model {
counter: 0,
}
}
fn update(&mut self, event: Msg) {
match event {
Decrement => self.model.counter -= 1,
Increment => self.model.counter += 1,
Quit => gtk::main_quit(),
}
}
view! {
gtk::Window {
SplitBox {
gtk::Button {
clicked => Increment,
label: "+",
},
gtk::Label {
text: &self.model.counter.to_string(),
},
Button {
},
CenterButton {
},
gtk::Button {
clicked => Decrement,
label: "-",
},
},
delete_event(_, _) => (Quit, Inhibit(false)),
}
}
}
fn main() {
Win::run(()).unwrap();
}