Skip to content

Commit

Permalink
PR #13392 from Noy-Zini: Update ImGui v1.90.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az authored Dec 18, 2024
2 parents 367937d + c6188ef commit 5b1ea01
Show file tree
Hide file tree
Showing 62 changed files with 43,158 additions and 11,026 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
164 changes: 117 additions & 47 deletions common/device-model.cpp

Large diffs are not rendered by default.

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
47 changes: 24 additions & 23 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 Expand Up @@ -280,29 +281,29 @@ namespace rs2

bool yes_no_dialog(const std::string& title, const std::string& message_text, bool& approved, ux_window& window, const std::string& error_message, bool disabled, const std::string& disabled_reason)
{
ImGui_ScopePushFont(window.get_font());
ImGui_ScopePushStyleColor(ImGuiCol_Button, button_color);
ImGui_ScopePushStyleColor(ImGuiCol_ButtonHovered, sensor_header_light_blue); //TODO: Change color?
ImGui_ScopePushStyleColor(ImGuiCol_ButtonActive, regular_blue); //TODO: Change color?
ImGui_ScopePushStyleColor(ImGuiCol_TextSelectedBg, light_grey);
ImGui_ScopePushStyleColor(ImGuiCol_TitleBg, header_color);
ImGui_ScopePushStyleColor(ImGuiCol_PopupBg, sensor_bg);
ImGui_ScopePushStyleColor(ImGuiCol_BorderShadow, dark_grey);
ImGui_ScopePushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10));
RsImGui_ScopePushFont(window.get_font());
RsImGui_ScopePushStyleColor(ImGuiCol_Button, button_color);
RsImGui_ScopePushStyleColor(ImGuiCol_ButtonHovered, sensor_header_light_blue); //TODO: Change color?
RsImGui_ScopePushStyleColor(ImGuiCol_ButtonActive, regular_blue); //TODO: Change color?
RsImGui_ScopePushStyleColor(ImGuiCol_TextSelectedBg, light_grey);
RsImGui_ScopePushStyleColor(ImGuiCol_TitleBg, header_color);
RsImGui_ScopePushStyleColor(ImGuiCol_PopupBg, sensor_bg);
RsImGui_ScopePushStyleColor(ImGuiCol_BorderShadow, dark_grey);
RsImGui_ScopePushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10));
auto clicked = false;

ImGui::OpenPopup(title.c_str());
ImGui::SetNextWindowPos( {window.width() * 0.35f, window.height() * 0.35f });
if (ImGui::BeginPopup(title.c_str()))
{
{
ImGui_ScopePushStyleColor(ImGuiCol_Text, almost_white_bg);
RsImGui_ScopePushStyleColor(ImGuiCol_Text, almost_white_bg);

ImGui::SetWindowFontScale(1.3f);
ImGui::Text("%s", title.c_str());
}
{
ImGui_ScopePushStyleColor(ImGuiCol_Text, light_grey);
RsImGui_ScopePushStyleColor(ImGuiCol_Text, light_grey);
ImGui::Separator();
ImGui::SetWindowFontScale(1.1f);
ImGui::Text("\n%s\n", message_text.c_str());
Expand Down Expand Up @@ -332,7 +333,7 @@ namespace rs2
{
ImGui::NewLine();
{
ImGui_ScopePushStyleColor(ImGuiCol_Text, red);
RsImGui_ScopePushStyleColor(ImGuiCol_Text, red);
ImGui::Text("%s\n\n", disabled_reason.c_str());
}
auto window_width = ImGui::GetWindowWidth();
Expand All @@ -354,24 +355,24 @@ namespace rs2
// and close button activated by the caller
bool status_dialog(const std::string& title, const std::string& process_topic_text, const std::string& process_status_text , bool enable_close, ux_window& window)
{
ImGui_ScopePushFont(window.get_font());
ImGui_ScopePushStyleColor(ImGuiCol_Button, button_color);
ImGui_ScopePushStyleColor(ImGuiCol_ButtonHovered, sensor_header_light_blue); //TODO: Change color?
ImGui_ScopePushStyleColor(ImGuiCol_ButtonActive, regular_blue); //TODO: Change color?
ImGui_ScopePushStyleColor(ImGuiCol_Text, light_grey);
ImGui_ScopePushStyleColor(ImGuiCol_TextSelectedBg, light_grey);
ImGui_ScopePushStyleColor(ImGuiCol_TitleBg, header_color);
ImGui_ScopePushStyleColor(ImGuiCol_PopupBg, sensor_bg);
ImGui_ScopePushStyleColor(ImGuiCol_BorderShadow, dark_grey);
ImGui_ScopePushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10));
RsImGui_ScopePushFont(window.get_font());
RsImGui_ScopePushStyleColor(ImGuiCol_Button, button_color);
RsImGui_ScopePushStyleColor(ImGuiCol_ButtonHovered, sensor_header_light_blue); //TODO: Change color?
RsImGui_ScopePushStyleColor(ImGuiCol_ButtonActive, regular_blue); //TODO: Change color?
RsImGui_ScopePushStyleColor(ImGuiCol_Text, light_grey);
RsImGui_ScopePushStyleColor(ImGuiCol_TextSelectedBg, light_grey);
RsImGui_ScopePushStyleColor(ImGuiCol_TitleBg, header_color);
RsImGui_ScopePushStyleColor(ImGuiCol_PopupBg, sensor_bg);
RsImGui_ScopePushStyleColor(ImGuiCol_BorderShadow, dark_grey);
RsImGui_ScopePushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 10));
auto close_clicked = false;

ImGui::OpenPopup(title.c_str());
ImGui::SetNextWindowPos({ window.width() * 0.35f, window.height() * 0.35f });
if (ImGui::BeginPopup(title.c_str()))
{
{
ImGui_ScopePushStyleColor(ImGuiCol_Text, almost_white_bg);
RsImGui_ScopePushStyleColor(ImGuiCol_Text, almost_white_bg);

ImGui::SetWindowFontScale(1.3f);
ImGui::Text("%s", title.c_str());
Expand Down
2 changes: 1 addition & 1 deletion common/notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ namespace rs2

auto s = ss.str();
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, regular_blue);
ImGui::InputTextMultiline("notification", const_cast<char*>(s.c_str()),
ImGui::InputTextMultiline("##notification", const_cast<char*>(s.c_str()),
s.size() + 1, { 500,100 }, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_ReadOnly);
ImGui::PopStyleColor();

Expand Down
24 changes: 13 additions & 11 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 Expand Up @@ -256,15 +257,15 @@ bool option_model::draw_combobox( notifications_model & model,
if( new_line )
ImGui::SetCursorPosX( combo_position_x );

ImGui::PushItemWidth( new_line ? -1.f : 100.f );
ImGui::PushItemWidth( new_line ? ImGui::GetContentRegionAvail().x - 25 : 100.f );

int selected;
std::vector< const char * > labels = get_combo_labels( &selected );
ImGui::PushStyleColor( ImGuiCol_TextSelectedBg, { 1, 1, 1, 1 } );

try
{
if( ImGui::Combo( id.c_str(), &selected, labels.data(), static_cast< int >( labels.size() ) ) )
if( RsImGui::CustomComboBox( id.c_str(), &selected, labels.data(), static_cast< int >( labels.size() ) ) )
{
float tmp_value = range.min + range.step * selected;
model.add_log( rsutils::string::from()
Expand Down Expand Up @@ -337,7 +338,7 @@ bool option_model::draw_slider( notifications_model & model,
ImGui::Text( "%s", txt.c_str() );

ImGui::SameLine();
ImGui::SetCursorPosX( read_only ? 268.f : 245.f );
ImGui::SetCursorPosX( read_only ? 280.f : 257.f );
ImGui::PushStyleColor( ImGuiCol_Text, grey );
ImGui::PushStyleColor( ImGuiCol_TextSelectedBg, grey );
ImGui::PushStyleColor( ImGuiCol_ButtonActive, { 1.f, 1.f, 1.f, 0.f } );
Expand All @@ -353,7 +354,7 @@ bool option_model::draw_slider( notifications_model & model,
if( ! read_only )
{
ImGui::SameLine();
ImGui::SetCursorPosX( 268 );
ImGui::SetCursorPosX( 280 );
if( ! edit_mode )
{
std::string edit_id = rsutils::string::from() << textual_icons::edit << "##" << id;
Expand Down Expand Up @@ -390,9 +391,10 @@ bool option_model::draw_slider( notifications_model & model,
ImGui::PopStyleColor( 4 );
}
}

ImGui::PushItemWidth( -1 );

float customWidth = 295 - ImGui::GetCursorPosX(); //set slider width from the current Xpos to the right border at 295 (the edit button pos)
ImGui::PushItemWidth(customWidth);
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, black);
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, black);
try
{
if( read_only )
Expand Down Expand Up @@ -495,12 +497,11 @@ bool option_model::draw_slider( notifications_model & model,
// runs when changing a value with slider and not the textbox
auto int_value = static_cast< int >( value_as_float() );

if( ImGui::SliderIntWithSteps( id.c_str(),
if( RsImGui::SliderIntWithSteps( id.c_str(),
&int_value,
static_cast< int >( range.min ),
static_cast< int >( range.max ),
static_cast< int >( range.step ),
"%.0f" ) ) // integers don't have any precision
static_cast< int >( range.step )) )
{
// TODO: Round to step?
slider_clicked = slider_selected( opt,
Expand Down Expand Up @@ -579,7 +580,8 @@ bool option_model::draw_slider( notifications_model & model,
{
error_message = error_to_string( e );
}

ImGui::PopStyleColor(2);
ImGui::PopItemWidth();
return slider_clicked;
}

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
Loading

0 comments on commit 5b1ea01

Please sign in to comment.