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/*
|
includes/*
|
||||||
recordings/
|
recordings/
|
||||||
font/*
|
font/*
|
||||||
|
Debug/*
|
||||||
|
Release/*
|
||||||
generate
|
generate
|
||||||
Makefile.me
|
Makefile.me
|
||||||
*.xcodeproj
|
*.xcodeproj
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "common/tpt-minmax.h"
|
#include "common/tpt-minmax.h"
|
||||||
|
|
||||||
|
#include "client/Client.h"
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
ScrollPanel::ScrollPanel(Point position, Point size):
|
ScrollPanel::ScrollPanel(Point position, Point size):
|
||||||
@ -19,9 +21,10 @@ ScrollPanel::ScrollPanel(Point position, Point size):
|
|||||||
scrollbarSelected(false),
|
scrollbarSelected(false),
|
||||||
scrollbarInitialYOffset(0),
|
scrollbarInitialYOffset(0),
|
||||||
scrollbarInitialYClick(0),
|
scrollbarInitialYClick(0),
|
||||||
scrollbarClickLocation(0)
|
scrollbarClickLocation(0),
|
||||||
|
momentumScroll(false)
|
||||||
{
|
{
|
||||||
|
momentumScroll = Client::Ref().GetPrefBool("MomentumScroll", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScrollPanel::GetScrollLimit()
|
int ScrollPanel::GetScrollLimit()
|
||||||
@ -43,7 +46,10 @@ void ScrollPanel::XOnMouseWheelInside(int localx, int localy, int d)
|
|||||||
{
|
{
|
||||||
if (!d)
|
if (!d)
|
||||||
return;
|
return;
|
||||||
yScrollVel -= d*2;
|
if (momentumScroll)
|
||||||
|
yScrollVel -= d * 2;
|
||||||
|
else
|
||||||
|
yScrollVel -= d * 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollPanel::Draw(const Point& screenPos)
|
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)
|
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 < -7.0f) xScrollVel = -7.0f;
|
if (xScrollVel < -7.0f) xScrollVel = -7.0f;
|
||||||
if (xScrollVel > -0.5f && xScrollVel < 0.5)
|
if (xScrollVel > -0.5f && xScrollVel < 0.5)
|
||||||
@ -140,7 +143,18 @@ void ScrollPanel::XTick(float dt)
|
|||||||
offsetY += yScrollVel;
|
offsetY += yScrollVel;
|
||||||
offsetX += xScrollVel;
|
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;
|
xScrollVel*=0.98f;
|
||||||
|
|
||||||
if (oldOffsetY!=int(offsetY))
|
if (oldOffsetY!=int(offsetY))
|
||||||
|
@ -16,6 +16,7 @@ namespace ui
|
|||||||
bool isMouseInsideScrollbar;
|
bool isMouseInsideScrollbar;
|
||||||
bool isMouseInsideScrollbarArea;
|
bool isMouseInsideScrollbarArea;
|
||||||
bool scrollbarSelected;
|
bool scrollbarSelected;
|
||||||
|
bool momentumScroll;
|
||||||
int scrollbarInitialYOffset;
|
int scrollbarInitialYOffset;
|
||||||
int scrollbarInitialYClick;
|
int scrollbarInitialYClick;
|
||||||
int scrollbarClickLocation;
|
int scrollbarClickLocation;
|
||||||
|
@ -112,6 +112,11 @@ void OptionsController::SetPerfectCircle(bool perfectCircle)
|
|||||||
model->SetPerfectCircle(perfectCircle);
|
model->SetPerfectCircle(perfectCircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsController::SetMomentumScroll(bool momentumScroll)
|
||||||
|
{
|
||||||
|
model->SetMomentumScroll(momentumScroll);
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsController::Exit()
|
void OptionsController::Exit()
|
||||||
{
|
{
|
||||||
view->CloseActiveWindow();
|
view->CloseActiveWindow();
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
void SetMouseClickrequired(bool mouseClickRequired);
|
void SetMouseClickrequired(bool mouseClickRequired);
|
||||||
void SetIncludePressure(bool includePressure);
|
void SetIncludePressure(bool includePressure);
|
||||||
void SetPerfectCircle(bool perfectCircle);
|
void SetPerfectCircle(bool perfectCircle);
|
||||||
|
void SetMomentumScroll(bool momentumScroll);
|
||||||
|
|
||||||
void Exit();
|
void Exit();
|
||||||
OptionsView * GetView();
|
OptionsView * GetView();
|
||||||
|
@ -226,6 +226,17 @@ void OptionsModel::SetPerfectCircle(bool perfectCircle)
|
|||||||
notifySettingsChanged();
|
notifySettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OptionsModel::GetMomentumScroll()
|
||||||
|
{
|
||||||
|
return Client::Ref().GetPrefBool("MomentumScroll", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsModel::SetMomentumScroll(bool state)
|
||||||
|
{
|
||||||
|
Client::Ref().SetPref("MomentumScroll", state);
|
||||||
|
notifySettingsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsModel::notifySettingsChanged()
|
void OptionsModel::notifySettingsChanged()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < observers.size(); i++)
|
for (size_t i = 0; i < observers.size(); i++)
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
void SetIncludePressure(bool includePressure);
|
void SetIncludePressure(bool includePressure);
|
||||||
bool GetPerfectCircle();
|
bool GetPerfectCircle();
|
||||||
void SetPerfectCircle(bool perfectCircle);
|
void SetPerfectCircle(bool perfectCircle);
|
||||||
|
bool GetMomentumScroll();
|
||||||
|
void SetMomentumScroll(bool momentumScroll);
|
||||||
virtual ~OptionsModel();
|
virtual ~OptionsModel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -239,6 +239,17 @@ OptionsView::OptionsView():
|
|||||||
scrollPanel->AddChild(tempLabel);
|
scrollPanel->AddChild(tempLabel);
|
||||||
scrollPanel->AddChild(showAvatars);
|
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;
|
currentY+=20;
|
||||||
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", "");
|
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", "");
|
||||||
autowidth(mouseClickRequired);
|
autowidth(mouseClickRequired);
|
||||||
@ -338,6 +349,7 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
|
|||||||
mouseClickRequired->SetChecked(sender->GetMouseClickRequired());
|
mouseClickRequired->SetChecked(sender->GetMouseClickRequired());
|
||||||
includePressure->SetChecked(sender->GetIncludePressure());
|
includePressure->SetChecked(sender->GetIncludePressure());
|
||||||
perfectCirclePressure->SetChecked(sender->GetPerfectCircle());
|
perfectCirclePressure->SetChecked(sender->GetPerfectCircle());
|
||||||
|
momentumScroll->SetChecked(sender->GetMomentumScroll());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsView::AttachController(OptionsController * c_)
|
void OptionsView::AttachController(OptionsController * c_)
|
||||||
|
@ -31,6 +31,7 @@ class OptionsView: public ui::Window
|
|||||||
ui::Checkbox * fastquit;
|
ui::Checkbox * fastquit;
|
||||||
ui::DropDown * decoSpace;
|
ui::DropDown * decoSpace;
|
||||||
ui::Checkbox * showAvatars;
|
ui::Checkbox * showAvatars;
|
||||||
|
ui::Checkbox * momentumScroll;
|
||||||
ui::Checkbox * mouseClickRequired;
|
ui::Checkbox * mouseClickRequired;
|
||||||
ui::Checkbox * includePressure;
|
ui::Checkbox * includePressure;
|
||||||
ui::Checkbox * perfectCirclePressure;
|
ui::Checkbox * perfectCirclePressure;
|
||||||
|
Reference in New Issue
Block a user