Back to index

unity  6.0.0
Functions | Variables
StandaloneSwitcher.cpp File Reference
#include "Nux/Nux.h"
#include "Nux/Button.h"
#include "Nux/VLayout.h"
#include "Nux/HLayout.h"
#include "Nux/WindowThread.h"
#include "Nux/CheckBox.h"
#include "Nux/SpinBox.h"
#include "Nux/EditTextBox.h"
#include "Nux/StaticText.h"
#include "Nux/RangeValueInteger.h"
#include "NuxGraphics/GraphicsEngine.h"
#include <gtk/gtk.h>
#include "SwitcherController.h"
#include "MockLauncherIcon.h"
#include "unity-shared/BackgroundEffectHelper.h"
#include <dbus/dbus-glib.h>

Go to the source code of this file.

Functions

static gboolean on_timeout (gpointer data)
void OnFlippingChanged (bool value)
void OnBorderSizeChanged (nux::RangeValueInteger *self)
void OnFlatSpacingSizeChanged (nux::RangeValueInteger *self)
void OnTextSizeChanged (nux::RangeValueInteger *self)
void OnIconSizeChanged (nux::RangeValueInteger *self)
void OnTileSizeChanged (nux::RangeValueInteger *self)
void OnAnimationLengthChanged (nux::RangeValueInteger *self)
void OnNumIconsChanged (nux::SpinBox *self)
void OnNextClicked (nux::View *sender)
void OnDetailClicked (nux::View *sender)
void OnPreviousClicked (nux::View *sender)
void ThreadWidgetInit (nux::NThread *thread, void *InitData)
int main (int argc, char **argv)

Variables

static bool enable_flipping = false
static Controllerview

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 288 of file StandaloneSwitcher.cpp.

{
  g_type_init();
  
  gtk_init(&argc, &argv);

  nux::NuxInitialize(0);

  BackgroundEffectHelper::blur_type = unity::BLUR_ACTIVE;
  nux::WindowThread* wt = nux::CreateGUIThread(TEXT("Unity Switcher"), 1200, 600, 0, &ThreadWidgetInit, 0);

  wt->Run(NULL);
  delete wt;
  return 0;
}

Here is the call graph for this function:

static gboolean on_timeout ( gpointer  data) [static]

Definition at line 48 of file StandaloneSwitcher.cpp.

