From 38366353e99be681c3c2267c10a3118344aecf7f Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Thu, 12 Sep 2024 17:45:54 +0200 Subject: [PATCH 1/4] Dropdown widget improvements - Added a clearSelected function, to clear any previously selected item and return it to the initial state (-1) - Exposed isDroppedDown, dropDown and foldUp functions, so that an application can programmatically call them to manipulate the state, depending on other events (e.g. keyboard events, joystick events) --- include/guisan/widgets/dropdown.hpp | 29 +++++++++++++++++++---------- src/widgets/dropdown.cpp | 11 ++++++++++- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/guisan/widgets/dropdown.hpp b/include/guisan/widgets/dropdown.hpp index 58e4574..43098f0 100644 --- a/include/guisan/widgets/dropdown.hpp +++ b/include/guisan/widgets/dropdown.hpp @@ -131,6 +131,11 @@ namespace gcn */ void setSelected(int selected); + /* + * Clears any selected item + */ + void clearSelected(void) const; + /** * Sets the list model to use when displaying the list. * @@ -175,6 +180,20 @@ namespace gcn */ void removeSelectionListener(SelectionListener* selectionListener); + /* + * Returns the current Dropdown status + */ + bool isDroppedDown(); + + /** + * 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 @@ -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; /** diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 653e33b..18b5837 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -284,6 +284,11 @@ namespace gcn } } + void DropDown::clearSelected() const + { + mListBox->setSelected(-1); + } + void DropDown::keyPressed(KeyEvent& keyEvent) { if (keyEvent.isConsumed()) @@ -456,6 +461,11 @@ namespace gcn mListBox->requestFocus(); } + bool DropDown::isDroppedDown() + { + return mDroppedDown; + } + void DropDown::foldUp() { if (mDroppedDown) @@ -620,4 +630,3 @@ namespace gcn } } } - From d0075978886a49378ce52d2ed5d640746954c36c Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Thu, 12 Sep 2024 17:50:05 +0200 Subject: [PATCH 2/4] Update include/guisan/widgets/dropdown.hpp Co-authored-by: Joris Dauphin --- include/guisan/widgets/dropdown.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/guisan/widgets/dropdown.hpp b/include/guisan/widgets/dropdown.hpp index 43098f0..77fe8e6 100644 --- a/include/guisan/widgets/dropdown.hpp +++ b/include/guisan/widgets/dropdown.hpp @@ -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

Date: Thu, 12 Sep 2024 17:50:11 +0200 Subject: [PATCH 3/4] Update include/guisan/widgets/dropdown.hpp Co-authored-by: Joris Dauphin --- include/guisan/widgets/dropdown.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/guisan/widgets/dropdown.hpp b/include/guisan/widgets/dropdown.hpp index 77fe8e6..c3ff1ca 100644 --- a/include/guisan/widgets/dropdown.hpp +++ b/include/guisan/widgets/dropdown.hpp @@ -183,7 +183,7 @@ namespace gcn /* * Returns the current Dropdown status */ - bool isDroppedDown(); + bool isDroppedDown() const; /** * Sets the DropDown Widget to dropped-down mode. From 7bb40c534e17165473875e6790f6635890df5c9b Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Thu, 12 Sep 2024 17:58:08 +0200 Subject: [PATCH 4/4] added missing const to isDroppedDown --- src/widgets/dropdown.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 0538c44..6a2de42 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -461,7 +461,7 @@ namespace gcn mListBox->requestFocus(); } - bool DropDown::isDroppedDown() + bool DropDown::isDroppedDown() const { return mDroppedDown; }