Back to index

unity  6.0.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
unity::shortcut::View Class Reference

#include <ShortcutView.h>

Inheritance diagram for unity::shortcut::View:
Inheritance graph
[legend]
Collaboration diagram for unity::shortcut::View:
Collaboration graph
[legend]

List of all members.

Public Types

typedef nux::ObjectPtr< ViewPtr
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 View ()
 ~View ()
bool GetBaseGeometry (nux::Geometry &)
void SetAdjustment (int x, int y)
void SetModel (Model::Ptr model)
Model::Ptr GetModel ()
void SetupBackground (bool enabled=true)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

nux::Property< nux::Color > background_color
nux::Property
< UnityWindowStyle::Ptr
style

Protected Member Functions

void DrawOverlay (nux::GraphicsEngine &GfxContext, bool force_draw, nux::Geometry clip)
nux::Geometry GetBackgroundGeometry ()
std::string GetName () const
void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
virtual void PreDraw (nux::GraphicsEngine &GfxContext, bool force_draw)
virtual void PostDraw (nux::GraphicsEngine &GfxContext, bool force_draw)
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_DECLARE_OBJECT_TYPE (View, ui::UnityWindowView)
nux::LinearLayout * CreateSectionLayout (const char *section_name)
nux::View * CreateShortKeyEntryView (AbstractHint::Ptr const &hint)
nux::LinearLayout * CreateIntermediateLayout ()
void RenderColumns ()

Private Attributes

Model::Ptr model_
nux::VLayout * layout_
nux::HLayout * columns_layout_
std::vector< nux::VLayout * > columns_
int x_adjustment_
int y_adjustment_

Detailed Description

Definition at line 40 of file ShortcutView.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

typedef nux::ObjectPtr<View> unity::shortcut::View::Ptr

Definition at line 44 of file ShortcutView.h.


Constructor & Destructor Documentation

