Skip to content

Commit

Permalink
Add GetText/SetText to CollapsableVert
Browse files Browse the repository at this point in the history
See the discussions in PR #6865
  • Loading branch information
Ewing Kang committed Jul 18, 2024
1 parent 4bddf59 commit 91b0dc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cpp/open3d/visualization/gui/Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,7 @@ CollapsableVert::CollapsableVert(const char* text,
int spacing,
const Margins& margins /*= Margins()*/)
: Vert(spacing, margins), impl_(new CollapsableVert::Impl()) {
static int g_next_id = 1;

impl_->text_ = text;
impl_->id_ = impl_->text_ + "##collapsing_" + std::to_string(g_next_id++);
SetText(text);
}

CollapsableVert::~CollapsableVert() {}
Expand All @@ -398,6 +395,15 @@ void CollapsableVert::SetIsOpen(bool is_open) { impl_->is_open_ = is_open; }

bool CollapsableVert::GetIsOpen() { return impl_->is_open_; }

void CollapsableVert::SetText(const char* text) {
static int g_next_id = 1;

impl_->text_ = text;
impl_->id_ = impl_->text_ + "##collapsing_" + std::to_string(g_next_id++);
}

std::string CollapsableVert::GetText() const { return impl_->text_; };

FontId CollapsableVert::GetFontId() const { return impl_->font_id_; }

void CollapsableVert::SetFontId(FontId font_id) { impl_->font_id_ = font_id; }
Expand Down
3 changes: 3 additions & 0 deletions cpp/open3d/visualization/gui/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class CollapsableVert : public Vert {
/// Returns true if open and false if collapsed.
bool GetIsOpen();

void SetText(const char* text);
std::string GetText() const;

FontId GetFontId() const;
void SetFontId(FontId font_id);

Expand Down

0 comments on commit 91b0dc0

Please sign in to comment.