Skip to content

Commit

Permalink
imgui_files_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Noy-Zini committed Aug 22, 2024
1 parent 7d98109 commit 0cb149a
Show file tree
Hide file tree
Showing 31 changed files with 42,878 additions and 10,849 deletions.
2 changes: 1 addition & 1 deletion common/calibration-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void calibration_model::update(ux_window& window, std::string& error_message)
ImGui::PopStyleColor(2);
}

ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, dark_sensor_bg);
ImGui::PushStyleColor(ImGuiCol_ChildBg, dark_sensor_bg);

ImGui::BeginChild("##CalibData",ImVec2(w - 15, h - 110), true);

Expand Down
35 changes: 18 additions & 17 deletions common/device-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "imgui-fonts-karla.hpp"
#include "imgui-fonts-fontawesome.hpp"
#include "imgui-fonts-monofont.hpp"
#include <realsense_imgui.h>

#include <rsutils/os/special-folder.h>
#include "os.h"
Expand Down Expand Up @@ -98,7 +99,7 @@ namespace rs2
style.Colors[ImGuiCol_ScrollbarGrab] = scrollbar_grab;
style.Colors[ImGuiCol_ScrollbarGrabHovered] = scrollbar_grab + 0.1f;
style.Colors[ImGuiCol_ScrollbarGrabActive] = scrollbar_grab + (-0.1f);
style.Colors[ImGuiCol_ComboBg] = dark_window_background;
style.Colors[ImGuiCol_PopupBg] = dark_window_background;
style.Colors[ImGuiCol_CheckMark] = regular_blue;
style.Colors[ImGuiCol_SliderGrab] = regular_blue;
style.Colors[ImGuiCol_SliderGrabActive] = regular_blue;
Expand Down Expand Up @@ -561,7 +562,7 @@ namespace rs2
//////////////////// Step Backwards Button ////////////////////
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + space_width);
std::string label = rsutils::string::from() << textual_icons::step_backward << "##Step Backward " << id;
if (ImGui::ButtonEx(label.c_str(), button_dim, supports_playback_step ? 0 : ImGuiButtonFlags_Disabled))
if (ImGui::ButtonEx(label.c_str(), button_dim, supports_playback_step ? 0 : ImGuiItemFlags_Disabled))
{
int fps = 0;
for (auto&& s : viewer.streams)
Expand Down Expand Up @@ -664,7 +665,7 @@ namespace rs2
//////////////////// Step Forward Button ////////////////////
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + space_width);
label = rsutils::string::from() << textual_icons::step_forward << "##Step Forward " << id;
if (ImGui::ButtonEx(label.c_str(), button_dim, supports_playback_step ? 0 : ImGuiButtonFlags_Disabled))
if (ImGui::ButtonEx(label.c_str(), button_dim, supports_playback_step ? 0 : ImGuiItemFlags_Disabled))
{
int fps = 0;
for (auto&& s : viewer.streams)
Expand Down Expand Up @@ -1221,7 +1222,7 @@ namespace rs2
auto record_button_color = is_recording ? light_blue : light_grey;
ImGui::PushStyleColor(ImGuiCol_Text, record_button_color);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, record_button_color);
if (ImGui::ButtonEx(record_button_name.c_str(), device_panel_icons_size, (disable_record_button_logic(is_streaming, is_playback_device)) ? ImGuiButtonFlags_Disabled : 0))
if (ImGui::ButtonEx(record_button_name.c_str(), device_panel_icons_size, (disable_record_button_logic(is_streaming, is_playback_device)) ? ImGuiItemFlags_Disabled : 0))
{
if (is_recording) //is_recording is changed inside stop/start_recording
{
Expand Down Expand Up @@ -1268,7 +1269,7 @@ namespace rs2
auto sync_button_color = is_sync_enabled ? light_blue : light_grey;
ImGui::PushStyleColor(ImGuiCol_Text, sync_button_color);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, sync_button_color);
if (ImGui::ButtonEx(sync_button_name.c_str(), device_panel_icons_size, ImGuiButtonFlags_Disabled))
if (ImGui::ButtonEx(sync_button_name.c_str(), device_panel_icons_size, ImGuiItemFlags_Disabled))
{
is_sync_enabled = !is_sync_enabled;
}
Expand Down Expand Up @@ -1437,18 +1438,18 @@ namespace rs2
//Move to next line, and we want to keep the horizontal alignment
ImGui::SetCursorPos({ panel_pos.x, ImGui::GetCursorPosY() });
//Using transparent-non-actionable buttons to have the same locations
ImGui::PushStyleColor(ImGuiCol_Button, ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4&)ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4&)ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4&)ImColor(0, 0, 0, 0));
const ImVec2 device_panel_icons_text_size = { icons_width, 5 };

