mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-19 16:39:13 +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;
|
||||
notification_type = NotificationType::BedTemperaturesDiffer;
|
||||
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;
|
||||
};
|
||||
} 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);
|
||||
|
||||
@ -1197,7 +1197,12 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category)
|
||||
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*/)
|
||||
|
@ -398,7 +398,7 @@ public:
|
||||
void on_value_change(const std::string& opt_key, const boost::any& value);
|
||||
|
||||
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 apply_config_from_cache();
|
||||
|
||||
|
@ -731,11 +731,33 @@ void HighlighterForWx::init(std::pair<OG_CustomCtrl*, bool*> params)
|
||||
if (!Highlighter::init(!params.first && !params.second))
|
||||
return;
|
||||
|
||||
m_custom_ctrl = params.first;
|
||||
m_show_blink_ptr = params.second;
|
||||
assert(m_blinking_custom_ctrls.empty());
|
||||
m_blinking_custom_ctrls.push_back({params.first, params.second});
|
||||
|
||||
*m_show_blink_ptr = true;
|
||||
m_custom_ctrl->Refresh();
|
||||
BlinkingCustomCtrl &blinking_custom_ctrl = m_blinking_custom_ctrls.back();
|
||||
*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
|
||||
@ -753,13 +775,15 @@ void HighlighterForWx::invalidate()
|
||||
{
|
||||
Highlighter::invalidate();
|
||||
|
||||
if (m_custom_ctrl && m_show_blink_ptr) {
|
||||
*m_show_blink_ptr = false;
|
||||
m_custom_ctrl->Refresh();
|
||||
m_show_blink_ptr = nullptr;
|
||||
m_custom_ctrl = nullptr;
|
||||
if (!m_blinking_custom_ctrls.empty()) {
|
||||
for (BlinkingCustomCtrl &blinking_custom_ctrl : m_blinking_custom_ctrls) {
|
||||
assert(blinking_custom_ctrl.is_valid());
|
||||
*blinking_custom_ctrl.show_blink_ptr = false;
|
||||
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 = nullptr;
|
||||
}
|
||||
@ -767,14 +791,17 @@ void HighlighterForWx::invalidate()
|
||||
|
||||
void HighlighterForWx::blink()
|
||||
{
|
||||
if (m_custom_ctrl && m_show_blink_ptr) {
|
||||
*m_show_blink_ptr = !*m_show_blink_ptr;
|
||||
m_custom_ctrl->Refresh();
|
||||
if (!m_blinking_custom_ctrls.empty()) {
|
||||
for (BlinkingCustomCtrl &blinking_custom_ctrl : m_blinking_custom_ctrls) {
|
||||
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();
|
||||
else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
Highlighter::blink();
|
||||
}
|
||||
|
@ -283,12 +283,24 @@ public:
|
||||
|
||||
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:
|
||||
// - 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
|
||||
OG_CustomCtrl* m_custom_ctrl { nullptr };
|
||||
bool* m_show_blink_ptr { nullptr };
|
||||
BlinkingCustomCtrls m_blinking_custom_ctrls;
|
||||
|
||||
public:
|
||||
HighlighterForWx() {}
|
||||
@ -297,6 +309,7 @@ public:
|
||||
void bind_timer(wxWindow* owner) override;
|
||||
void init(BlinkingBitmap* blinking_bitmap);
|
||||
void init(std::pair<OG_CustomCtrl*, bool*>);
|
||||
void init(const std::vector<std::pair<OG_CustomCtrl *, bool *>> &blinking_custom_ctrls_params);
|
||||
void blink();
|
||||
void invalidate();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user