[8498] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Benjamin Grauer |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | |
---|
[8688] | 17 | #include "glgui_imagebutton.h" |
---|
[8498] | 18 | |
---|
| 19 | #include "debug.h" |
---|
| 20 | |
---|
[8503] | 21 | namespace OrxGui |
---|
[8498] | 22 | { |
---|
| 23 | |
---|
[8689] | 24 | GLGuiImageButton::GLGuiImageButton(const std::string& label, unsigned int levelID, const std::string& imageName, GLGuiImage* image) |
---|
[8698] | 25 | : GLGuiPushButton(label) |
---|
[8689] | 26 | { |
---|
| 27 | this->imageName = imageName; |
---|
| 28 | this->levelID = levelID; |
---|
| 29 | this->image = image; |
---|
[8698] | 30 | |
---|
| 31 | image->loadImageFromFile(imageName); |
---|
[8689] | 32 | } |
---|
[8498] | 33 | |
---|
[8689] | 34 | GLGuiImageButton::~GLGuiImageButton() |
---|
| 35 | {} |
---|
| 36 | |
---|
| 37 | void GLGuiImageButton::releasing(const Vector2D& pos, bool focused) |
---|
| 38 | { |
---|
[8740] | 39 | GLGuiPushButton::releasing(pos, focused); |
---|
[8698] | 40 | if (focused) |
---|
[9406] | 41 | this->startLevel.emit(this->levelID); |
---|
[8689] | 42 | } |
---|
| 43 | |
---|
| 44 | void GLGuiImageButton::receivedFocus() |
---|
[8691] | 45 | { |
---|
[9869] | 46 | PRINTF(4)("%s:: %s\n", this->label().c_str(), this->imageName.c_str()); |
---|
[8698] | 47 | |
---|
[8691] | 48 | this->image->loadImageFromFile(this->imageName); |
---|
| 49 | } |
---|
[8689] | 50 | void GLGuiImageButton::removedFocus() |
---|
[8698] | 51 | {} |
---|
[8689] | 52 | |
---|
| 53 | |
---|
[8694] | 54 | void GLGuiImageButton::showing() |
---|
| 55 | { |
---|
[8698] | 56 | GLGuiPushButton::showing(); |
---|
[8740] | 57 | |
---|
| 58 | //this->image->show(); |
---|
[8694] | 59 | } |
---|
[8689] | 60 | |
---|
[8694] | 61 | void GLGuiImageButton::hiding() |
---|
| 62 | { |
---|
[8698] | 63 | GLGuiPushButton::hiding(); |
---|
| 64 | |
---|
[8740] | 65 | //this->image->hide(); |
---|
[8694] | 66 | } |
---|
[8689] | 67 | |
---|
[8740] | 68 | bool GLGuiImageButton::processEvent(const Event& event) |
---|
| 69 | { |
---|
| 70 | if (event.type == SDLK_SPACE) |
---|
| 71 | { |
---|
| 72 | if (event.bPressed) |
---|
| 73 | // emit(pushed()); |
---|
| 74 | ; |
---|
| 75 | else |
---|
| 76 | { |
---|
| 77 | // emit(released()); |
---|
[9406] | 78 | startLevel.emit(this->levelID); |
---|
[8740] | 79 | } |
---|
| 80 | return true; |
---|
| 81 | } |
---|
| 82 | return false; |
---|
| 83 | } |
---|
[8694] | 84 | |
---|
[8740] | 85 | |
---|
| 86 | |
---|
[8498] | 87 | } |
---|