Back to index

unity  6.0.0
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
unity::WindowButton Class Reference
Inheritance diagram for unity::WindowButton:
Inheritance graph
[legend]
Collaboration diagram for unity::WindowButton:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 WindowButton (panel::WindowButtonType type)
void SetVisualState (nux::ButtonVisualState new_state)
void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
void UpdateSize ()
void LoadImages ()
void SetOpacity (double opacity)
double GetOpacity () const
void SetFocusedState (bool focused)
void SetOverlayOpen (bool open)
bool IsOverlayOpen ()
panel::WindowButtonType GetType () const
void ChangeType (panel::WindowButtonType new_type)
void SetEnabled (bool enabled)
bool IsEnabled ()
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Protected Member Functions

std::string GetName () const
void AddProperties (GVariantBuilder *builder)
virtual std::string GetChildsName () const
 Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Private Member Functions

nux::BaseTexture * GetDashWindowButton (panel::WindowButtonType type, panel::WindowState state)

Private Attributes

panel::WindowButtonType _type
bool _focused
bool _overlay_is_open
double _opacity
nux::ObjectPtr< nux::BaseTexture > _normal_tex
nux::ObjectPtr< nux::BaseTexture > _prelight_tex
nux::ObjectPtr< nux::BaseTexture > _pressed_tex
nux::ObjectPtr< nux::BaseTexture > _unfocused_tex
nux::ObjectPtr< nux::BaseTexture > _unfocused_prelight_tex
nux::ObjectPtr< nux::BaseTexture > _unfocused_pressed_tex
nux::ObjectPtr< nux::BaseTexture > _disabled_tex
nux::ObjectPtr< nux::BaseTexture > _normal_dash_tex
nux::ObjectPtr< nux::BaseTexture > _prelight_dash_tex
nux::ObjectPtr< nux::BaseTexture > _pressed_dash_tex
nux::ObjectPtr< nux::BaseTexture > _disabled_dash_tex

Detailed Description

Definition at line 38 of file WindowButtons.cpp.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.


Constructor & Destructor Documentation

Definition at line 42 of file WindowButtons.cpp.

    : nux::Button("", NUX_TRACKER_LOCATION)
    , _type(type)
    , _focused(true)
    , _overlay_is_open(false)
    , _opacity(1.0f)
  {
    SetAcceptKeyNavFocusOnMouseDown(false);
    panel::Style::Instance().changed.connect(sigc::mem_fun(this, &WindowButton::LoadImages));
    LoadImages();
  }

Here is the call graph for this function:


Member Function Documentation

Definition at line 78 of file Introspectable.cpp.

{
  _children.push_back(child);
  child->_parents.push_back(this);
}

Here is the caller graph for this function:

