Skip to content

Commit

Permalink
Merge pull request kallisti5#82 from kallisti5/dropdown-improvements
Browse files Browse the repository at this point in the history
Dropdown widget improvements
  • Loading branch information
midwan authored Sep 12, 2024
2 parents 3a7296c + 7bb40c5 commit 9a3ffaa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
33 changes: 21 additions & 12 deletions include/guisan/widgets/dropdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
* Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
*
* Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
* .)j(] .d_/ '-( P . S
Expand Down Expand Up @@ -131,6 +131,11 @@ namespace gcn
*/
void setSelected(int selected) const;

/*
* Clears any selected item
*/
void clearSelected() const;

/**
* Sets the list model to use when displaying the list.
*
Expand Down Expand Up @@ -175,6 +180,20 @@ namespace gcn
*/
void removeSelectionListener(SelectionListener* selectionListener);

/*
* Returns the current Dropdown status
*/
bool isDroppedDown() const;

/**
* Sets the DropDown Widget to dropped-down mode.
*/
virtual void dropDown();

/**
* Sets the DropDown Widget to folded-up mode.
*/
virtual void foldUp();

// Inherited from Widget

Expand Down Expand Up @@ -242,16 +261,6 @@ namespace gcn
*/
virtual void drawButton(Graphics *graphics);

/**
* Sets the DropDown Widget to dropped-down mode.
*/
virtual void dropDown();

/**
* Sets the DropDown Widget to folded-up mode.
*/
virtual void foldUp();

bool mDroppedDown;

/**
Expand Down
11 changes: 10 additions & 1 deletion src/widgets/dropdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ namespace gcn
}
}

void DropDown::clearSelected() const
{
mListBox->setSelected(-1);
}

void DropDown::keyPressed(KeyEvent& keyEvent)
{
if (keyEvent.isConsumed())
Expand Down Expand Up @@ -456,6 +461,11 @@ namespace gcn
mListBox->requestFocus();
}

bool DropDown::isDroppedDown() const
{
return mDroppedDown;
}

void DropDown::foldUp()
{
if (mDroppedDown)
Expand Down Expand Up @@ -620,4 +630,3 @@ namespace gcn
}
}
}

0 comments on commit 9a3ffaa

Please sign in to comment.