istereo2

view libs/goatkit/checkbox.cc @ 27:f0da8b2b61ec

removed iOS cpu restriction and bumped build number to 3 implemented android JNI calls to show/hide ads (untested)
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 05 Oct 2015 17:15:02 +0300
parents 3bccfc7d10fe
children
line source
1 /*
2 GoatKit - a themable/animated widget toolkit for games
3 Copyright (C) 2014 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "checkbox.h"
19 #include "boolanm.h"
21 namespace goatkit {
23 struct CheckBoxImpl {
24 BoolAnim checked;
25 };
27 CheckBox::CheckBox()
28 {
29 cbox = new CheckBoxImpl;
30 cbox->checked = false;
31 cbox->checked.set_transition_duration(60);
32 }
34 CheckBox::~CheckBox()
35 {
36 delete cbox;
37 }
39 const char *CheckBox::get_type_name() const
40 {
41 return "checkbox";
42 }
45 void CheckBox::check()
46 {
47 cbox->checked.change(true);
48 }
50 void CheckBox::uncheck()
51 {
52 cbox->checked.change(false);
53 }
55 float CheckBox::get_checked() const
56 {
57 return cbox->checked.get_value();
58 }
60 bool CheckBox::is_checked() const
61 {
62 return cbox->checked.get_state();
63 }
65 void CheckBox::toggle()
66 {
67 if(is_checked()) {
68 uncheck();
69 } else {
70 check();
71 }
72 }
74 void CheckBox::set_toggle_transition(long msec)
75 {
76 cbox->checked.set_transition_duration(msec);
77 }
79 long CheckBox::get_toggle_transition() const
80 {
81 return cbox->checked.get_transition_duration();
82 }
84 void CheckBox::on_click()
85 {
86 toggle();
88 Event ev;
89 ev.type = EV_CHANGE;
90 handle_event(ev);
91 }
93 } // namespace goatkit