Skip to content

Commit

Permalink
Fix ui fluctuations
Browse files Browse the repository at this point in the history
  • Loading branch information
SinghRajenM committed Nov 14, 2024
1 parent 14e0f81 commit 9f7e5b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/NppJsonViewer/JsonViewDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,9 @@ void JsonViewDlg::HandleZoomOnScroll(WPARAM wParam) const
int pos = GetZoomLevel(); // Current zoom level
int delta = GET_WHEEL_DELTA_WPARAM(wParam);

const auto& zoomRange = m_pTreeViewZoom->GetRange();
const bool isZoomIn = delta > 0;
const auto& zoomRange = m_pTreeViewZoom->GetRange();
const bool isZoomIn = delta > 0;
bool bRefreshUI = true;

if (isZoomIn && pos < zoomRange.m_nMaxZoom)
{
Expand All @@ -952,8 +953,15 @@ void JsonViewDlg::HandleZoomOnScroll(WPARAM wParam) const
{
pos -= 10; // Zoom out
}
else
{
bRefreshUI = false;
}

UpdateUIOnZoom(pos);
if (bRefreshUI)
{
UpdateUIOnZoom(pos);
}
}

void JsonViewDlg::HandleTreeEvents(LPARAM lParam) const
Expand Down
1 change: 1 addition & 0 deletions src/NppJsonViewer/SliderCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void SliderCtrl::OnInit(HWND hParent, int sliderID, int sliderInfoID)
// Set slider range and initial position
SendMessage(m_hSelf, TBM_SETRANGE, TRUE, MAKELPARAM(m_sliderRange.m_nMinZoom, m_sliderRange.m_nMaxZoom));
SendMessage(m_hSelf, TBM_SETPOS, TRUE, m_sliderRange.m_nDefault);
SendMessage(m_hSelf, TBM_SETPAGESIZE, 0, m_sliderRange.m_nSteps);

UpdateInfo(m_sliderRange.m_nDefault);

Expand Down
1 change: 1 addition & 0 deletions src/NppJsonViewer/SliderCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct SliderRange
int m_nDefault = 100;
int m_nMinZoom = 80;
int m_nMaxZoom = 250;
int m_nSteps = 10;
}; // namespace SliderRange

class SliderCtrl
Expand Down
2 changes: 1 addition & 1 deletion src/NppJsonViewer/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ BEGIN
CONTROL "",IDC_DIVIDER,"Static",SS_ETCHEDVERT,56,1,2,16
EDITTEXT IDC_EDT_SEARCH,60,2,99,12,ES_AUTOHSCROLL
PUSHBUTTON "",IDC_BTN_SEARCH,160,2,16,12,BS_ICON
CONTROL "",IDC_ZOOM_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_NOTICKS,2,16,58,12
CONTROL "",IDC_ZOOM_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,2,16,58,12
RTEXT "100%",IDC_ZOOM_PERCENT,60,16,22,12,SS_NOTIFY | NOT WS_GROUP,WS_EX_RIGHT
CONTROL "",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | WS_HSCROLL | WS_TABSTOP,2,30,173,264,WS_EX_CLIENTEDGE
EDITTEXT IDC_EDT_NODEPATH,2,296,173,12,ES_AUTOHSCROLL | ES_READONLY
Expand Down

0 comments on commit 9f7e5b9

Please sign in to comment.