ENH:add tooltip for search item
JIRA: STUDIO-6459 Signed-off-by: Kunlong Ma <kunlong.ma@bambulab.com> Change-Id: I7602a32159d21de8f37ea0208dd6a9f59b90dcce
This commit is contained in:
parent
5841dc041c
commit
e1cca42a42
|
@ -1512,10 +1512,10 @@ void ObjectDataViewModel::assembly_name(ObjectDataViewModelNode* item, wxString
|
|||
auto type = this->GetItemType(wxDataViewItem(item));
|
||||
if (type != itPlate) {
|
||||
wxString str = name + ":" + item->GetName();
|
||||
assembly_name_list.push_back(std::make_pair(item, str));
|
||||
assembly_name_list.push_back(std::make_tuple(item, str, str));
|
||||
}
|
||||
else {
|
||||
assembly_name_list.push_back(std::make_pair(item, name));
|
||||
assembly_name_list.push_back(std::make_tuple(item, name, name));
|
||||
}
|
||||
for (size_t i = 0; i < item->GetChildCount(); ++i) {
|
||||
wxString str_name = name + ":" + item->GetName();
|
||||
|
@ -1535,8 +1535,8 @@ void ObjectDataViewModel::search_object(wxString search_text)
|
|||
search_found_list.clear();
|
||||
search_text = search_text.MakeLower();
|
||||
|
||||
for (const auto& pair : assembly_name_list) {
|
||||
wxString sub_str = pair.second;
|
||||
for (const auto& [model_node, name, tip] : assembly_name_list) {
|
||||
wxString sub_str = name;
|
||||
sub_str = sub_str.MakeLower();
|
||||
|
||||
wxString new_str = "";
|
||||
|
@ -1544,18 +1544,18 @@ void ObjectDataViewModel::search_object(wxString search_text)
|
|||
size_t curr_str_len = 0;
|
||||
size_t pos = sub_str.find(search_text);
|
||||
while (pos != wxString::npos) {
|
||||
wxString new_search_str = "<b>" + pair.second.Mid(curr_str_len + pos, search_text_len) + "</b>";
|
||||
new_str += pair.second.Mid(curr_str_len, pos) + new_search_str;
|
||||
wxString new_search_str = "<b>" + name.Mid(curr_str_len + pos, search_text_len) + "</b>";
|
||||
new_str += name.Mid(curr_str_len, pos) + new_search_str;
|
||||
curr_str_len += search_text_len + pos;
|
||||
sub_str = sub_str.substr(pos + 1);
|
||||
sub_str = sub_str.substr(pos + search_text_len);
|
||||
pos = sub_str.find(search_text);
|
||||
}
|
||||
|
||||
if (curr_str_len > 0 && curr_str_len < pair.second.length()) {
|
||||
new_str += pair.second.substr(curr_str_len);
|
||||
if (curr_str_len > 0 && curr_str_len < name.length()) {
|
||||
new_str += name.substr(curr_str_len);
|
||||
}
|
||||
if (!new_str.empty())
|
||||
search_found_list.push_back(std::make_pair(pair.first, new_str));
|
||||
search_found_list.push_back(std::tuple(model_node, new_str, tip));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,8 +332,8 @@ class ObjectDataViewModel :public wxDataViewModel
|
|||
ObjectDataViewModelNode* m_plate_outside;
|
||||
|
||||
wxDataViewCtrl* m_ctrl { nullptr };
|
||||
std::vector<std::pair<ObjectDataViewModelNode*, wxString>> assembly_name_list;
|
||||
std::vector<std::pair<ObjectDataViewModelNode*, wxString>> search_found_list;
|
||||
std::vector<std::tuple<ObjectDataViewModelNode*, wxString, wxString>> assembly_name_list;
|
||||
std::vector<std::tuple<ObjectDataViewModelNode*, wxString, wxString>> search_found_list;
|
||||
std::map<int, int> m_ui_and_3d_volume_map;
|
||||
|
||||
public:
|
||||
|
@ -509,9 +509,9 @@ public:
|
|||
|
||||
void assembly_name(ObjectDataViewModelNode* item, wxString name);
|
||||
void assembly_name();
|
||||
std::vector<std::pair<ObjectDataViewModelNode*, wxString>> get_assembly_name_list() { return assembly_name_list; }
|
||||
std::vector<std::tuple<ObjectDataViewModelNode*, wxString, wxString>> get_assembly_name_list() const { return assembly_name_list; }
|
||||
void search_object(wxString search_text);
|
||||
std::vector<std::pair<ObjectDataViewModelNode*, wxString>> get_found_list() { return search_found_list; }
|
||||
std::vector<std::tuple<ObjectDataViewModelNode*, wxString, wxString>> get_found_list() const { return search_found_list; }
|
||||
|
||||
void sys_color_changed();
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ void OptionsSearcher::add_key(const std::string &opt_key, Preset::Type type, con
|
|||
// SearchItem
|
||||
//------------------------------------------
|
||||
|
||||
SearchItem::SearchItem(wxWindow *parent, wxString text, int index, SearchDialog* sdialog, SearchObjectDialog* search_dialog)
|
||||
SearchItem::SearchItem(wxWindow *parent, wxString text, int index, SearchDialog* sdialog, SearchObjectDialog* search_dialog, wxString tooltip)
|
||||
: wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(parent->GetSize().GetWidth(), 3 * GUI::wxGetApp().em_unit()))
|
||||
{
|
||||
m_sdialog = sdialog;
|
||||
|
@ -403,6 +403,8 @@ SearchItem::SearchItem(wxWindow *parent, wxString text, int index, SearchDialog*
|
|||
m_text = text;
|
||||
m_index = index;
|
||||
|
||||
this->SetToolTip(tooltip);
|
||||
|
||||
SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#FFFFFF")));
|
||||
Bind(wxEVT_ENTER_WINDOW, &SearchItem::on_mouse_enter, this);
|
||||
Bind(wxEVT_LEAVE_WINDOW, &SearchItem::on_mouse_leave, this);
|
||||
|
@ -997,13 +999,11 @@ void SearchObjectDialog::update_list()
|
|||
m_listPanel->SetBackgroundColour(StateColor::darkModeColorFor(m_bg_color));
|
||||
m_listPanel->SetSize(wxSize(m_scrolledWindow->GetSize().GetWidth(), -1));
|
||||
|
||||
const std::vector<std::pair<GUI::ObjectDataViewModelNode*, wxString>>& found = m_object_list->GetModel()->get_found_list();
|
||||
const std::vector<std::tuple<GUI::ObjectDataViewModelNode*, wxString, wxString>>& found = m_object_list->GetModel()->get_found_list();
|
||||
auto index = 0;
|
||||
for (const auto& item : found) {
|
||||
GUI::ObjectDataViewModelNode* data_item = item.first;
|
||||
wxString data_str = item.second;
|
||||
auto tmp = new SearchItem(m_listPanel, data_str, index, nullptr, this);
|
||||
tmp->m_item = data_item;
|
||||
for (const auto& [model_node, name, tip] : found) {
|
||||
auto tmp = new SearchItem(m_listPanel, name, index, nullptr, this, tip);
|
||||
tmp->m_item = model_node;
|
||||
m_listsizer->Add(tmp, 0, wxEXPAND, 0);
|
||||
index++;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public:
|
|||
SearchObjectDialog* m_search_object_dialog{ nullptr };
|
||||
GUI::ObjectDataViewModelNode* m_item{ nullptr };
|
||||
|
||||
SearchItem(wxWindow *parent, wxString text, int index, SearchDialog *sdialog = nullptr, SearchObjectDialog* search_dialog = nullptr);
|
||||
SearchItem(wxWindow *parent, wxString text, int index, SearchDialog *sdialog = nullptr, SearchObjectDialog* search_dialog = nullptr, wxString tooltip = "");
|
||||
~SearchItem(){};
|
||||
|
||||
wxSize DrawTextString(wxDC &dc, const wxString &text, const wxPoint &pt, bool bold);
|
||||
|
|
Loading…
Reference in New Issue