*

texus

  • *****
  • 1342
    • View Profile
    • Texus's Blog
Re: Trouble syncing scrollbar and knob widgets
« Reply #15 on: 19 December 2015, 23:02:14 »
The config file seems to be wrong. Try replacing "ImageRotation = 0" with "ImageRotation = 90", does it work fine then? The rotation is closely related with mathematics, so 0° would mean that the line in the front image is facing to the right while 90° is upward like in your image.

Edit: You would also have to add 90 to the start and end rotations in your code to get the same knob as you have now.
« Last Edit: 19 December 2015, 23:05:28 by texus »

Re: Trouble syncing scrollbar and knob widgets
« Reply #16 on: 19 December 2015, 23:15:58 »
Yea, that works. All is good now. :)

Re: Trouble syncing scrollbar and knob widgets
« Reply #17 on: 20 August 2016, 18:18:40 »
I left this project for a while but decided to do some cleaning to get around some oddities and visual bugs, there is one thing that i can't seem to get working now: flipping the visual range of scroll bars.
Theoretically 255-value should do the trick but the application gets stuck in a loop. "value" can only range from 0 to 255 anyway.

Initialization:
Code: [Select]
#define SCROLLBAR_BTN_SIZE 12 // makes the scrollbar visible

tgui::Scrollbar::Ptr scrollbar1(gui);
scrollbar1->load(THEME_CONFIG_FILE);
scrollbar1->setVerticalScroll(true);
scrollbar1->setPosition(20, 20);
scrollbar1->setSize(18, 256);
scrollbar1->setMaximum(255 + SCROLLBAR_BTN_SIZE);
scrollbar1->setLowValue(SCROLLBAR_BTN_SIZE);

tgui::Knob::Ptr knob1(gui);
knob1->load("data/widgets/Knob/Knob.conf");
knob1->setPosition(55, 235);
knob1->setSize(40, 40);
knob1->setStartRotation(127 + 90);
knob1->setEndRotation(-128 + 90);
knob1->setMinimum(0);
knob1->setMaximum(255);

//...  ... knob/slider 8

Callback handling:
Code: [Select]
// Knobs
case Knob_CALLBACK_ID + 1:
{
value = knob1->getValue();

if (invert_Knob_SYNC == true) scrollbar1->setValue(value); // Do something here ??
else scrollbar1->setValue(value); // default
_itoa_s(value, valText, 10);
reverse(valText);
char lvalue[7];
lvalue[0] = valText[0];
lvalue[1] = '\n';
lvalue[2] = valText[1];
lvalue[3] = '\n';
lvalue[4] = valText[2];
lvalue[5] = '\0';
val1->setText(lvalue);

std::cout << value << '\t' << "knob1" << '\t';

break;
}
//...  ... case 8
case Knob_CALLBACK_ID + 9:
{
invert_Knob_SYNC = !invert_Knob_SYNC;
break;
}
case KnobScroll_CALLBACK_ID + 1:
{
value = scrollbar1->getValue();

if (invert_Knob_SYNC == true) knob1->setValue(value); // Do something here as well ???
else knob1->setValue(value); // default
break;
}
//...  ... case 8

Any suggestions on how to accomplish this?

*

texus

  • *****
  • 1342
    • View Profile
    • Texus's Blog
Re: Trouble syncing scrollbar and knob widgets
« Reply #18 on: 20 August 2016, 18:31:07 »
Only one of the 2 should do "255-value" while the other should still set "value". Otherwise you are endlessly inverting the values.

Re: Trouble syncing scrollbar and knob widgets
« Reply #19 on: 20 August 2016, 18:47:49 »
Fixed. I overlooked the callback's lower half when testing before