示例#1
0
RatingsButton::RatingsButton(int star_size, int star_gap, NUX_FILE_LINE_DECL)
  : nux::ToggleButton(NUX_FILE_LINE_PARAM)
  , scale(1.0)
  , star_size_(star_size)
  , star_gap_(star_gap)
  , editable_(true)
  , rating_(0.0)
  , focused_star_(-1)
{
  SetAcceptKeyNavFocusOnMouseDown(false);
  SetAcceptKeyNavFocusOnMouseEnter(true);

  mouse_up.connect(sigc::mem_fun(this, &RatingsButton::RecvMouseUp));
  mouse_move.connect(sigc::mem_fun(this, &RatingsButton::RecvMouseMove));
  mouse_drag.connect(sigc::mem_fun(this, &RatingsButton::RecvMouseDrag));

  key_nav_focus_change.connect([this](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
  {
    if (has_focus && direction != nux::KEY_NAV_NONE)
      focused_star_ = 0;
    else if (!has_focus)
      focused_star_ = -1;

    QueueDraw();
  });

  key_nav_focus_activate.connect([this](nux::Area*) { SetRating(static_cast<float>(focused_star_+1)/NUM_STARS); });
  key_down.connect(sigc::mem_fun(this, &RatingsButton::OnKeyDown));

  scale.changed.connect(sigc::hide(sigc::mem_fun(this, &RatingsButton::QueueDraw)));
}
void PanelView::EnableOverlayMode(bool overlay_mode)
{
  if (overlay_mode)
  {
    bg_effect_helper_.enabled = true;
    indicators_->OverlayShown();
    menu_view_->OverlayShown();
    SetAcceptKeyNavFocusOnMouseDown(false);
  }
  else
  {
    if (opacity_ >= 1.0f)
      bg_effect_helper_.enabled = false;

    menu_view_->OverlayHidden();
    indicators_->OverlayHidden();
    SetAcceptKeyNavFocusOnMouseDown(true);
  }

  ForceUpdateBackground();
}
ScopeBarIcon::ScopeBarIcon(std::string id_, std::string icon_hint)
  : IconTexture(icon_hint, TEXTURE_SIZE)
  , id(id_)
  , active(false)
  , scale(DEFAULT_SCALE)
  , inactive_opacity_(0.4f)
{
  SetMinMaxSize(FOCUS_OVERLAY_WIDTH.CP(scale()), FOCUS_OVERLAY_HEIGHT.CP(scale()));

  focus_layer_.reset(Style::Instance().FocusOverlay(FOCUS_OVERLAY_WIDTH.CP(scale()), FOCUS_OVERLAY_HEIGHT.CP(scale())));

  SetOpacity(inactive_opacity_);

  SetAcceptKeyNavFocus(true);
  SetAcceptKeyNavFocusOnMouseDown(false);
  SetAcceptKeyNavFocusOnMouseEnter(true);

  active.changed.connect(sigc::mem_fun(this, &ScopeBarIcon::OnActiveChanged));
  scale.changed.connect(sigc::mem_fun(this, &ScopeBarIcon::UpdateScale));
  key_nav_focus_change.connect([this](nux::Area*, bool, nux::KeyNavDirection){ QueueDraw(); });
}