gdritter repos palladio / ab02ff5
Add right tileset toolbar Getty Ritter 6 years ago
1 changed file(s) with 62 addition(s) and 15 deletion(s). Collapse all Expand all
11 use gdk;
22 use gtk::{
33 self,
4 BoxExt,
5 EntryExt,
46 ContainerExt,
57 HeaderBarExt,
8 PanedExt,
69 WindowExt,
710 WidgetExt,
811 DialogExt,
1215 use std::cell::RefCell;
1316 use std::process;
1417 use std::rc::Rc;
15
16 pub struct App {
17 pub window: gtk::Window,
18 pub canvas: GridCanvas,
19 pub header: Header,
20 }
21
22 pub struct Header {
23 pub container: gtk::HeaderBar,
24 pub open_btn: gtk::Button,
25 pub save_btn: gtk::Button,
26 pub save_as_btn: gtk::Button,
27 }
2818
2919 pub struct GridCanvas {
3020 pub canvas: gtk::DrawingArea,
8171 }
8272 }
8373
74 pub struct App {
75 pub window: gtk::Window,
76 pub canvas: GridCanvas,
77 pub container: gtk::Paned,
78 pub toolbar: Toolbar,
79 pub header: Header,
80 }
81
8482 impl App {
8583 fn new() -> App {
8684 let window = gtk::Window::new(gtk::WindowType::Toplevel);
85 let container = gtk::Paned::new(gtk::Orientation::Horizontal);
8786 let header = Header::new();
8887 let canvas = GridCanvas::new();
8988
9190 window.set_titlebar(&header.container);
9291 window.set_title("Palladio");
9392 window.set_wmclass("palladio", "Palladio");
94 window.add(&canvas.canvas);
9593
9694 gtk::Window::set_default_icon_name("iconname");
9795
10098 gtk::Inhibit(false)
10199 });
102100
103 App { window, header, canvas }
101 let toolbar = Toolbar::new();
102 container.pack1(&canvas.canvas, true, true);
103 container.pack2(&toolbar.toolbar, false, true);
104 window.add(&container);
105
106 App { window, header, canvas, toolbar, container }
104107 }
105108
106109 pub fn run() {
113116 app.window.show_all();
114117 gtk::main();
115118 }
119 }
120
121 // HEADER
122
123 pub struct Header {
124 pub container: gtk::HeaderBar,
125 pub open_btn: gtk::Button,
126 pub save_btn: gtk::Button,
127 pub save_as_btn: gtk::Button,
116128 }
117129
118130 impl Header {
170182 save_dialog.destroy();
171183 }
172184 }
185
186
187 pub struct Toolbar {
188 toolbar: gtk::Box,
189 tile_width: gtk::Entry,
190 tile_height: gtk::Entry,
191 load_tileset_btn: gtk::Button,
192 }
193
194 impl Toolbar {
195 fn new() -> Toolbar {
196 let container = gtk::Box::new(gtk::Orientation::Vertical, 5);
197
198 let tile_label = gtk::Label::new("Tileset");
199
200 let tile_width = gtk::Entry::new();
201 tile_width.set_text("16");
202 let tile_height = gtk::Entry::new();
203 tile_height.set_text("16");
204
205 let load_tileset_btn = gtk::Button::new_with_label("Load Tileset Image");
206
207 container.pack_start(&tile_label, false, true, 0);
208 container.pack_start(&tile_width, false, true, 0);
209 container.pack_start(&tile_height, false, true, 0);
210 container.pack_start(&load_tileset_btn, false, true, 0);
211
212 Toolbar {
213 toolbar: container,
214 tile_width,
215 tile_height,
216 load_tileset_btn,
217 }
218 }
219 }