mirror of
https://github.com/13hannes11/focus_annotator.git
synced 2024-09-03 23:21:01 +02:00
rename widgets and add comments to make code structure more easy to understand
This commit is contained in:
85
src/main.rs
85
src/main.rs
@@ -3,7 +3,8 @@ use gtk::prelude::*;
|
|||||||
|
|
||||||
use adw::{ApplicationWindow, HeaderBar, SplitButton};
|
use adw::{ApplicationWindow, HeaderBar, SplitButton};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
ActionBar, Adjustment, Application, Box, Button, Image, Orientation, Scale, ToggleButton,
|
ActionBar, Adjustment, Application, Box, Button, Image, Orientation, Scale, Separator,
|
||||||
|
ToggleButton,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MARGIN_TOP: i32 = 32;
|
const MARGIN_TOP: i32 = 32;
|
||||||
@@ -21,14 +22,11 @@ fn main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
application.connect_activate(|app| {
|
application.connect_activate(|app| {
|
||||||
let adjustment = Adjustment::builder()
|
//////////////////
|
||||||
.lower(0.0)
|
// MAIN CONTENT //
|
||||||
.upper(10.0)
|
//////////////////
|
||||||
.value(5.0)
|
|
||||||
.step_increment(1.0)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let image = Image::builder()
|
let focus_image = Image::builder()
|
||||||
.file("/var/home/hannes/Downloads/test/I12982_X022_Y029_Z5048.jpg")
|
.file("/var/home/hannes/Downloads/test/I12982_X022_Y029_Z5048.jpg")
|
||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.hexpand(true)
|
.hexpand(true)
|
||||||
@@ -38,16 +36,16 @@ fn main() {
|
|||||||
.margin_start(MARGIN_LEFT)
|
.margin_start(MARGIN_LEFT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let adjustment = Adjustment::builder()
|
let focus_scale_adjustment = Adjustment::builder()
|
||||||
.lower(0.0)
|
.lower(0.0)
|
||||||
.upper(10.0)
|
.upper(10.0)
|
||||||
.value(5.0)
|
.value(5.0)
|
||||||
.step_increment(1.0)
|
.step_increment(1.0)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let scale = Scale::builder()
|
let focus_scale = Scale::builder()
|
||||||
.orientation(Orientation::Vertical)
|
.orientation(Orientation::Vertical)
|
||||||
.adjustment(&adjustment)
|
.adjustment(&focus_scale_adjustment)
|
||||||
.vexpand(true)
|
.vexpand(true)
|
||||||
.margin_top(MARGIN_TOP)
|
.margin_top(MARGIN_TOP)
|
||||||
.margin_bottom(MARGIN_BOTTOM)
|
.margin_bottom(MARGIN_BOTTOM)
|
||||||
@@ -59,18 +57,18 @@ fn main() {
|
|||||||
.digits(0)
|
.digits(0)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let seperator = Separator::new(Orientation::Vertical);
|
let center_content_seperator = Separator::new(Orientation::Vertical);
|
||||||
let content = Box::builder()
|
let center_content = Box::builder()
|
||||||
//.hexpand(true)
|
//.hexpand(true)
|
||||||
.orientation(Orientation::Horizontal)
|
.orientation(Orientation::Horizontal)
|
||||||
.spacing(0)
|
.spacing(0)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
content.append(&scale);
|
center_content.append(&focus_scale);
|
||||||
content.append(&seperator);
|
center_content.append(¢er_content_seperator);
|
||||||
content.append(&image);
|
center_content.append(&focus_image);
|
||||||
|
|
||||||
scale.connect_value_changed(move |x| {
|
focus_scale.connect_value_changed(move |x| {
|
||||||
eprintln!("Changed value! {:?}", x.value());
|
eprintln!("Changed value! {:?}", x.value());
|
||||||
let path = if x.value() > 6.0 {
|
let path = if x.value() > 6.0 {
|
||||||
"/var/home/hannes/Downloads/test/I12982_X022_Y029_Z5048.jpg"
|
"/var/home/hannes/Downloads/test/I12982_X022_Y029_Z5048.jpg"
|
||||||
@@ -79,9 +77,13 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
"/var/home/hannes/Downloads/test/I12985_X022_Y029_Z5195.jpg"
|
"/var/home/hannes/Downloads/test/I12985_X022_Y029_Z5195.jpg"
|
||||||
};
|
};
|
||||||
image.set_from_file(Some(path));
|
focus_image.set_from_file(Some(path));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
////////////
|
||||||
|
// HEADER //
|
||||||
|
////////////
|
||||||
|
|
||||||
//let show_start_title_buttons = Button::new();
|
//let show_start_title_buttons = Button::new();
|
||||||
let header_bar = HeaderBar::builder()
|
let header_bar = HeaderBar::builder()
|
||||||
.title_widget(&adw::WindowTitle::new("First App", ""))
|
.title_widget(&adw::WindowTitle::new("First App", ""))
|
||||||
@@ -91,38 +93,47 @@ fn main() {
|
|||||||
let open_button = SplitButton::builder().label("Open").build();
|
let open_button = SplitButton::builder().label("Open").build();
|
||||||
header_bar.pack_start(&open_button);
|
header_bar.pack_start(&open_button);
|
||||||
|
|
||||||
// Combine the content in a box
|
////////////////////
|
||||||
let title_widget_content = Box::new(Orientation::Vertical, 0);
|
// BOTTOM TOOLBAR //
|
||||||
// Adwaitas' ApplicationWindow does not include a HeaderBar
|
///////////////////
|
||||||
|
|
||||||
/*let bottom_toolbar_widget = Box::builder()
|
let bottom_toolbar = ActionBar::builder().build();
|
||||||
.orientation(Orientation::Horizontal)
|
|
||||||
.css_classes(vec!["toolbox".to_string()])
|
|
||||||
.halign(gtk::Align::End)
|
|
||||||
//.margin_top(MARGIN_TOP / 2)
|
|
||||||
.margin_bottom(MARGIN_BOTTOM / 2)
|
|
||||||
.build();*/
|
|
||||||
|
|
||||||
let bottom_toolbar_widget = ActionBar::builder().build();
|
|
||||||
|
|
||||||
// TODO: add functionality
|
// TODO: add functionality
|
||||||
let focus_button = Button::builder().label("Set Focus").build();
|
let skip_button = Button::builder().label("Skip").build();
|
||||||
|
let focus_button = Button::builder()
|
||||||
|
.label("Set Focus")
|
||||||
|
.css_classes(vec!["suggested-action".to_string()])
|
||||||
|
.build();
|
||||||
|
let focus_skip_link_widget = Box::builder()
|
||||||
|
.css_classes(vec!["linked".to_string()])
|
||||||
|
.build();
|
||||||
|
focus_skip_link_widget.append(&skip_button);
|
||||||
|
focus_skip_link_widget.append(&focus_button);
|
||||||
|
|
||||||
let neighbour_toggle_button = ToggleButton::builder().label("Toggle Neighbours").build();
|
let neighbour_toggle_button = ToggleButton::builder().label("Toggle Neighbours").build();
|
||||||
|
|
||||||
bottom_toolbar_widget.pack_start(&neighbour_toggle_button);
|
bottom_toolbar.pack_start(&neighbour_toggle_button);
|
||||||
bottom_toolbar_widget.pack_end(&focus_button);
|
bottom_toolbar.pack_end(&focus_skip_link_widget);
|
||||||
|
|
||||||
title_widget_content.append(&header_bar);
|
//////////////////////
|
||||||
title_widget_content.append(&content);
|
// MAIN APPLICATION //
|
||||||
title_widget_content.append(&bottom_toolbar_widget);
|
//////////////////////
|
||||||
|
|
||||||
|
// Combine the content in a box
|
||||||
|
let application_vertical_widget = Box::new(Orientation::Vertical, 0);
|
||||||
|
// Adwaitas' ApplicationWindow does not include a HeaderBar
|
||||||
|
|
||||||
|
application_vertical_widget.append(&header_bar);
|
||||||
|
application_vertical_widget.append(¢er_content);
|
||||||
|
application_vertical_widget.append(&bottom_toolbar);
|
||||||
|
|
||||||
let window = ApplicationWindow::builder()
|
let window = ApplicationWindow::builder()
|
||||||
.application(app)
|
.application(app)
|
||||||
.default_width(800)
|
.default_width(800)
|
||||||
.default_height(600)
|
.default_height(600)
|
||||||
// add content to window
|
// add content to window
|
||||||
.content(&title_widget_content)
|
.content(&application_vertical_widget)
|
||||||
.build();
|
.build();
|
||||||
window.show();
|
window.show();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user