3 * \brief Implementation of fading icon
5 * \author Norman Feske <norman.feske@genode-labs.com>
7 * Fading icons are presented at a alpha value of 50 percent.
8 * When getting the mouse focus, we smoothly increase the
9 * alpha value to 100 percent.
13 * Copyright (C) 2005-2009
14 * Genode Labs, Feske & Helmuth Systementwicklung GbR
16 * This file is part of the Genode OS framework, which is distributed
17 * under the terms of the GNU General Public License version 2.
22 #include <l4/scout-gfx/pt_icon>
23 #include <l4/scout-gfx/fader>
25 namespace Scout_gfx { namespace Pt {
27 template <typename PT>
28 class Fade_icon : public Fader, public Icon<PT>
32 typedef Icon<PT> Base_icon;
42 Fade_icon() : _default_alpha(100), _focus_alpha(255)
44 _curr_value = _dst_value = _default_alpha;
51 int default_alpha() { return _default_alpha; }
54 * Define alpha value for unfocused icon
56 void default_alpha(int alpha ) { _default_alpha = alpha; }
59 * Define alpha value when having the mouse focus
61 void focus_alpha(int alpha) { _focus_alpha = alpha; }
68 /* call on_tick function of the fader */
69 if (Fader::on_tick() == 0) return 0;
71 Base_icon::alpha(_curr_value);
81 Base_icon::alpha(alpha);
89 Base_icon::mfocus(flag);
90 int step = _focus_alpha - _default_alpha;
91 step *= flag ? 26 : 19;
92 fade_to(flag ? _focus_alpha : _default_alpha, step >> 8);