xoreos  0.0.5
close.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/system.h"
26 #include "src/common/ustring.h"
27 
29 
31 
33 
34 namespace Engines {
35 
36 namespace NWN {
37 
39  const Common::UString &model) : ModelWidget(gui, tag, model) {
40 
41  _model->setClickable(true);
42 }
43 
45 }
46 
49 
50  if (isDisabled())
51  return;
52 
53  _model->setState("");
54 }
55 
56 void WidgetClose::mouseDown(uint8 state, float UNUSED(x), float UNUSED(y)) {
57  if (isDisabled())
58  return;
59 
60  if (state != SDL_BUTTON_LMASK)
61  return;
62 
63  _model->setState("down");
64  playSound("gui_button", Sound::kSoundTypeSFX);
65 }
66 
67 void WidgetClose::mouseUp(uint8 UNUSED(state), float UNUSED(x), float UNUSED(y)) {
68  if (isDisabled())
69  return;
70 
71  _model->setState("");
72  setActive(true);
73 }
74 
75 } // End of namespace NWN
76 
77 } // End of namespace Engines
A class holding an UTF-8 string.
Definition: ustring.h:48
A NWN close button widget.
uint8_t uint8
Definition: types.h:200
void setActive(bool active)
The widget&#39;s active state.
Definition: widget.cpp:268
void leave()
The mouse left the widget.
Definition: close.cpp:47
void setState(const Common::UString &name="")
Set the current animation state.
Definition: model.cpp:324
void leave()
The mouse left the widget.
Definition: nwnwidget.cpp:55
A GUI.
Definition: gui.h:43
void setClickable(bool clickable)
Set the object&#39;s clickable state.
Definition: renderable.cpp:94
#define UNUSED(x)
Definition: system.h:170
A 3D model of an object.
Graphics::Aurora::Model * _model
Definition: modelwidget.h:64
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType, bool loop, float volume, bool pitchVariance)
Play this sound resource.
Definition: util.cpp:81
Unicode string handling.
A NWN model widget.
Definition: modelwidget.h:45
void mouseUp(uint8 state, float x, float y)
A mouse button was released on the widget.
Definition: close.cpp:67
Low-level detection of architecture/system properties.
bool isDisabled() const
Is the widget disabled?
Definition: widget.cpp:63
Sound effect.
Definition: types.h:45
Generic Aurora engines utility functions.
WidgetClose(::Engines::GUI &gui, const Common::UString &tag, const Common::UString &model)
Definition: close.cpp:38
void mouseDown(uint8 state, float x, float y)
A mouse button was pressed on the widget.
Definition: close.cpp:56