simplify enabled ui for if function is some
This commit is contained in:
parent
a224ae7497
commit
be86d5191e
@ -117,10 +117,11 @@ impl FunctionManager {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// If not fully open, return here as buttons cannot yet be displayed, therefore the user is inable to mark it for deletion
|
// If not fully open, return here as buttons cannot yet be displayed, therefore the user is inable to mark it for deletion
|
||||||
if ui.ctx().animate_bool(*te_id, re.has_focus()) >= 1.0 {
|
if ui.ctx().animate_bool(*te_id, re.has_focus()) == 1.0 {
|
||||||
function.autocomplete.update_string(&new_string);
|
function.autocomplete.update_string(&new_string);
|
||||||
|
|
||||||
if function.autocomplete.hint.is_some() {
|
if function.autocomplete.hint.is_some() {
|
||||||
|
// only register up and down arrow movements if hint is type `Hint::Many`
|
||||||
if !function.autocomplete.hint.is_single() {
|
if !function.autocomplete.hint.is_single() {
|
||||||
if ui.input().key_pressed(Key::ArrowDown) {
|
if ui.input().key_pressed(Key::ArrowDown) {
|
||||||
movement = Movement::Down;
|
movement = Movement::Down;
|
||||||
@ -136,6 +137,7 @@ impl FunctionManager {
|
|||||||
movement = Movement::Complete;
|
movement = Movement::Complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register movement and apply proper changes
|
||||||
function.autocomplete.register_movement(&movement);
|
function.autocomplete.register_movement(&movement);
|
||||||
|
|
||||||
if movement != Movement::Complete && let Some(hints) = function.autocomplete.hint.many() {
|
if movement != Movement::Complete && let Some(hints) = function.autocomplete.hint.many() {
|
||||||
@ -192,35 +194,37 @@ impl FunctionManager {
|
|||||||
remove_i = Some(i);
|
remove_i = Some(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
let func_some = function.is_some();
|
ui.add_enabled_ui(function.is_some(), |ui| {
|
||||||
// Toggle integral being enabled or not
|
// Toggle integral being enabled or not
|
||||||
function.integral.bitxor_assign(
|
function.integral.bitxor_assign(
|
||||||
ui.add_enabled(func_some, button_area_button("∫"))
|
ui.add(button_area_button("∫"))
|
||||||
.on_hover_text(match function.integral {
|
.on_hover_text(match function.integral {
|
||||||
true => "Don't integrate",
|
true => "Don't integrate",
|
||||||
false => "Integrate",
|
false => "Integrate",
|
||||||
})
|
})
|
||||||
.clicked(),
|
.clicked(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Toggle showing the derivative (even though it's already calculated this option just toggles if it's displayed or not)
|
// Toggle showing the derivative (even though it's already calculated this option just toggles if it's displayed or not)
|
||||||
function.derivative.bitxor_assign(
|
function.derivative.bitxor_assign(
|
||||||
ui.add_enabled(func_some, button_area_button("d/dx"))
|
ui.add(button_area_button("d/dx"))
|
||||||
.on_hover_text(match function.derivative {
|
.on_hover_text(match function.derivative {
|
||||||
true => "Don't Differentiate",
|
true => "Don't Differentiate",
|
||||||
false => "Differentiate",
|
false => "Differentiate",
|
||||||
})
|
})
|
||||||
.clicked(),
|
.clicked(),
|
||||||
);
|
);
|
||||||
|
|
||||||
function.settings_opened.bitxor_assign(
|
// Toggle showing the settings window
|
||||||
ui.add_enabled(func_some, button_area_button("⚙"))
|
function.settings_opened.bitxor_assign(
|
||||||
.on_hover_text(match function.settings_opened {
|
ui.add(button_area_button("⚙"))
|
||||||
true => "Close Settings",
|
.on_hover_text(match function.settings_opened {
|
||||||
false => "Open Settings",
|
true => "Close Settings",
|
||||||
})
|
false => "Open Settings",
|
||||||
.clicked(),
|
})
|
||||||
);
|
.clicked(),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user