Skip to content

Commit

Permalink
ENGINES: Enable scrolling in list boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Jul 22, 2018
1 parent 4953a21 commit f84342a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/engines/aurora/kotorjadegui/listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void WidgetListBox::createItemWidgets(uint32 count) {
break;
case kLBItemTypeDefault:
default:
item = new WidgetProtoItem(*_gui, tag);
item = new WidgetProtoItem(*_gui, tag, this);
break;
}

Expand Down Expand Up @@ -382,4 +382,15 @@ void WidgetListBox::applyChangesToItemWidgets() {
}
}

void WidgetListBox::mouseWheel(uint8 state, int x, int y) {
if (y == 0 || !_adjustHeight)
return;

_startIndex = MIN(
MAX(_startIndex - y, 0),
MIN(static_cast<int>(_itemWidgets.size()) - _numVisibleItems, 0)
);
refreshItemWidgets();
}

} // End of namespace Engines
2 changes: 2 additions & 0 deletions src/engines/aurora/kotorjadegui/listbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class WidgetListBox : public KotORJadeWidget {

void subActive(Widget &widget);

void mouseWheel(uint8 state, int x, int y);

void setSoundSelectItem(const Common::UString &resRef);
void setSoundHoverItem(const Common::UString &resRef);
void setSoundClickItem(const Common::UString &resRef);
Expand Down
10 changes: 8 additions & 2 deletions src/engines/aurora/kotorjadegui/protoitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@

namespace Engines {

WidgetProtoItem::WidgetProtoItem(GUI &gui, const Common::UString &tag)
WidgetProtoItem::WidgetProtoItem(GUI &gui, const Common::UString &tag, WidgetListBox *parentList)
: KotORJadeWidget(gui, tag),
_disableHighlight(false),
_hovered(false) {
_hovered(false),
_parentList(parentList) {
}

WidgetProtoItem::~WidgetProtoItem() {
Expand Down Expand Up @@ -104,4 +105,9 @@ void WidgetProtoItem::setDefaultHighlighting(Graphics::Aurora::Highlightable *hi
highlightable->setHighlightUpperBound(1.0f, 1.0f, 0.0f, 1.0f);
}

void WidgetProtoItem::mouseWheel(uint8 state, int x, int y) {
if (_parentList)
_parentList->mouseWheel(state, x, y);
}

} // End of namespace Engines
7 changes: 6 additions & 1 deletion src/engines/aurora/kotorjadegui/protoitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
#define ENGINES_AURORA_KOTORJADEGUI_PROTOITEM_H

#include "src/engines/aurora/kotorjadegui/kotorjadewidget.h"
#include "src/engines/aurora/kotorjadegui/listbox.h"

namespace Engines {

class WidgetProtoItem : public KotORJadeWidget {
public:
WidgetProtoItem(GUI &gui, const Common::UString &tag);
WidgetProtoItem(GUI &gui, const Common::UString &tag, WidgetListBox *parentList = 0);
~WidgetProtoItem();

/** Set item contents. If not overriden this method will only
Expand All @@ -48,6 +49,8 @@ class WidgetProtoItem : public KotORJadeWidget {

void mouseUp(uint8 state, float x, float y);

virtual void mouseWheel(uint8 state, int x, int y);

void setDisableHighlight(bool disableHighlight);

void setSoundHover(const Common::UString &resRef);
Expand All @@ -57,6 +60,8 @@ class WidgetProtoItem : public KotORJadeWidget {
bool _disableHighlight;
bool _hovered;

WidgetListBox *_parentList;

Common::UString _soundHover;
Common::UString _soundClick;

Expand Down

0 comments on commit f84342a

Please sign in to comment.