widgets.h
Go to the documentation of this file.
00001 /* This file is part of the Pangolin Project.
00002  * http://github.com/stevenlovegrove/Pangolin
00003  *
00004  * Copyright (c) 2011 Steven Lovegrove
00005  *
00006  * Permission is hereby granted, free of charge, to any person
00007  * obtaining a copy of this software and associated documentation
00008  * files (the "Software"), to deal in the Software without
00009  * restriction, including without limitation the rights to use,
00010  * copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following
00013  * conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be
00016  * included in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00019  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00020  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00021  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00022  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00023  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  * OTHER DEALINGS IN THE SOFTWARE.
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     //Cache params on resize
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     //Cache params on resize
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     //Cache params on resize
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     //Cache params on resize
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


pangolin_wrapper
Author(s): Todor Stoyanov
autogenerated on Wed Feb 13 2013 14:03:25