Skip to content

Commit

Permalink
UI: Set min/max zoom levels for preview
Browse files Browse the repository at this point in the history
Prevents the preview from zooming in or out too far.
Min zoom: 10%
Max zoom: 1000%
  • Loading branch information
cg2121 authored and jp9000 committed Mar 5, 2023
1 parent 03a94ae commit b464ba8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions UI/window-basic-preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,8 @@ void OBSBasicPreview::ResetScrollingOffset()

void OBSBasicPreview::SetScalingLevel(int32_t newScalingLevelVal)
{
newScalingLevelVal = std::clamp(newScalingLevelVal, -MAX_SCALING_LEVEL,
MAX_SCALING_LEVEL);
float newScalingAmountVal =
pow(ZOOM_SENSITIVITY, float(newScalingLevelVal));
scalingLevel = newScalingLevelVal;
Expand Down
4 changes: 3 additions & 1 deletion UI/window-basic-preview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class QMouseEvent;
#define ITEM_BOTTOM (1 << 3)
#define ITEM_ROT (1 << 4)

#define ZOOM_SENSITIVITY 1.125f
#define MAX_SCALING_LEVEL 20
#define MAX_SCALING_AMOUNT 10.0f
#define ZOOM_SENSITIVITY pow(MAX_SCALING_AMOUNT, 1.0f / MAX_SCALING_LEVEL)

#define SPACER_LABEL_MARGIN 6.0f

Expand Down

0 comments on commit b464ba8

Please sign in to comment.