phylony / maratis

Automatically exported from code.google.com/p/maratis
0 stars 0 forks source link

[MGui] Patch - Windows selection, Z-order, overlapping, input #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Patch should be applied in
"maratis\branches\Experimental\Sources\MSDK\MGui"

** explanation of the patch
This patch allows selecting (highlighting) windows, with the following features:
* selecting a window will bring it to front
* clicking where there's no windows will unselect all windows
* windows can overlap with no side effects
* you can query if there are selected windows
* you can query if the mouse is over some window
* you have two modes for selecting windows:
  rootWindow->setHardSelecting(true);
    you have to click on a window to select it
  rootWindow->setHardSelecting(false);
    just hovering the mouse on a window will select it

In the case that the user is operating on a MGuiWindow, you may decide not to 
send the input to the Maratis engine too (e.g. for clicking on 3D objects).
In other words you may want a GUI window to block a click or a key which 
otherwise will be sent to the engine.
So you can also do "W,A,S,D movement" and still type those letters in a 
MGuiEditText.

Here's an example on how to use the patch for what concerns input:

    if(input->onKeyDown("MOUSE_BUTTON1"))
    {   if(guiWinRoot->isMouseOverSomething())
        guiWinRoot->onMouseButtonDown(MMOUSE_BUTTON_LEFT);
        else
        {   guiWinRoot->unHighLightAllWindows();
            pick_3d_objects_with_raycasting();
        }
    }
    else if(input->onKeyUp("MOUSE_BUTTON1"))
    {   if(guiWinRoot->isSomethingHighlighted())
        guiWinRoot->onMouseButtonUp(MMOUSE_BUTTON_LEFT);
    }

    if(guiWinRoot->isMouseOverSomething())
    {   //send characters and keys to MGui
    }

    if(guiWinRoot->isSomethingHighlighted())
        return;

    //because of the previous lines and the "return", the following input won't work if there's a selected MGUI window

    if(input->onKeyDown("ENTER"))
    {   //do stuff
    }
    else if(input->onKeyDown("SPACE"))
    {   //do stuff
    }
    //etc

Original issue reported on code.google.com by hkwareho...@gmail.com on 16 Nov 2013 at 5:59

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Woops sorry posting a correct patch, now it should compile with no errors.

Original comment by hkwareho...@gmail.com on 16 Nov 2013 at 6:28

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Adding a plugin example with screenshot.

Original comment by hkwareho...@gmail.com on 16 Nov 2013 at 10:39

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you !
Very useful.

Original comment by anael.se...@gmail.com on 17 Nov 2013 at 8:43

GoogleCodeExporter commented 9 years ago
New version of the patch which stops events from reaching a window covered by 
another one. So you can click a button of a window in the background only if 
the button is actually visible (not covered by other windows).

Original comment by hkwareho...@gmail.com on 17 Nov 2013 at 11:56

Attachments: