Change ScrollPanel scroll behaviour
Small change to replace the momentum-based scrolling with the more common method of scrolling with each scroll wheel step.
This commit is contained in:
parent
1f7e9095da
commit
02b26a9da3
2
.gitignore
vendored
2
.gitignore
vendored
@ -20,6 +20,8 @@ generated/*
|
||||
includes/*
|
||||
recordings/
|
||||
font/*
|
||||
Debug/*
|
||||
Release/*
|
||||
generate
|
||||
Makefile.me
|
||||
*.xcodeproj
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "common/tpt-minmax.h"
|
||||
|
||||
#include "client/Client.h"
|
||||
|
||||
using namespace ui;
|
||||
|
||||
ScrollPanel::ScrollPanel(Point position, Point size):
|
||||
@ -19,9 +21,10 @@ ScrollPanel::ScrollPanel(Point position, Point size):
|
||||
scrollbarSelected(false),
|
||||
scrollbarInitialYOffset(0),
|
||||
scrollbarInitialYClick(0),
|
||||
scrollbarClickLocation(0)
|
||||
scrollbarClickLocation(0),
|
||||
momentumScroll(false)
|
||||
{
|
||||
|
||||
momentumScroll = Client::Ref().GetPrefBool("MomentumScroll", true);
|
||||
}
|
||||
|
||||
int ScrollPanel::GetScrollLimit()
|
||||
@ -43,7 +46,10 @@ void ScrollPanel::XOnMouseWheelInside(int localx, int localy, int d)
|
||||
{
|
||||
if (!d)
|
||||
return;
|
||||
yScrollVel -= d*2;
|
||||
if (momentumScroll)
|
||||
yScrollVel -= d * 2;
|
||||
else
|
||||
yScrollVel -= d * 20;
|
||||
}
|
||||
|
||||
void ScrollPanel::Draw(const Point& screenPos)
|
||||
@ -124,9 +130,6 @@ void ScrollPanel::XOnMouseMoved(int x, int y, int dx, int dy)
|
||||
|
||||
void ScrollPanel::XTick(float dt)
|
||||
{
|
||||
if (yScrollVel > -0.5f && yScrollVel < 0.5)
|
||||
yScrollVel = 0;
|
||||
|
||||
if (xScrollVel > 7.0f) xScrollVel = 7.0f;
|
||||
if (xScrollVel < -7.0f) xScrollVel = -7.0f;
|
||||
if (xScrollVel > -0.5f && xScrollVel < 0.5)
|
||||
@ -140,7 +143,18 @@ void ScrollPanel::XTick(float dt)
|
||||
offsetY += yScrollVel;
|
||||
offsetX += xScrollVel;
|
||||
|
||||
yScrollVel*=0.98f;
|
||||
|
||||
if (momentumScroll)
|
||||
{
|
||||
if (yScrollVel > -0.5f && yScrollVel < 0.5)
|
||||
yScrollVel = 0;
|
||||
yScrollVel *= 0.98f;
|
||||
}
|
||||
else
|
||||
{
|
||||
yScrollVel = 0.0f;
|
||||
}
|
||||
|
||||
xScrollVel*=0.98f;
|
||||
|
||||
if (oldOffsetY!=int(offsetY))
|
||||
|
@ -16,6 +16,7 @@ namespace ui
|
||||
bool isMouseInsideScrollbar;
|
||||
bool isMouseInsideScrollbarArea;
|
||||
bool scrollbarSelected;
|
||||
bool momentumScroll;
|
||||
int scrollbarInitialYOffset;
|
||||
int scrollbarInitialYClick;
|
||||
int scrollbarClickLocation;
|
||||
|
@ -112,6 +112,11 @@ void OptionsController::SetPerfectCircle(bool perfectCircle)
|
||||
model->SetPerfectCircle(perfectCircle);
|
||||
}
|
||||
|
||||
void OptionsController::SetMomentumScroll(bool momentumScroll)
|
||||
{
|
||||
model->SetMomentumScroll(momentumScroll);
|
||||
}
|
||||
|
||||
void OptionsController::Exit()
|
||||
{
|
||||
view->CloseActiveWindow();
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
void SetMouseClickrequired(bool mouseClickRequired);
|
||||
void SetIncludePressure(bool includePressure);
|
||||
void SetPerfectCircle(bool perfectCircle);
|
||||
void SetMomentumScroll(bool momentumScroll);
|
||||
|
||||
void Exit();
|
||||
OptionsView * GetView();
|
||||
|
@ -226,6 +226,17 @@ void OptionsModel::SetPerfectCircle(bool perfectCircle)
|
||||
notifySettingsChanged();
|
||||
}
|
||||
|
||||
bool OptionsModel::GetMomentumScroll()
|
||||
{
|
||||
return Client::Ref().GetPrefBool("MomentumScroll", true);
|
||||
}
|
||||
|
||||
void OptionsModel::SetMomentumScroll(bool state)
|
||||
{
|
||||
Client::Ref().SetPref("MomentumScroll", state);
|
||||
notifySettingsChanged();
|
||||
}
|
||||
|
||||
void OptionsModel::notifySettingsChanged()
|
||||
{
|
||||
for (size_t i = 0; i < observers.size(); i++)
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
void SetIncludePressure(bool includePressure);
|
||||
bool GetPerfectCircle();
|
||||
void SetPerfectCircle(bool perfectCircle);
|
||||
bool GetMomentumScroll();
|
||||
void SetMomentumScroll(bool momentumScroll);
|
||||
virtual ~OptionsModel();
|
||||
};
|
||||
|
||||
|
@ -239,6 +239,17 @@ OptionsView::OptionsView():
|
||||
scrollPanel->AddChild(tempLabel);
|
||||
scrollPanel->AddChild(showAvatars);
|
||||
|
||||
currentY += 20;
|
||||
momentumScroll = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Momentum/Old Scrolling", "");
|
||||
autowidth(momentumScroll);
|
||||
momentumScroll->SetActionCallback({ [this] { c->SetMomentumScroll(momentumScroll->GetChecked()); } });
|
||||
tempLabel = new ui::Label(ui::Point(momentumScroll->Position.X + Graphics::textwidth(momentumScroll->GetText()) + 20, currentY), ui::Point(1, 16), "\bg- Accelerating instead of step scroll");
|
||||
autowidth(tempLabel);
|
||||
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
scrollPanel->AddChild(tempLabel);
|
||||
scrollPanel->AddChild(momentumScroll);
|
||||
|
||||
currentY+=20;
|
||||
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", "");
|
||||
autowidth(mouseClickRequired);
|
||||
@ -338,6 +349,7 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
|
||||
mouseClickRequired->SetChecked(sender->GetMouseClickRequired());
|
||||
includePressure->SetChecked(sender->GetIncludePressure());
|
||||
perfectCirclePressure->SetChecked(sender->GetPerfectCircle());
|
||||
momentumScroll->SetChecked(sender->GetMomentumScroll());
|
||||
}
|
||||
|
||||
void OptionsView::AttachController(OptionsController * c_)
|
||||
|
@ -31,6 +31,7 @@ class OptionsView: public ui::Window
|
||||
ui::Checkbox * fastquit;
|
||||
ui::DropDown * decoSpace;
|
||||
ui::Checkbox * showAvatars;
|
||||
ui::Checkbox * momentumScroll;
|
||||
ui::Checkbox * mouseClickRequired;
|
||||
ui::Checkbox * includePressure;
|
||||
ui::Checkbox * perfectCirclePressure;
|
||||
|
Loading…
Reference in New Issue
Block a user