void unity::WindowButton::AddProperties ( GVariantBuilder *  builder) [inline, protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 247 of file WindowButtons.cpp.

  {
    std::string type_name;
    std::string state_name;

    switch (_type)
    {
      case panel::WindowButtonType::CLOSE:
        type_name = "Close";
        break;
      case panel::WindowButtonType::MINIMIZE:
        type_name = "Minimize";
        break;
      case panel::WindowButtonType::MAXIMIZE:
        type_name = "Maximize";
        break;
      case panel::WindowButtonType::UNMAXIMIZE:
        type_name = "Unmaximize";
        break;
    }

    switch (visual_state_)
    {
      case nux::VISUAL_STATE_PRESSED:
        state_name = "pressed";
        break;
      case nux::VISUAL_STATE_PRELIGHT:
        state_name = "prelight";
        break;
      default:
        state_name = "normal";
    }

    variant::BuilderWrapper(builder).add(GetAbsoluteGeometry())
                                    .add("type", type_name)
                                    .add("visible", IsVisible() && _opacity != 0.0f)
                                    .add("sensitive", GetInputEventSensitivity())
                                    .add("enabled", IsEnabled())
                                    .add("visual_state", state_name)
                                    .add("opacity", _opacity)
                                    .add("focused", _focused)
                                    .add("overlay_mode", _overlay_is_open);
  }

Here is the call graph for this function:

Definition at line 218 of file WindowButtons.cpp.

  {
    if (_type != new_type)
    {
      _type = new_type;
      LoadImages();
    }
  }

Here is the call graph for this function:

void unity::WindowButton::Draw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [inline]

Definition at line 63 of file WindowButtons.cpp.

  {
    nux::Geometry const& geo = GetGeometry();
    nux::BaseTexture* tex;
    nux::TexCoordXForm texxform;

    GfxContext.PushClippingRectangle(geo);

    if (_overlay_is_open)
    {
      if (!IsEnabled())
      {
        tex = _disabled_dash_tex.GetPointer();
      }
      else
      {
        switch (visual_state_)
        {
          case nux::VISUAL_STATE_PRESSED:
            tex = _pressed_dash_tex.GetPointer();
            break;
          case nux::VISUAL_STATE_PRELIGHT:
            tex = _prelight_dash_tex.GetPointer();
            break;
          default:
            tex = _normal_dash_tex.GetPointer();
        }
      }
    }
    else if (!IsEnabled())
    {
      tex = _disabled_tex.GetPointer();
    }
    else if (!_focused)
    {
      switch (visual_state_)
      {
        case nux::VISUAL_STATE_PRESSED:
          tex = _unfocused_pressed_tex.GetPointer();
          break;
        case nux::VISUAL_STATE_PRELIGHT:
          tex = _unfocused_prelight_tex.GetPointer();
          break;
        default:
          tex = _unfocused_tex.GetPointer();
      }
    }
    else
    {
      switch (visual_state_)
      {
        case nux::VISUAL_STATE_PRESSED:
          tex = _pressed_tex.GetPointer();
          break;
        case nux::VISUAL_STATE_PRELIGHT:
          tex = _prelight_tex.GetPointer();
          break;
        default:
          tex = _normal_tex.GetPointer();
      }
    }

    if (tex)
    {
      GfxContext.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
                          tex->GetDeviceTexture(), texxform,
                          nux::color::White * _opacity);
    }

    GfxContext.PopClippingRectangle();
  }

Here is the call graph for this function:

std::string unity::debug::Introspectable::GetChildsName ( ) const [protected, virtual, inherited]

Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Definition at line 92 of file Introspectable.cpp.

{
  return "Children";
}

Here is the caller graph for this function:

nux::BaseTexture* unity::WindowButton::GetDashWindowButton ( panel::WindowButtonType  type,
panel::WindowState  state 
) [inline, private]

Definition at line 310 of file WindowButtons.cpp.

  {
    nux::BaseTexture* texture = nullptr;
    const char* names[] = { "close_dash", "minimize_dash", "unmaximize_dash", "maximize_dash" };
    const char* states[] = { "", "_prelight", "_pressed", "_disabled" };

    std::ostringstream subpath;
    subpath << names[static_cast<int>(type)]
            << states[static_cast<int>(state)] << ".png";

    glib::String filename(g_build_filename(PKGDATADIR, subpath.str().c_str(), NULL));

    glib::Error error;
    glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file(filename, &error));

    if (pixbuf && !error)
      texture = nux::CreateTexture2DFromPixbuf(pixbuf, true);

    if (!texture)
      texture = panel::Style::Instance().GetFallbackWindowButton(type, state);

    return texture;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Introspectable::IntrospectableList unity::debug::Introspectable::GetIntrospectableChildren ( ) [virtual, inherited]

Reimplemented in unity::hud::View, unity::launcher::LauncherModel, unity::QuicklistView, and unity::dash::ResultView.

Definition at line 41 of file Introspectable.cpp.

{
  return _children;
}

Here is the caller graph for this function:

guint64 unity::debug::Introspectable::GetIntrospectionId ( ) const [inherited]

Definition at line 97 of file Introspectable.cpp.

{
  return _id;
}

Here is the caller graph for this function:

