mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-28 18:29:49 +02:00
Fix some scrolling issues
This commit is contained in:
@@ -327,8 +327,8 @@ void EventProcess(SDL_Event event)
|
|||||||
x *= -1;
|
x *= -1;
|
||||||
y *= -1;
|
y *= -1;
|
||||||
}
|
}
|
||||||
bool positiveDir = y == 0 ? x > 0 : y > 0;
|
|
||||||
engine->onMouseWheel(event.motion.x, event.motion.y, positiveDir ? 1 : -1);
|
engine->onMouseWheel(mousex, mousey, y); // TODO: pass x?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
|
@@ -390,7 +390,7 @@ void GameController::InvertAirSim()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis, bool yAxis)
|
void GameController::AdjustBrushSize(int delta, bool logarithmic, bool xAxis, bool yAxis)
|
||||||
{
|
{
|
||||||
if(xAxis && yAxis)
|
if(xAxis && yAxis)
|
||||||
return;
|
return;
|
||||||
@@ -398,9 +398,9 @@ void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis
|
|||||||
ui::Point newSize(0, 0);
|
ui::Point newSize(0, 0);
|
||||||
ui::Point oldSize = gameModel->GetBrush()->GetRadius();
|
ui::Point oldSize = gameModel->GetBrush()->GetRadius();
|
||||||
if(logarithmic)
|
if(logarithmic)
|
||||||
newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction * ((gameModel->GetBrush()->GetRadius().X/5)>0?gameModel->GetBrush()->GetRadius().X/5:1), direction * ((gameModel->GetBrush()->GetRadius().Y/5)>0?gameModel->GetBrush()->GetRadius().Y/5:1));
|
newSize = gameModel->GetBrush()->GetRadius() + ui::Point(delta * std::max(gameModel->GetBrush()->GetRadius().X / 5, 1), delta * std::max(gameModel->GetBrush()->GetRadius().Y / 5, 1));
|
||||||
else
|
else
|
||||||
newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction, direction);
|
newSize = gameModel->GetBrush()->GetRadius() + ui::Point(delta, delta);
|
||||||
if(newSize.X < 0)
|
if(newSize.X < 0)
|
||||||
newSize.X = 0;
|
newSize.X = 0;
|
||||||
if(newSize.Y < 0)
|
if(newSize.Y < 0)
|
||||||
@@ -423,13 +423,13 @@ void GameController::SetBrushSize(ui::Point newSize)
|
|||||||
gameModel->GetBrush()->SetRadius(newSize);
|
gameModel->GetBrush()->SetRadius(newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::AdjustZoomSize(int direction, bool logarithmic)
|
void GameController::AdjustZoomSize(int delta, bool logarithmic)
|
||||||
{
|
{
|
||||||
int newSize;
|
int newSize;
|
||||||
if(logarithmic)
|
if(logarithmic)
|
||||||
newSize = gameModel->GetZoomSize()+(((gameModel->GetZoomSize()/10)>0?(gameModel->GetZoomSize()/10):1)*direction);
|
newSize = gameModel->GetZoomSize() + std::max(gameModel->GetZoomSize() / 10, 1) * delta;
|
||||||
else
|
else
|
||||||
newSize = gameModel->GetZoomSize()+direction;
|
newSize = gameModel->GetZoomSize() + delta;
|
||||||
if(newSize<5)
|
if(newSize<5)
|
||||||
newSize = 5;
|
newSize = 5;
|
||||||
if(newSize>64)
|
if(newSize>64)
|
||||||
|
@@ -170,7 +170,7 @@ namespace ui
|
|||||||
// Params:
|
// Params:
|
||||||
// localx: Local mouse X position.
|
// localx: Local mouse X position.
|
||||||
// localy: Local mouse Y position.
|
// localy: Local mouse Y position.
|
||||||
// d: The mouse wheel movement value.
|
// d: The vertical scroll offset
|
||||||
///
|
///
|
||||||
virtual void OnMouseWheel(int localx, int localy, int d);
|
virtual void OnMouseWheel(int localx, int localy, int d);
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ namespace ui
|
|||||||
// Params:
|
// Params:
|
||||||
// localx: Local mouse X position.
|
// localx: Local mouse X position.
|
||||||
// localy: Local mouse Y position.
|
// localy: Local mouse Y position.
|
||||||
// d: The mouse wheel movement value.
|
// d: The vertical scroll offset
|
||||||
///
|
///
|
||||||
virtual void OnMouseWheelInside(int localx, int localy, int d);
|
virtual void OnMouseWheelInside(int localx, int localy, int d);
|
||||||
|
|
||||||
|
@@ -115,24 +115,19 @@ void LocalBrowserController::ClearSelection()
|
|||||||
browserModel->ClearSelected();
|
browserModel->ClearSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalBrowserController::NextPage()
|
|
||||||
{
|
|
||||||
if(browserModel->GetPageNum() < browserModel->GetPageCount())
|
|
||||||
browserModel->UpdateSavesList(browserModel->GetPageNum()+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalBrowserController::PrevPage()
|
|
||||||
{
|
|
||||||
if(browserModel->GetPageNum()>1)
|
|
||||||
browserModel->UpdateSavesList(browserModel->GetPageNum()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocalBrowserController::SetPage(int page)
|
void LocalBrowserController::SetPage(int page)
|
||||||
{
|
{
|
||||||
if (page != browserModel->GetPageNum() && page > 0 && page <= browserModel->GetPageCount())
|
if (page != browserModel->GetPageNum() && page > 0 && page <= browserModel->GetPageCount())
|
||||||
browserModel->UpdateSavesList(page);
|
browserModel->UpdateSavesList(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalBrowserController::SetPageRelative(int offset)
|
||||||
|
{
|
||||||
|
int page = std::min(std::max(browserModel->GetPageNum() + offset, 1), browserModel->GetPageCount());
|
||||||
|
if(page != browserModel->GetPageCount())
|
||||||
|
browserModel->UpdateSavesList(page);
|
||||||
|
}
|
||||||
|
|
||||||
void LocalBrowserController::Update()
|
void LocalBrowserController::Update()
|
||||||
{
|
{
|
||||||
if(browserModel->GetSave())
|
if(browserModel->GetSave())
|
||||||
|
@@ -26,9 +26,8 @@ public:
|
|||||||
void OpenSave(SaveFile * stamp);
|
void OpenSave(SaveFile * stamp);
|
||||||
bool GetMoveToFront();
|
bool GetMoveToFront();
|
||||||
void SetMoveToFront(bool move);
|
void SetMoveToFront(bool move);
|
||||||
void NextPage();
|
|
||||||
void PrevPage();
|
|
||||||
void SetPage(int page);
|
void SetPage(int page);
|
||||||
|
void SetPageRelative(int offset);
|
||||||
void Update();
|
void Update();
|
||||||
void Exit();
|
void Exit();
|
||||||
virtual ~LocalBrowserController();
|
virtual ~LocalBrowserController();
|
||||||
|
@@ -49,31 +49,22 @@ LocalBrowserView::LocalBrowserView():
|
|||||||
AddComponent(pageCountLabel);
|
AddComponent(pageCountLabel);
|
||||||
AddComponent(pageTextbox);
|
AddComponent(pageTextbox);
|
||||||
|
|
||||||
class NextPageAction : public ui::ButtonAction
|
class RelativePageAction : public ui::ButtonAction
|
||||||
{
|
{
|
||||||
LocalBrowserView * v;
|
LocalBrowserView * v;
|
||||||
|
int offset;
|
||||||
public:
|
public:
|
||||||
NextPageAction(LocalBrowserView * _v) { v = _v; }
|
RelativePageAction(LocalBrowserView * _v, int _offset): v(_v), offset(_offset) {}
|
||||||
void ActionCallback(ui::Button * sender)
|
void ActionCallback(ui::Button * sender)
|
||||||
{
|
{
|
||||||
v->c->NextPage();
|
v->c->SetPageRelative(offset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
nextButton->SetActionCallback(new NextPageAction(this));
|
nextButton->SetActionCallback(new RelativePageAction(this, 1));
|
||||||
nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
|
nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
|
||||||
nextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
nextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
|
|
||||||
class PrevPageAction : public ui::ButtonAction
|
previousButton->SetActionCallback(new RelativePageAction(this, -1));
|
||||||
{
|
|
||||||
LocalBrowserView * v;
|
|
||||||
public:
|
|
||||||
PrevPageAction(LocalBrowserView * _v) { v = _v; }
|
|
||||||
void ActionCallback(ui::Button * sender)
|
|
||||||
{
|
|
||||||
v->c->PrevPage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
previousButton->SetActionCallback(new PrevPageAction(this));
|
|
||||||
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
|
|
||||||
@@ -254,12 +245,8 @@ void LocalBrowserView::NotifySelectedChanged(LocalBrowserModel * sender)
|
|||||||
|
|
||||||
void LocalBrowserView::OnMouseWheel(int x, int y, int d)
|
void LocalBrowserView::OnMouseWheel(int x, int y, int d)
|
||||||
{
|
{
|
||||||
if(!d)
|
if(d)
|
||||||
return;
|
c->SetPageRelative(d);
|
||||||
if(d<0)
|
|
||||||
c->NextPage();
|
|
||||||
else
|
|
||||||
c->PrevPage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalBrowserView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
void LocalBrowserView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
||||||
|
@@ -128,24 +128,19 @@ void SearchController::Refresh()
|
|||||||
doRefresh = true;
|
doRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchController::PrevPage()
|
|
||||||
{
|
|
||||||
if (searchModel->GetPageNum()>1)
|
|
||||||
searchModel->UpdateSaveList(searchModel->GetPageNum()-1, searchModel->GetLastQuery());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchController::NextPage()
|
|
||||||
{
|
|
||||||
if (searchModel->GetPageNum() < searchModel->GetPageCount())
|
|
||||||
searchModel->UpdateSaveList(searchModel->GetPageNum()+1, searchModel->GetLastQuery());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchController::SetPage(int page)
|
void SearchController::SetPage(int page)
|
||||||
{
|
{
|
||||||
if (page != searchModel->GetPageNum() && page > 0 && page <= searchModel->GetPageCount())
|
if (page != searchModel->GetPageNum() && page > 0 && page <= searchModel->GetPageCount())
|
||||||
searchModel->UpdateSaveList(page, searchModel->GetLastQuery());
|
searchModel->UpdateSaveList(page, searchModel->GetLastQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchController::SetPageRelative(int offset)
|
||||||
|
{
|
||||||
|
int page = std::min(std::max(searchModel->GetPageNum() + offset, 1), searchModel->GetPageCount());
|
||||||
|
if(page != searchModel->GetPageCount())
|
||||||
|
searchModel->UpdateSaveList(page, searchModel->GetLastQuery());
|
||||||
|
}
|
||||||
|
|
||||||
void SearchController::ChangeSort()
|
void SearchController::ChangeSort()
|
||||||
{
|
{
|
||||||
if(searchModel->GetSort() == "new")
|
if(searchModel->GetSort() == "new")
|
||||||
|
@@ -35,9 +35,8 @@ public:
|
|||||||
void DoSearch(String query, bool now = false);
|
void DoSearch(String query, bool now = false);
|
||||||
void DoSearch2(String query);
|
void DoSearch2(String query);
|
||||||
void Refresh();
|
void Refresh();
|
||||||
void NextPage();
|
|
||||||
void PrevPage();
|
|
||||||
void SetPage(int page);
|
void SetPage(int page);
|
||||||
|
void SetPageRelative(int offset);
|
||||||
void ChangeSort();
|
void ChangeSort();
|
||||||
void ShowOwn(bool show);
|
void ShowOwn(bool show);
|
||||||
void ShowFavourite(bool show);
|
void ShowFavourite(bool show);
|
||||||
|
@@ -148,31 +148,22 @@ SearchView::SearchView():
|
|||||||
clearSearchButton->Appearance.BorderInactive = ui::Colour(170,170,170);
|
clearSearchButton->Appearance.BorderInactive = ui::Colour(170,170,170);
|
||||||
AddComponent(clearSearchButton);
|
AddComponent(clearSearchButton);
|
||||||
|
|
||||||
class NextPageAction : public ui::ButtonAction
|
class RelativePageAction : public ui::ButtonAction
|
||||||
{
|
{
|
||||||
SearchView * v;
|
SearchView * v;
|
||||||
|
int offset;
|
||||||
public:
|
public:
|
||||||
NextPageAction(SearchView * _v) { v = _v; }
|
RelativePageAction(SearchView * _v, int _offset): v(_v), offset(_offset) {}
|
||||||
void ActionCallback(ui::Button * sender)
|
void ActionCallback(ui::Button * sender)
|
||||||
{
|
{
|
||||||
v->c->NextPage();
|
v->c->SetPageRelative(offset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
nextButton->SetActionCallback(new NextPageAction(this));
|
nextButton->SetActionCallback(new RelativePageAction(this, 1));
|
||||||
nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
|
nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
|
||||||
nextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
nextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
nextButton->Visible = false;
|
nextButton->Visible = false;
|
||||||
class PrevPageAction : public ui::ButtonAction
|
previousButton->SetActionCallback(new RelativePageAction(this, -1));
|
||||||
{
|
|
||||||
SearchView * v;
|
|
||||||
public:
|
|
||||||
PrevPageAction(SearchView * _v) { v = _v; }
|
|
||||||
void ActionCallback(ui::Button * sender)
|
|
||||||
{
|
|
||||||
v->c->PrevPage();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
previousButton->SetActionCallback(new PrevPageAction(this));
|
|
||||||
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||||
previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||||
previousButton->Visible = false;
|
previousButton->Visible = false;
|
||||||
@@ -787,12 +778,8 @@ void SearchView::OnTick(float dt)
|
|||||||
|
|
||||||
void SearchView::OnMouseWheel(int x, int y, int d)
|
void SearchView::OnMouseWheel(int x, int y, int d)
|
||||||
{
|
{
|
||||||
if(!d)
|
if(d)
|
||||||
return;
|
c->SetPageRelative(d);
|
||||||
if(d<0)
|
|
||||||
c->NextPage();
|
|
||||||
else
|
|
||||||
c->PrevPage();
|
|
||||||
}
|
}
|
||||||
void SearchView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
void SearchView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user