-
Notifications
You must be signed in to change notification settings - Fork 3
Search Highlight #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Search Highlight #664
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,6 +198,7 @@ FlameTrackItem::ExtractPointsFromData() | |
| const TraceEvent& event = events_data[i]; | ||
| m_chart_items[i].event = event; | ||
| m_chart_items[i].selected = m_timeline_selection->EventSelected(event.m_id.uuid); | ||
| m_chart_items[i].search_highlighted = m_timeline_selection->EventSearchHighlighted(event.m_id.uuid); | ||
| if(m_chart_items[i].event.m_child_count > 1) | ||
| { | ||
| m_chart_items[i].name_hash = | ||
|
|
@@ -294,6 +295,7 @@ FlameTrackItem::HandleTimelineSelectionChanged(std::shared_ptr<RocEvent> e) | |
| for(ChartItem& item : m_chart_items) | ||
| { | ||
| item.selected = m_timeline_selection->EventSelected(item.event.m_id.uuid); | ||
| item.search_highlighted = m_timeline_selection->EventSearchHighlighted(item.event.m_id.uuid); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -364,6 +366,11 @@ FlameTrackItem::DrawBox(ImVec2 start_position, int color_index, ChartItem& chart | |
| if(ImGui::IsMouseClicked(ImGuiMouseButton_Right)) | ||
| { | ||
| TimelineFocusManager::GetInstance().SetRightClickLayer(Layer::kGraphLayer); | ||
| m_timeline_selection->ClearSearchHighlights(); | ||
| for(ChartItem& item : m_chart_items) | ||
| { | ||
| item.search_highlighted = false; | ||
| } | ||
| } | ||
|
|
||
| // Select on click | ||
|
|
@@ -382,6 +389,11 @@ FlameTrackItem::DrawBox(ImVec2 start_position, int color_index, ChartItem& chart | |
| true; // Ensure only one click is handled per render cycle | ||
| chart_item.selected = !chart_item.selected; | ||
|
|
||
| m_timeline_selection->ClearSearchHighlights(); | ||
| for(ChartItem& item : m_chart_items) | ||
| { | ||
| item.search_highlighted = false; | ||
| } | ||
|
|
||
| //Control to multiselect | ||
| const ImGuiIO& io = ImGui::GetIO(); | ||
|
|
@@ -410,6 +422,10 @@ FlameTrackItem::DrawBox(ImVec2 start_position, int color_index, ChartItem& chart | |
| { | ||
| m_selected_chart_items.push_back(chart_item); | ||
| } | ||
| if(chart_item.search_highlighted) | ||
| { | ||
| m_search_highlighted_chart_items.push_back(chart_item); | ||
| } | ||
| } | ||
|
|
||
| void | ||
|
|
@@ -681,6 +697,37 @@ FlameTrackItem::RenderChart(float graph_width) | |
| } | ||
|
|
||
| m_selected_chart_items.clear(); | ||
|
|
||
| for(ChartItem& item : m_search_highlighted_chart_items) | ||
| { | ||
| ImVec2 container_pos = ImGui::GetWindowPos(); | ||
| double normalized_start = | ||
| container_pos.x + m_tpt->RawTimeToPixel(item.event.m_start_ts); | ||
|
|
||
| double normalized_duration = | ||
| std::max(item.event.m_duration * m_tpt->GetPixelsPerNs(), 1.0); | ||
|
|
||
| ImVec2 start_position; | ||
| float rounding = 2.0f; | ||
| start_position = ImVec2(static_cast<float>(normalized_start), | ||
|
Comment on lines
+703
to
+712
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extract rendering logic into a RenderBoxFrame(frame_color) method and use for both selection and highlight |
||
| item.event.m_level * m_level_height); | ||
|
|
||
| ImVec2 cursor_position = ImGui::GetCursorScreenPos(); | ||
| ImVec2 content_size = ImGui::GetContentRegionAvail(); | ||
|
|
||
| ImVec2 rectMin = ImVec2(start_position.x - HIGHLIGHT_THICKNESS_HALF, | ||
| start_position.y + cursor_position.y + | ||
| HIGHLIGHT_THICKNESS_HALF - ANTI_ALIASING_WORKAROUND); | ||
| ImVec2 rectMax = | ||
| ImVec2(start_position.x + static_cast<float>(normalized_duration) + | ||
| HIGHLIGHT_THICKNESS_HALF, | ||
| start_position.y + m_level_height + cursor_position.y - | ||
| HIGHLIGHT_THICKNESS_HALF + ANTI_ALIASING_WORKAROUND); | ||
| draw_list->AddRect(rectMin, rectMax, m_settings.GetColor(Colors::kSearchHighlight), | ||
| rounding, 0, HIGHLIGHT_THICKNESS); | ||
| } | ||
|
|
||
| m_search_highlighted_chart_items.clear(); | ||
| m_deferred_click_handled = false; | ||
|
|
||
| ImGui::EndChild(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,5 +207,35 @@ TimelineSelection::HasSelectedEvents() const | |
| return !m_selected_event_ids.empty(); | ||
| } | ||
|
|
||
| void | ||
| TimelineSelection::SearchHighlightEvent(uint64_t track_id, uint64_t event_id) | ||
| { | ||
| m_search_highlighted_event_ids.clear(); | ||
| m_search_highlighted_event_ids.insert(event_id); | ||
| SendEventSelectionChanged(event_id, track_id, true); | ||
| } | ||
|
Comment on lines
+214
to
+216
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Highlight needs it own event(s). It should not piggy back off of event selection events. As is highlighting an event will clear / alter selection |
||
|
|
||
| void | ||
| TimelineSelection::ClearSearchHighlights() | ||
| { | ||
| if(!m_search_highlighted_event_ids.empty()) | ||
| { | ||
| m_search_highlighted_event_ids.clear(); | ||
| SendEventSelectionChanged(INVALID_SELECTION_ID, INVALID_SELECTION_ID, false, true); | ||
| } | ||
| } | ||
|
|
||
| bool | ||
| TimelineSelection::EventSearchHighlighted(uint64_t event_id) const | ||
| { | ||
| return m_search_highlighted_event_ids.count(event_id) > 0; | ||
| } | ||
|
|
||
| bool | ||
| TimelineSelection::HasSearchHighlightedEvents() const | ||
| { | ||
| return !m_search_highlighted_event_ids.empty(); | ||
| } | ||
|
|
||
| } // namespace View | ||
| } // namespace RocProfVis | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Search highlight state should be handled in a dedicated event