ImGui::PushStyleColor(ImGuiCol_Text, record_button_color);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, record_button_color);
ImGui::ButtonEx(is_recording ? "Stop" : "Record", device_panel_icons_size, (!is_streaming ? ImGuiButtonFlags_Disabled : 0));
ImGui::ButtonEx(is_recording ? "Stop" : "Record", device_panel_icons_size, (!is_streaming ? ImGuiItemFlags_Disabled : 0));
if (ImGui::IsItemHovered() && is_streaming) window.link_hovered();
ImGui::PopStyleColor(2);

ImGui::SameLine(); ImGui::ButtonEx("Sync", device_panel_icons_size, ImGuiButtonFlags_Disabled);
ImGui::SameLine(); ImGui::ButtonEx("Sync", device_panel_icons_size, ImGuiItemFlags_Disabled);

auto info_button_color = show_device_info ? light_blue : light_grey;
ImGui::PushStyleColor(ImGuiCol_Text, info_button_color);
Expand Down Expand Up @@ -2035,7 +2036,7 @@ namespace rs2
const ImVec2 icons_size{ 20, 20 };
//TODO: Change this once we have support for loading jsons with more data than only advanced controls
bool is_streaming = std::any_of(subdevices.begin(), subdevices.end(), [](const std::shared_ptr<subdevice_model>& sm) { return sm->streaming; });
const int buttons_flags = serializable ? 0 : ImGuiButtonFlags_Disabled;
const int buttons_flags = serializable ? 0 : ImGuiItemFlags_Disabled;
static bool require_advanced_mode_enable_prompt = false;
auto advanced_dev = dev.as<advanced_mode>();
auto is_advanced_device = false;
Expand All @@ -2060,7 +2061,7 @@ namespace rs2
ImGui::PushStyleColor(ImGuiCol_Text, light_grey);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, light_grey);

if (ImGui::ButtonEx(upload_button_name.c_str(), icons_size, (is_streaming && !load_json_if_streaming) ? ImGuiButtonFlags_Disabled : buttons_flags))
if (ImGui::ButtonEx(upload_button_name.c_str(), icons_size, (is_streaming && !load_json_if_streaming) ? ImGuiItemFlags_Disabled : buttons_flags))
{
if (serializable && (!is_advanced_device || is_advanced_mode_enabled))
{
Expand Down Expand Up @@ -2182,8 +2183,8 @@ namespace rs2

auto pos = ImGui::GetCursorPos();
ImGui::PushFont(window.get_large_font());
ImGui::PushStyleColor(ImGuiCol_Button, device_header_background_color);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, device_header_background_color);
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4&)device_header_background_color);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4&)device_header_background_color);

////////////////////////////////////////
// Draw device name
Expand Down Expand Up @@ -2396,7 +2397,7 @@ namespace rs2
ImGui::PopStyleColor(2);

auto sensor_top_y = ImGui::GetCursorPosY();
ImGui::SetContentRegionWidth(windows_width - 36);
ImGui::SetNextWindowContentSize(ImVec2(ImGui::GetWindowWidth() - 36, ImGui::GetWindowHeight()));

ImGui::PushStyleColor(ImGuiCol_HeaderHovered, sensor_bg);
ImGui::PushStyleColor(ImGuiCol_Text, light_grey);
Expand Down Expand Up @@ -2800,7 +2801,7 @@ namespace rs2

ImGui::PushStyleColor(ImGuiCol_Text, redish);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, redish + 0.1f);
ImGui::ButtonEx(label.c_str(), button_size, ImGuiButtonFlags_Disabled);
ImGui::ButtonEx(label.c_str(), button_size, ImGuiItemFlags_Disabled);
}
else
{
Expand All @@ -2810,7 +2811,7 @@ namespace rs2
<< pb->get_name();
ImGui::PushStyleColor(ImGuiCol_Text, light_blue);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, light_blue + 0.1f);
ImGui::ButtonEx(label.c_str(), button_size, ImGuiButtonFlags_Disabled);
ImGui::ButtonEx(label.c_str(), button_size, ImGuiItemFlags_Disabled);
}
}
else
Expand Down
8 changes: 5 additions & 3 deletions common/measurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ std::vector<int> measurement_state::find_path(int from, int to)

