klepto2 Posted May 27, 2021 Share Posted May 27, 2021 It seems there is a bug where you can't scroll the slider using mousedragging when the containing window is too small: #include "UltraEngine.h" using namespace UltraEngine; bool RescaleUI(const Event& event, shared_ptr<Object> extra) { float dpiscale = float(event.data) / 100.0f; auto ui = dynamic_pointer_cast<Interface>(extra); ui->SetScale(dpiscale); auto window = dynamic_pointer_cast<Window>(event.source); window->SetShape(event.position.x, event.position.y, event.size.x, event.size.y); return true; } int main(int argc, const char* argv[]) { //Get displays auto displays = GetDisplays(); if (displays.empty()) return 1; float dpiscale = displays[0]->scale; //Create window auto mainwindow = CreateWindow("Ultra App Kit", 0, 0, 300 * dpiscale, 400 * dpiscale, displays[0], WINDOW_HIDDEN | WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE); //Create user interface auto ui = CreateInterface(mainwindow); iVec2 sz = ui->root->ClientSize(); auto label = CreateSlider(0, 0, 20, sz.y, ui->root, SLIDER_SCROLLBAR | SLIDER_VERTICAL); label->SetLayout(1, 0, 1, 1); label->SetRange(200,800); //Enable DPI scaling changes ui->SetScale(dpiscale); ListenEvent(EVENT_WINDOWDPICHANGED, mainwindow, RescaleUI, ui); //Show the window mainwindow->Show(); mainwindow->Activate(); while (true) { const Event event = WaitEvent(); switch (event.id) { case EVENT_WIDGETSELECT: break; case EVENT_WIDGETACTION: break; case EVENT_WINDOWCLOSE: if (event.source == mainwindow) return 0; break; } } return 0; } When you start this, you can't scroll the slider, but if you resize the window to some extend the dragging starts working. Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
klepto2 Posted May 27, 2021 Author Share Posted May 27, 2021 As a side node, the scrolling behaviour when dragging with a mouse is a bit uncomfortable. It seems to move with the slower than the actualmousespeed. The common behaviour would be that the knob is synchron with the actual mouseposition. Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Slastraf Posted May 27, 2021 Share Posted May 27, 2021 I had this happen so often to me over years on random applications and feels like this has bugging me ever since. Link to comment Share on other sites More sharing options...
Josh Posted May 27, 2021 Share Posted May 27, 2021 If you have very high numbers, where there are more divisions than actual pixels, the slider is likely to have problems. I might be able to improve the behavior a little, but in general you should try to avoid this situation. It would be better to set the range to 2,8 instead of 200,800. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted May 27, 2021 Author Share Posted May 27, 2021 Well, while I agree that too high values might lead to problems I doubt that this is the case here. it only occurs while using the knob dragging with the mouse, setting the value with the mousewheel or directly doesn't have the issue When I set the values to 2 and 8 I lose a precision of 100px in the case i want Pixel Perfect scrolling ( Imageviewer) Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted May 27, 2021 Share Posted May 27, 2021 I believe you. That was just something I immediately noticed and I am nearing the end of my day... My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted May 27, 2021 Author Share Posted May 27, 2021 No problem ; ) i just thought the description needed some addition to make the problem more clear. Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted June 1, 2021 Share Posted June 1, 2021 There are a few different things going on here, so I wanted to eliminate the DPI scaling setting and make a simpler example. This code demonstrates a slight mismatch between the cursor position and the dragged position when you grab and move the slider knob: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get displays auto displays = GetDisplays(); if (displays.empty()) return 1; //Create window auto mainwindow = CreateWindow("Ultra App Kit", 0, 0, 300, 800, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE); //Create user interface auto ui = CreateInterface(mainwindow); iVec2 sz = ui->root->ClientSize(); auto slider = CreateSlider(0, 0, 20, sz.y, ui->root, SLIDER_SCROLLBAR | SLIDER_VERTICAL); slider->SetLayout(1, 0, 1, 1); slider->SetRange(4, 200); while (true) { const Event event = WaitEvent(); switch (event.id) { case EVENT_WIDGETSELECT: break; case EVENT_WIDGETACTION: break; case EVENT_WINDOWCLOSE: if (event.source == mainwindow) return 0; break; } } return 0; } My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted June 1, 2021 Share Posted June 1, 2021 And then this code shows your original reported problem, that the slider cannot be dragged at all if the range exceeds the slider height (presumably): #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get displays auto displays = GetDisplays(); if (displays.empty()) return 1; //Create window auto mainwindow = CreateWindow("Ultra App Kit", 0, 0, 300, 400, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE); //Create user interface auto ui = CreateInterface(mainwindow); iVec2 sz = ui->root->ClientSize(); auto label = CreateSlider(0, 0, 20, sz.y, ui->root, SLIDER_SCROLLBAR | SLIDER_VERTICAL); label->SetLayout(1, 0, 1, 1); label->SetRange(200, 800); while (true) { const Event event = WaitEvent(); switch (event.id) { case EVENT_WIDGETSELECT: break; case EVENT_WIDGETACTION: break; case EVENT_WINDOWCLOSE: if (event.source == mainwindow) return 0; break; } } return 0; } My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted June 1, 2021 Share Posted June 1, 2021 Okay, I think I have the original problem resolved by leaving some values in floats during a certain calculation and then rounding the result. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted June 1, 2021 Solution Share Posted June 1, 2021 Okay, I think this executable demonstrates that both problems are solved. Thank you for reporting this! App Kit_d.rar 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts