-
Notifications
You must be signed in to change notification settings - Fork 6
/
GUIController.h
59 lines (43 loc) · 1.96 KB
/
GUIController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// GUIController.h
// Deep
//
// Created by Nathan Daly on 1/2/13.
// Copyright (c) 2013 Lions Entertainment. All rights reserved.
//
#ifndef Deep_GUIController_h
#define Deep_GUIController_h
#include "Compatibility.h"
#include "GUIUtility.h"
namespace GUI {
// This class is seperated out from GUI::View to allow creation of a class to
// receive mouse/key events without having to associate it with a displayed view.
class Controller {
public:
virtual ~Controller() {}
// Mouse Events. Following three functions all work the same:
// Return true if the mouse-event is finished being handled, false otherwise.
virtual bool handle_mouse_down(DispPoint coord) { return false; }
virtual bool handle_mouse_up(DispPoint coord) { return false; }
virtual bool handle_mouse_motion(DispPoint coord, DispPoint rel_motion) { return false; }
// up == true, down == false.
virtual bool handle_mouse_scroll_start(bool up_down) { return false; }
virtual bool handle_mouse_scroll_stop(bool up_down) { return false; }
// Key Events. Following two functions all work the same:
// Return true if the key-event is finished being handled, false otherwise.
virtual bool handle_key_down(SDL_keysym key) { return false; }
virtual bool handle_key_up(SDL_keysym key) { return false; }
// These functions will be called by capture/lose focus, and may be
// overridden to provide behavior on focus gain/loss.
virtual void got_focus() { }
virtual void lost_focus() { }
// *** The following two functions will call got_focus() and lost_focus().
// *** Derived behavior may be specified by overriding those two functions.
// This function may be optionally called to tell the Application to send
// mouse and keyboard input to this controller.
void capture_focus();
// If focus was captured, this function may be called to release focus.
void lose_focus();
};
} // namespace GUI
#endif