From c62fe609a69058e2e30f757e9a06f72a98464232 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 17 Sep 2010 15:19:34 +0000 Subject: Bump network protocol version to 19, menudescriptions use the info infrastructure, client-side lazy info update requests. Updated ROADMAP --- src/ui/Makefile.am | 4 ++-- src/ui/button.cc | 3 +++ src/ui/listview.cc | 2 ++ src/ui/modelview.cc | 4 ++-- src/ui/widget.cc | 2 +- src/ui/widget.h | 16 +++++++++------- 6 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src/ui') diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am index 98c8dab..d12571d 100644 --- a/src/ui/Makefile.am +++ b/src/ui/Makefile.am @@ -8,12 +8,12 @@ noinst_LTLIBRARIES = libui.la endif noinst_HEADERS = bitmap.h button.h console.h container.h definitions.h font.h \ - iconbutton.h inputbox.h label.h listview.h menu.h modelview.h paint.h \ + iconbutton.h inputbox.h label.h listitem.h listview.h menu.h modelview.h paint.h \ palette.h scrollpane.h toolbar.h ui.h widget.h \ window.h libui_la_SOURCES = bitmap.cc button.cc console.cc container.cc \ - font.cc iconbutton.cc inputbox.cc label.cc listview.cc \ + font.cc iconbutton.cc inputbox.cc label.cc listitem.cc listview.cc \ menu.cc modelview.cc paint.cc palette.cc scrollpane.cc \ toolbar.cc ui.cc widget.cc window.cc libui_la_LDFLAGS = -avoid-version -no-undefined diff --git a/src/ui/button.cc b/src/ui/button.cc index 85cad7e..9196b90 100644 --- a/src/ui/button.cc +++ b/src/ui/button.cc @@ -81,6 +81,9 @@ bool Button::on_keypress(const int key, const unsigned int modifier) if (key == 512 + SDL_BUTTON_LEFT) { core::cmd() << button_command << std::endl; audio::play("ui/button"); + + emit(EventButtonClicked); + return true; } diff --git a/src/ui/listview.cc b/src/ui/listview.cc index 56fa324..da320c5 100644 --- a/src/ui/listview.cc +++ b/src/ui/listview.cc @@ -13,6 +13,8 @@ ListView::ListView(Widget *parent) : Widget(parent) { set_label("listview"); set_border(true); + + listview_scroll = 0.0f; } ListView::~ListView() diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index f247e5b..18cc091 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -83,9 +83,9 @@ void ModelView::draw() } paint::color(1.0f, 1.0f, 1.0f); - model::Model *model = model::Model::find(modelview_modelname); + model::Model *model = model::Model::load(modelview_modelname); if (!model) { - paint::bitmap(global_location(), size(), "bitmap/notex"); + paint::bitmap(global_location(), size(), "bitmaps/notex"); return; } diff --git a/src/ui/widget.cc b/src/ui/widget.cc index 39fbe98..5fe6f17 100644 --- a/src/ui/widget.cc +++ b/src/ui/widget.cc @@ -327,7 +327,7 @@ bool Widget::event_emit(Widget *sender, const Event event, void *data) if (on_emit(sender, event, data)) { return true; } else if (parent()) { - return (parent()->on_emit(sender, event, data)); + return (parent()->event_emit(sender, event, data)); } else { return false; } diff --git a/src/ui/widget.h b/src/ui/widget.h index 50678fa..856fca0 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -28,7 +28,7 @@ class Widget public: /// types of custom events a widget can emit - enum Event {EventNone = 0, EventSelected = 1}; + enum Event {EventNone = 0, EventButtonClicked, EventListItemClicked}; /// create a new widget Widget(Widget *parent = 0); @@ -202,9 +202,6 @@ public: /// enable or disable widget background void set_background(bool background = true); - /// emit a custom event - void emit(const Event event, const void *data=0); - /* -- event distributors --------------------------------------- */ /** @@ -239,6 +236,14 @@ public: **/ bool event_emit(Widget *sender, const Event event, void *data = 0); + /// emit a custom event + inline void emit(const Event event, void *data=0) { + event_emit(this, event, data); + } + + /// remove all child widgets + virtual void remove_children(); + protected: /// type definition for child widgets typedef std::list Children; @@ -339,9 +344,6 @@ protected: /// remove a child widget virtual void remove_child(Widget *child); - /// remove all child widgets - virtual void remove_children(); - private: void draw_debug_border(); -- cgit v1.2.3