ColorBank::Colorf ColorBank::colorf(DotPath const &path) const { if (path.isEmpty()) return Colorf(); Vector4d clamped = data(path).as<Impl::ColorData>().color; clamped = clamped.max(Vector4d(0, 0, 0, 0)).min(Vector4d(1, 1, 1, 1)); return Colorf(float(clamped.x), float(clamped.y), float(clamped.z), float(clamped.w)); }
ColorBank::Color ColorBank::color(DotPath const &path) const { if (path.isEmpty()) return Color(); Colorf col = colorf(path); return Color(round<dbyte>(col.x * 255), round<dbyte>(col.y * 255), round<dbyte>(col.z * 255), round<dbyte>(col.w * 255)); }
void setState(State st) { if(state == st) return; State const prev = state; state = st; animating = true; switch(st) { case Up: scale.setValue(1.f, .3f); scale.setStyle(prev == Down? Animation::Bounce : Animation::EaseOut); frameOpacity.setValue(.08f, .6f); if(!hoverTextColor.isEmpty()) { // Restore old color. self.setTextColor(textColor); } break; case Hover: //scale.setValue(1.1f, .15f); //scale.setStyle(Animation::EaseOut); frameOpacity.setValue(.4f, .15f); if(!hoverTextColor.isEmpty()) { // Remember the old color. textColor = self.textColorId(); self.setTextColor(hoverTextColor); } break; case Down: scale.setValue(.95f); frameOpacity.setValue(0); break; } DENG2_FOR_PUBLIC_AUDIENCE(StateChange, i) { i->buttonStateChanged(self, state); }