roymacdonald / ofxdropdown Goto Github PK
View Code? Open in Web Editor NEWopenFramewoks addon that creates dropdown menus using ofxGui
License: Other
openFramewoks addon that creates dropdown menus using ofxGui
License: Other
I understand how to fill the dropdown menu with values via the ->add function.
But what about changing / updating the content during run time?
Right now I am testing.
IP_strDropdown->clear();
IP_strDropdown->add("offline");
vector<string> ip_list = getLocalIPs();
for(int i=0; i<ip_list.size(); i++){
ofLog()<<ip_list[i];
IP_strDropdown->add(ofTrim(ip_list[i]));
}
ofLog()<<"myIP "<<myIP<<" IP_strDropdown "<<IP_strDropdown->getDropdownParameters().size();
IP_strDropdown->getDropdownParameters().size()
does report the updated size but the gui element does not show the new options.
thanks for your advice.
Is it possible to get the name / id of the selected option? It would be helpful for deselecting the option if it is not in the updated options list.
When I try the example-basic on Ubuntu, I get this :
In file included from /home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/example_Basic/src/ofApp.h:5,
from /home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/example_Basic/src/main.cpp:2:
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/src/ofxDropdown.h: In instantiation of ‘class ofxDropdown_<std::__cxx11::basic_string<char> >’:
/usr/include/c++/9/bits/unique_ptr.h:79:16: required from ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = ofxDropdown_<std::__cxx11::basic_string<char> >]’
/usr/include/c++/9/bits/unique_ptr.h:292:17: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = ofxDropdown_<std::__cxx11::basic_string<char> >; _Dp = std::default_delete<ofxDropdown_<std::__cxx11::basic_string<char> > >]’
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/example_Basic/src/ofApp.h:6:7: required from here
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/src/ofxDropdown.h:129:7: error: ‘void ofxDropdown_<T>::registerMouseEvents() [with T = std::__cxx11::basic_string<char>]’ marked ‘override’, but does not override
129 | void registerMouseEvents() override;
| ^~~~~~~~~~~~~~~~~~~
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/src/ofxDropdown.h:130:7: error: ‘void ofxDropdown_<T>::unregisterMouseEvents() [with T = std::__cxx11::basic_string<char>]’ marked ‘override’, but does not override
130 | void unregisterMouseEvents() override;
| ^~~~~~~~~~~~~~~~~~~~~
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/src/ofxDropdown.h: In instantiation of ‘class ofxDropdown_<int>’:
/usr/include/c++/9/bits/unique_ptr.h:79:16: required from ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = ofxDropdown_<int>]’
/usr/include/c++/9/bits/unique_ptr.h:292:17: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = ofxDropdown_<int>; _Dp = std::default_delete<ofxDropdown_<int> >]’
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/example_Basic/src/ofApp.h:6:7: required from here
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/src/ofxDropdown.h:129:7: error: ‘void ofxDropdown_<T>::registerMouseEvents() [with T = int]’ marked ‘override’, but does not override
129 | void registerMouseEvents() override;
| ^~~~~~~~~~~~~~~~~~~
/home/anas/of_v0.11.0_linux64gcc6_release/addons/ofxDropdown/src/ofxDropdown.h:130:7: error: ‘void ofxDropdown_<T>::unregisterMouseEvents() [with T = int]’ marked ‘override’, but does not override
130 | void unregisterMouseEvents() override;
| ^~~~~~~~~~~~~~~~~~~~~
Process failed with exit code 1.
If there are other panels where the dropdown is shown, it is not possible to click on those items. Even if I changed the order to make sure the dropdown is drawn last, the mouse movements are captured by the other gui. Maybe the first component to be drawn is the one that gets the the mouse input.
For now I'll tell the user to collapse the conflicting panel if they want to change the song.
When I load the settings, the correct options appear selected, however the function getAllSelected() return empty (for fields that allow multi selection) and channels[i].get()->selectedValue also return empty. I have to click on the highlighted selection for it to be returned.
for(int i = 0; i < 24; i++)
{
unique_ptr<ofxIntDropdown> aux;
aux = make_unique<ofxIntDropdown>("Fixture "+ ofToString(i+1));
aux->disableMultipleSelection();
aux->enableCollapseOnSelection();
channels.push_back(std::move(aux));
}
unique_ptr<ofxIntDropdown> aux;
aux = make_unique<ofxIntDropdown>("Grouping "+ ofToString(1));
aux->enableMultipleSelection();
aux->disableCollapseOnSelection();
channels.push_back(std::move(aux));
This is how i'm creating and adding the options to the panel.
Maybe it helps someone...
// .h
#pragma once
#include "ofMain.h"
#include "ofxGui.h"
#include "ofxDropdown.h"
class ofApp : public ofBaseApp {
public:
void setup();
void draw();
void onSongChange(ofFile & file);
ofxPanel gui;
unique_ptr<ofxDropdown_<ofFile>> songDropdown;
};
// .cpp
#include "ofApp.h"
void ofApp::setup() {
songDropdown = make_unique<ofxDropdown_<ofFile>>("Song");
songDropdown->enableCollapseOnSelection(true);
songDropdown->populateFromDirectory("/home/bla/myOfProject/bin/data/sounds", { "mp3"});
songDropdown->addListener(this, &ofApp::onSongChange);
gui.setup("gui", "DropdownsSettings.xml");
gui.add(songDropdown.get());
}
void ofApp::draw() {
gui.draw();
}
void ofApp::onSongChange(ofFile & file) {
std::cout << file.path() << std::endl;
}
Hi,
Thanks for the addon Roy!
As referenced here, windows doesn't understand the operator <<
for ofFile
.
Not a big deal in my case, just commented out the relevant code ( ofxDropdpwn::addFromDir and ofxDropdown::addFromDir ), but it would be nice to add it to the OF source code for windows?
This is the error message I am receiving when I compile the example:
addons/ofxDropdown/src/ofxDropdown.cpp:33: error: returning a value from a constructor
return setup(name, width, height);
^
Hey @roymacdonald.
Is it possible to disable the darkened background when options are shown?
And somehow the position of the options seems wrong(also in the FolderFiles example). Both is not an issue with the older version.
And sorry for my last issue, I was using the older version until now.
Here is a screenshot from the current version:
If the component is near the bottom border of the window, the dropdown is not visible. I didn't test but the same might happen if the component is near the right edge of the window.
As a solution one could test for these conditions and make sure the dropdown is placed inside the visible area.
Hello Roy, I am currently using this addon and I have noticed that when calling gui.saveToFile(myFile)
the selected option is correctly saved, but when calling gui.loadFromFile(myFile)
the selected option saved in the file it is not reflected in the GUI, as it is happening for the other parameters.
openFrameworks/addons/ofxDropdown/src/ofxDropdown.cpp:46:8: error: no member named
'disableHeader' in 'ofxGuiGroup'
group.disableHeader();
~~~~~ ^
what version of ofxGui (ie of openframeworks) does ofxDropdown compile against?
Not sure if this is intended, but with ofxPanel
mousescrolled moves the options up and down the screen (with ofxGuiGroup
nothing happens). I would rather expect scroll to change the preselected option (like with mouse move), so that you can select it with enter (for example), if not with clicking the option (that would be nice for ofxGuiGroup
, too). Also, if I move the ofxPanel
, the option do not move with it. And, is it possible to hide the option on "onmouseout", if the mouse leaves the ofxPanel
/ ofxGuiGroup
or the selected option?
All the ofxPanel
issues do not affect my case, because I use ofxGuiGroup
, just wanted to mention it.
It disappears only after the second click. Maybe the best behavior would be, if the request gets cancelled and the options disappear...
Is it possible to use the dropdown menu as part of a ofParameterGroup?
Or can it only be part of an ofxPanel ?
//in ofApp.h
ofParamaterGroup group_test;
//in ofApp.cpp
group_test.setName("test group");
intOptions.setName("INT Options");
intDropdown = make_unique<ofxIntDropdown>(intOptions);
group_test.add(intDropdown->getDropdownParameters());
for(int i = 0; i < 15; i++){
intDropdown->add(i, "Opcion " + ofToString(i));
}
group_test.add(intDropdown.get());
gui.add(group_test);
These functions in the example seem the wrong way round. You have to select 'multi select' to enable ' collapse on selection'.
OSX 11.6.8, OF 0.11.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.