~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to tests/guiDisabledMenu.cpp

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2008-2011 Colin MacDonald
 
2
// No rights reserved: this software is in the public domain.
 
3
 
 
4
#include "testUtils.h"
 
5
 
 
6
using namespace irr;
 
7
using namespace core;
 
8
using namespace gui;
 
9
 
 
10
// Tests that disabled GUI menu items don't cause their submenu to appear when hovered over.
 
11
/**
 
12
        http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=178436#178436
 
13
 */
 
14
 
 
15
bool guiDisabledMenu(void)
 
16
{
 
17
        IrrlichtDevice *device = createDevice( video::EDT_BURNINGSVIDEO,
 
18
                                                                                        dimension2d<u32>(160, 40), 32);
 
19
        assert(device);
 
20
        if (!device)
 
21
                return false;
 
22
 
 
23
        video::IVideoDriver* driver = device->getVideoDriver();
 
24
        gui::IGUIEnvironment* env = device->getGUIEnvironment();
 
25
 
 
26
        gui::IGUIContextMenu* menu = env->addMenu();
 
27
        menu->addItem(L"Menu", -1, true, true);
 
28
        gui::IGUIContextMenu* subMenu = menu->getSubMenu(0);
 
29
        subMenu->addItem(L"Submenu 1", -1, false, true);
 
30
        gui::IGUIContextMenu* subSubMenu = subMenu->getSubMenu(0);
 
31
        subSubMenu->addItem(L"Final item");
 
32
 
 
33
        SEvent event;
 
34
        event.EventType = EET_MOUSE_INPUT_EVENT;
 
35
        event.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
 
36
        event.MouseInput.X = menu->getAbsolutePosition().UpperLeftCorner.X + 1;
 
37
        event.MouseInput.Y = menu->getAbsolutePosition().UpperLeftCorner.Y + 1;
 
38
        (void)menu->OnEvent(event);
 
39
 
 
40
        // Hovering over the disabled submenu shouldn't cause the "Final item" to appear.
 
41
        event.MouseInput.Event = EMIE_MOUSE_MOVED;
 
42
        event.MouseInput.X = subMenu->getAbsolutePosition().UpperLeftCorner.X + 40;
 
43
        event.MouseInput.Y = subMenu->getAbsolutePosition().UpperLeftCorner.Y + 10;
 
44
        (void)menu->OnEvent(event);
 
45
 
 
46
        device->run();
 
47
        driver->beginScene(true, true, video::SColor(150,50,50,50));
 
48
        env->drawAll();
 
49
        driver->endScene();
 
50
 
 
51
        bool result = takeScreenshotAndCompareAgainstReference(driver, "-guiDisabledMenu.png", 98.77f);
 
52
        device->closeDevice();
 
53
        device->run();
 
54
        device->drop();
 
55
 
 
56
        return result;
 
57
}
 
58