Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ImGui v1.90.9 #13392

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
134 changes: 101 additions & 33 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))
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
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
20 changes: 11 additions & 9 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 @@ -264,7 +265,7 @@ bool option_model::draw_combobox( notifications_model & model,

try
{
if( ImGui::Combo( id.c_str(), &selected, labels.data(), static_cast< int >( labels.size() ) ) )
if( ImGui::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 @@ -499,8 +501,7 @@ bool option_model::draw_slider( notifications_model & model,
&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
26 changes: 13 additions & 13 deletions common/realsense-ui-advanced-mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Depth Control"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -268,7 +268,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Rsm"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -299,7 +299,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Rau Support Vector Control"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -333,7 +333,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Color Control"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -364,7 +364,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Rau Color Thresholds Control"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -393,7 +393,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("SLO Color Thresholds Control"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -422,7 +422,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("SLO Penalty Control"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -454,7 +454,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("HDAD"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -485,7 +485,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Color Correction"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -523,7 +523,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Depth Table"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -554,7 +554,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("AE Control"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand All @@ -581,7 +581,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Census Enable Reg"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down Expand Up @@ -609,7 +609,7 @@ inline void draw_advanced_mode_controls(rs400::advanced_mode& advanced,

if (ImGui::TreeNode("Disparity Modulation"))
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(ImGui::CalcItemWidth());

auto to_set = false;

Expand Down
3 changes: 2 additions & 1 deletion 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 Expand Up @@ -366,7 +367,7 @@ namespace rs2
bool draw_combo_box(const std::string& id, const std::vector<std::string>& device_names, int& new_index)
{
std::vector<const char*> device_names_chars = get_string_pointers(device_names);
return ImGui::Combo(id.c_str(), &new_index, device_names_chars.data(), static_cast<int>(device_names.size()));
return ImGui::CustomComboBox(id.c_str(), &new_index, device_names_chars.data(), static_cast<int>(device_names.size()));
}

void stream_model::show_stream_header(ImFont* font, const rect &stream_rect, viewer_model& viewer)
Expand Down
Loading
Loading