generated from emilk/eframe_template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from dmackdev/selected-message-view
Add selected message view
- Loading branch information
Showing
7 changed files
with
196 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use serde_json::Value; | ||
|
||
pub fn show_json_context_menu(value: &Value) -> impl FnMut(egui::Response, &String) + '_ { | ||
|response, pointer| { | ||
response | ||
.on_hover_cursor(egui::CursorIcon::ContextMenu) | ||
.context_menu(|ui| { | ||
show_json_context_menu_impl(ui, pointer, value); | ||
}); | ||
} | ||
} | ||
|
||
fn show_json_context_menu_impl(ui: &mut egui::Ui, pointer: &String, value: &Value) { | ||
ui.with_layout(egui::Layout::top_down_justified(egui::Align::LEFT), |ui| { | ||
ui.set_width(150.0); | ||
|
||
if !pointer.is_empty() | ||
&& ui | ||
.add(egui::Button::new("Copy property path").frame(false)) | ||
.clicked() | ||
{ | ||
ui.output_mut(|o| o.copied_text = pointer.clone()); | ||
ui.close_menu(); | ||
} | ||
|
||
if ui | ||
.add(egui::Button::new("Copy contents").frame(false)) | ||
.clicked() | ||
{ | ||
if let Some(val) = value.pointer(pointer) { | ||
if let Ok(pretty_str) = serde_json::to_string_pretty(val) { | ||
ui.output_mut(|o| o.copied_text = pretty_str); | ||
} | ||
} | ||
ui.close_menu(); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
mod json_ui; | ||
mod messages_view; | ||
mod modal; | ||
mod publish_view; | ||
mod selected_message; | ||
mod topic_name; | ||
mod validity_frame; | ||
|
||
pub use json_ui::show_json_context_menu; | ||
pub use messages_view::MessagesView; | ||
pub use modal::Modal; | ||
pub use publish_view::PublishView; | ||
pub use selected_message::render_selected_message; | ||
pub use topic_name::render_topic_name; |
Oops, something went wrong.