Skip to content

Commit

Permalink
KOTOR: Load listbox widget scrollbar, offset items by its size
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii authored and DrMcCoy committed May 11, 2018
1 parent c7a3204 commit 1107ecf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/engines/kotor/gui/widgets/listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ namespace Engines {

namespace KotOR {

WidgetListBox::WidgetListBox(::Engines::GUI &gui, const Common::UString &tag) :
KotORWidget(gui, tag), _protoItem(0), _itemCount(0), _padding(0) {
WidgetListBox::WidgetListBox(::Engines::GUI &gui, const Common::UString &tag)
: KotORWidget(gui, tag), _protoItem(0), _scrollBar(0), _itemCount(0),
_padding(0), _leftScrollBar(false) {
}

WidgetListBox::~WidgetListBox() {
Expand All @@ -47,8 +48,12 @@ void WidgetListBox::load(const Aurora::GFF3Struct &gff) {
_protoItem = &gff.getStruct("PROTOITEM");
}

if (gff.hasField("SCROLLBAR")) {
if (gff.hasField("LEFTSCROLLBAR")) {
_leftScrollBar = gff.getBool("LEFTSCROLLBAR");
}

if (gff.hasField("SCROLLBAR")) {
_scrollBar = &gff.getStruct("SCROLLBAR");
}

if (gff.hasField("PADDING")) {
Expand Down Expand Up @@ -81,6 +86,10 @@ KotORWidget *WidgetListBox::createItem(Common::UString name) {
float x, y, z;
getPosition(x, y, z);

if (_scrollBar && _leftScrollBar)
x += _scrollBar->getStruct("BORDER").getSint("DIMENSION") +
_scrollBar->getStruct("EXTENT").getSint("WIDTH");

assert(getHeight() > 0);

y = y - _itemCount * (item->getHeight() + _padding) + getHeight() - item->getHeight();
Expand Down
2 changes: 2 additions & 0 deletions src/engines/kotor/gui/widgets/listbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ class WidgetListBox : public KotORWidget {

private:
const Aurora::GFF3Struct *_protoItem;
const Aurora::GFF3Struct *_scrollBar;

int _itemCount;
int _padding;
bool _leftScrollBar;
};

} // End of namespace KotOR
Expand Down

0 comments on commit 1107ecf

Please sign in to comment.