gameui
diff src/widget.cc @ 5:5a84873185ff
rudimentary theme plugin system and other minor fixes
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 22 Mar 2014 01:50:01 +0200 |
parents | e0916bb20b7f |
children |
line diff
1.1 --- a/src/widget.cc Fri Mar 21 21:45:37 2014 +0200 1.2 +++ b/src/widget.cc Sat Mar 22 01:50:01 2014 +0200 1.3 @@ -9,7 +9,6 @@ 1.4 namespace goatkit { 1.5 1.6 struct WidgetImpl { 1.7 - std::string type_str; 1.8 std::string name; 1.9 BBox box; 1.10 1.11 @@ -22,10 +21,9 @@ 1.12 static int widget_count; 1.13 1.14 widget = new WidgetImpl; 1.15 - set_type_string("widget"); 1.16 1.17 std::stringstream sstr; 1.18 - sstr << widget->type_str << widget_count++; 1.19 + sstr << get_type_name() << widget_count++; 1.20 widget->name = sstr.str(); 1.21 1.22 widget->box.bmin = Vec2(0, 0); 1.23 @@ -43,6 +41,11 @@ 1.24 delete widget; 1.25 } 1.26 1.27 +const char *Widget::get_type_name() const 1.28 +{ 1.29 + return "widget"; 1.30 +} 1.31 + 1.32 void Widget::show() 1.33 { 1.34 widget->visible.change(true); 1.35 @@ -173,10 +176,10 @@ 1.36 1.37 void Widget::draw() const 1.38 { 1.39 - widget_draw_func draw_func = default_draw_func; 1.40 + WidgetDrawFunc draw_func = default_draw_func; 1.41 1.42 if(theme) { 1.43 - draw_func = theme->get_draw_func(widget->type_str.c_str()); 1.44 + draw_func = theme->get_draw_func(get_type_name()); 1.45 } 1.46 1.47 draw_func(this); 1.48 @@ -212,11 +215,6 @@ 1.49 } 1.50 1.51 1.52 -void Widget::set_type_string(const char *type_str) 1.53 -{ 1.54 - widget->type_str = type_str; 1.55 -} 1.56 - 1.57 /* the event dispatcher generates high-level events (click, etc) 1.58 * and calls the on_whatever() functions for both low and high-level 1.59 * events.