00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef PANGOLIN_WIDGETS_H
00029 #define PANGOLIN_WIDGETS_H
00030
00031 #include "platform.h"
00032 #include "display.h"
00033 #include "vars.h"
00034
00035 namespace pangolin
00036 {
00037
00038 bool GuiVarHasChanged();
00039
00040 View& CreatePanel(const std::string& name);
00041
00042 struct Panel : public View
00043 {
00044 Panel();
00045 Panel(const std::string& auto_register_var_prefix);
00046 void Render();
00047 void ResizeChildren();
00048 static void AddVariable(void* data, const std::string& name, _Var& var, const char* reg_type_name, bool brand_new);
00049 boost::ptr_unordered_map<const std::string,View>& context_views;
00050 };
00051
00052 template<typename T>
00053 struct Widget : public View, Handler, Var<T>
00054 {
00055 Widget(std::string title, _Var& tv)
00056 : Var<T>(tv), title(title)
00057 {
00058 handler = this;
00059 }
00060
00061 std::string title;
00062 };
00063
00064 struct Button : public Widget<bool>
00065 {
00066 Button(std::string title, _Var& tv);
00067 void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
00068 void Render();
00069
00070
00071 void ResizeChildren();
00072 int text_width;
00073 GLfloat raster[2];
00074 Viewport vinside;
00075 bool down;
00076 };
00077
00078 struct Checkbox : public Widget<bool>
00079 {
00080 Checkbox(std::string title, _Var& tv);
00081 void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
00082 void Render();
00083
00084
00085 void ResizeChildren();
00086 int text_width;
00087 GLfloat raster[2];
00088 Viewport vcb;
00089 };
00090
00091 struct Slider : public Widget<double>
00092 {
00093 Slider(std::string title, _Var& tv);
00094 void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
00095 void MouseMotion(View&, int x, int y, int mouse_state);
00096 void Keyboard(View&, unsigned char key, int x, int y, bool pressed);
00097 void Render();
00098
00099
00100 void ResizeChildren();
00101 int text_width;
00102 GLfloat raster[2];
00103 bool lock_bounds;
00104 bool logscale;
00105 };
00106
00107 struct TextInput : public Widget<std::string>
00108 {
00109 TextInput(std::string title, _Var& tv);
00110 void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
00111 void MouseMotion(View&, int x, int y, int mouse_state);
00112 void Keyboard(View&, unsigned char key, int x, int y, bool pressed);
00113 void Render();
00114
00115 std::string edit;
00116
00117
00118 void ResizeChildren();
00119 int text_width;
00120 GLfloat raster[2];
00121 bool do_edit;
00122 int sel[2];
00123 };
00124
00125
00126 }
00127 #endif // PANGOLIN_WIDGETS_H