std::string unity::WindowButton::GetName ( ) const [inline, protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 242 of file WindowButtons.cpp.

  {
    return "WindowButton";
  }
double unity::WindowButton::GetOpacity ( ) const [inline]

Definition at line 183 of file WindowButtons.cpp.

  {
    return _opacity;
  }

Definition at line 213 of file WindowButtons.cpp.

  {
    return _type;
  }
GVariant * unity::debug::Introspectable::Introspect ( ) [inherited]

Definition at line 47 of file Introspectable.cpp.

{
  GVariantBuilder  builder;
  GVariantBuilder  child_builder;
  gint             n_children = 0;

  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
  g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id));

  AddProperties(&builder);

  g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as"));

  auto children = GetIntrospectableChildren();
  for (auto it = children.begin(); it != children.end(); it++)
  {
    if ((*it)->GetName() != "")
    {
      g_variant_builder_add(&child_builder, "s", (*it)->GetName().c_str());
      n_children++;
    }
  }

  GVariant* child_results = g_variant_builder_end(&child_builder);

  if (n_children > 0)
    g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results);
  return g_variant_builder_end(&builder);
}

Here is the call graph for this function:

bool unity::WindowButton::IsEnabled ( ) [inline]

Definition at line 236 of file WindowButtons.cpp.

  {
    return IsViewEnabled();
  }

Here is the caller graph for this function:

Definition at line 208 of file WindowButtons.cpp.

  {
    return _overlay_is_open;
  }

Here is the caller graph for this function:

Definition at line 152 of file WindowButtons.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 85 of file Introspectable.cpp.

{
  _children.remove(child);
  child->_parents.remove(this);
}

Here is the caller graph for this function:

void unity::WindowButton::SetEnabled ( bool  enabled) [inline]

Definition at line 227 of file WindowButtons.cpp.

  {
    if (enabled == IsEnabled())
      return;

    SetEnableView(enabled);
    QueueDraw();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::WindowButton::SetFocusedState ( bool  focused) [inline]

Definition at line 188 of file WindowButtons.cpp.

  {
    if (_focused != focused)
    {
      _focused = focused;
      QueueDraw();
    }
  }

Here is the caller graph for this function:

void unity::WindowButton::SetOpacity ( double  opacity) [inline]

Definition at line 172 of file WindowButtons.cpp.

  {
    if (_opacity != opacity)
    {
      _opacity = opacity;
      SetInputEventSensitivity(_opacity != 0.0f);

      QueueDraw();
    }
  }

Here is the caller graph for this function:

void unity::WindowButton::SetOverlayOpen ( bool  open) [inline]

Definition at line 197 of file WindowButtons.cpp.

  {
    if (_overlay_is_open == open)
      return;

    _overlay_is_open = open;

    UpdateSize();
    QueueDraw();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::WindowButton::SetVisualState ( nux::ButtonVisualState  new_state) [inline]

Definition at line 54 of file WindowButtons.cpp.

  {
    if (new_state != visual_state_)
    {
      visual_state_ = new_state;
      QueueDraw();
    }
  }

Here is the caller graph for this function:

Definition at line 135 of file WindowButtons.cpp.

  {
    int panel_height = panel::Style::Instance().panel_height;
    nux::BaseTexture* tex;
    tex = (_overlay_is_open) ? _normal_dash_tex.GetPointer() : _normal_tex.GetPointer();
    int width = 0;
    int height = 0;

    if (tex)
    {
      width = std::min(panel_height, tex->GetWidth());
      height = std::min(panel_height, tex->GetHeight());
    }

    SetMinMaxSize(width, height);
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_disabled_dash_tex [private]

Definition at line 308 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_disabled_tex [private]

Definition at line 304 of file WindowButtons.cpp.

Definition at line 294 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_normal_dash_tex [private]

Definition at line 305 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_normal_tex [private]

Definition at line 298 of file WindowButtons.cpp.

Definition at line 296 of file WindowButtons.cpp.

Definition at line 295 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_prelight_dash_tex [private]

Definition at line 306 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_prelight_tex [private]

Definition at line 299 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_pressed_dash_tex [private]

Definition at line 307 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_pressed_tex [private]

Definition at line 300 of file WindowButtons.cpp.

Definition at line 293 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_unfocused_prelight_tex [private]

Definition at line 302 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_unfocused_pressed_tex [private]

Definition at line 303 of file WindowButtons.cpp.

nux::ObjectPtr<nux::BaseTexture> unity::WindowButton::_unfocused_tex [private]

Definition at line 301 of file WindowButtons.cpp.


The documentation for this class was generated from the following file: