mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-19 22:09:05 +08:00
SPE-2501: Add support for blinking arrow for more items on the same tab.
This commit is contained in:
parent
d7a0dfd8e4
commit
6b28de6634
@ -2138,7 +2138,7 @@ void Plater::priv::process_validation_warning(const std::vector<std::string>& wa
|
|||||||
multiline = true;
|
multiline = true;
|
||||||
notification_type = NotificationType::BedTemperaturesDiffer;
|
notification_type = NotificationType::BedTemperaturesDiffer;
|
||||||
action_fn = [](wxEvtHandler*) {
|
action_fn = [](wxEvtHandler*) {
|
||||||
GUI::wxGetApp().jump_to_option("bed_temperature_extruder", Preset::Type::TYPE_PRINT, boost::nowide::widen("Multiple Extruders"));
|
GUI::wxGetApp().get_tab(Preset::Type::TYPE_PRINT)->activate_option("bed_temperature_extruder", boost::nowide::widen("Multiple Extruders"), { "wipe_tower_extruder" });
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
} else if (text == "_FILAMENT_SHRINKAGE_DIFFER") {
|
} else if (text == "_FILAMENT_SHRINKAGE_DIFFER") {
|
||||||
|
@ -1149,7 +1149,7 @@ void Tab::update_wiping_button_visibility() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::activate_option(const std::string& opt_key, const wxString& category)
|
void Tab::activate_option(const std::string &opt_key, const wxString &category, const std::vector<std::string> &another_blinking_opt_keys)
|
||||||
{
|
{
|
||||||
wxString page_title = translate_category(category, m_type);
|
wxString page_title = translate_category(category, m_type);
|
||||||
|
|
||||||
@ -1197,7 +1197,12 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category)
|
|||||||
set_focus(field->getWindow());
|
set_focus(field->getWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_highlighter.init(get_custom_ctrl_with_blinking_ptr(opt_key));
|
std::vector<std::pair<OG_CustomCtrl *, bool *>> custom_blinking_ctrls = { get_custom_ctrl_with_blinking_ptr(opt_key) };
|
||||||
|
for (const std::string &another_blinking_opt_key : another_blinking_opt_keys) {
|
||||||
|
custom_blinking_ctrls.emplace_back(get_custom_ctrl_with_blinking_ptr(another_blinking_opt_key));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_highlighter.init(custom_blinking_ctrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::cache_config_diff(const std::vector<std::string>& selected_options, const DynamicPrintConfig* config/* = nullptr*/)
|
void Tab::cache_config_diff(const std::vector<std::string>& selected_options, const DynamicPrintConfig* config/* = nullptr*/)
|
||||||
|
@ -398,7 +398,7 @@ public:
|
|||||||
void on_value_change(const std::string& opt_key, const boost::any& value);
|
void on_value_change(const std::string& opt_key, const boost::any& value);
|
||||||
|
|
||||||
void update_wiping_button_visibility();
|
void update_wiping_button_visibility();
|
||||||
void activate_option(const std::string& opt_key, const wxString& category);
|
void activate_option(const std::string &opt_key, const wxString &category, const std::vector<std::string> &another_blinking_opt_keys = {});
|
||||||
void cache_config_diff(const std::vector<std::string>& selected_options, const DynamicPrintConfig* config = nullptr);
|
void cache_config_diff(const std::vector<std::string>& selected_options, const DynamicPrintConfig* config = nullptr);
|
||||||
void apply_config_from_cache();
|
void apply_config_from_cache();
|
||||||
|
|
||||||
|
@ -731,11 +731,33 @@ void HighlighterForWx::init(std::pair<OG_CustomCtrl*, bool*> params)
|
|||||||
if (!Highlighter::init(!params.first && !params.second))
|
if (!Highlighter::init(!params.first && !params.second))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_custom_ctrl = params.first;
|
assert(m_blinking_custom_ctrls.empty());
|
||||||
m_show_blink_ptr = params.second;
|
m_blinking_custom_ctrls.push_back({params.first, params.second});
|
||||||
|
|
||||||
*m_show_blink_ptr = true;
|
BlinkingCustomCtrl &blinking_custom_ctrl = m_blinking_custom_ctrls.back();
|
||||||
m_custom_ctrl->Refresh();
|
*blinking_custom_ctrl.show_blink_ptr = true;
|
||||||
|
blinking_custom_ctrl.custom_ctrl_ptr->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HighlighterForWx::init(const std::vector<std::pair<OG_CustomCtrl *, bool *>> &blinking_custom_ctrls_params)
|
||||||
|
{
|
||||||
|
this->invalidate();
|
||||||
|
|
||||||
|
const bool input_failed = blinking_custom_ctrls_params.empty() ||
|
||||||
|
std::any_of(blinking_custom_ctrls_params.cbegin(), blinking_custom_ctrls_params.cend(),
|
||||||
|
[](auto ¶ms) { return params.first == nullptr || params.second == nullptr; });
|
||||||
|
|
||||||
|
if (!Highlighter::init(input_failed))
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert(m_blinking_custom_ctrls.empty());
|
||||||
|
for (const std::pair<OG_CustomCtrl *, bool *> &blinking_custom_ctrl_params : blinking_custom_ctrls_params) {
|
||||||
|
m_blinking_custom_ctrls.push_back({blinking_custom_ctrl_params.first, blinking_custom_ctrl_params.second});
|
||||||
|
|
||||||
|
BlinkingCustomCtrl &blinking_custom_ctrl = m_blinking_custom_ctrls.back();
|
||||||
|
*blinking_custom_ctrl.show_blink_ptr = true;
|
||||||
|
blinking_custom_ctrl.custom_ctrl_ptr->Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - using a BlinkingBitmap. Change state of this bitmap
|
// - using a BlinkingBitmap. Change state of this bitmap
|
||||||
@ -753,13 +775,15 @@ void HighlighterForWx::invalidate()
|
|||||||
{
|
{
|
||||||
Highlighter::invalidate();
|
Highlighter::invalidate();
|
||||||
|
|
||||||
if (m_custom_ctrl && m_show_blink_ptr) {
|
if (!m_blinking_custom_ctrls.empty()) {
|
||||||
*m_show_blink_ptr = false;
|
for (BlinkingCustomCtrl &blinking_custom_ctrl : m_blinking_custom_ctrls) {
|
||||||
m_custom_ctrl->Refresh();
|
assert(blinking_custom_ctrl.is_valid());
|
||||||
m_show_blink_ptr = nullptr;
|
*blinking_custom_ctrl.show_blink_ptr = false;
|
||||||
m_custom_ctrl = nullptr;
|
blinking_custom_ctrl.custom_ctrl_ptr->Refresh();
|
||||||
}
|
}
|
||||||
else if (m_blinking_bitmap) {
|
|
||||||
|
m_blinking_custom_ctrls.clear();
|
||||||
|
} else if (m_blinking_bitmap) {
|
||||||
m_blinking_bitmap->invalidate();
|
m_blinking_bitmap->invalidate();
|
||||||
m_blinking_bitmap = nullptr;
|
m_blinking_bitmap = nullptr;
|
||||||
}
|
}
|
||||||
@ -767,14 +791,17 @@ void HighlighterForWx::invalidate()
|
|||||||
|
|
||||||
void HighlighterForWx::blink()
|
void HighlighterForWx::blink()
|
||||||
{
|
{
|
||||||
if (m_custom_ctrl && m_show_blink_ptr) {
|
if (!m_blinking_custom_ctrls.empty()) {
|
||||||
*m_show_blink_ptr = !*m_show_blink_ptr;
|
for (BlinkingCustomCtrl &blinking_custom_ctrl : m_blinking_custom_ctrls) {
|
||||||
m_custom_ctrl->Refresh();
|
assert(blinking_custom_ctrl.is_valid());
|
||||||
|
*blinking_custom_ctrl.show_blink_ptr = !*blinking_custom_ctrl.show_blink_ptr;
|
||||||
|
blinking_custom_ctrl.custom_ctrl_ptr->Refresh();
|
||||||
}
|
}
|
||||||
else if (m_blinking_bitmap)
|
} else if (m_blinking_bitmap) {
|
||||||
m_blinking_bitmap->blink();
|
m_blinking_bitmap->blink();
|
||||||
else
|
} else {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Highlighter::blink();
|
Highlighter::blink();
|
||||||
}
|
}
|
||||||
|
@ -283,12 +283,24 @@ public:
|
|||||||
|
|
||||||
class HighlighterForWx : public Highlighter
|
class HighlighterForWx : public Highlighter
|
||||||
{
|
{
|
||||||
|
struct BlinkingCustomCtrl
|
||||||
|
{
|
||||||
|
OG_CustomCtrl *custom_ctrl_ptr;
|
||||||
|
bool *show_blink_ptr;
|
||||||
|
|
||||||
|
bool is_valid() const
|
||||||
|
{
|
||||||
|
return custom_ctrl_ptr != nullptr && show_blink_ptr != nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using BlinkingCustomCtrls = std::vector<BlinkingCustomCtrl>;
|
||||||
|
|
||||||
// There are 2 possible cases to use HighlighterForWx:
|
// There are 2 possible cases to use HighlighterForWx:
|
||||||
// - using a BlinkingBitmap. Change state of this bitmap
|
// - using a BlinkingBitmap. Change state of this bitmap
|
||||||
BlinkingBitmap* m_blinking_bitmap { nullptr };
|
BlinkingBitmap *m_blinking_bitmap { nullptr };
|
||||||
// - using OG_CustomCtrl where arrow will be rendered and flag indicated "show/hide" state of this arrow
|
// - using OG_CustomCtrl where arrow will be rendered and flag indicated "show/hide" state of this arrow
|
||||||
OG_CustomCtrl* m_custom_ctrl { nullptr };
|
BlinkingCustomCtrls m_blinking_custom_ctrls;
|
||||||
bool* m_show_blink_ptr { nullptr };
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HighlighterForWx() {}
|
HighlighterForWx() {}
|
||||||
@ -297,6 +309,7 @@ public:
|
|||||||
void bind_timer(wxWindow* owner) override;
|
void bind_timer(wxWindow* owner) override;
|
||||||
void init(BlinkingBitmap* blinking_bitmap);
|
void init(BlinkingBitmap* blinking_bitmap);
|
||||||
void init(std::pair<OG_CustomCtrl*, bool*>);
|
void init(std::pair<OG_CustomCtrl*, bool*>);
|
||||||
|
void init(const std::vector<std::pair<OG_CustomCtrl *, bool *>> &blinking_custom_ctrls_params);
|
||||||
void blink();
|
void blink();
|
||||||
void invalidate();
|
void invalidate();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user