Skip to content

Commit

Permalink
Better integrate watch/unwatch with the buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
rgiot committed Aug 17, 2023
1 parent d04b678 commit 1c33f6d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cpclib-visual-bndbuild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,13 @@ impl BndBuildApp {
for tgt in layer.iter() {
let rule = bnl.borrow_owner().get_rule(tgt);

let txt = RichText::new(tgt.display().to_string());
let txt = tgt.display().to_string();
let txt = if let Some(watched) = self.watched.as_ref() && watched == tgt {
format!("{txt} [watched]")
} else {
txt
};
let txt = RichText::new(txt);
// set in bold the default target to see it
let txt = if let Some(default) = &default && default == tgt {
txt.strong().strong()
Expand Down Expand Up @@ -495,8 +501,11 @@ impl BndBuildApp {
Color32::LIGHT_GREEN
};

// Create the button
let button = Button::new(txt).fill(color);

// finally add the button
let button = ui.add(Button::new(txt).fill(color));
let button = ui.add(button);
let button = if let Some(rule) = rule {
if let Some(help) = rule.help() {
button.on_hover_text(help)
Expand All @@ -516,7 +525,7 @@ impl BndBuildApp {
self.hovered_target = Some(tgt.into());
}
button.context_menu(|ui|{
if tgt.exists() && ui.button(&format!("Open {}", tgt.display())).clicked() {
if tgt.exists() && ui.button(&format!("Open \"{}\"", tgt.display())).clicked() {
match open::that(tgt) {
Ok(_) => {},
Err(e) => {
Expand All @@ -526,7 +535,7 @@ impl BndBuildApp {
ui.close_menu();
}

if self.watched.is_some() {
if let Some(watched) = self.watched.as_ref() && watched == tgt {
if ui.button("Unwatch").clicked() {
self.watched.take();
ui.close_menu();
Expand Down

0 comments on commit 1c33f6d

Please sign in to comment.