Skip to content

Commit 40f4f27

Browse files
committed
Scale everthing with the dpiScale factor
1 parent 979d5f2 commit 40f4f27

18 files changed

Lines changed: 44 additions & 41 deletions

examples/demo-app/demo_app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ void callback() {
780780
static int loadedMat = 1;
781781
static bool depthClick = false;
782782

783-
ImGui::PushItemWidth(100);
783+
ImGui::PushItemWidth(100 * polyscope::state::globalContext.dpiScale);
784784

785785
ImGui::InputInt("num points", &numPoints);
786786
ImGui::InputFloat("param value", &param);

include/polyscope/parameterization_quantity.ipp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ParameterizationQuantity<QuantityT>::ParameterizationQuantity(QuantityT& quantit
6161
template <typename QuantityT>
6262
void ParameterizationQuantity<QuantityT>::buildParameterizationUI() {
6363
64-
ImGui::PushItemWidth(100);
64+
ImGui::PushItemWidth(100 * state::globalContext.dpiScale);
6565
6666
// Modulo stripey width
6767
if (ImGui::DragFloat("period", &checkerSize.get(), .001, 0.0001, 1.0, "%.4f",
@@ -82,7 +82,7 @@ void ParameterizationQuantity<QuantityT>::buildParameterizationUI() {
8282
setCheckerColors(getCheckerColors());
8383
break;
8484
case ParamVizStyle::CHECKER_ISLANDS:
85-
ImGui::PushItemWidth(100);
85+
ImGui::PushItemWidth(100 * state::globalContext.dpiScale);
8686
if (ImGui::DragFloat("alt darkness", &altDarkness.get(), 0.01, 0., 1.)) {
8787
altDarkness.manuallyChanged();
8888
requestRedraw();
@@ -103,7 +103,7 @@ void ParameterizationQuantity<QuantityT>::buildParameterizationUI() {
103103
case ParamVizStyle::LOCAL_CHECK:
104104
case ParamVizStyle::LOCAL_RAD: {
105105
// Angle slider
106-
ImGui::PushItemWidth(100);
106+
ImGui::PushItemWidth(100 * state::globalContext.dpiScale);
107107
ImGui::SliderAngle("angle shift", &localRot, -180,
108108
180); // displays in degrees, works in radians TODO refresh/update/persist
109109
if (ImGui::DragFloat("alt darkness", &altDarkness.get(), 0.01, 0., 1.)) {

include/polyscope/scalar_quantity.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void ScalarQuantity<QuantityT>::buildScalarUI() {
147147
// Isolines
148148
if (isolinesEnabled.get()) {
149149

150-
ImGui::PushItemWidth(100);
150+
ImGui::PushItemWidth(100 * state::globalContext.dpiScale);
151151

152152

153153
auto styleName = [](const IsolineStyle& m) -> std::string {

src/camera_view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void CameraView::buildCustomUI() {
366366

367367
void CameraView::buildCustomOptionsUI() {
368368

369-
ImGui::PushItemWidth(150);
369+
ImGui::PushItemWidth(150 * state::globalContext.dpiScale);
370370

371371
if (widgetFocalLengthUpper == -777) widgetFocalLengthUpper = 2. * (*widgetFocalLength.get().getValuePtr());
372372
if (ImGui::SliderFloat("widget focal length", widgetFocalLength.get().getValuePtr(), 0, widgetFocalLengthUpper,

src/curve_network.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ void CurveNetwork::buildCustomUI() {
402402
setColor(getColor());
403403
}
404404
ImGui::SameLine();
405-
ImGui::PushItemWidth(100);
405+
ImGui::PushItemWidth(100 * state::globalContext.dpiScale);
406406
if (ImGui::SliderFloat("Radius", radius.get().getValuePtr(), 0.0, .1, "%.5f",
407407
ImGuiSliderFlags_Logarithmic | ImGuiSliderFlags_NoRoundToFormat)) {
408408
radius.manuallyChanged();

src/file_helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void filenamePromptCallback(char* buff, size_t len) {
1414
static bool windowOpen = true;
1515
ImGui::Begin("Enter filename", &windowOpen, ImGuiWindowFlags_AlwaysAutoResize);
1616

17-
ImGui::PushItemWidth(500);
17+
ImGui::PushItemWidth(500 * state::globalContext.dpiScale);
1818
ImGui::InputText("##filename", buff, len);
1919

2020
if (ImGui::Button("Ok")) {

src/image_quantity_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void ImageQuantity::buildImageUI() {
114114

115115
if (getShowFullscreen()) {
116116

117-
ImGui::PushItemWidth(100);
117+
ImGui::PushItemWidth(100 * state::globalContext.dpiScale);
118118
if (ImGui::SliderFloat("transparency", &transparency.get(), 0.f, 1.f)) {
119119
transparency.manuallyChanged();
120120
requestRedraw();

src/messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void buildWarningUI(std::string warningBaseString, std::string warningDetailStri
174174
}
175175

176176
// Nice button sizing
177-
float buttonWidth = 120;
177+
float buttonWidth = 120 * state::globalContext.dpiScale;
178178
float buttonOffset = (warningModalSize.x - buttonWidth) / 2.0;
179179
buttonOffset = std::max(buttonOffset, 0.0f);
180180
doIndent = buttonOffset > 0;

src/point_cloud.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void PointCloud::buildCustomUI() {
266266
setPointColor(getPointColor());
267267
}
268268
ImGui::SameLine();
269-
ImGui::PushItemWidth(70);
269+
ImGui::PushItemWidth(70 * state::globalContext.dpiScale);
270270
if (ImGui::SliderFloat("Radius", pointRadius.get().getValuePtr(), 0.0, .1, "%.5f",
271271
ImGuiSliderFlags_Logarithmic | ImGuiSliderFlags_NoRoundToFormat)) {
272272
pointRadius.manuallyChanged();

src/polyscope.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ bool unshowRequested = false;
4747
float imguiStackMargin = 10;
4848
float lastWindowHeightPolyscope = 200;
4949
float lastWindowHeightUser = 200;
50-
float leftWindowsWidth = 305;
51-
float rightWindowsWidth = 500;
50+
constexpr float LEFT_WINDOWS_WIDTH = 305;
51+
constexpr float RIGHT_WINDOWS_WIDTH = 500;
52+
float leftWindowsWidth = LEFT_WINDOWS_WIDTH;
53+
float rightWindowsWidth = RIGHT_WINDOWS_WIDTH;
5254

5355
auto lastMainLoopIterTime = std::chrono::steady_clock::now();
5456

@@ -554,7 +556,7 @@ void userGuiBegin() {
554556
void userGuiEnd() {
555557

556558
if (options::userGuiIsOnRightSide) {
557-
rightWindowsWidth = ImGui::GetWindowWidth();
559+
rightWindowsWidth = RIGHT_WINDOWS_WIDTH * state::globalContext.dpiScale;
558560
lastWindowHeightUser = imguiStackMargin + ImGui::GetWindowHeight();
559561
} else {
560562
lastWindowHeightUser = 0;
@@ -645,7 +647,7 @@ void buildPolyscopeGui() {
645647
ImGui::Text("Rolling: %.1f ms/frame (%.1f fps)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
646648
ImGui::Text("Last: %.1f ms/frame (%.1f fps)", ImGui::GetIO().DeltaTime * 1000.f, 1.f / ImGui::GetIO().DeltaTime);
647649

648-
ImGui::PushItemWidth(40);
650+
ImGui::PushItemWidth(40 * state::globalContext.dpiScale);
649651
if (ImGui::InputInt("max fps", &options::maxFPS, 0)) {
650652
if (options::maxFPS < 1 && options::maxFPS != -1) {
651653
options::maxFPS = -1;
@@ -679,7 +681,7 @@ void buildPolyscopeGui() {
679681

680682

681683
lastWindowHeightPolyscope = imguiStackMargin + ImGui::GetWindowHeight();
682-
leftWindowsWidth = ImGui::GetWindowWidth();
684+
leftWindowsWidth = LEFT_WINDOWS_WIDTH * state::globalContext.dpiScale;
683685

684686
ImGui::End();
685687
}
@@ -748,7 +750,7 @@ void buildStructureGui() {
748750
ImGui::PopID();
749751
}
750752

751-
leftWindowsWidth = ImGui::GetWindowWidth();
753+
leftWindowsWidth = LEFT_WINDOWS_WIDTH * state::globalContext.dpiScale;
752754

753755
ImGui::End();
754756
}
@@ -767,7 +769,7 @@ void buildPickGui() {
767769
ImGui::Separator();
768770
selection.first->buildPickUI(selection.second);
769771

770-
rightWindowsWidth = ImGui::GetWindowWidth();
772+
rightWindowsWidth = RIGHT_WINDOWS_WIDTH * state::globalContext.dpiScale;
771773
ImGui::End();
772774
}
773775
}

0 commit comments

Comments
 (0)