Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-10-03 19:57:17 +0000
committerStijn Buys <ingar@osirion.org>2010-10-03 19:57:17 +0000
commit75906b43ecb9a04fdab365bd8b1a00fbdbc66918 (patch)
tree1a065487f09c694d93612b4f99489b878b0f8a95 /src
parent25af16fac3127523d532d4b4797eec7947ed5a72 (diff)
ui updates, removed impulse and jumpgte g_devel conditions, jumpdrive crash bugfix
Diffstat (limited to 'src')
-rw-r--r--src/client/buymenu.cc4
-rw-r--r--src/client/buymenu.h4
-rw-r--r--src/client/entitymenu.cc4
-rw-r--r--src/client/entitymenu.h4
-rw-r--r--src/client/playerview.cc89
-rw-r--r--src/client/playerview.h12
-rw-r--r--src/client/targeticonbutton.cc2
-rw-r--r--src/client/trademenu.cc12
-rw-r--r--src/client/trademenu.h2
-rw-r--r--src/client/worldview.cc43
-rw-r--r--src/client/worldview.h10
-rw-r--r--src/game/base/jumppoint.cc7
-rw-r--r--src/game/base/ship.cc49
-rw-r--r--src/render/render.cc5
-rw-r--r--src/ui/iconbutton.cc17
-rw-r--r--src/ui/iconbutton.h24
-rw-r--r--src/ui/widget.cc1
-rw-r--r--src/ui/widget.h34
18 files changed, 168 insertions, 155 deletions
diff --git a/src/client/buymenu.cc b/src/client/buymenu.cc
index b42dc00..91f3dba 100644
--- a/src/client/buymenu.cc
+++ b/src/client/buymenu.cc
@@ -13,7 +13,7 @@
namespace client
{
-BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
+BuyMenu::BuyMenu(ui::Widget *parent, const char * label) : ui::Widget(parent)
{
set_border(false);
set_background(false);
@@ -150,7 +150,7 @@ bool BuyMenu::on_keypress(const int key, const unsigned int modifier)
break;
}
- return Window::on_keypress(key, modifier);
+ return Widget::on_keypress(key, modifier);
}
}
diff --git a/src/client/buymenu.h b/src/client/buymenu.h
index 85801ce..91ed10e 100644
--- a/src/client/buymenu.h
+++ b/src/client/buymenu.h
@@ -12,14 +12,14 @@
#include "ui/button.h"
#include "ui/label.h"
#include "ui/modelview.h"
-#include "ui/window.h"
+#include "ui/widget.h"
#include "ui/scrollpane.h"
namespace client
{
/// The buy menu is used to trade a single item, like a ship or an upgrade
-class BuyMenu : public ui::Window
+class BuyMenu : public ui::Widget
{
public:
/// create a new menu
diff --git a/src/client/entitymenu.cc b/src/client/entitymenu.cc
index d0fccef..56ce235 100644
--- a/src/client/entitymenu.cc
+++ b/src/client/entitymenu.cc
@@ -12,7 +12,7 @@
namespace client
{
-EntityMenu::EntityMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
+EntityMenu::EntityMenu(ui::Widget *parent, const char * label) : ui::Widget(parent)
{
set_border(false);
set_background(false);
@@ -191,7 +191,7 @@ bool EntityMenu::on_keypress(const int key, const unsigned int modifier)
break;
}
- return Window::on_keypress(key, modifier);
+ return Widget::on_keypress(key, modifier);
}
}
diff --git a/src/client/entitymenu.h b/src/client/entitymenu.h
index 0285879..4907c98 100644
--- a/src/client/entitymenu.h
+++ b/src/client/entitymenu.h
@@ -10,13 +10,13 @@
#include "core/entity.h"
#include "ui/container.h"
#include "ui/label.h"
-#include "ui/window.h"
+#include "ui/widget.h"
namespace client
{
/// entity menu
-class EntityMenu : public ui::Window
+class EntityMenu : public ui::Widget
{
public:
/// create a new menu
diff --git a/src/client/playerview.cc b/src/client/playerview.cc
index 159371c..5cbd408 100644
--- a/src/client/playerview.cc
+++ b/src/client/playerview.cc
@@ -10,8 +10,10 @@
#include "core/info.h"
#include "core/application.h"
#include "audio/audio.h"
-#include "client/playerview.h"
#include "ui/ui.h"
+#include "client/targeticonbutton.h"
+#include "client/playerview.h"
+
namespace client
{
@@ -31,16 +33,23 @@ PlayerView::PlayerView(ui::Widget *parent) : ui::Widget(parent)
label_viewname->set_background(true);
label_viewname->set_font(ui::root()->font_large());
- view_chat = new Chat(this);
+ // sub menus
view_map = new Map(this);
view_entitymenu = new EntityMenu(this);
view_buymenu = new BuyMenu(this);
view_trademenu = new TradeMenu(this);
view_inventory = new Inventory(this);
+ view_chat = new Chat(this);
- //view_hud->set_focus();
- //view_hud->raise();
- //view_entitymenu->raise();
+ // icon buttons
+ view_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "ui_menu");
+
+ view_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "launch");
+ view_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "dock", core::Entity::Dockable);
+
+ view_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "ui_chat");
+ view_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "ui_map");
+ view_inventorybutton = new ui::IconButton(this, "bitmaps/icons/button_inventory", "ui_inventory");
}
PlayerView::~PlayerView()
@@ -80,14 +89,23 @@ void PlayerView::toggle_map()
if (view_entitymenu->visible()) {
view_entitymenu->hide();
}
+
+ if (view_buymenu->visible()) {
+ view_buymenu->hide();
+ }
+
+ if (view_trademenu->visible()) {
+ view_trademenu->hide();
+ }
}
map()->toggle();
audio::play("ui/menu");
- if (map()->visible() && chat()->visible() && chat()->small_view()) {
+/* if (map()->visible() && chat()->visible() && chat()->small_view()) {
chat()->raise();
}
+*/
}
void PlayerView::toggle_inventory()
@@ -105,18 +123,31 @@ void PlayerView::toggle_inventory()
if (view_entitymenu->visible()) {
view_entitymenu->hide();
}
+
+ if (view_buymenu->visible()) {
+ view_buymenu->hide();
+ }
+
+ if (view_trademenu->visible()) {
+ view_trademenu->hide();
+ }
}
inventory()->toggle();
audio::play("ui/menu");
- if (inventory()->visible() && chat()->visible() && chat()->small_view()) {
+/* if (inventory()->visible() && chat()->visible() && chat()->small_view()) {
chat()->raise();
}
+*/
}
void PlayerView::toggle_chat()
{
+ if (chat()->small_view()) {
+ chat()->hide();
+ }
+
if (!chat()->visible()) {
if (map()->visible())
map()->hide();
@@ -125,9 +156,19 @@ void PlayerView::toggle_chat()
inventory()->hide();
}
- if (view_entitymenu->visible())
+ if (view_entitymenu->visible()) {
view_entitymenu->hide();
+ }
+
+ if (view_buymenu->visible()) {
+ view_buymenu->hide();
+ }
+
+ if (view_trademenu->visible()) {
+ view_trademenu->hide();
+ }
}
+
chat()->set_small_view(false);
chat()->toggle();
audio::play("ui/menu");
@@ -135,6 +176,10 @@ void PlayerView::toggle_chat()
void PlayerView::toggle_chatbar()
{
+ if (!chat()->small_view()) {
+ chat()->hide();
+ }
+
chat()->set_small_view(true);
chat()->toggle();
}
@@ -167,7 +212,7 @@ void PlayerView::show_menu(const std::string & args)
// requesting the info through game makes sure it is retreived from the server
view_buymenu->set_item( core::game()->request_info(id));
// show buy menu
- view_buymenu->show();
+ view_buymenu->show();
} else {
con_print << "usage: view buy [info id] show the buy menu for this kind of item" << std::endl;
}
@@ -203,8 +248,9 @@ void PlayerView::show_menu(const std::string & args)
view_entitymenu->show();
}
- if (chat()->visible() && chat()->small_view())
+/* if (chat()->visible() && chat()->small_view())
chat()->raise();
+*/
}
void PlayerView::resize()
@@ -213,6 +259,21 @@ void PlayerView::resize()
set_size(parent()->size());
+ // icons
+ const float icon_margin = 4.0f;
+ const float icon_size = 48.0f;
+ const float icon_count = 7;
+ const float l = (width() - ((icon_count + 1) * icon_margin) - (icon_count * icon_size)) * 0.5f;
+
+ view_menubutton->set_geometry(l, icon_margin, icon_size, icon_size);
+ // spacer
+ view_dockbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ view_launchbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ // spacer
+ view_inventorybutton->set_geometry(l + 4.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ view_chatbutton->set_geometry(l + 5.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
+ view_mapbutton->set_geometry(l + 6.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
+
// reposition buy menu
view_buymenu->event_resize();
// reposition trade menu
@@ -241,6 +302,14 @@ void PlayerView::resize()
void PlayerView::draw()
{
const float smallmargin = ui::UI::elementsize.height();
+
+ if (core::localcontrol()->state() == core::Entity::Docked) {
+ view_launchbutton->show();
+ view_dockbutton->hide();
+ } else {
+ view_launchbutton->hide();
+ view_dockbutton->show();
+ }
if (core::localplayer()->view()) {
diff --git a/src/client/playerview.h b/src/client/playerview.h
index 66672cf..5e82be5 100644
--- a/src/client/playerview.h
+++ b/src/client/playerview.h
@@ -7,6 +7,9 @@
#ifndef __INCLUDED_CLIENT_PLAYERVIEW_H__
#define __INCLUDED_CLIENT_PLAYERVIEW_H__
+#include "ui/widget.h"
+#include "ui/label.h"
+#include "ui/iconbutton.h"
#include "client/chat.h"
#include "client/buymenu.h"
#include "client/entitymenu.h"
@@ -15,8 +18,6 @@
#include "client/hud.h"
#include "client/map.h"
#include "client/notifications.h"
-#include "ui/widget.h"
-#include "ui/label.h"
namespace client
{
@@ -82,6 +83,13 @@ private:
TradeMenu *view_trademenu;
ui::Label *label_viewname;
+
+ ui::IconButton *view_menubutton;
+ ui::IconButton *view_dockbutton;
+ ui::IconButton *view_launchbutton;
+ ui::IconButton *view_chatbutton;
+ ui::IconButton *view_mapbutton;
+ ui::IconButton *view_inventorybutton;
};
}
diff --git a/src/client/targeticonbutton.cc b/src/client/targeticonbutton.cc
index 8bd3b1a..1ef2da0 100644
--- a/src/client/targeticonbutton.cc
+++ b/src/client/targeticonbutton.cc
@@ -33,7 +33,7 @@ bool TargetIconButton::on_keypress(const int key, const unsigned int modifier)
void TargetIconButton::draw()
{
- enable(targets::current() && ((targets::current()->flags() & entity_flags) == entity_flags));
+ set_enabled(targets::current() && ((targets::current()->flags() & entity_flags) == entity_flags));
ui::IconButton::draw();
}
diff --git a/src/client/trademenu.cc b/src/client/trademenu.cc
index c0d1f03..f0030f5 100644
--- a/src/client/trademenu.cc
+++ b/src/client/trademenu.cc
@@ -17,7 +17,7 @@
namespace client {
-TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Window(parent)
+TradeMenu::TradeMenu(ui::Widget *parent, const char * label) : ui::Widget(parent)
{
set_border(false);
set_background(false);
@@ -188,7 +188,7 @@ void TradeMenu::set_item(ui::ListItem *item)
std::ostringstream str;
str << "Price: " << std::setw(12) << (amount > 0 ? amount : 1) * trader_item->price() << '\n'
- << "Volume: " << std::setw(12) << std::setprecision(2) << (float)(amount > 0 ? amount : 1) * trader_item->info()->volume();
+ << "Volume: " << std::setw(12) << (float)(amount > 0 ? amount : 1) * trader_item->info()->volume();
menu_tradertext->set_text(str.str());
} else {
menu_msgtext->set_text("^1Can not sell here");
@@ -244,7 +244,7 @@ void TradeMenu::set_item(ui::ListItem *item)
std::ostringstream str;
str << "Price: " << std::setw(12) << (amount > 0 ? amount : 1) * item->item()->price() << '\n'
- << "Volume: " << std::setw(12) << std::setprecision(2) << (float) (amount > 0 ? amount : 1) * item->info()->volume();
+ << "Volume: " << std::setw(12) << (float) (amount > 0 ? amount : 1) * item->info()->volume();
menu_tradertext->set_text(str.str());
}
@@ -337,7 +337,7 @@ bool TradeMenu::on_emit(Widget *sender, const Event event, void *data)
return true;
}
- return ui::Window::on_emit(sender, event, data);
+ return ui::Widget::on_emit(sender, event, data);
}
void TradeMenu::draw()
@@ -361,7 +361,7 @@ void TradeMenu::draw()
}
menu_inventorytext->set_text(str.str());
- Window::draw();
+ Widget::draw();
}
bool TradeMenu::on_keypress(const int key, const unsigned int modifier)
@@ -376,7 +376,7 @@ bool TradeMenu::on_keypress(const int key, const unsigned int modifier)
break;
}
- return Window::on_keypress(key, modifier);
+ return Widget::on_keypress(key, modifier);
}
} // namespace client
diff --git a/src/client/trademenu.h b/src/client/trademenu.h
index ecc41b9..56fe259 100644
--- a/src/client/trademenu.h
+++ b/src/client/trademenu.h
@@ -22,7 +22,7 @@ namespace client
{
/// trade menu
-class TradeMenu : public ui::Window
+class TradeMenu : public ui::Widget
{
public:
/// create a new trade menu
diff --git a/src/client/worldview.cc b/src/client/worldview.cc
index 265277f..35cada2 100644
--- a/src/client/worldview.cc
+++ b/src/client/worldview.cc
@@ -27,16 +27,6 @@ WorldView::WorldView(ui::Widget *parent) : ui::Widget(parent)
view_playerview = new PlayerView(this);
view_playerview->raise();
view_playerview->hide();
-
- // icon buttons
- view_menubutton = new ui::IconButton(this, "bitmaps/icons/button_menu", "ui_menu");
-
- view_launchbutton = new ui::IconButton(this, "bitmaps/icons/button_launch", "launch");
- view_dockbutton = new TargetIconButton(this, "bitmaps/icons/button_dock", "dock", core::Entity::Dockable);
-
- view_chatbutton = new ui::IconButton(this, "bitmaps/icons/button_chat", "ui_chat");
- view_mapbutton = new ui::IconButton(this, "bitmaps/icons/button_map", "ui_map");
- view_inventorybutton = new ui::IconButton(this, "bitmaps/icons/button_inventory", "ui_inventory");
}
WorldView::~WorldView()
@@ -66,21 +56,6 @@ void WorldView::resize()
view_keyinfo->set_size(font()->width()*12, font()->height()*1);
view_keyinfo->set_location(width() - view_keyinfo->width() - smallmargin,
height() - view_keyinfo->height() - smallmargin);
-
- // icons
- const float icon_margin = 4.0f;
- const float icon_size = 48.0f;
- const float icon_count = 7;
- const float l = (width() - ((icon_count + 1) * icon_margin) - (icon_count * icon_size)) * 0.5f;
-
- view_menubutton->set_geometry(l, icon_margin, icon_size, icon_size);
- // spacer
- view_dockbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_launchbutton->set_geometry(l + 2.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- // spacer
- view_inventorybutton->set_geometry(l + 4.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_chatbutton->set_geometry(l + 5.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
- view_mapbutton->set_geometry(l + 6.0f *(icon_margin + icon_size), icon_margin, icon_size, icon_size);
}
void WorldView::clear()
@@ -104,28 +79,10 @@ void WorldView::draw()
if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol() || (core::localplayer()->view() && !core::localplayer()->view()->menus().size())) {
view_playerview->hide();
- view_menubutton->hide();
- view_dockbutton->hide();
- view_launchbutton->hide();
- view_chatbutton->hide();
- view_mapbutton->hide();
- view_inventorybutton->hide();
} else {
view_playerview->show();
view_playerview->set_focus();
- if (core::localcontrol()->state() == core::Entity::Docked) {
- view_launchbutton->show();
- view_dockbutton->hide();
- } else {
- view_launchbutton->hide();
- view_dockbutton->show();
- }
-
- view_menubutton->show();
- view_chatbutton->show();
- view_mapbutton->show();
- view_inventorybutton->show();
}
}
diff --git a/src/client/worldview.h b/src/client/worldview.h
index 266d3eb..9def8c5 100644
--- a/src/client/worldview.h
+++ b/src/client/worldview.h
@@ -10,7 +10,6 @@
#include "ui/widget.h"
#include "client/playerview.h"
#include "client/infowidget.h"
-#include "ui/iconbutton.h"
namespace client
{
@@ -40,15 +39,6 @@ private:
KeyInfoWidget *view_keyinfo;
Notifications *view_notify;
PlayerView *view_playerview;
-
- ui::IconButton *view_menubutton;
-
- ui::IconButton *view_dockbutton;
- ui::IconButton *view_launchbutton;
-
- ui::IconButton *view_chatbutton;
- ui::IconButton *view_mapbutton;
- ui::IconButton *view_inventorybutton;
};
}
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc
index 9ef18d9..ae66262 100644
--- a/src/game/base/jumppoint.cc
+++ b/src/game/base/jumppoint.cc
@@ -20,6 +20,8 @@ JumpPoint::JumpPoint() : core::EntityDynamic()
set_radius(0.25f);
set_flag(core::Entity::Static);
set_flag(core::Entity::Bright);
+ // FIXME jumppoints should be harder to find
+ set_flag(core::Entity::ShowOnMap);
entity_moduletypeid = jumppoint_enttype;
jumppoint_target = 0;
@@ -60,17 +62,18 @@ void JumpPoint::validate()
core::Entity *targetentity = targetzone->find_entity(entitylabel);
if (!targetentity) {
- con_warn << " Could not find target jumppoint '" << entitylabel << "'\n";
+ con_warn << " Could not find target jumppoint '" << entitylabel << "' in zone '" << zonelabel << "'\n";
return;
}
if ((targetentity->moduletype() != jumppoint_enttype) && (targetentity->moduletype() != jumpgate_enttype)) {
- con_warn << " Jumppoint with invalid target jumppoint '" << entitylabel << "'\n";
+ con_warn << " Jumppoint with invalid target jumppoint '" << entitylabel << "' in zone '" << zonelabel << "'\n";
return;
}
jumppoint_target = static_cast<JumpPoint *>(targetentity);
+ con_debug << " jumppoint to " << targetzone->label() << std::endl;
//con_debug << " Jumppoint " << zone->label() << ":" << label() << " with target " << targetlabel() << std::endl;
}
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index d51a119..78764e3 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -23,6 +23,9 @@ namespace game
{
const float MIN_DELTA = 0.000001f;
+const float impulse_delay = 3.0f; // 3 second delay before impulse kicks in
+ // note: this delay must match the impulse drive sound set
+const float jump_delay = 5.0f; // 5 seconds delay before jump driv kicks in
Ship::Ship(core::Player *owner, ShipModel *shipmodel) : core::EntityControlable(), PhysicsBody(this)
{
@@ -126,29 +129,30 @@ void Ship::func_impulse()
entity_state = core::Entity::Normal;
target_thrust = 1.0f;
entity_thrust = 0.0f;
+ set_dirty();
+ return;
+ }
- } else if (entity_state == core::Entity::ImpulseInitiate) {
+ if (entity_state == core::Entity::ImpulseInitiate) {
entity_state = core::Entity::Normal;
-
- } else if (entity_state != core::Entity::Normal) {
+ set_dirty();
return;
+ }
- } else {
- if (entity_state == core::Entity::JumpInitiate) {
- ship_jumpdrive_timer = 0;
- entity_timer = 0;
- }
-
- entity_state = core::Entity::ImpulseInitiate;
- if (Game::g_devel->value()) {
- entity_timer = 0;
- } else {
- entity_timer = 3;
- }
- ship_impulsedrive_timer = core::server()->time();
+ if (entity_state == core::Entity::JumpInitiate) {
+ entity_state = core::Entity::Normal;
+ ship_jumpdrive_timer = 0;
+ entity_timer = 0;
+ set_dirty();
}
- set_dirty();
+ if (entity_state != core::Entity::Normal)
+ return;
+
+ entity_state = core::Entity::ImpulseInitiate;
+ entity_timer = impulse_delay;
+ ship_impulsedrive_timer = core::server()->time();
+
}
void Ship::initiate_jump(JumpPoint *depart)
@@ -163,14 +167,9 @@ void Ship::initiate_jump(JumpPoint *depart)
ship_jumpdepart = depart;
entity_state = core::Entity::JumpInitiate;
-
- if (Game::g_devel->value()) {
- entity_timer = 0;
- } else {
- entity_timer = 8;
- }
-
+ entity_timer = jump_delay;
ship_jumpdrive_timer = core::server()->time();
+
set_dirty();
}
@@ -351,7 +350,7 @@ void Ship::frame(float seconds)
set_zone(ship_jumpdepart->target()->zone());
- if (owner() && owner()->view()->zone() != ship_jumpdepart->target()->zone())
+ if (owner() && owner()->view() && (owner()->view()->zone() != ship_jumpdepart->target()->zone()))
owner()->set_view(0);
owner()->send("^BJumping to the " + ship_jumpdepart->target()->zone()->name());
diff --git a/src/render/render.cc b/src/render/render.cc
index 384280c..5a6c6bc 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -80,7 +80,7 @@ void init(int width, int height)
r_normals->set_info("[bool] render face normals");
r_normalize = core::Cvar::get("r_normalize", "0", core::Cvar::Archive);
- r_normalize->set_info("[bool] use GL_NORMALIZE instead of GL_RESCALE_NORMAL (recommended off)");
+ r_normalize->set_info("[bool] use GL_NORMALIZE instead of GL_RESCALE_NORMAL (recommended off)");
r_grid = core::Cvar::get("r_grid", "0", core::Cvar::Archive);
r_grid->set_info("[bool] render the space grid");
@@ -92,7 +92,7 @@ void init(int width, int height)
r_bbox->set_info("[bool] render model bounding box");
r_sky = core::Cvar::get("r_sky", "1", core::Cvar::Archive);
- r_sky->set_info("[bool] render the sky globe");
+ r_sky->set_info("[bool] render the sky");
r_particles = core::Cvar::get("r_particles", "1", core::Cvar::Archive);
r_particles->set_info("[bool] render particles");
@@ -141,7 +141,6 @@ void init(int width, int height)
func = core::Func::add("list_materials", func_list_materials);
func->set_info("list registered materials");
-
func = core::Func::add("list_particles", func_list_particles);
func->set_info("list registered particle scripts");
diff --git a/src/ui/iconbutton.cc b/src/ui/iconbutton.cc
index 87203ee..204918e 100644
--- a/src/ui/iconbutton.cc
+++ b/src/ui/iconbutton.cc
@@ -24,7 +24,7 @@ IconButton::IconButton(Widget *parent, const char *icon, const char *command) :
set_border(false);
set_command(command);
set_icon(icon);
- iconbutton_enabled = true;
+ set_highlight(false);
}
IconButton::~IconButton()
@@ -58,19 +58,14 @@ void IconButton::set_icon(const char *icon)
iconbutton_icon.clear();
}
-void IconButton::set_icon(const std::string &icon)
+void IconButton::set_highlight(const bool highlight)
{
- iconbutton_icon.assign(icon);
+ iconbutton_highlight = highlight;
}
-void IconButton::enable(bool enabled)
-{
- iconbutton_enabled = enabled;
-}
-
-void IconButton::disable(bool disabled)
+void IconButton::set_icon(const std::string &icon)
{
- iconbutton_enabled = !disabled;
+ iconbutton_icon.assign(icon);
}
void IconButton::draw()
@@ -80,7 +75,7 @@ void IconButton::draw()
if (disabled()) {
Paint::set_color(palette()->disabled());
- } else if (has_mouse_focus()) {
+ } else if (highlight() || has_mouse_focus()) {
Paint::set_color(palette()->highlight());
} else {
Paint::set_color(palette()->foreground());
diff --git a/src/ui/iconbutton.h b/src/ui/iconbutton.h
index 37d1c7b..c9a7c5b 100644
--- a/src/ui/iconbutton.h
+++ b/src/ui/iconbutton.h
@@ -28,22 +28,11 @@ public:
return iconbutton_icon;
}
- /// enabled or disabled
- inline const bool enabled() const {
- return iconbutton_enabled;
+ /// highlight state
+ inline const bool highlight() const {
+ return iconbutton_highlight;
}
-
- /// enabled or disabled
- inline const bool disabled() const {
- return !iconbutton_enabled;
- }
-
- /// enable or disable the button
- void enable(bool enabled = true);
-
- /// enable or disable the button
- void disable(bool disabled = true);
-
+
/// set the command this button will execute
void set_command(const std::string &command);
@@ -56,6 +45,9 @@ public:
/// set the icon texture
void set_icon(const char *icon);
+ /// set the highlight state
+ void set_highlight(const bool highlight);
+
/// print button description
virtual void print(const size_t indent) const;
@@ -78,7 +70,7 @@ protected:
private:
std::string iconbutton_command;
std::string iconbutton_icon;
- bool iconbutton_enabled;
+ bool iconbutton_highlight;
};
}
diff --git a/src/ui/widget.cc b/src/ui/widget.cc
index 2f35185..f663cc6 100644
--- a/src/ui/widget.cc
+++ b/src/ui/widget.cc
@@ -188,6 +188,7 @@ void Widget::set_enabled(const bool enabled)
else
disable();
}
+
void Widget::set_border(const bool border)
{
widget_border = border;
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 8b61bc1..530af05 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -57,7 +57,7 @@ public:
/**
* @see location()
*/
- inline float left() const {
+ inline const float left() const {
return widget_location.x();
}
@@ -66,7 +66,7 @@ public:
* @see location()
* @see size()
*/
- inline float right() const {
+ inline const float right() const {
return widget_location.x() + widget_size.width();
}
@@ -74,7 +74,7 @@ public:
/**
* @see location()
*/
- inline float top() const {
+ inline const float top() const {
return widget_location.y();
}
@@ -83,7 +83,7 @@ public:
* @see location()
* @see size()
*/
- inline float bottom() const {
+ inline const float bottom() const {
return widget_location.y() + widget_size.height();
}
@@ -91,7 +91,7 @@ public:
/**
* @see size()
*/
- inline float width() const {
+ inline const float width() const {
return widget_size.width();
}
@@ -99,7 +99,7 @@ public:
/**
* @see size()
*/
- inline float height() const {
+ inline const float height() const {
return widget_size.height();
}
@@ -109,32 +109,32 @@ public:
}
/// true if this widget will draw a background
- inline bool background() const {
+ inline const bool background() const {
return widget_background;
}
/// true if this widget will draw a border
- inline bool border() const {
+ inline const bool border() const {
return widget_border;
}
/// true if this widget is visible
- inline bool visible() const {
+ inline const bool visible() const {
return widget_visible;
}
/// true if this widget is not visible
- inline bool hidden() const {
+ inline const bool hidden() const {
return !widget_visible;
}
/// true if the widget is enabled
- inline bool enabled() const {
+ inline const bool enabled() const {
return widget_enabled;
}
/// true if the widget is disabled
- inline bool disabled() const {
+ inline const bool disabled() const {
return !widget_enabled;
}
@@ -170,12 +170,12 @@ public:
/// set visibility
void set_visible(const bool visible = true);
- /// disable the widget
- virtual void disable();
-
- /// enable the widget
+ /// enable or disable the widget
virtual void enable();
-
+
+ /// enable or disable the widget
+ virtual void disable();
+
///set enabled or disabled state
void set_enabled(const bool enabled = true);