diff options
author | Stijn Buys <ingar@osirion.org> | 2009-06-07 18:13:15 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-06-07 18:13:15 +0000 |
commit | f33257521bf80dcef8575c4fc3ddaf4a40ff588a (patch) | |
tree | 5e3a112e814478ba3ab624e0867761654a5ea0a4 /src/ui/modelview.cc | |
parent | 5b94df1df2707b36401d91d80b92d0e4cdfd2277 (diff) |
fixed a few widget order problems, changed map targetting behaviour
Diffstat (limited to 'src/ui/modelview.cc')
-rwxr-xr-x | src/ui/modelview.cc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index 11dd318..e3816cd 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -22,6 +22,8 @@ ModelView::ModelView(Widget *parent, const char *modelname) : Widget(parent) set_label("modelview"); set_modelname(modelname); + + modelview_zoom = 1.0f; } ModelView::~ModelView() @@ -51,6 +53,29 @@ void ModelView::set_color(const math::Color & color) modelview_color.assign(color); } +void ModelView::set_zoom(const float zoom) +{ + modelview_zoom = zoom; + math::clamp(modelview_zoom, 1.0f, 10.0f); +} + +bool ModelView::on_keypress(const int key, const unsigned int modifier) +{ + if (key == 512 + SDL_BUTTON_WHEELUP) { + modelview_zoom -= 0.1f; + if (modelview_zoom < 1.0f) + modelview_zoom = 1.0f; + return true; + } else if (key == 512 + SDL_BUTTON_WHEELDOWN) { + modelview_zoom += 0.1f; + if (modelview_zoom > 10.0f) + modelview_zoom = 10.0f; + return true; + } + + return false; +} + void ModelView::draw() { if (!modelview_modelname.size()) @@ -68,7 +93,7 @@ void ModelView::draw() gl::clear(GL_DEPTH_BUFFER_BIT); // gl 3d mode - render::Camera::frustum_default(model->radius(), center.x, center.y); + render::Camera::frustum_default(model->radius() * modelview_zoom, center.x, center.y); gl::disable(GL_BLEND); gl::depthmask(GL_TRUE); // enable writing to the depth buffer |