void measurement::add_point(interest_point p)
{
auto shift = ImGui::IsKeyDown(GLFW_KEY_LEFT_SHIFT) || ImGui::IsKeyDown(GLFW_KEY_RIGHT_SHIFT);
ImGuiIO& io = ImGui::GetIO();
auto shift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];

if (is_enabled())
{
Expand Down Expand Up @@ -334,7 +335,7 @@ void measurement::update_input(ux_window& win, const rs2::rect& viewer_rect)
{
id = 0;

if (ImGui::IsKeyPressed('Z') || ImGui::IsKeyPressed('z'))
if (ImGui::IsKeyPressed(ImGuiKey_Z))
restore_state();

input_ctrl.prev_mouse_down = input_ctrl.mouse_down;
Expand Down Expand Up @@ -430,7 +431,8 @@ void measurement::restore_state()

void measurement::draw(ux_window& win)
{
auto shift = ImGui::IsKeyDown(GLFW_KEY_LEFT_SHIFT) || ImGui::IsKeyDown(GLFW_KEY_RIGHT_SHIFT);
ImGuiIO& io = ImGui::GetIO();
auto shift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];

auto p_idx = point_hovered(win);
if (p_idx >= 0 && !win.get_mouse().mouse_down[0])
Expand Down
1 change: 1 addition & 0 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <librealsense2/rs.hpp>

#include "realsense_imgui.h""
#include "model-views.h"
#include "subdevice-model.h"
#include "stream-model.h"
Expand Down
1 change: 1 addition & 0 deletions common/option-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.

#include "option-model.h"
#include <realsense_imgui.h>
#include <librealsense2/rs_advanced_mode.hpp>
#include <imgui.h>
#include <imgui_internal.h>
Expand Down
20 changes: 10 additions & 10 deletions common/output-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool output_model::round_indicator(ux_window& win, std::string icon,

auto pos = ImGui::GetCursorScreenPos();
ImGui::GetWindowDrawList()->AddRectFilled({ pos.x, pos.y + 3 },
{ pos.x + size.x + 15, pos.y + 27 }, ImColor(color), 12, 15);
{ pos.x + size.x + 15, pos.y + 27 }, ImColor(color), 12, ImDrawFlags_RoundCornersNone);

auto res = ImGui::Button(ss.str().c_str(), ImVec2(size.x + 15, 28));
if (count > 0 && ImGui::IsItemHovered())
Expand Down Expand Up @@ -438,7 +438,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev


ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0,0));
ImGui::PushStyleColor(ImGuiCol_ChildWindowBg, dark_sensor_bg);
ImGui::PushStyleColor(ImGuiCol_ChildBg, dark_sensor_bg);

const float log_area_width = w - get_dashboard_width() - 2;

Expand Down Expand Up @@ -520,7 +520,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 4);

