rezaali / ofxUI

[DEPRECATED] UI Addon for openFrameworks
http://www.syedrezaali.com/#/ofxui-project-showcase/
518 stars 202 forks source link

addMinimalSlider, erratic behavior #218

Closed dimitre closed 9 years ago

dimitre commented 10 years ago

Sometimes addMinimalSlider doesn't obey minimum, maximum and default parameters, returning zero, nan or infinite. issues vary each time. I've changed everything to addSlider and it works good!

morphogencc commented 9 years ago

Do you make sure to initialize the variable? I find that makes a difference.

That said, I have the same erratic behavior on OSX 10.8.5 and oF 0.9.0 but with normal Sliders -- minimal sliders give me no problem.

dimitre commented 9 years ago

Yes variables are initialized. here is the minimum code to reproduce the issue:

#pragma once

#include "ofMain.h"
#include "ofxUI.h"

class ofApp : public ofBaseApp{
    public:
        void setup();
        void update();
        void draw();

        void keyPressed(int key);
        void keyReleased(int key);
        void mouseMoved(int x, int y);
        void mouseDragged(int x, int y, int button);
        void mousePressed(int x, int y, int button);
        void mouseReleased(int x, int y, int button);
        void windowResized(int w, int h);
        void dragEvent(ofDragInfo dragInfo);
        void gotMessage(ofMessage msg);

        map <string,ofxUIScrollableCanvas *>    guiMap;
        map <string,float>          parametrosFloat;

};
#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
    string guiName = "master";
    guiMap[guiName] = new ofxUIScrollableCanvas(0,0,200,770);
    for (int a=0; a<33; a++) {
        string nome = "slider" + ofToString(a);
        float min = a;
        float max = a*2 + 2;
        float def = (min + max)/2.0;
        parametrosFloat[nome] = def;
        guiMap[guiName]->addMinimalSlider(nome,min,max,&parametrosFloat[nome]);
        //guiMap[guiName]->addSlider(nome,min,max,&parametrosFloat[nome]);
    }
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){

}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){ 

}
dimitre commented 9 years ago

fixed on develop branch

sethismyfriend commented 9 years ago

I am having this issue on the master - I'll try pulling the develop branch

dimitre commented 9 years ago

It would be great to have it in master @rezaali :)