Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - KnIfER

Pages: [1]
1
Window / Re: How to make the entire window draggable?
« on: March 24, 2018, 02:14:40 pm »
new issue:click on the border and immediately move the mouse cursor out of the application window quickly,instead of scaling out the window,I find the window loses all mouseMove events.
and with mouseButton still pressed,move the cursor backwards,then I can scale in the window correctly once the cursor has reached the borders.

clickling on the border then after a while moving cursor out of the application window quickly won's repeat this issue.

I have pushed my code and made a pre-release to show this issue.
https://github.com/KnIfER/imgui-sfml-ui-test/releases/tag/a
the application only looks laggy when I am recording the screen.

The major problem is that when I abandon titlebar&borders,I also give up all windows features,such as auto maximization when I drag the window to screen edge.
I guess that Plotplayer actually doesn't abandon titlebar&borders,instead it draws UI on the non-client area.

I will move forward anyway..

2
Window / Re: How to make the entire window draggable?
« on: March 24, 2018, 01:15:17 pm »
I think potplayer just did the same thing——disable default titlebar、borders and implements it's own
And I love the process too :),feeling like I am still dealing with android stuffs:custom views,touch events,etc.
Others either leave users enduring visual artifacts,or simply disable resizing,for me neither is a good idea.


3
Window / Re: How to make the entire window draggable?
« on: March 24, 2018, 08:13:18 am »
this will allow for scaling by dragging the four borders.
and won't block the main loop.
and you can grab one of the corners to scale as well.

    case sf::Event::MouseMoved:
            if (ImGui::IsAnyItemActive() || ImGui::IsAnyWindowFocused())
               break;
            if (isMouseDragging) {
               window.setPosition(window.getPosition() + sf::Vector2<int>(event.mouseMove.x - lastDownX, event.mouseMove.y - lastDownY));
            }
            //
            if (isScalingLeft) {
               window.setPosition(window.getPosition() + sf::Vector2<int>(event.mouseMove.x - lastDownX, 0));
               window.setSize(window.getSize() - sf::Vector2u{ (unsigned int)(event.mouseMove.x - lastDownX ), 0 });
            }
            if (isScalingRight) {
               //window.setSize(windowOldSize + sf::Vector2u{ (unsigned int)(event.mouseMove.x - lastDownX ), 0 });
               window.setSize(window.getSize() + sf::Vector2u{ (unsigned int)(event.mouseMove.x - lastDownX), 0 });
               lastDownX = event.mouseMove.x;
            }
            if (isScalingTop) {
               window.setPosition(window.getPosition() + sf::Vector2<int>(0,event.mouseMove.y - lastDownY));
               window.setSize(window.getSize() - sf::Vector2u{0, (unsigned int)(event.mouseMove.y - lastDownY)});
            }
            if (isScalingBottom) {
               //window.setSize(windowOldSize + sf::Vector2u{ 0,(unsigned int)(event.mouseMove.y - lastDownY)});
               window.setSize(window.getSize() + sf::Vector2u{ 0, (unsigned int)(event.mouseMove.y - lastDownY) });
               lastDownY = event.mouseMove.y;
            }
            break;
    case sf::Event::MouseButtonPressed:
            std::cout <<"MouseButtonPressed"<< std::endl;
            lastDownX = event.mouseButton.x;
            lastDownY = event.mouseButton.y;
            //
            if (lastDownX <= borderWidth) {
               isScalingLeft = true;
            }
            if (lastDownX >= window.getSize().x - borderWidth) {
               isScalingRight = true;
            }
            if (lastDownY <= borderWidth) {
               isScalingTop = true;
            }
            if (lastDownY >= window.getSize().y - borderWidth) {
               isScalingBottom = true;
            }
            if(isScalingLeft || isScalingRight || isScalingTop || isScalingBottom)break;
            isMouseDragging = true;
            break;
    case sf::Event::MouseButtonReleased:
            isMouseDragging =
            isScalingBottom=
            isScalingTop=
            isScalingRight=
            isScalingLeft = false;
            break;

The remaining problem however, ;),is that can i change the mouse cursor when hovering on the borders?
well,I can,but only for the latest build.

4
Window / Re: How to make the entire window draggable?
« on: March 24, 2018, 02:46:38 am »
in main loop:
event loop:

         case sf::Event::MouseMoved:
            if (isMouseDragging) {
            window.setPosition(window.getPosition() + sf::Vector2<int>(event.mouseMove.x- lastDownX, event.mouseMove.y- lastDownY));
            }
            break;
         case sf::Event::MouseButtonPressed:
            lastDownX = event.mouseButton.x;
            lastDownY = event.mouseButton.y;
            isMouseDragging = true;
            break;
         case sf::Event::MouseButtonReleased:
            isMouseDragging = false;
            break;

this will enable dragging on the window. 
The only problem however,is that dragging on imgui widgets doesn't consume the event.
luckily for me, IMGui has some useful APIs,and that solves the problem.
https://github.com/kjetand/imgui-sfml/issues/1


bug:after window.setposition programmatically,  window lost response to alt+f4,but still it is detecting key events,and after moving the mouse,window regain the response to alt+f4.

5
Window / How to make the entire window draggable?
« on: March 24, 2018, 02:28:56 am »
Hi all :),I am using sfml on the platform windows,to mimic potplayer. 
with sfml and windows my application is blocked while resizing or moving,so I've decided to abandon the default title bar and the four borders:
sf::RenderWindowmy window(vmode, "Imgui-sfml widgets test", 0);

Now I have a lot of questions:
  I.How to make the entire window draggable?(solved)
 II.Is it possible to fake a title bar and four borders using imgui?
III.Once I've faked four borders,how do I change mouse cursor when it is hovering on one of the boders?

I think the first question is the simplest so I use that as my title.

Pages: [1]