32 #include "cairo/cairo.h"
39 #include "base/threaded_timer.h"
40 #include "base/geometry.h"
42 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45 typedef std::list<double> ThresholdList;
53 void set_right_align(
bool flag);
54 void enable_auto_scale(
bool enable);
55 double get_upper_range()
const;
56 void set_value_range(
double low,
double high);
57 void set_thresholds(ThresholdList lower_thresholds, ThresholdList upper_thresholds);
58 void set_description(
const std::string& description);
60 virtual void repaint(cairo_t *cr,
int areax,
int areay,
int areaw,
int areah);
61 virtual void get_layout_size(
int* w,
int* h);
63 virtual void step() {};
67 cairo_surface_t* _background;
70 base::Rect _diagram_area;
76 double normalize(
double input);
77 virtual void prepare_background() {};
78 virtual void destroy_background();
79 virtual void range_updated(
double scale,
double offset) {};
80 virtual bool layout(cairo_t *cr);
81 void auto_scale(
double value);
82 bool compute_scale(
double min,
double max);
83 virtual void get_minmax_values(
double* min,
double* max);
88 ThresholdList _lower_thresholds;
89 ThresholdList _upper_thresholds;
90 std::string _description;
95 int _description_offset;
97 cairo_t* _layout_context;
98 cairo_surface_t* _layout_surface;
99 void create_context_for_layout();
105 virtual void repaint(cairo_t *cr,
int areax,
int areay,
int areaw,
int areah);
109 #define HEARTBEAT_DATA_SIZE 80
117 virtual void repaint(cairo_t *cr,
int areax,
int areay,
int areaw,
int areah);
120 void set_value(
double value);
122 virtual void prepare_background();
123 virtual void range_updated(
double scale,
double offset);
124 virtual void get_minmax_values(
double* min,
double* max);
127 double _luminance[HEARTBEAT_DATA_SIZE];
128 double _deflection[HEARTBEAT_DATA_SIZE];
137 ServerStatusWidget();
138 ~ServerStatusWidget();
141 virtual void repaint(cairo_t *cr,
int areax,
int areay,
int areaw,
int areah);
143 void set_server_status(
int status);
145 virtual bool layout(cairo_t *cr);
149 cairo_surface_t* _image_unknown;
150 cairo_surface_t* _image_running;
151 cairo_surface_t* _image_stopped;
164 virtual void repaint(cairo_t *cr,
int areax,
int areay,
int areaw,
int areah);
166 void set_value(
double value);
168 virtual void prepare_background();
169 virtual void destroy_background();
170 void create_value_gradient();
171 virtual void range_updated(
double scale,
double offset);
172 virtual void get_minmax_values(
double* min,
double* max);
175 cairo_pattern_t* _value_gradient;
176 cairo_surface_t* _grid;
183 #define LINE_SERIES_DATA_SIZE 500
189 ~LineDiagramWidget();
192 virtual void repaint(cairo_t *cr,
int areax,
int areay,
int areaw,
int areah);
195 void set_value(
double value);
197 virtual void prepare_background();
198 virtual void destroy_background();
199 virtual void range_updated(
double scale,
double offset);
200 virtual void get_minmax_values(
double* min,
double* max);
203 double _deflection[LINE_SERIES_DATA_SIZE];
204 double _timestamp[LINE_SERIES_DATA_SIZE];
206 cairo_pattern_t* _value_gradient;
208 cairo_surface_t* _grid;
209 double _content_alpha;
210 double _warning_alpha;
215 enum {Awake, GoSleeping, Sleeping, Awaking} _sleep_mode;
217 cairo_text_extents_t _warning_extents;
219 void show_feedback(cairo_t* cr,
const base::Rect& bounds);
220 void begin_sleeping(
double timestamp);
221 void end_sleeping(
double timestamp);
222 bool feedback_step();
227 #endif // !DOXYGEN_SHOULD_SKIP_THIS
229 #endif // _WIDGETS_H_