Implemented blinking icon to highlight a searched field
This commit is contained in:
parent
2317437ede
commit
752083cbe6
@ -57,6 +57,9 @@ void Field::PostInitialize()
|
|||||||
m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_initial_value(); }));
|
m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_initial_value(); }));
|
||||||
m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); }));
|
m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); }));
|
||||||
|
|
||||||
|
m_attention_bmp = ScalableBitmap(m_parent, "error_tick_f");
|
||||||
|
m_find_image = new wxStaticBitmap(m_parent, wxID_ANY, wxNullBitmap, wxDefaultPosition, m_attention_bmp.bmp().GetSize());
|
||||||
|
|
||||||
switch (m_opt.type)
|
switch (m_opt.type)
|
||||||
{
|
{
|
||||||
case coPercents:
|
case coPercents:
|
||||||
|
@ -191,6 +191,19 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void invalidate_attention_bmp() const {
|
||||||
|
m_find_image->SetBitmap(wxNullBitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void activate_attention_bmp() const {
|
||||||
|
m_find_image->SetBitmap(m_attention_bmp.bmp());
|
||||||
|
}
|
||||||
|
|
||||||
|
void blink_attention_bmp() const {
|
||||||
|
bool is_shown = m_find_image->IsShown();
|
||||||
|
m_find_image->Show(!is_shown);
|
||||||
|
}
|
||||||
|
|
||||||
bool set_label_colour_force(const wxColour *clr) {
|
bool set_label_colour_force(const wxColour *clr) {
|
||||||
if (m_Label == nullptr) return false;
|
if (m_Label == nullptr) return false;
|
||||||
m_Label->SetForegroundColour(*clr);
|
m_Label->SetForegroundColour(*clr);
|
||||||
@ -240,6 +253,9 @@ protected:
|
|||||||
const ScalableBitmap* m_undo_to_sys_bitmap = nullptr;
|
const ScalableBitmap* m_undo_to_sys_bitmap = nullptr;
|
||||||
const wxString* m_undo_to_sys_tooltip = nullptr;
|
const wxString* m_undo_to_sys_tooltip = nullptr;
|
||||||
|
|
||||||
|
ScalableBitmap m_attention_bmp;
|
||||||
|
wxStaticBitmap* m_find_image{ nullptr };
|
||||||
|
|
||||||
wxStaticText* m_Label = nullptr;
|
wxStaticText* m_Label = nullptr;
|
||||||
// Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one.
|
// Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one.
|
||||||
const wxColour* m_label_color = nullptr;
|
const wxColour* m_label_color = nullptr;
|
||||||
|
@ -110,6 +110,7 @@ void OptionsGroup::add_undo_buttuns_to_sizer(wxSizer* sizer, const t_field& fiel
|
|||||||
|
|
||||||
sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL);
|
sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL);
|
sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
sizer->Add(field->m_find_image, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = nullptr*/) {
|
void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = nullptr*/) {
|
||||||
|
@ -195,23 +195,6 @@ public:
|
|||||||
sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
|
sizer->Add(m_grid_sizer, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
|
||||||
#endif /* __WXGTK__ */
|
#endif /* __WXGTK__ */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (stb)
|
|
||||||
stb->Bind(wxEVT_PAINT, [this](wxPaintEvent& evt) {
|
|
||||||
evt.Skip();
|
|
||||||
const wxSize sz = stb->GetSize();
|
|
||||||
wxPaintDC dc(stb);
|
|
||||||
const wxPen pen = wxPen(wxColour(250, 10, 10), 2, wxPENSTYLE_SOLID);
|
|
||||||
dc.SetPen(pen);
|
|
||||||
dc.SetBrush(wxBrush(wxColour(250, 0, 0), wxBRUSHSTYLE_SOLID));
|
|
||||||
dc.DrawRectangle(25, 25, sz.x - 25, sz.y - 25);
|
|
||||||
/*
|
|
||||||
HDC hdc = GetHdcOf(dc);
|
|
||||||
RECT dim = { 5, 5, sz.x - 5, sz.y - 5 };
|
|
||||||
::FillRect(hdc, &dim, GetHbrushOf(wxBrush(wxColour( 0, 250,0), wxBRUSHSTYLE_SOLID)));
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGridSizer* get_grid_sizer() { return m_grid_sizer; }
|
wxGridSizer* get_grid_sizer() { return m_grid_sizer; }
|
||||||
|
@ -69,6 +69,13 @@ Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) :
|
|||||||
page->layout_valid = false;
|
page->layout_valid = false;
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this->m_highlighting_timer.SetOwner(this, 0);
|
||||||
|
this->Bind(wxEVT_TIMER, [this](wxTimerEvent&)
|
||||||
|
{
|
||||||
|
if (!m_highlighter.blink())
|
||||||
|
m_highlighting_timer.Stop();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab::set_type()
|
void Tab::set_type()
|
||||||
@ -992,8 +999,11 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category)
|
|||||||
tap_panel->SetSelection(page_id);
|
tap_panel->SetSelection(page_id);
|
||||||
|
|
||||||
// focused selected field
|
// focused selected field
|
||||||
if (field)
|
if (field) {
|
||||||
field->getWindow()->SetFocus();
|
field->getWindow()->SetFocus();
|
||||||
|
m_highlighting_timer.Start(500, false);
|
||||||
|
m_highlighter.init(field);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,6 +224,34 @@ protected:
|
|||||||
bool m_completed { false };
|
bool m_completed { false };
|
||||||
ConfigOptionMode m_mode = comExpert; // to correct first Tab update_visibility() set mode to Expert
|
ConfigOptionMode m_mode = comExpert; // to correct first Tab update_visibility() set mode to Expert
|
||||||
|
|
||||||
|
wxTimer m_highlighting_timer;
|
||||||
|
struct {
|
||||||
|
Field* field {nullptr};
|
||||||
|
int blink_counter {0};
|
||||||
|
|
||||||
|
void init(Field* f)
|
||||||
|
{
|
||||||
|
field = f;
|
||||||
|
field->activate_attention_bmp();
|
||||||
|
}
|
||||||
|
|
||||||
|
void invalidate()
|
||||||
|
{
|
||||||
|
field->invalidate_attention_bmp();
|
||||||
|
field = nullptr;
|
||||||
|
blink_counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool blink()
|
||||||
|
{
|
||||||
|
field->blink_attention_bmp();
|
||||||
|
if ((++blink_counter) == 5)
|
||||||
|
invalidate();
|
||||||
|
|
||||||
|
return blink_counter != 0;
|
||||||
|
}
|
||||||
|
} m_highlighter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PresetBundle* m_preset_bundle;
|
PresetBundle* m_preset_bundle;
|
||||||
bool m_show_btn_incompatible_presets = false;
|
bool m_show_btn_incompatible_presets = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user