]> Creatis software - creaWT.git/blobdiff - wt/bbtk_wt_PKG/src/bbwtSlider.cxx
#2498 creaWt Feature New Normal wt-version kernel
[creaWT.git] / wt / bbtk_wt_PKG / src / bbwtSlider.cxx
index ec59dc405da04832fee0358378a496851e2e042f..875d5b833dc7426314a77136be5b693958804851 100644 (file)
@@ -24,6 +24,7 @@ namespace bbwt
                /// Events callbacks
     /// Called when the slider is moved
        void OnSliderTrack();
+       void OnSliderMove();
     /// Called when the little slider which controls the resolution
     /// of the main slider is moved (if activated)
        void OnResolutionOfSlider();
@@ -41,6 +42,8 @@ namespace bbwt
        Slider*      mBox;
                  Wt::WSlider     *mwtSlider;
                  Wt::WSlider     *mResolutionOfSlider;
+                 Wt::WText    *textTitle;
+                 Wt::WString  tTitle;
                  int          min;
                  int          max;
                        bool         reactiveOnTrack;
@@ -66,6 +69,7 @@ namespace bbwt
     : 
        Wt::WContainerWidget(parent),
        mBox(box),
+       tTitle(title),
                  min(vmin),
                  max(vmax),
                        reactiveOnTrack(reactiveontrack)
@@ -101,16 +105,17 @@ namespace bbwt
     // Any top level sub-widget must have the panel returned by panel
     // for parent
     
-                               std::cout<<"Creando SLIDER  --  2  "<<std::endl;
+               std::cout<<"Creando SLIDER  --  2  "<<std::endl;
                mwtSlider = new Wt::WSlider(wtorientation);
                mwtSlider->resize(sizeX,sizeY);
                mwtSlider->setMinimum(min);
                mwtSlider->setMaximum(max);             
                mwtSlider->setValue(value);
                mwtSlider->setTickPosition(Wt::WSlider::TicksBothSides);
-               mwtSlider->setValueText(title);
+               //mwtSlider->setValueText(title);
                mwtSlider->valueChanged().connect(this,&SliderWidget::OnSliderTrack);
-               mwtSlider->sliderMoved().connect(this,&SliderWidget::OnSliderTrack);
+               mwtSlider->sliderMoved().connect(this,&SliderWidget::OnSliderMove);
+   // mwtSlider->resize(Wt::WLength::Auto, 50);
 
               
     // If asked : creation of the other little slider which allows to change 
@@ -145,6 +150,8 @@ namespace bbwt
     //---------------------------------------------------------------------
     // 2) Insertion of the components in the window
                std::cout<<"Creando SLIDER  --  4  "<<std::endl;
+               textTitle = new Wt::WText(tTitle + bbtk::std2wt(" : ")+ mwtSlider->valueText());
+               layout->addWidget(textTitle,Wt::WBorderLayout::North);
                layout->addWidget(mwtSlider,Wt::WBorderLayout::Center);
                                std::cout<<"Creando SLIDER  --  5  "<<std::endl;
     // Insert the sizer in the main panel and refresh the layout
@@ -199,6 +206,24 @@ namespace bbwt
                }
     // and signal that the output has changed
     mBox->bbSignalOutputModification(std::string("Out"));    
+    textTitle->setText(tTitle + bbtk::std2wt(" : ") + mwtSlider->valueText());
+  }
+  
+  
+  //-------------------------------------------------------------------------
+  void SliderWidget::OnSliderMove()
+  {
+
+    // When user releases the slider 
+    // we update the output of the box
+     if(!reactiveOnTrack)
+    {
+                 mBox->bbSetOutputOut( mwtSlider->value() );
+                 mBox->bbSetInputIn( mwtSlider->value() );
+       }
+    // and signal that the output has changed
+    mBox->bbSignalOutputModification(std::string("Out"));    
+        textTitle->setText(tTitle + bbtk::std2wt(" : ") + mwtSlider->valueText());
 
   }
 
@@ -235,6 +260,7 @@ namespace bbwt
                bbtkDebugMessage("process",3,
                                   "Slider "<<bbGetName()<<" input="
                                   <<bbGetInputIn()<<std::endl);
+               
 
                        // desperate try // JPR
                if ( bbGetInputMin() != ((SliderWidget*)bbGetOutputWidget())->GetMin() ||  bbGetInputMax() != ((SliderWidget*)bbGetOutputWidget())->GetMax() )       
@@ -274,7 +300,8 @@ namespace bbwt
                                        ); 
     //    std::cout << "w = "<<w<<std::endl;
     // w->SetName( bbtk::std2wx( bbGetInputWinTitle() ) );
-         
+    w->setMinimumSize(Wt::WLength::Auto, 120);
+         w->setMaximumSize(Wt::WLength::Auto, 180);
     bbSetOutputWidget( w );
   }