Color picker added, does not function yet

This commit is contained in:
Sebastian H. Gabrielli 2022-06-19 00:11:16 +02:00
parent ff1590e4b8
commit 02b218fddd
2 changed files with 62 additions and 1 deletions

45
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'keyboard_control_software'",
"cargo": {
"args": [
"build",
"--bin=keyboard_control_software",
"--package=keyboard_control_software"
],
"filter": {
"name": "keyboard_control_software",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'keyboard_control_software'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=keyboard_control_software",
"--package=keyboard_control_software"
],
"filter": {
"name": "keyboard_control_software",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

View File

@ -5,7 +5,7 @@ extern crate json;
use colored::Colorize; use colored::Colorize;
use std::path::Path; use std::path::Path;
use gtk::prelude::*; use gtk::{prelude::*, Window};
use gtk::{Application, ApplicationWindow, Button, ListBox}; use gtk::{Application, ApplicationWindow, Button, ListBox};
#[derive(Debug)] #[derive(Debug)]
@ -159,6 +159,22 @@ fn build_ui(app: &Application) {
.build(); .build();
button.connect_clicked(move |button| { button.connect_clicked(move |button| {
let color = gtk::ColorChooserDialog::builder()
.default_width(400)
.default_height(200)
.name("Color picker")
.visible(true)
.use_alpha(true)
.use_header_bar(1)
.hide_on_close(true)
.build();
color.display();
color.connect_color_activated(move |color, rgba| {
println!("The selected color is: {}", rgba);
});
println!("The label of the button is {}", button.label().unwrap()); println!("The label of the button is {}", button.label().unwrap());
}); });