mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-10 05:52:44 +00:00
Increase selecting color shortcut
This commit is contained in:
@@ -434,7 +434,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
|
||||
m_selected_extruder_idx = extruder_idx;
|
||||
}
|
||||
|
||||
if (extruder_idx < 16 && ImGui::IsItemHovered()) m_imgui->tooltip(_L("Shortcut Key ") + std::to_string(extruder_idx + 1), max_tooltip_width);
|
||||
if (extruder_idx < int(GLGizmoMmuSegmentation::EXTRUDERS_LIMIT) && ImGui::IsItemHovered())
|
||||
m_imgui->tooltip(_L("Shortcut Key ") + std::to_string(extruder_idx + 1), max_tooltip_width);
|
||||
}
|
||||
// ORCA: Remap filaments section (Border only, Title in border).
|
||||
// Styled as a panel for visual grouping.
|
||||
|
||||
@@ -998,16 +998,42 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
||||
keyCode = keyCode- WXK_NUMPAD0+'0';
|
||||
}
|
||||
if (keyCode >= '0' && keyCode <= '9') {
|
||||
if (keyCode == '1' && !m_timer_set_color.IsRunning()) {
|
||||
m_timer_set_color.StartOnce(500);
|
||||
processed = true;
|
||||
}
|
||||
else if (keyCode < '7' && m_timer_set_color.IsRunning()) {
|
||||
processed = mmu_seg->on_number_key_down(keyCode - '0'+10);
|
||||
m_timer_set_color.Stop();
|
||||
}
|
||||
else {
|
||||
processed = mmu_seg->on_number_key_down(keyCode - '0');
|
||||
const int digit = keyCode - '0';
|
||||
const int shortcut_max = int(GLGizmoMmuSegmentation::EXTRUDERS_LIMIT);
|
||||
auto select_shortcut = [mmu_seg](int number) {
|
||||
return number > 0 && mmu_seg->on_number_key_down(number);
|
||||
};
|
||||
|
||||
if (m_timer_set_color.IsRunning() && m_pending_color_shortcut_tens > 0) {
|
||||
const int two_digit_shortcut = m_pending_color_shortcut_tens * 10 + digit;
|
||||
if (two_digit_shortcut <= shortcut_max) {
|
||||
processed = select_shortcut(two_digit_shortcut);
|
||||
m_pending_color_shortcut_tens = 0;
|
||||
m_timer_set_color.Stop();
|
||||
} else {
|
||||
// Fall back to the pending single-digit shortcut and then process current digit as fresh input.
|
||||
processed = select_shortcut(m_pending_color_shortcut_tens);
|
||||
m_pending_color_shortcut_tens = 0;
|
||||
m_timer_set_color.Stop();
|
||||
|
||||
const bool can_start_two_digit = digit > 0 && digit * 10 <= shortcut_max;
|
||||
if (can_start_two_digit) {
|
||||
m_pending_color_shortcut_tens = digit;
|
||||
m_timer_set_color.StartOnce(500);
|
||||
processed = true;
|
||||
} else {
|
||||
processed = select_shortcut(digit) || processed;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const bool can_start_two_digit = digit > 0 && digit * 10 <= shortcut_max;
|
||||
if (can_start_two_digit) {
|
||||
m_pending_color_shortcut_tens = digit;
|
||||
m_timer_set_color.StartOnce(500);
|
||||
processed = true;
|
||||
} else {
|
||||
processed = select_shortcut(digit);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (keyCode == 'F' || keyCode == 'T' || keyCode == 'S' || keyCode == 'C' || keyCode == 'H' || keyCode == 'G') {
|
||||
@@ -1054,11 +1080,14 @@ bool GLGizmosManager::on_key(wxKeyEvent& evt)
|
||||
|
||||
void GLGizmosManager::on_set_color_timer(wxTimerEvent& evt)
|
||||
{
|
||||
if (m_current == MmSegmentation) {
|
||||
if (m_current == MmSegmentation && m_pending_color_shortcut_tens > 0) {
|
||||
GLGizmoMmuSegmentation* mmu_seg = dynamic_cast<GLGizmoMmuSegmentation*>(get_current());
|
||||
mmu_seg->on_number_key_down(1);
|
||||
m_parent.set_as_dirty();
|
||||
if (mmu_seg != nullptr) {
|
||||
mmu_seg->on_number_key_down(m_pending_color_shortcut_tens);
|
||||
m_parent.set_as_dirty();
|
||||
}
|
||||
}
|
||||
m_pending_color_shortcut_tens = 0;
|
||||
}
|
||||
|
||||
void GLGizmosManager::update_after_undo_redo(const UndoRedo::Snapshot& snapshot)
|
||||
|
||||
@@ -144,6 +144,7 @@ private:
|
||||
|
||||
//When there are more than 9 colors, shortcut key coloring
|
||||
wxTimer m_timer_set_color;
|
||||
int m_pending_color_shortcut_tens = 0;
|
||||
void on_set_color_timer(wxTimerEvent& evt);
|
||||
|
||||
// key MENU_ICON_NAME, value = ImtextureID
|
||||
|
||||
Reference in New Issue
Block a user