FLTK logo

Re: [RFE] STR #3222: Make the text box area of Fl_Value_Slider etc. user settable

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.bugs  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [RFE] STR #3222: Make the text box area of Fl_Value_Slider etc. user settable Albrecht Schlosser Nov 26, 2022  
 
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: https://www.fltk.org/str.php?L3222
Version: 1.4-feature


Attached file "value_slider.cxx"...


Link: https://www.fltk.org/str.php?L3222
Version: 1.4-feature
//
// Simple Value Slider test program for the Fast Light Tool Kit (FLTK).
//
// Copyright 2022 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file.  If this
// file is missing or damaged, see the license at:
//
//     https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
//     https://www.fltk.org/bugs.php
//

// Beware: this test program is a "quick and dirty hack".

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Value_Slider.H>

Fl_Value_Slider *s1 = 0;
Fl_Value_Slider *s2 = 0;
Fl_Value_Slider *s3 = 0;
Fl_Value_Slider *s4 = 0;

void value_width_cb(Fl_Value_Slider *o, void*) {
  int width = (int)o->value();
  s1->value_width(width);
  s1->value_height(width - 10);
  s2->value_width(width + 5);
  s3->value_width(width + 10);
  s1->parent()->redraw();
}

void callback(Fl_Widget* o, void*) {
  const char *name = (const char*)(o->user_data() ? o->user_data() : "???");
  fprintf(stderr, "callback(): %s value() = \033[2m%g\033[0m\n",
          name, ((Fl_Valuator*)o)->value());
}

int main(int argc, char **argv) {
  Fl_Window *window = new Fl_Window(500, 400, "Fl_Value_Slider Test");

  { Fl_Value_Slider *o = s1 = new Fl_Value_Slider(20, 20, 60, 120, "FL_HOR_SLIDER");
    o->type(0);
    o->selection_color((Fl_Color)1);
    o->labelsize(8);
    o->callback((Fl_Callback*)callback, (void*)("Fl_Value_Slider FL_HOR_SLIDER"));
  } // Fl_Value_Slider* o

  { Fl_Value_Slider* o = s2 = new Fl_Value_Slider(100, 100, 200, 20, "FL_HOR_FILL_SLIDER");
    o->type(3);
    o->selection_color((Fl_Color)1);
    o->labelsize(8);
    o->callback((Fl_Callback*)callback, (void*)("Fl_Value_Slider FL_HOR_FILL_SLIDER"));
  } // Fl_Value_Slider* o

  { Fl_Value_Slider* o = s3 = new Fl_Value_Slider(180, 180, 300, 20, "FL_HOR_NICE_SLIDER");
    o->type(5);
    o->box(FL_FLAT_BOX);
    o->color((Fl_Color)10);
    o->selection_color((Fl_Color)1);
    o->labelsize(8);
    o->minimum(-999999);
    o->maximum(999999);
    o->step(0.001);
    o->callback((Fl_Callback*)callback, (void*)("Fl_Value_Slider FL_HOR_NICE_SLIDER"));
  } // Fl_Value_Slider* o

  { Fl_Value_Slider* o = s4 = new Fl_Value_Slider(30, 330, 300, 20, "value_width");
    o->type(5);
    o->box(FL_FLAT_BOX);
    o->color((Fl_Color)10);
    o->selection_color((Fl_Color)1);
    o->labelsize(8);
    o->callback((Fl_Callback*)value_width_cb, (void*)(0));
    o->minimum(0);
    o->maximum(300);
    o->step(1);
    o->value(35);

  } // Fl_Value_Slider* o

  window->end();
  window->resizable(window);
  window->size_range(200, 200);
  window->show(argc, argv);
  return Fl::run();
}
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.