void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { if (skip_draw_) return; nux::Geometry const& geo = GetGeometry(); GfxContext.PushClippingRectangle(geo); gPainter.PaintBackground(GfxContext, geo); // set up our texture mode nux::TexCoordXForm texxform; texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP); texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); // clear what is behind us unsigned int alpha = 0, src = 0, dest = 0; GfxContext.GetRenderStates().GetBlend(alpha, src, dest); GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); GfxContext.GetRenderStates().SetBlend(true); nux::Color col(nux::color::Black); col.alpha = 0; GfxContext.QRP_Color(geo.x, geo.y, geo.width, geo.height, col); nux::BaseTexture* texture = normal_->GetTexture(); if (HasKeyFocus() || fake_focused()) texture = active_->GetTexture(); else if (HasKeyFocus()) texture = prelight_->GetTexture(); else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED) texture = active_->GetTexture(); GfxContext.QRP_1Tex(geo.x, geo.y, texture->GetWidth(), texture->GetHeight(), texture->GetDeviceTexture(), texxform, nux::color::White); GfxContext.GetRenderStates().SetBlend(alpha, src, dest); GfxContext.PopClippingRectangle(); }
void RatingsButton::RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags) { if (!editable_) return; int width = NUM_STARS*star_size_.CP(scale)+ (NUM_STARS-1)*star_gap_.CP(scale); focused_star_ = std::max(0, std::min(static_cast<int>(ceil((static_cast<float>(x) / width) * NUM_STARS) - 1), NUM_STARS - 1)); if (!HasKeyFocus()) nux::GetWindowCompositor().SetKeyFocusArea(this); QueueDraw(); }
void ScopeBarIcon::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { nux::Geometry const& geo = GetGeometry(); graphics_engine.PushClippingRectangle(geo); if (HasKeyFocus() && focus_layer_) { nux::Geometry geo(GetGeometry()); nux::AbstractPaintLayer* layer = focus_layer_.get(); layer->SetGeometry(geo); layer->Renderlayer(graphics_engine); } if (texture()) { unsigned int current_alpha_blend; unsigned int current_src_blend_factor; unsigned int current_dest_blend_factor; graphics_engine.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); float opacity = active ? 1.0f : inactive_opacity_; int width = 0, height = 0; GetTextureSize(&width, &height); nux::TexCoordXForm texxform; texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); graphics_engine.QRP_1Tex(geo.x + ((geo.width - width) / 2), geo.y + ((geo.height - height) / 2), width, height, texture()->GetDeviceTexture(), texxform, nux::color::White * opacity); graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); } graphics_engine.PopClippingRectangle(); }