Skip to content

Commit 18f99ed

Browse files
committed
add option to set right gui panel width
1 parent ac0a2e1 commit 18f99ed

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

include/polyscope/options.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ extern bool userGuiIsOnRightSide;
124124
// effect the user gui panel. (default: true)
125125
extern bool buildDefaultGuiPanels;
126126

127+
// The width of the user GUI panel which is usually on the right side (default: 500)
128+
extern int rightGuiPaneWidth;
129+
127130
// If false, Polyscope will not render the scene into the draw buffer
128131
// (this is useful if you are doing custom rendering and filling the draw buffer yourself)
129132
extern bool renderScene;

src/options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ int transparencyRenderPasses = 8;
6262
bool buildGui = true;
6363
bool userGuiIsOnRightSide = true;
6464
bool buildDefaultGuiPanels = true;
65+
int rightGuiPaneWidth = 500;
6566
bool renderScene = true;
6667
bool openImGuiWindowForUserCallback = true;
6768
bool doDefaultMouseInteraction = true;

src/polyscope.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ bool unshowRequested = false;
5050

5151
// Some state about imgui windows to stack them
5252
constexpr float INITIAL_LEFT_WINDOWS_WIDTH = 305;
53-
constexpr float INITIAL_RIGHT_WINDOWS_WIDTH = 500;
5453

5554
auto prevMainLoopTime = std::chrono::steady_clock::now();
5655
float rollingMainLoopDurationMicrosec = 0.;
@@ -137,13 +136,14 @@ void writePrefsFile() {
137136

138137
void setInitialWindowWidths() {
139138
internal::leftWindowsWidth = INITIAL_LEFT_WINDOWS_WIDTH * options::uiScale;
140-
internal::rightWindowsWidth = INITIAL_RIGHT_WINDOWS_WIDTH * options::uiScale;
139+
internal::rightWindowsWidth = options::rightGuiPaneWidth * options::uiScale;
141140
}
142141

143142
void ensureWindowWidthsSet() {
144143
if (internal::leftWindowsWidth <= 0. || internal::rightWindowsWidth <= 0.) {
145144
setInitialWindowWidths();
146145
}
146+
internal::rightWindowsWidth = options::rightGuiPaneWidth * options::uiScale;
147147
}
148148

149149
// Helper to get a structure map
@@ -683,16 +683,18 @@ void userGuiBegin() {
683683
// right side
684684
userGuiLoc = ImVec2(view::windowWidth - (internal::rightWindowsWidth + internal::imguiStackMargin),
685685
internal::imguiStackMargin);
686+
686687
ImGui::SetNextWindowSize(ImVec2(internal::rightWindowsWidth, 0.));
687688
} else {
688689
// left side
689690
if (options::buildDefaultGuiPanels) {
690-
userGuiLoc = ImVec2(internal::leftWindowsWidth + 3 * internal::imguiStackMargin, internal::imguiStackMargin);
691+
userGuiLoc = ImVec2(internal::leftWindowsWidth + 2 * internal::imguiStackMargin, internal::imguiStackMargin);
691692
} else {
692693
userGuiLoc = ImVec2(internal::imguiStackMargin, internal::imguiStackMargin);
693694
}
694695
}
695696

697+
696698
ImGui::PushID("user_callback");
697699
ImGui::SetNextWindowPos(userGuiLoc);
698700

@@ -702,7 +704,6 @@ void userGuiBegin() {
702704
void userGuiEnd() {
703705

704706
if (options::userGuiIsOnRightSide) {
705-
internal::rightWindowsWidth = INITIAL_RIGHT_WINDOWS_WIDTH * options::uiScale;
706707
internal::lastWindowHeightUser =
707708
internal::imguiStackMargin + ImGui::GetWindowHeight(); // TODO using deprecated function
708709
internal::lastRightSideFreeX = view::windowWidth - internal::imguiStackMargin;

0 commit comments

Comments
 (0)