supertux
src
gui
notification.hpp
1
// SuperTux
2
// Copyright (C) 2022 Vankata453
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#ifndef HEADER_SUPERTUX_GUI_NOTIFICATION_HPP
18
#define HEADER_SUPERTUX_GUI_NOTIFICATION_HPP
19
20
#include <SDL.h>
21
#include <functional>
22
#include <string>
23
24
#include "control/controller.hpp"
25
#include "math/sizef.hpp"
26
#include "video/drawing_context.hpp"
27
28
class
Notification
29
{
30
private
:
31
const
std::string m_id;
32
const
bool
m_auto_hide;
33
const
bool
m_auto_disable;
34
35
std::string m_text;
36
std::string m_mini_text;
37
Sizef
m_text_size;
38
Sizef
m_mini_text_size;
39
40
Vector m_pos;
41
Sizef
m_size;
42
43
Vector m_mouse_pos;
44
bool
m_mouse_over;
45
bool
m_mouse_over_sym1;
// Mouse is over "Do not show again".
46
bool
m_mouse_over_sym2;
// Mouse is over "Close".
47
48
bool
m_quit;
// Requested notification quit.
49
50
std::function<void ()> m_callback;
51
52
public
:
53
Notification
(std::string
id
,
bool
no_auto_hide =
false
,
bool
no_auto_disable =
false
);
54
~
Notification
();
55
56
void
set_text(
const
std::string& text);
57
void
set_mini_text(
const
std::string& text);
58
void
on_press(
const
std::function<
void
()>& callback) { m_callback = callback; }
59
60
void
event(
const
SDL_Event& event);
61
void
process_input(
const
Controller
& controller);
62
void
draw(
DrawingContext
& context);
63
64
// Notification actions
65
66
void
disable();
67
void
close();
68
69
// Static functions, serving as utilities
70
71
static
bool
is_disabled(std::string
id
);
72
73
private
:
74
void
calculate_size();
75
76
private
:
77
Notification
(
const
Notification
&) =
delete
;
78
Notification
& operator=(
const
Notification
&) =
delete
;
79
};
80
81
#endif
82
83
/* EOF */
Controller
Definition:
controller.hpp:57
Notification
Definition:
notification.hpp:28
DrawingContext
This class provides functions for drawing things on screen.
Definition:
drawing_context.hpp:42
Sizef
Definition:
sizef.hpp:26
Generated by
1.8.13