/* * \brief Implementation of fading icon * \date 2005-10-24 * \author Norman Feske * * Fading icons are presented at a alpha value of 50 percent. * When getting the mouse focus, we smoothly increase the * alpha value to 100 percent. */ /* * Copyright (C) 2005-2013 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. */ #ifndef _FADE_ICON_H_ #define _FADE_ICON_H_ #include #include #include "widgets.h" namespace Scout { template class Fade_icon; } template class Scout::Fade_icon : public Fader, public Icon { private: int _default_alpha; int _focus_alpha; public: /** * Constructor */ Fade_icon() { _curr_value = _dst_value = _default_alpha = 100; _focus_alpha = 255; step(12); } /** * Accessor functions */ int default_alpha() { return _default_alpha; } /** * Define alpha value for unfocused icon */ void default_alpha(int alpha ) { _default_alpha = alpha; } /** * Define alpha value when having the mouse focus */ void focus_alpha(int alpha) { _focus_alpha = alpha; } /** * Tick interface */ int on_tick() { /* call on_tick function of the fader */ if (Fader::on_tick() == 0) return 0; Icon::alpha(_curr_value); return 1; } /** * Icon interface */ void alpha(int alpha) { _curr_value = alpha; Icon::alpha(alpha); } /** * Element interface */ void mfocus(int flag) { Icon::mfocus(flag); int step = _focus_alpha - _default_alpha; step *= flag ? 26 : 19; fade_to(flag ? _focus_alpha : _default_alpha, step >> 8); } }; #endif /* _FADE_ICON_H_ */