15 #ifndef TOUCHSCREEN_BUTTON_H
16 #define TOUCHSCREEN_BUTTON_H
19 #include "config_generated.h"
20 #include "pie_noon_common_generated.h"
21 #include "precompiled.h"
30 void AdvanceFrame(WorldTime delta_time, fplbase::InputSystem* input,
34 void Render(fplbase::Renderer& renderer);
35 void AdvanceFrame(WorldTime delta_time);
36 ButtonId GetId()
const;
37 bool WillCapturePointer(
const fplbase::InputPointer& pointer,
41 fplbase::Button& button() {
return button_; }
43 const std::vector<fplbase::Material*>& up_materials()
const {
46 void set_up_material(
size_t i, fplbase::Material* up_material) {
48 if (i >= up_materials_.size()) up_materials_.resize(i + 1);
49 up_materials_[i] = up_material;
51 void set_current_up_material(
size_t which) {
52 assert(which < up_materials_.size());
56 fplbase::Material* down_material()
const {
return down_material_; }
57 void set_down_material(fplbase::Material* down_material) {
58 down_material_ = down_material;
61 mathfu::vec2 up_offset()
const {
return mathfu::vec2(up_offset_); }
62 void set_up_offset(mathfu::vec2 up_offset) { up_offset_ = up_offset; }
64 mathfu::vec2 down_offset()
const {
return mathfu::vec2(down_offset_); }
65 void set_down_offset(mathfu::vec2 down_offset) { down_offset_ = down_offset; }
67 const ButtonDef* button_def()
const {
return button_def_; }
68 void set_button_def(
const ButtonDef* button_def) { button_def_ = button_def; }
70 fplbase::Shader* inactive_shader()
const {
return inactive_shader_; }
71 void set_inactive_shader(fplbase::Shader* inactive_shader) {
72 inactive_shader_ = inactive_shader;
75 fplbase::Shader* shader()
const {
return shader_; }
76 void set_shader(fplbase::Shader* shader) { shader_ = shader; }
77 fplbase::Shader* debug_shader()
const {
return debug_shader_; }
78 void set_debug_shader(fplbase::Shader* shader) { debug_shader_ = shader; }
79 void DebugRender(
const vec3& position,
const vec3& texture_size,
80 fplbase::Renderer& renderer)
const;
81 void set_draw_bounds(
bool enable) { draw_bounds_ = enable; };
83 bool is_active()
const {
return is_active_; }
84 void set_is_active(
bool is_active) { is_active_ = is_active; }
86 bool is_visible()
const {
return is_visible_; }
87 void set_is_visible(
bool is_visible) { is_visible_ = is_visible; }
89 bool is_highlighted()
const {
return is_highlighted_; }
90 void set_is_highlighted(
bool is_highlighted) {
91 is_highlighted_ = is_highlighted;
94 void set_color(
const mathfu::vec4& color) { color_ = color; }
95 mathfu::vec4 color() {
return mathfu::vec4(color_); }
97 void SetCannonicalWindowHeight(
int height) {
98 one_over_cannonical_window_height_ = 1.0f /
static_cast<float>(height);
102 fplbase::Button button_;
103 WorldTime elapsed_time_;
105 const ButtonDef* button_def_;
106 fplbase::Shader* shader_;
107 fplbase::Shader* inactive_shader_;
108 fplbase::Shader* debug_shader_;
111 std::vector<fplbase::Material*> up_materials_;
114 fplbase::Material* down_material_;
117 mathfu::vec4_packed color_;
120 mathfu::vec2_packed up_offset_;
121 mathfu::vec2_packed down_offset_;
125 bool is_highlighted_;
130 float one_over_cannonical_window_height_;
136 void Initialize(
const StaticImageDef& image_def,
137 std::vector<fplbase::Material*> materials,
138 fplbase::Shader* shader,
139 int cannonical_window_height);
140 void Render(fplbase::Renderer& renderer);
142 ButtonId GetId()
const {
143 return image_def_ ==
nullptr ? ButtonId_Undefined : image_def_->ID();
145 const StaticImageDef* image_def()
const {
return image_def_; }
146 mathfu::vec2 scale()
const {
return mathfu::vec2(scale_); }
147 void set_scale(
const mathfu::vec2& scale) { scale_ = scale; }
148 void set_current_material_index(
int i) { current_material_index_ = i; }
150 void set_is_visible(
bool b) { is_visible_ = b; }
151 bool is_visible() {
return is_visible_; }
153 void set_color(
const mathfu::vec4& color) { color_ = color; }
154 mathfu::vec4 color() {
return mathfu::vec4(color_); }
158 void set_texture_position(
const mathfu::vec2& position) {
159 texture_position_ = position;
161 mathfu::vec2 texture_position() {
return mathfu::vec2(texture_position_); }
165 const StaticImageDef* image_def_;
169 std::vector<fplbase::Material*> materials_;
172 int current_material_index_;
175 fplbase::Shader* shader_;
178 mathfu::vec2_packed scale_;
181 mathfu::vec2_packed texture_position_;
184 mathfu::vec4_packed color_;
188 float one_over_cannonical_window_height_;
196 #endif // TOUCHSCREEN_BUTTON_H
Definition: touchscreen_button.h:133