#pragma once #include #include #include #include #include #include #include #include #include "imgui.h" #include "tools/cabana/dbc/dbcmanager.h" #include "tools/cabana/streams/abstractstream.h" class MessageList { public: enum Column { NAME = 0, SOURCE, ADDRESS, NODE, FREQ, COUNT, DATA, COLUMN_COUNT }; struct Item { MessageId id; std::string name; std::string node; bool operator==(const Item &other) const { return id == other.id && name == other.name && node == other.node; } }; MessageList(); void sort(int column, ImGuiSortDirection order); void setFilters(const std::map &filters); void showInactiveMessages(bool show); bool filterAndSort(); std::vector items; bool show_inactive_messages = true; Observable<> changed; private: void msgsReceived(const std::set *new_msgs, bool has_new_ids); void dbcModified(); void sortItems(std::vector &list); bool match(const Item &item); std::map filters_; std::set dbc_messages_; int sort_column_ = NAME; ImGuiSortDirection sort_order_ = ImGuiSortDirection_Ascending; int sort_threshold_ = 0; Connections connections_; }; class MessagesWidget { public: MessagesWidget(); void draw(); void selectMessage(const MessageId &message_id); void suppressHighlighted(bool from_suppress_add = false); const std::string &title() const { return title_; } std::string whatsThis() const; Observable msgSelectionChanged; private: void drawToolBar(); void drawTable(); void drawHeader(); void drawRow(int row); void drawContextMenu(); void handleKeys(); void setCurrentRow(int row); void updateBytesSectionSize(); void updateTitle(); void setMultiLineBytes(bool multi); MessageList list_; std::optional current_msg_id_; int current_row_ = -1; bool scroll_to_current_ = false; int bytes_section_bytes_ = 8; float fixed_columns_width_ = 0; bool has_scrollbar_y_ = false; int visible_rows_ = 1; std::array filters_; std::array hidden_ = {}; std::array display_order_; std::vector> pending_hidden_; bool header_menu_requested_ = false; std::string suppress_clear_text_; bool suppress_clear_enabled_ = false; std::string title_ = "MESSAGES"; Connections connections_; };