added color widget (difference to the color button, is thats its not hidden behind a button so you can always see it. (#38)
This commit is contained in:
parent
5f3e16e70c
commit
4ddbea7194
1 changed files with 23 additions and 0 deletions
|
@ -22,6 +22,7 @@ pub(super) fn widget_to_gtk_widget(bargs: &mut BuilderArgs) -> Result<Option<gtk
|
||||||
"calendar" => build_gtk_calendar(bargs)?.upcast(),
|
"calendar" => build_gtk_calendar(bargs)?.upcast(),
|
||||||
"color-button" => build_gtk_color_button(bargs)?.upcast(),
|
"color-button" => build_gtk_color_button(bargs)?.upcast(),
|
||||||
"expander" => build_gtk_expander(bargs)?.upcast(),
|
"expander" => build_gtk_expander(bargs)?.upcast(),
|
||||||
|
"color-chooser" => build_gtk_color_chooser(bargs)?.upcast(),
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
};
|
};
|
||||||
Ok(Some(gtk_widget))
|
Ok(Some(gtk_widget))
|
||||||
|
@ -178,6 +179,28 @@ fn build_gtk_color_button(bargs: &mut BuilderArgs) -> Result<gtk::ColorButton> {
|
||||||
Ok(gtk_widget)
|
Ok(gtk_widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @widget color-chooser
|
||||||
|
fn build_gtk_color_chooser(bargs: &mut BuilderArgs) -> Result<gtk::ColorChooserWidget> {
|
||||||
|
let gtk_widget = gtk::ColorChooserWidget::new();
|
||||||
|
let on_change_handler_id: Rc<RefCell<Option<glib::SignalHandlerId>>> = Rc::new(RefCell::new(None));
|
||||||
|
resolve_block!(bargs, gtk_widget, {
|
||||||
|
// @prop use-alpha - bool to wether or not use alpha
|
||||||
|
prop(use_alpha: as_bool) {gtk_widget.set_use_alpha(use_alpha);},
|
||||||
|
|
||||||
|
// @prop onchange - runs the code when the color was selected
|
||||||
|
prop(onchange: as_string) {
|
||||||
|
let old_id = on_change_handler_id.replace(Some(
|
||||||
|
gtk_widget.connect_color_activated(move |_a, gtk_widget| {
|
||||||
|
run_command(&onchange, gtk_widget);
|
||||||
|
})
|
||||||
|
));
|
||||||
|
old_id.map(|id| gtk_widget.disconnect(id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(gtk_widget)
|
||||||
|
}
|
||||||
|
|
||||||
/// @widget scale extends range
|
/// @widget scale extends range
|
||||||
/// @desc a slider.
|
/// @desc a slider.
|
||||||
fn build_gtk_scale(bargs: &mut BuilderArgs) -> Result<gtk::Scale> {
|
fn build_gtk_scale(bargs: &mut BuilderArgs) -> Result<gtk::Scale> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue