Skip to content

Commit

Permalink
add label/prop/del buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiqwerty committed Feb 9, 2024
1 parent 664a3c8 commit 10a797f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/rvlib/menu/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ macro_rules! handle_error {
pub struct ToolSelectMenu {
are_tools_active: bool, // can deactivate all tools, overrides activated_tool
recently_activated_tool: Option<usize>,
label_propagation_buffer: String,
label_deletion_buffer: String,
}
impl ToolSelectMenu {
fn new() -> Self {
Self {
are_tools_active: true,
recently_activated_tool: None,
label_propagation_buffer: "".to_string(),
label_deletion_buffer: "".to_string(),
}
}
pub fn recently_clicked_tool(&self) -> Option<usize> {
Expand All @@ -125,9 +129,14 @@ impl ToolSelectMenu {
});
for v in tools_menu_map.values_mut().filter(|v| v.menu_active) {
let tmp = match &mut v.specifics {
ToolSpecifics::Bbox(x) => {
bbox_menu(ui, v.menu_active, mem::take(x), &mut self.are_tools_active)
}
ToolSpecifics::Bbox(x) => bbox_menu(
ui,
v.menu_active,
mem::take(x),
&mut self.label_propagation_buffer,
&mut self.label_deletion_buffer,
&mut self.are_tools_active,
),
ToolSpecifics::Brush(x) => {
brush_menu(ui, v.menu_active, mem::take(x), &mut self.are_tools_active)
}
Expand Down
31 changes: 31 additions & 0 deletions src/rvlib/menu/tools_menus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,27 @@ fn toggle_erase(ui: &mut Ui, mut options: CoreOptions) -> CoreOptions {
}
options
}
fn triggerable_number(
ui: &mut Ui,
buffer: &mut String,
are_tools_active: &mut bool,
input: &mut Option<usize>,
name: &str,
) {
ui.horizontal(|ui| {
text_edit_singleline(ui, buffer, are_tools_active);

if ui.button(name).clicked() {
*input = buffer.parse::<usize>().ok();
}
});
}
pub fn bbox_menu(
ui: &mut Ui,
mut window_open: bool,
mut data: BboxSpecificData,
label_propagation_buffer: &mut String,
label_deletion_buffer: &mut String,
are_tools_active: &mut bool,
) -> RvResult<ToolsData> {
let LabelMenuResult {
Expand All @@ -224,6 +241,20 @@ pub fn bbox_menu(

let mut export_file_menu_result = Ok(());
egui::CollapsingHeader::new("advanced").show(ui, |ui| {
triggerable_number(
ui,
label_propagation_buffer,
are_tools_active,
&mut data.options.core_options.label_propagation,
"label propagation",
);
triggerable_number(
ui,
label_deletion_buffer,
are_tools_active,
&mut data.options.core_options.label_deletion,
"label deletion",
);
ui.checkbox(
&mut data.options.core_options.track_changes,
"track changes",
Expand Down
8 changes: 8 additions & 0 deletions src/rvlib/tools/bbox/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ fn check_cocoexport(mut world: World) -> World {
world
}

fn check_propagate_or_delete(mut world: World) -> World {
let options = get_options_mut(&mut world);
if let Some(n_prop) = options.and_then(|o| o.core_options.label_propagation) {}
let options = get_options_mut(&mut world);
if let Some(n_del) = options.and_then(|o| o.core_options.label_deletion) {}
world
}

fn check_cocoimport(mut world: World) -> World {
// import coco if demanded
let options = get_options(&world);
Expand Down
4 changes: 4 additions & 0 deletions src/rvlib/tools_data/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct Options {
pub is_history_update_triggered: bool,
pub track_changes: bool,
pub erase: bool,
pub label_propagation: Option<usize>,
pub label_deletion: Option<usize>,
}
impl Default for Options {
fn default() -> Self {
Expand All @@ -43,6 +45,8 @@ impl Default for Options {
is_history_update_triggered: false,
track_changes: false,
erase: false,
label_propagation: None,
label_deletion: None,
}
}
}
Expand Down

0 comments on commit 10a797f

Please # to comment.