diff --git a/cpp/open3d/visualization/gui/ProgressBar.cpp b/cpp/open3d/visualization/gui/ProgressBar.cpp index a55e32bb090a..0c930155a411 100644 --- a/cpp/open3d/visualization/gui/ProgressBar.cpp +++ b/cpp/open3d/visualization/gui/ProgressBar.cpp @@ -42,16 +42,19 @@ Widget::DrawResult ProgressBar::Draw(const DrawContext& context) { auto fg = context.theme.border_color; auto color = colorToImguiRGBA(fg); float rounding = frame.height / 2.0f; + ImGui::GetWindowDrawList()->AddRect( - ImVec2(float(frame.x), float(frame.y)), - ImVec2(float(frame.GetRight()), float(frame.GetBottom())), color, - rounding); + ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()), + ImVec2(float(frame.GetRight()), + float(frame.GetBottom()) - ImGui::GetScrollY()), + color, rounding); float x = float(frame.x) + float(frame.width) * impl_->value_; x = std::max(x, float(frame.x + rounding)); + ImGui::GetWindowDrawList()->AddRectFilled( - ImVec2(float(frame.x), float(frame.y)), - ImVec2(float(x), float(frame.GetBottom())), color, - frame.height / 2.0f); + ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()), + ImVec2(float(x), float(frame.GetBottom()) - ImGui::GetScrollY()), + color, frame.height / 2.0f); return DrawResult::NONE; } diff --git a/examples/cpp/BasicGUI.cpp b/examples/cpp/BasicGUI.cpp new file mode 100644 index 000000000000..f6141dcc6875 --- /dev/null +++ b/examples/cpp/BasicGUI.cpp @@ -0,0 +1,36 @@ +#include "open3d/Open3D.h" + +using namespace open3d; +using namespace open3d::visualization; + +class BasicGUI { +public: + explicit BasicGUI() { gui::Application::GetInstance().Initialize(); } + + void Run() { + auto window = std::make_shared("Basic GUI", 200, 200); + + auto scrollableVert = std::make_shared(10); + + for (auto i = 0; i < 20; i++) { + auto label = std::make_shared("Hello World"); + scrollableVert->AddChild(label); + } + + // add progress bar + auto progressBar = std::make_shared(); + progressBar->SetValue(0.5f); + scrollableVert->AddChild(progressBar); + + window->AddChild(scrollableVert); + + gui::Application::GetInstance().AddWindow(window); + gui::Application::GetInstance().Run(); + } +}; + +int main(int argc, char *argv[]) { + auto gui = BasicGUI(); + gui.Run(); + return 0; +} \ No newline at end of file