mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-07-25 19:32:03 +08:00
jp: misc polish (#37919)
* remove useless zoom out buttons * rm flip * rm those too * no dragging
This commit is contained in:
@@ -1334,20 +1334,6 @@ bool apply_pane_menu_action(AppSession *session, UiState *state, int pane_index,
|
||||
layout_changed = true;
|
||||
success_status = "Plot view reset";
|
||||
break;
|
||||
case PaneMenuActionKind::ResetHorizontal:
|
||||
reset_shared_range(state, *session);
|
||||
state->follow_latest = session->data_mode == SessionDataMode::Stream;
|
||||
state->suppress_range_side_effects = true;
|
||||
clamp_shared_range(state, *session);
|
||||
persist_shared_range_to_tab(tab, *state);
|
||||
layout_changed = true;
|
||||
success_status = "Horizontal zoom reset";
|
||||
break;
|
||||
case PaneMenuActionKind::ResetVertical:
|
||||
clear_pane_vertical_limits(&tab->panes[static_cast<size_t>(pane_index)]);
|
||||
layout_changed = true;
|
||||
success_status = "Vertical zoom reset";
|
||||
break;
|
||||
case PaneMenuActionKind::Clear:
|
||||
clear_pane(tab, pane_index);
|
||||
tab_state->active_pane_index = pane_index;
|
||||
|
||||
@@ -139,6 +139,14 @@ bool env_flag_enabled(const char *name, bool default_value) {
|
||||
return !(value == "0" || value == "false" || value == "no" || value == "off");
|
||||
}
|
||||
|
||||
bool app_begin_popup(const char *str_id, ImGuiWindowFlags flags) {
|
||||
return ImGui::BeginPopup(str_id, flags | ImGuiWindowFlags_NoMove);
|
||||
}
|
||||
|
||||
bool app_begin_popup_modal(const char *name, bool *p_open, ImGuiWindowFlags flags) {
|
||||
return ImGui::BeginPopupModal(name, p_open, flags | ImGuiWindowFlags_NoMove);
|
||||
}
|
||||
|
||||
void open_external_url(std::string_view url) {
|
||||
#ifdef __APPLE__
|
||||
const std::string command = "open " + shell_quote(url) + " &";
|
||||
|
||||
@@ -57,6 +57,10 @@ const char *stream_source_kind_label(StreamSourceKind kind);
|
||||
std::string stream_source_target_label(const StreamSourceConfig &source);
|
||||
|
||||
bool env_flag_enabled(const char *name, bool default_value = false);
|
||||
bool app_begin_popup(const char *str_id, ImGuiWindowFlags flags = 0);
|
||||
bool app_begin_popup_modal(const char *name,
|
||||
bool *p_open = nullptr,
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize);
|
||||
void open_external_url(std::string_view url);
|
||||
std::string route_useradmin_url(const RouteIdentifier &route_id);
|
||||
std::string route_connect_url(const RouteIdentifier &route_id);
|
||||
|
||||
@@ -292,7 +292,7 @@ void draw_custom_series_help_popup(CustomSeriesEditorState *editor) {
|
||||
ImGui::OpenPopup("Custom Series Help");
|
||||
editor->open_help = false;
|
||||
}
|
||||
if (!ImGui::BeginPopupModal("Custom Series Help", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Custom Series Help")) {
|
||||
return;
|
||||
}
|
||||
ImGui::TextUnformatted("Available variables");
|
||||
|
||||
@@ -26,8 +26,6 @@ enum class PaneMenuActionKind {
|
||||
SplitTop,
|
||||
SplitBottom,
|
||||
ResetView,
|
||||
ResetHorizontal,
|
||||
ResetVertical,
|
||||
Clear,
|
||||
Close,
|
||||
};
|
||||
|
||||
@@ -92,7 +92,7 @@ bool open_find_signal_result(UiState *state, const std::string &path) {
|
||||
}
|
||||
|
||||
void draw_open_route_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("Open Route", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Open Route")) {
|
||||
return;
|
||||
}
|
||||
ImGui::TextUnformatted("Load a route into the current layout.");
|
||||
@@ -116,7 +116,7 @@ void draw_open_route_popup(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
void draw_stream_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("Live Stream", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Live Stream")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ void draw_stream_popup(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
void draw_load_layout_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("Load Layout", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Load Layout")) {
|
||||
return;
|
||||
}
|
||||
ImGui::TextUnformatted("Load a JotPlugger JSON layout.");
|
||||
@@ -177,7 +177,7 @@ void draw_load_layout_popup(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
void draw_save_layout_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("Save Layout", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Save Layout")) {
|
||||
return;
|
||||
}
|
||||
ImGui::TextUnformatted("Save the current workspace as a JotPlugger JSON layout.");
|
||||
@@ -201,7 +201,7 @@ void draw_save_layout_popup(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
void draw_preferences_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("Preferences", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Preferences")) {
|
||||
return;
|
||||
}
|
||||
if (session->map_data) {
|
||||
@@ -234,7 +234,7 @@ void draw_preferences_popup(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
void draw_find_signal_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("Find Signal", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Find Signal")) {
|
||||
return;
|
||||
}
|
||||
ImGui::TextUnformatted("Search decoded signals across the loaded route.");
|
||||
@@ -353,7 +353,7 @@ bool save_dbc_editor_contents(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
void draw_dbc_editor_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("DBC Editor", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("DBC Editor")) {
|
||||
return;
|
||||
}
|
||||
DbcEditorState &editor = state->dbc_editor;
|
||||
@@ -392,7 +392,7 @@ void draw_dbc_editor_popup(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
void draw_axis_limits_popup(AppSession *session, UiState *state) {
|
||||
if (!ImGui::BeginPopupModal("Edit Axis Limits", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Edit Axis Limits")) {
|
||||
return;
|
||||
}
|
||||
const WorkspaceTab *tab = app_active_tab(session->layout, *state);
|
||||
@@ -452,7 +452,7 @@ void draw_error_popup(UiState *state) {
|
||||
ImGui::OpenPopup("Error");
|
||||
state->open_error_popup = false;
|
||||
}
|
||||
if (!ImGui::BeginPopupModal("Error", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
if (!app_begin_popup_modal("Error")) {
|
||||
return;
|
||||
}
|
||||
ImGui::TextWrapped("%s", state->error_text.c_str());
|
||||
|
||||
@@ -921,28 +921,15 @@ std::optional<PaneMenuAction> draw_pane_context_menu(const WorkspaceTab &tab, in
|
||||
ImGui::Separator();
|
||||
if (icon_menu_item(icon::ZOOM_OUT, "Zoom Out", nullptr, false, is_plot)) {
|
||||
action.kind = PaneMenuActionKind::ResetView;
|
||||
} else if (icon_menu_item(icon::ARROW_LEFT_RIGHT, "Zoom Out Horizontally", nullptr, false, is_plot)) {
|
||||
action.kind = PaneMenuActionKind::ResetHorizontal;
|
||||
} else if (icon_menu_item(icon::ARROW_DOWN_UP, "Zoom Out Vertically", nullptr, false, is_plot)) {
|
||||
action.kind = PaneMenuActionKind::ResetVertical;
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (icon_menu_item(icon::TRASH, "Remove ALL curves", nullptr, false, is_plot)) {
|
||||
action.kind = PaneMenuActionKind::Clear;
|
||||
}
|
||||
ImGui::Separator();
|
||||
icon_menu_item(icon::ARROW_LEFT_RIGHT, "Flip Horizontal Axis", nullptr, false, false);
|
||||
icon_menu_item(icon::ARROW_DOWN_UP, "Flip Vertical Axis", nullptr, false, false);
|
||||
ImGui::Separator();
|
||||
icon_menu_item(icon::FILES, "Copy", nullptr, false, false);
|
||||
icon_menu_item(icon::CLIPBOARD2, "Paste", nullptr, false, false);
|
||||
icon_menu_item(icon::FILE_EARMARK_IMAGE, "Copy image to clipboard", nullptr, false, false);
|
||||
icon_menu_item(icon::SAVE, "Save plot to file", nullptr, false, false);
|
||||
icon_menu_item(icon::BAR_CHART, "Show data statistics", nullptr, false, false);
|
||||
ImGui::Separator();
|
||||
if (icon_menu_item(icon::X_SQUARE, "Close Pane")) {
|
||||
action.kind = PaneMenuActionKind::Close;
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
if (action.kind == PaneMenuActionKind::None) return std::nullopt;
|
||||
return action;
|
||||
|
||||
@@ -444,8 +444,7 @@ void draw_route_info_popup(AppSession *session, UiState *state, ImVec2 anchor) {
|
||||
}
|
||||
ImGui::SetNextWindowPos(anchor, ImGuiCond_Appearing);
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(300.0f, 0.0f), ImVec2(420.0f, FLT_MAX));
|
||||
if (!ImGui::BeginPopup("##route_info_popup",
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings)) {
|
||||
if (!app_begin_popup("##route_info_popup", ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -643,7 +642,7 @@ void draw_route_id_chip(AppSession *session, UiState *state) {
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(chip_max.x - 60.0f, chip_max.y + 4.0f), ImGuiCond_Appearing);
|
||||
if (ImGui::BeginPopup("##route_selector_popup")) {
|
||||
if (app_begin_popup("##route_selector_popup")) {
|
||||
for (LogSelector selector : {LogSelector::Auto, LogSelector::RLog, LogSelector::QLog}) {
|
||||
const bool selected = route_id.selector == selector;
|
||||
const std::string label = std::string(log_selector_name(selector)) + " " + log_selector_description(selector);
|
||||
|
||||
Reference in New Issue
Block a user