forked from scarsty/kys-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextBox.h
More file actions
51 lines (41 loc) · 1.54 KB
/
TextBox.h
File metadata and controls
51 lines (41 loc) · 1.54 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
#pragma once
#include "RunNode.h"
class TextBox : public RunNode
{
public:
TextBox() {}
virtual ~TextBox() {}
protected:
std::string text_ = "";
int font_size_ = 20;
int text_x_ = 0, text_y_ = 0;
BP_Color color_normal_ = { 32, 32, 32, 255 };
BP_Color color_pass_ = { 255, 255, 255, 255 };
BP_Color color_press_ = { 255, 255, 255, 255 };
bool have_box_ = true;
bool have_alpha_box_ = false;
BP_Color outline_color_;
BP_Color background_color_;
std::string texture_path_ = "";
int texture_normal_id_ = -1, texture_pass_id_ = -1, texture_press_id_ = -1; //三种状态的按钮图片
bool resize_with_text_ = false;
public:
void setAlphaBox(BP_Color outlineColor, BP_Color backgroundColor);
void setTexture(const std::string& path, int normal_id, int pass_id = -1, int press_id = -1);
int getNormalTextureID() { return texture_normal_id_; }
void setFontSize(int size);
void setText(std::string text);
std::string getText() { return text_; };
//注意:这个会导致焦点出现问题,通常是为了实现一些其他效果,请勿任意使用
void setTextPosition(int x, int y)
{
text_x_ = x;
text_y_ = y;
}
void setTextColor(BP_Color c1, BP_Color c2, BP_Color c3);
void setTextColor(BP_Color c1) { color_normal_ = c1; }
virtual void draw() override;
void setHaveBox(bool h) { have_box_ = h; }
virtual void onPressedOK() override { exitWithResult(0); }
virtual void onPressedCancel() override { exitWithResult(-1); }
};