diff --git a/data/gui/glass_iconhighlight.png b/data/gui/glass_iconhighlight.png index c384072aa..f906ef0c9 100644 Binary files a/data/gui/glass_iconhighlight.png and b/data/gui/glass_iconhighlight.png differ diff --git a/data/gui/glass_iconhighlight_focus.png b/data/gui/glass_iconhighlight_focus.png index 9c2358956..385d7b500 100644 Binary files a/data/gui/glass_iconhighlight_focus.png and b/data/gui/glass_iconhighlight_focus.png differ diff --git a/data/gui/glassspinner_focus.png b/data/gui/glassspinner_focus.png index fe9c717d1..e83e02c2d 100644 Binary files a/data/gui/glassspinner_focus.png and b/data/gui/glassspinner_focus.png differ diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index f0a25e1f6..557a77d7e 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -329,7 +329,7 @@ void IrrDriver::update(float dt) m_device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140)); m_scene_manager->drawAll(); - GUIEngine::render(); + GUIEngine::render(dt); m_device->getVideoDriver()->endScene(); } // update diff --git a/src/gui/engine.cpp b/src/gui/engine.cpp index 8d7231635..8f13e21c6 100644 --- a/src/gui/engine.cpp +++ b/src/gui/engine.cpp @@ -19,6 +19,12 @@ namespace GUIEngine std::vector g_loaded_screens; Screen* g_current_screen = NULL; + float dt = 0; + + float getLatestDt() + { + return dt; + } // ----------------------------------------------------------------------------- IrrlichtDevice* getDevice() { @@ -111,8 +117,10 @@ void transmitEvent(Widget* widget, std::string& name) g_event_callback(widget, name); } // ----------------------------------------------------------------------------- -void render() +void render(float elapsed_time) { + GUIEngine::dt = elapsed_time; + // on one end, making these static is not too clean. // on another end, these variables are really only used locally, // and making them static avoids doing the same stupid computations every frame diff --git a/src/gui/engine.hpp b/src/gui/engine.hpp index 2b8920427..efa4d3cdc 100644 --- a/src/gui/engine.hpp +++ b/src/gui/engine.hpp @@ -22,13 +22,15 @@ namespace GUIEngine extern IVideoDriver* getDriver(); extern IGUIFont* getFont(); + float getLatestDt(); + void init(irr::IrrlichtDevice* device, irr::video::IVideoDriver* driver, void (*eventCallback)(Widget* widget, std::string& name) ); void switchToScreen(const char* ); void clear(); Screen* getCurrentScreen(); - void render(); + void render(float dt); void transmitEvent(Widget* widget, std::string& name); } diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index 3845dcedc..8b2a883df 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -253,6 +253,8 @@ void Skin::drawButton(const core::rect< s32 > &rect, const bool pressed, const b } void Skin::drawRibbon(const core::rect< s32 > &rect, const Widget* widget, const bool pressed, bool focused) { + return; + // only combo ribbons need a border if ( ((RibbonWidget*)widget)->getRibbonType() != RIBBON_COMBO ) return; @@ -284,6 +286,7 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget, const bool parent_focused = GUIEngine::getGUIEnv()->getFocus() == widget->m_parent->m_element; + /* tab-bar ribbons */ if(widget->m_type == WTYPE_BUTTON) { // ribbons containing buttons are actually tabs @@ -309,13 +312,9 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget, left_border, right_border, border_above, border_below, 0); } - /* - if(mark_selected) - GUIEngine::getDriver()->draw2DRectangle( SColor(255, 0, 150, 150), rect ); - else - GUIEngine::getDriver()->draw2DRectangle( SColor(255, 150, 0, 0), rect ); - */ + } + /* icon ribbons */ else { if(widget->m_parent != NULL && widget->m_parent->m_type == WTYPE_RIBBON && @@ -324,10 +323,50 @@ void Skin::drawRibbonChild(const core::rect< s32 > &rect, const Widget* widget, if(mark_selected) { - const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X - 5, rect.UpperLeftCorner.Y - 5, - rect.UpperLeftCorner.X + rect.getWidth() + 5, - rect.UpperLeftCorner.Y + rect.getHeight() + 5); - GUIEngine::getDriver()->draw2DRectangle( SColor(2555, 0, 175, 255), rect2 ); + int grow = 45; + static float glow_effect = 0; + + if(focused || parent_focused) + { + const float dt = GUIEngine::getLatestDt(); + glow_effect += dt*3; + if (glow_effect > 6.2832 /* 2*PI */) glow_effect -= 6.2832; + grow = 45 + 10*sin(glow_effect); + } + + /* + const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X - 5 - grow, + rect.UpperLeftCorner.Y - 5 - grow, + rect.UpperLeftCorner.X + rect.getWidth() + 5 + grow, + rect.UpperLeftCorner.Y + rect.getHeight() + 5 + grow); + */ + + const int glow_center_x = rect.UpperLeftCorner.X + rect.getWidth()/2; + const int glow_center_y = rect.UpperLeftCorner.Y + rect.getHeight() - 5; + + const core::rect< s32 > rect2 = core::rect< s32 >(glow_center_x - 45 - grow, + glow_center_y - 25 - grow/2, + glow_center_x + 45 + grow, + glow_center_y + 25 + grow/2); + + // GUIEngine::getDriver()->draw2DRectangle( SColor(2555, 0, 175, 255), rect2 ); + + const int texture_w = m_tex_ficonhighlight->getSize().Width; + const int texture_h = m_tex_ficonhighlight->getSize().Height; + + core::rect source_area = core::rect(0, 0, texture_w, texture_h); + + if(!focused && !parent_focused) + { + GUIEngine::getDriver()->draw2DImage(m_tex_iconhighlight, rect2, source_area, + 0 /* no clipping */, 0, true /* alpha */); + } + else + { + GUIEngine::getDriver()->draw2DImage(m_tex_ficonhighlight, rect2, source_area, + 0 /* no clipping */, 0, true /* alpha */); + } + } }