std::string label = rsutils::string::from() << "##log_entry" << i++;
ImGui::InputTextEx(label.c_str(),
ImGui::InputTextEx(label.c_str(),NULL,
(char*)line.data(),
static_cast<int>(line.size() + 1),
ImVec2(-1, size.y + margin),
Expand Down Expand Up @@ -592,19 +592,19 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
ImGui::PushItemWidth( w - get_dashboard_width() - 30 );

bool force_refresh = false;
if (ImGui::IsWindowFocused() && (ImGui::IsKeyPressed(GLFW_KEY_UP) || ImGui::IsKeyPressed(GLFW_KEY_DOWN)))
if (ImGui::IsWindowFocused() && (ImGui::GetIO().KeysDown[ImGuiKey_UpArrow] || ImGui::GetIO().KeysDown[ImGuiKey_DownArrow]))
{
if (commands_histroy.size())
{
if (ImGui::IsKeyPressed(GLFW_KEY_UP)) history_offset = (history_offset + 1) % commands_histroy.size();
if (ImGui::IsKeyPressed(GLFW_KEY_DOWN)) history_offset = (history_offset - 1 + (int)commands_histroy.size()) % commands_histroy.size();
if (ImGui::GetIO().KeysDown[ImGuiKey_UpArrow]) history_offset = (history_offset + 1) % commands_histroy.size();
if (ImGui::GetIO().KeysDown[ImGuiKey_DownArrow]) history_offset = (history_offset - 1 + (int)commands_histroy.size()) % commands_histroy.size();
command_line = commands_histroy[history_offset];

force_refresh = true;
}
}

if (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(GLFW_KEY_TAB))
if (ImGui::IsWindowFocused() && ImGui::GetIO().KeysDown[GLFW_KEY_TAB])
{
if (!autocomplete.size() || !starts_with(to_lower(autocomplete.front()), to_lower(command_line)))
{
Expand Down Expand Up @@ -661,7 +661,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
ImGui::PopFont();
ImGui::PopStyleColor();

if (ImGui::IsWindowFocused() && (ImGui::IsKeyPressed(GLFW_KEY_ENTER) || ImGui::IsKeyPressed(GLFW_KEY_KP_ENTER)))
if (ImGui::IsWindowFocused() && (ImGui::GetIO().KeysDown[GLFW_KEY_ENTER] || ImGui::GetIO().KeysDown[GLFW_KEY_KP_ENTER]))
{
if (commands_histroy.size() > 100) commands_histroy.pop_back();
commands_histroy.push_front(command_line);
Expand All @@ -671,7 +671,7 @@ void output_model::draw(ux_window& win, rect view_rect, device_models_list & dev
}
else command_focus = false;

if (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(GLFW_KEY_ESCAPE))
if (ImGui::IsWindowFocused() && ImGui::GetIO().KeysDown[GLFW_KEY_ESCAPE])
{
command_line = "";
}
Expand Down Expand Up @@ -862,7 +862,7 @@ void output_model::foreach_log(std::function<void(log_entry& line)> action)

if (new_log)
{
ImGui::SetScrollPosHere();
ImGui::SetScrollHereY();
new_log = false;
}
}
Expand Down
1 change: 1 addition & 0 deletions common/stream-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "viewer.h"
#include "os.h"
#include <imgui_internal.h>
#include <realsense_imgui.h>


namespace rs2
Expand Down
6 changes: 3 additions & 3 deletions common/updates-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void updates_model::draw(std::shared_ptr<notifications_model> not_model, ux_wind
ImGui::SetNextWindowSize({ positions.w, positions.h });

auto flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ShowBorders;
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings ;

ImGui::PushStyleColor(ImGuiCol_PopupBg, sensor_bg);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, white);
Expand Down Expand Up @@ -411,7 +411,7 @@ bool updates_model::draw_software_section(const char * window_name, update_profi
sw_text_pos.y += 15;
ImGui::SetCursorScreenPos(sw_text_pos);
ImGui::InputTextMultiline("##Software Update Description", const_cast<char*>(msg),
strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvailWidth() - 150, pos.mid_y - (pos.orig_pos.y + 160) - 40),
strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvail().x - 150, pos.mid_y - (pos.orig_pos.y + 160) - 40),
ImGuiInputTextFlags_ReadOnly);
ImGui::PopStyleColor(7);
ImGui::PopTextWrapPos();
Expand Down Expand Up @@ -686,7 +686,7 @@ bool updates_model::draw_firmware_section(std::shared_ptr<notifications_model> n
fw_text_pos.y += 15;
ImGui::SetCursorScreenPos(fw_text_pos);
ImGui::InputTextMultiline("##Firmware Update Description", const_cast<char*>(msg),
strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvailWidth() - 150, 75),
strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvail().x - 150, 75),
ImGuiInputTextFlags_ReadOnly);
ImGui::PopStyleColor(7);
ImGui::PopTextWrapPos();
Expand Down
6 changes: 5 additions & 1 deletion common/ux-alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ux-alignment.h"
#include <imgui.h>
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
#include <vector>
#include <memory>

Expand Down Expand Up @@ -46,10 +47,13 @@ bool is_gui_aligned(GLFWwindow *win)
ImGui::PopStyleVar();

ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

glfwSwapBuffers(win);

ImGui_ImplGlfw_NewFrame(1.f);
//ImGui_ImplOpenGL3_NewFrame();
//ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();

SetFocus(hwn);

Expand Down
Loading

0 comments on commit 0cb149a

Please sign in to comment.