Definition at line 68 of file ShortcutView.cpp.

  : ui::UnityWindowView()
  , x_adjustment_(0)
  , y_adjustment_(0)
{
  layout_ = new nux::VLayout();
  layout_->SetPadding(50, 38);
  layout_->SetSpaceBetweenChildren(20);
  SetLayout(layout_);

  std::string header = "<b>";
  header += _("Keyboard Shortcuts");
  header += "</b>";

  nux::StaticText* header_view = new nux::StaticText(header, NUX_TRACKER_LOCATION);
  header_view->SetTextPointSize(20/1.33);
  header_view->SetFontName("Ubuntu");
  layout_->AddView(header_view, 1 , nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);

  layout_->AddView(new HSeparator(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);

  columns_layout_ = new nux::HLayout();
  columns_layout_->SetSpaceBetweenChildren(30);
  layout_->AddLayout(columns_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);

  // Column 1...
  columns_.push_back(new nux::VLayout());
  columns_layout_->AddLayout(columns_[0], 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);

  // Column 2...
  columns_.push_back(new nux::VLayout());
  columns_layout_->AddLayout(columns_[1], 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
}

Definition at line 102 of file ShortcutView.cpp.

{
}

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::ui::UnityWindowView::AddProperties ( GVariantBuilder *  builder) [protected, virtual, inherited]

Implements unity::debug::Introspectable.

Reimplemented in unity::switcher::SwitcherView.

Definition at line 255 of file UnityWindowView.cpp.

{
  unity::variant::BuilderWrapper(builder)
    .add("bg-texture-is-valid", bg_texture_.IsValid());
}

Here is the call graph for this function:

nux::LinearLayout * unity::shortcut::View::CreateIntermediateLayout ( ) [private]

Definition at line 225 of file ShortcutView.cpp.

{
  nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
  layout->SetSpaceBetweenChildren(LINE_SPACING);

  return layout;
}

Here is the caller graph for this function:

nux::LinearLayout * unity::shortcut::View::CreateSectionLayout ( const char *  section_name) [private]

Definition at line 146 of file ShortcutView.cpp.

{
  nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);

  std::string name("<b>");
  name += glib::String(g_markup_escape_text(section_name, -1)).Str();
  name += "</b>";

  nux::StaticText* section_name_view = new nux::StaticText(name, NUX_TRACKER_LOCATION);
  section_name_view->SetTextPointSize(SECTION_NAME_FONT_SIZE);
  section_name_view->SetFontName("Ubuntu");
  layout->AddView(new nux::SpaceLayout(10, 10, 10, 10), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
  layout->AddView(section_name_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
  layout->AddView(new nux::SpaceLayout(15, 15, 15, 15), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);

  return layout;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nux::View * unity::shortcut::View::CreateShortKeyEntryView ( AbstractHint::Ptr const &  hint) [private]

Definition at line 164 of file ShortcutView.cpp.

{
  nux::View* view = new SectionView(NUX_TRACKER_LOCATION);

  nux::HLayout* layout = new nux::HLayout("EntryLayout", NUX_TRACKER_LOCATION);
  view->SetLayout(layout);

  nux::HLayout* shortkey_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
  nux::HLayout* description_layout = new nux::HLayout(NUX_TRACKER_LOCATION);

  glib::String shortkey(g_markup_escape_text(hint->shortkey().c_str(), -1));

  std::string skey = "<b>";
  skey += shortkey.Str();
  skey += "</b>";

  nux::StaticText* shortkey_view = new nux::StaticText(skey, NUX_TRACKER_LOCATION);
  shortkey_view->SetTextAlignment(nux::StaticText::ALIGN_LEFT);
  shortkey_view->SetFontName("Ubuntu");
  shortkey_view->SetTextPointSize(SHORTKEY_ENTRY_FONT_SIZE);
  shortkey_view->SetMinimumWidth(SHORTKEY_COLUMN_WIDTH);
  shortkey_view->SetMaximumWidth(SHORTKEY_COLUMN_WIDTH);

  glib::String es_desc(g_markup_escape_text(hint->description().c_str(), -1));

  nux::StaticText* description_view = new nux::StaticText(es_desc.Value(), NUX_TRACKER_LOCATION);
  description_view->SetTextAlignment(nux::StaticText::ALIGN_LEFT);
  shortkey_view->SetFontName("Ubuntu");
  description_view->SetTextPointSize(SHORTKEY_ENTRY_FONT_SIZE);
  description_view->SetMinimumWidth(DESCRIPTION_COLUMN_WIDTH);
  description_view->SetMaximumWidth(DESCRIPTION_COLUMN_WIDTH);

  shortkey_layout->AddView(shortkey_view, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
  shortkey_layout->SetContentDistribution(nux::MAJOR_POSITION_START);
  shortkey_layout->SetMinimumWidth(SHORTKEY_COLUMN_WIDTH);
  shortkey_layout->SetMaximumWidth(SHORTKEY_COLUMN_WIDTH);

  description_layout->AddView(description_view, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
  description_layout->SetContentDistribution(nux::MAJOR_POSITION_START);
  description_layout->SetMinimumWidth(DESCRIPTION_COLUMN_WIDTH);
  description_layout->SetMaximumWidth(DESCRIPTION_COLUMN_WIDTH);

  layout->AddLayout(shortkey_layout, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
  layout->AddLayout(description_layout, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
  layout->SetSpaceBetweenChildren(INTER_SPACE_SHORTKEY_DESCRIPTION);
  description_layout->SetContentDistribution(nux::MAJOR_POSITION_START);

   auto on_shortkey_changed = [](std::string const& new_shortkey, nux::View* main_view, nux::StaticText* view) {
      std::string skey("<b>");
      skey += new_shortkey;
      skey += "</b>";

      view->SetText(skey);
      main_view->SetVisible(!new_shortkey.empty());
   };

  hint->shortkey.changed.connect(sigc::bind(sigc::slot<void, std::string const&, nux::View*, nux::StaticText*>(on_shortkey_changed), view, shortkey_view));

  return view;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::ui::UnityWindowView::Draw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, inherited]

Definition at line 46 of file UnityWindowView.cpp.

{
  // fixme???
}
void unity::ui::UnityWindowView::DrawContent ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, inherited]

Definition at line 51 of file UnityWindowView.cpp.

{
  PreDraw(GfxContext, force_draw);

  nux::Geometry base = GetGeometry();
  GfxContext.PushClippingRectangle(base);

  // clear region
  gPainter.PaintBackground(GfxContext, base);

  nux::Geometry background_geo(GetBackgroundGeometry());
  int internal_offset = style()->GetInternalOffset();

  nux::Geometry internal_clip(background_geo.x + internal_offset,
                              background_geo.y + internal_offset,
                              background_geo.width - internal_offset * 2,
                              background_geo.height - internal_offset * 2);
  GfxContext.PushClippingRectangle(internal_clip);

  nux::Geometry const& geo_absolute = GetAbsoluteGeometry();
  nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, base.width, base.height);

  if (BackgroundEffectHelper::blur_type != BLUR_NONE)
  {
    bg_texture_ = bg_helper_.GetBlurRegion(blur_geo);
  }
  else
  {
    bg_texture_ = bg_helper_.GetRegion(blur_geo);
  }

  if (bg_texture_.IsValid())
  {
    nux::TexCoordXForm texxform_blur_bg;
    texxform_blur_bg.flip_v_coord = true;
    texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
    texxform_blur_bg.uoffset = ((float) base.x) / geo_absolute.width;
    texxform_blur_bg.voffset = ((float) base.y) / geo_absolute.height;

    nux::ROPConfig rop;
    rop.Blend = false;
    rop.SrcBlend = GL_ONE;
    rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;

#ifndef NUX_OPENGLES_20
    if (GfxContext.UsingGLSLCodePath())
      gPainter.PushDrawCompositionLayer(GfxContext, base,
                                        bg_texture_,
                                        texxform_blur_bg,
                                        nux::color::White,
                                        background_color, nux::LAYER_BLEND_MODE_OVERLAY,
                                        true, rop);
    else
      gPainter.PushDrawTextureLayer(GfxContext, base,
                                    bg_texture_,
                                    texxform_blur_bg,
                                    nux::color::White,
                                    true,
                                    rop);
#else
      gPainter.PushDrawCompositionLayer(GfxContext, base,
                                        bg_texture_,
                                        texxform_blur_bg,
                                        nux::color::White,
                                        background_color, nux::LAYER_BLEND_MODE_OVERLAY,
                                        true, rop);
#endif
  }

  nux::ROPConfig rop;
  rop.Blend = true;

#ifndef NUX_OPENGLES_20
  if (GfxContext.UsingGLSLCodePath() == false)
  {
    rop.SrcBlend = GL_ONE;
    rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
    gPainter.PushDrawColorLayer (GfxContext, internal_clip, background_color, false, rop);
  }
#endif

  // Make round corners
  rop.Blend = true;
  rop.SrcBlend = GL_ZERO;
  rop.DstBlend = GL_SRC_ALPHA;
  gPainter.PaintShapeCornerROP(GfxContext,
                               internal_clip,
                               nux::color::White,
                               nux::eSHAPE_CORNER_ROUND5,
                               nux::eCornerTopLeft | nux::eCornerTopRight |
                               nux::eCornerBottomLeft | nux::eCornerBottomRight,
                               true,
                               rop);

  DrawOverlay(GfxContext, force_draw, internal_clip);

  GfxContext.PopClippingRectangle();
  GfxContext.PopClippingRectangle();

  DrawBackground(GfxContext, background_geo);

  PostDraw(GfxContext, force_draw);
}

Here is the call graph for this function:

void unity::shortcut::View::DrawOverlay ( nux::GraphicsEngine &  GfxContext,
bool  force_draw,
nux::Geometry  clip 
) [protected, virtual]

Implements unity::ui::UnityWindowView.

Definition at line 246 of file ShortcutView.cpp.

{
  layout_->ProcessDraw(GfxContext, force_draw);
}
nux::Geometry unity::shortcut::View::GetBackgroundGeometry ( ) [protected, virtual]

Implements unity::ui::UnityWindowView.

Definition at line 233 of file ShortcutView.cpp.

{
  nux::Geometry base = GetGeometry();
  nux::Geometry background_geo;

  background_geo.width = base.width;
  background_geo.height = base.height;
  background_geo.x = (base.width - background_geo.width)/2;
  background_geo.y = (base.height - background_geo.height)/2;

  return background_geo;
}
bool unity::shortcut::View::GetBaseGeometry ( nux::Geometry &  geo)

Definition at line 125 of file ShortcutView.cpp.

{
  UScreen* uscreen = UScreen::GetDefault();
  int primary_monitor = uscreen->GetMonitorWithMouse();
  auto monitor_geo = uscreen->GetMonitorGeometry(primary_monitor);

  int w = GetAbsoluteWidth();
  int h = GetAbsoluteHeight();

  if (x_adjustment_ + w > monitor_geo.width ||
      y_adjustment_ + h > monitor_geo.height)
    return false;

  geo.width = w;
  geo.height = h;

  geo.x = monitor_geo.x + x_adjustment_ + (monitor_geo.width - geo.width -  x_adjustment_) / 2;
  geo.y = monitor_geo.y + y_adjustment_ + (monitor_geo.height - geo.height -  y_adjustment_) / 2;
  return true;
}

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:

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:

Definition at line 114 of file ShortcutView.cpp.

{
  return model_;
}
std::string unity::shortcut::View::GetName ( ) const [protected, virtual]

Reimplemented from unity::ui::UnityWindowView.

Definition at line 293 of file ShortcutView.cpp.

{
  return "ShortcutView";
}
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:

virtual void unity::ui::UnityWindowView::PostDraw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [inline, protected, virtual, inherited]

Definition at line 54 of file UnityWindowView.h.

{};

Here is the caller graph for this function:

virtual void unity::ui::UnityWindowView::PreDraw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [inline, protected, virtual, inherited]

Reimplemented in unity::switcher::SwitcherView.

Definition at line 52 of file UnityWindowView.h.

{};

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:

Definition at line 251 of file ShortcutView.cpp.

{
  int i = 0;
  int column = 0;

  for (auto category : model_->categories())
  {
    // Three sections in the fist column...
    if (i > 2)
      column = 1;

    nux::LinearLayout* section_layout = CreateSectionLayout(category.c_str());
    nux::LinearLayout* intermediate_layout = CreateIntermediateLayout();
    intermediate_layout->SetContentDistribution(nux::MAJOR_POSITION_START);

    for (auto hint : model_->hints()[category])
    {
      nux::View* view = CreateShortKeyEntryView(hint);
      view->SetVisible(!hint->shortkey().empty());
      intermediate_layout->AddView(view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
    }

    section_layout->AddLayout(intermediate_layout, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);

    if (i == 0 or i==1 or i==3 or i==4)
    {
      // Add space before the line
      section_layout->AddView(new nux::SpaceLayout(23, 23, 23, 23), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
      section_layout->AddView(new HSeparator(), 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
      // Add space after the line
      section_layout->AddView(new nux::SpaceLayout(20, 20, 20, 20), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
    }

    columns_[column]->AddView(section_layout, 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);

    i++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::shortcut::View::SetAdjustment ( int  x,
int  y 
)

Definition at line 119 of file ShortcutView.cpp.

Definition at line 106 of file ShortcutView.cpp.

{
  model_ = model;

  // Fills the columns...
  RenderColumns();
}

Here is the call graph for this function:

void unity::ui::UnityWindowView::SetupBackground ( bool  enabled = true) [inherited]

Definition at line 41 of file UnityWindowView.cpp.

{
  bg_helper_.enabled = enabled;
}

Member Data Documentation

nux::Property<nux::Color> unity::ui::UnityWindowView::background_color [inherited]

Definition at line 40 of file UnityWindowView.h.

std::vector<nux::VLayout*> unity::shortcut::View::columns_ [private]

Definition at line 77 of file ShortcutView.h.

nux::HLayout* unity::shortcut::View::columns_layout_ [private]

Definition at line 76 of file ShortcutView.h.

nux::VLayout* unity::shortcut::View::layout_ [private]

Definition at line 75 of file ShortcutView.h.

Definition at line 73 of file ShortcutView.h.

Definition at line 41 of file UnityWindowView.h.

Definition at line 79 of file ShortcutView.h.

Definition at line 80 of file ShortcutView.h.


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