-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
177 lines (118 loc) · 4.79 KB
/
main.cpp
File metadata and controls
177 lines (118 loc) · 4.79 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
#include <Screen.hpp>
#include <Widget.hpp>
#include <Label.hpp>
#include <Button.hpp>
#include <ButtonRadio.hpp>
#include <ButtonCheck.hpp>
#include <Rectangle.hpp>
#define MAIN
///////////////////////////////////////////////////
Label *myLabel = NULL;
sf::Font myFont;
sf::Text prompt;
Screen *myScreen = NULL;
///////////////////////////////////////////////////
void TestDisplay_02(sf::RenderWindow *win){
win->draw(prompt);
}
void TestDisplay_01(sf::RenderWindow *win){
TestDisplay_02( win );
//myLabel->Display(win);
}
void myFuncion(std::string idKey, EVENTS *evn){
LOG_WARN("LLAMADA DESDE: " << idKey);
// Para recuperar el Sender
Widget *wdt = myScreen->Search(idKey);
// Para ubicar el tipo de la class y convertir
if(wdt->get_idType() == CTYPES::CButton){
Button *btn = (Button *)wdt;
//. Para imprimir los datos
LOG_INFO( btn->toString() );
}
}
void myMouseEntered(std::string idKey, EVENTS *evn){
LOG_WARN("Llamanda al MouseEntered desde: " << idKey);
}
void myMouseExited(std::string idKey, EVENTS *evn){
LOG_WARN("Llamada a MouseExited desde: " << idKey);
LOG_WARN("Argumantos: " << evn->arguments);
}
///////////////////////////////////////////////////
bool running = false;
int main()
{
//. Crea la Window principal
sf::RenderWindow win(sf::VideoMode(800, 480), "AppGame");
//. No sera dibujada a 60fps, como un juego.-
win.setFramerateLimit(30);
running = true;
COORD crd = COORD(10,10);
std::cout << crd.toString() << std::endl;
DIMENSION dm = DIMENSION(100, 100, 64, 24);
std::cout << dm.toString() << std::endl;
myScreen = new Screen();
myLabel = Create_Label(myScreen, 40,40, "SFML GUI Interface", 20.0f);
myScreen->Widget_add("tittle", myLabel);
Label *lbName = Create_Label(myScreen, 40,80, "Texto de Etiqueta", 16.0f);
myScreen->Widget_add("subtext", lbName);
Button *myButton = Create_Button(myScreen, 40,120, "Boton", 16.0f);
myButton->Connect(Event::on_Pressed, (callback*)&myFuncion, "8489:yryy:59069");
myButton->Connect(Event::on_MouseEntered, (callback*)&myMouseEntered, "arg1,arg2,arg3");
myButton->Connect(Event::on_MouseExited, (callback*)&myMouseExited, "111,222,333,444");
myScreen->Widget_add("btnData", myButton);
Button *myToogle = Create_Button(myScreen, 130, 120, "Toque", 16.0f);
myToogle->setToggled(true);
myScreen->Widget_add("btnToogle", myToogle);
ButtonRadio *myOption1 = Create_Option(myScreen, 40, 160 +(30*0), "Color-Normal", 16.0f, "grpColor");
myScreen->Widget_add("btnOptn-1", (Button*)myOption1);
ButtonRadio *myOption2 = Create_Option(myScreen, 40, 160 +(30*1), "Color-Dark", 16.0f, "grpColor");
myScreen->Widget_add("btnOptn-2", (Button*)myOption2);
ButtonRadio *myOption3 = Create_Option(myScreen, 40, 160 +(30*2), "Color-Light", 16.0f, "grpColor");
myScreen->Widget_add("btnOptn-3", (Button*)myOption3);
ButtonRadio *myOption4 = Create_Option(myScreen, 40, 160 +(30*3), "Color-Neon", 16.0f, "grpColor");
myScreen->Widget_add("btnOptn-4", (Button*)myOption4);
ButtonCheck *myCasilla1 = Create_Check(myScreen, 40, 160 + (30*4), "Casilla-1", 16.0f);
myScreen->Widget_add("Casilla-1", (Button*)myCasilla1);
ButtonCheck *myCasilla2 = Create_Check(myScreen, 40, 160 + (30*5), "Casilla-2", 16.0f);
myScreen->Widget_add("Casilla-2", (Button*)myCasilla2);
ButtonCheck *myCasilla3 = Create_Check(myScreen, 40, 160 + (30*6), "Casilla-3", 16.0f);
myScreen->Widget_add("Casilla-3", (Button*)myCasilla3);
ButtonCheck *myCasilla4 = Create_Check(myScreen, 40, 160 + (30*7), "Casilla-4", 16.0f);
myScreen->Widget_add("Casilla-4", (Button*)myCasilla4);
Rectangle *rectangle = Create_Rectangle(myScreen, 250, 20, 100,100);
myScreen->Widget_add("rectangle-1", rectangle);
Rectangle *rectImage = Create_RectImage(myScreen, 380, 20, 100,100, "moon_03.png");
myScreen->Widget_add("rectangle-2", rectImage);
// TODO (esbva#1#): Modos Pendientes
/*
myButton->setVisible( true | false )
myButton->setEnabled( true | false )
myButton->setToogled( true | false )
*/
//. Pruebas locales antes de encapsular
if(win.isOpen()){
while(running){
sf::Event event;
while(win.pollEvent(event)){
if(event.type == sf::Event::Closed){
win.close();
running = false;
}
//myButton->MouseInRect(&win);
myScreen->Update(&win);
}
win.clear(sf::Color(0,0,0));
myScreen->Display(&win);
win.display();
}
//delete myButton;
//myButton = NULL;
delete myScreen;
myScreen = NULL;
}
std::cout << "Hello world!" << std::endl;
return 0;
}