{
  if (!enable_flipping)
    return TRUE;

  Controller* self = static_cast<Controller*>(data);
  self->Next();

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnAnimationLengthChanged ( nux::RangeValueInteger *  self)

Definition at line 94 of file StandaloneSwitcher.cpp.

{
  view->GetView ()->animation_length = self->GetValue ();
  view->GetView ()->QueueDraw ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnBorderSizeChanged ( nux::RangeValueInteger *  self)

Definition at line 64 of file StandaloneSwitcher.cpp.

{
  view->GetView ()->border_size = self->GetValue ();
  view->GetView ()->QueueDraw ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnDetailClicked ( nux::View *  sender)

Definition at line 116 of file StandaloneSwitcher.cpp.

{
  view->NextDetail ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnFlatSpacingSizeChanged ( nux::RangeValueInteger *  self)

Definition at line 70 of file StandaloneSwitcher.cpp.

{
  view->GetView ()->flat_spacing = self->GetValue ();
  view->GetView ()->QueueDraw ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnFlippingChanged ( bool  value)

Definition at line 59 of file StandaloneSwitcher.cpp.

{
  enable_flipping = value;
}

Here is the caller graph for this function:

void OnIconSizeChanged ( nux::RangeValueInteger *  self)

Definition at line 82 of file StandaloneSwitcher.cpp.

{
  view->GetView ()->icon_size = self->GetValue ();
  view->GetView ()->QueueDraw ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnNextClicked ( nux::View *  sender)

Definition at line 111 of file StandaloneSwitcher.cpp.

{
  view->Next ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnNumIconsChanged ( nux::SpinBox *  self)

Definition at line 100 of file StandaloneSwitcher.cpp.

{
  view->Hide();

  std::vector<nux::ObjectPtr<AbstractLauncherIcon>> icons;
  for (int i = 0; i < self->GetValue (); i++)
    icons.push_back(nux::ObjectPtr<AbstractLauncherIcon>(new MockLauncherIcon()));

  view->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, false, icons);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnPreviousClicked ( nux::View *  sender)

Definition at line 121 of file StandaloneSwitcher.cpp.

{
  view->Prev();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnTextSizeChanged ( nux::RangeValueInteger *  self)

Definition at line 76 of file StandaloneSwitcher.cpp.

{
  view->GetView ()->text_size = self->GetValue ();
  view->GetView ()->QueueDraw ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OnTileSizeChanged ( nux::RangeValueInteger *  self)

Definition at line 88 of file StandaloneSwitcher.cpp.

{
  view->GetView ()->tile_size = self->GetValue ();
  view->GetView ()->QueueDraw ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ThreadWidgetInit ( nux::NThread *  thread,
void *  InitData 
)

Definition at line 126 of file StandaloneSwitcher.cpp.

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

  view = new Controller();
  view->timeout_length = 0;
  view->SetWorkspace(nux::Geometry(0, 0, 900, 600), 0);

  layout->SetContentDistribution(nux::eStackCenter);
  layout->SetHorizontalExternalMargin (10);
  nux::GetWindowThread()->SetLayout(layout);

  std::vector<nux::ObjectPtr<AbstractLauncherIcon>> icons;
  for (int i = 0; i < 9; i++)
    icons.push_back(nux::ObjectPtr<AbstractLauncherIcon>(new MockLauncherIcon()));

  view->Show(ShowMode::ALL, SortMode::FOCUS_ORDER, false, icons);

  view->GetView ()->render_boxes = true;

  nux::CheckBox* flipping_check = new nux::CheckBox(TEXT("Enable Automatic Flipping"), false, NUX_TRACKER_LOCATION);
  flipping_check->SetMaximumWidth(250);
  flipping_check->state_change.connect (sigc::ptr_fun (OnFlippingChanged));
  layout->AddView(flipping_check, 1, nux::eRight, nux::eFull);


  nux::HLayout* num_icons_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  num_icons_layout->SetMaximumWidth(250);
  num_icons_layout->SetMaximumHeight(30);
  num_icons_layout->SetHorizontalInternalMargin (10);

  nux::StaticText* num_icons_label = new nux::StaticText(TEXT("Num Icons:"), NUX_TRACKER_LOCATION);
  num_icons_layout->AddView(num_icons_label, 1, nux::eLeft, nux::eFull);

  nux::SpinBox * num_icons_spin = new nux::SpinBox (icons.size (), 1, 2, 100, NUX_TRACKER_LOCATION);
  num_icons_spin->sigValueChanged.connect (sigc::ptr_fun (OnNumIconsChanged));
  num_icons_layout->AddView(num_icons_spin, 1, nux::eRight, nux::eFix);

  layout->AddView(num_icons_layout, 1, nux::eRight, nux::eFull);



  nux::HLayout* border_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  border_layout->SetMaximumWidth(250);
  border_layout->SetMaximumHeight(30);
  border_layout->SetHorizontalInternalMargin (10);

  nux::StaticText* border_label = new nux::StaticText(TEXT("Border Size:"), NUX_TRACKER_LOCATION);
  border_layout->AddView(border_label, 1, nux::eLeft, nux::eFull);

  nux::RangeValueInteger * border_size_range = new nux::RangeValueInteger (view->GetView ()->border_size, 0, 200, NUX_TRACKER_LOCATION);
  border_size_range->sigValueChanged.connect (sigc::ptr_fun (OnBorderSizeChanged));
  border_layout->AddView(border_size_range, 1, nux::eRight, nux::eFix);

  layout->AddView(border_layout, 1, nux::eRight, nux::eFull);



  nux::HLayout* flat_spacing_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  flat_spacing_layout->SetMaximumWidth(250);
  flat_spacing_layout->SetMaximumHeight(30);
  flat_spacing_layout->SetHorizontalInternalMargin (10);

  nux::StaticText* flat_spacing_label = new nux::StaticText(TEXT("Flat Spacing:"), NUX_TRACKER_LOCATION);
  flat_spacing_layout->AddView(flat_spacing_label, 1, nux::eLeft, nux::eFull);

  nux::RangeValueInteger * flat_spacing_size_range = new nux::RangeValueInteger (view->GetView ()->flat_spacing, 0, 200, NUX_TRACKER_LOCATION);
  flat_spacing_size_range->sigValueChanged.connect (sigc::ptr_fun (OnFlatSpacingSizeChanged));
  flat_spacing_layout->AddView(flat_spacing_size_range, 1, nux::eRight, nux::eFix);

  layout->AddView(flat_spacing_layout, 1, nux::eRight, nux::eFull);
  

  nux::HLayout* text_size_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  text_size_layout->SetMaximumWidth(250);
  text_size_layout->SetMaximumHeight(30);
  text_size_layout->SetHorizontalInternalMargin (10);

  nux::StaticText* text_size_label = new nux::StaticText(TEXT("Text Size:"), NUX_TRACKER_LOCATION);
  text_size_layout->AddView(text_size_label, 1, nux::eLeft, nux::eFull);

  nux::RangeValueInteger * text_size_size_range = new nux::RangeValueInteger (view->GetView ()->text_size, 0, 200, NUX_TRACKER_LOCATION);
  text_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTextSizeChanged));
  text_size_layout->AddView(text_size_size_range, 1, nux::eRight, nux::eFix);

  layout->AddView(text_size_layout, 1, nux::eRight, nux::eFull);


  nux::HLayout* icon_size_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  icon_size_layout->SetMaximumWidth(250);
  icon_size_layout->SetMaximumHeight(30);
  icon_size_layout->SetHorizontalInternalMargin (10);

  nux::StaticText* icon_size_label = new nux::StaticText(TEXT("Icon Size:"), NUX_TRACKER_LOCATION);
  icon_size_layout->AddView(icon_size_label, 1, nux::eLeft, nux::eFull);

  nux::RangeValueInteger * icon_size_size_range = new nux::RangeValueInteger (view->GetView ()->icon_size, 0, 200, NUX_TRACKER_LOCATION);
  icon_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnIconSizeChanged));
  icon_size_layout->AddView(icon_size_size_range, 1, nux::eRight, nux::eFix);

  layout->AddView(icon_size_layout, 1, nux::eRight, nux::eFull);


  nux::HLayout* tile_size_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  tile_size_layout->SetMaximumWidth(250);
  tile_size_layout->SetMaximumHeight(30);
  tile_size_layout->SetHorizontalInternalMargin (10);

  nux::StaticText* tile_size_label = new nux::StaticText(TEXT("Tile Size:"), NUX_TRACKER_LOCATION);
  tile_size_layout->AddView(tile_size_label, 1, nux::eLeft, nux::eFull);

  nux::RangeValueInteger * tile_size_size_range = new nux::RangeValueInteger (view->GetView ()->tile_size, 0, 200, NUX_TRACKER_LOCATION);
  tile_size_size_range->sigValueChanged.connect (sigc::ptr_fun (OnTileSizeChanged));
  tile_size_layout->AddView(tile_size_size_range, 1, nux::eRight, nux::eFix);

  layout->AddView(tile_size_layout, 1, nux::eRight, nux::eFull);


  nux::HLayout* animation_length_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  animation_length_layout->SetMaximumWidth(250);
  animation_length_layout->SetMaximumHeight(30);
  animation_length_layout->SetHorizontalInternalMargin (10);

  nux::StaticText* animation_length_label = new nux::StaticText(TEXT("Animation Length:"), NUX_TRACKER_LOCATION);
  animation_length_layout->AddView(animation_length_label, 1, nux::eLeft, nux::eFull);

  nux::RangeValueInteger * animation_length_size_range = new nux::RangeValueInteger (view->GetView ()->animation_length, 0, 2000, NUX_TRACKER_LOCATION);
  animation_length_size_range->sigValueChanged.connect (sigc::ptr_fun (OnAnimationLengthChanged));
  animation_length_layout->AddView(animation_length_size_range, 1, nux::eRight, nux::eFix);

  layout->AddView(animation_length_layout, 1, nux::eRight, nux::eFull);


  nux::HLayout* control_buttons_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
  control_buttons_layout->SetMaximumWidth(250);
  control_buttons_layout->SetMaximumHeight(30);
  control_buttons_layout->SetHorizontalInternalMargin (10);

  nux::Button* prev_button = new nux::Button ("Previous", NUX_TRACKER_LOCATION);
  prev_button->state_change.connect (sigc::ptr_fun (OnPreviousClicked));
  control_buttons_layout->AddView(prev_button, 1, nux::eLeft, nux::eFull);

  nux::Button* next_button = new nux::Button ("Next", NUX_TRACKER_LOCATION);
  next_button->state_change.connect (sigc::ptr_fun (OnNextClicked));
  control_buttons_layout->AddView(next_button, 1, nux::eRight, nux::eFull);

  nux::Button* detail_button = new nux::Button ("Detail", NUX_TRACKER_LOCATION);
  detail_button->state_change.connect (sigc::ptr_fun (OnDetailClicked));
  control_buttons_layout->AddView(detail_button, 1, nux::eRight, nux::eFull);

  layout->AddView(control_buttons_layout, 1, nux::eRight, nux::eFull);


  layout->SetContentDistribution(nux::eStackCenter);

  nux::BaseTexture *background = nux::CreateTexture2DFromFile("/usr/share/backgrounds/Grey_day_by_Drew__.jpg", -1, true);
  nux::GetGraphicsDisplay()->GetGpuDevice()->backup_texture0_ = background->GetDeviceTexture();


  g_timeout_add(1500, on_timeout, view);
}

Here is the call graph for this function:


Variable Documentation

bool enable_flipping = false [static]

Definition at line 44 of file StandaloneSwitcher.cpp.

Controller* view [static]

Definition at line 46 of file StandaloneSwitcher.cpp.