diff options
| author | Neil Jagdish Patel <neil.patel@canonical.com> | 2011-04-07 15:49:00 +0100 | 
|---|---|---|
| committer | Neil Jagdish Patel <neil.patel@canonical.com> | 2011-04-07 15:49:00 +0100 | 
| commit | 04d74ea740604aab4310830992d8a94020b0f13e (patch) | |
| tree | 6481ad5bf97f338a36ee0d30bf74065ff7f5b704 | |
| parent | 646043659bb4cc18fb8820f2b62fce2b83f248de (diff) | |
| parent | 64dddd0e381669fd2ae6965b7cb64427f221beb1 (diff) | |
[merge] fixes
(bzr r1084)
| -rw-r--r-- | src/IndicatorObjectFactoryRemote.cpp | 4 | ||||
| -rw-r--r-- | src/LauncherIcon.cpp | 5 | ||||
| -rw-r--r-- | src/LauncherIcon.h | 2 | ||||
| -rw-r--r-- | src/PanelController.cpp | 7 | ||||
| -rw-r--r-- | src/PanelHomeButton.cpp | 4 | ||||
| -rw-r--r-- | src/PanelHomeButton.h | 1 | ||||
| -rw-r--r-- | src/PanelMenuView.cpp | 2 | ||||
| -rw-r--r-- | src/PlaceFactoryFile.cpp | 35 | ||||
| -rw-r--r-- | src/PlaceFactoryFile.h | 6 | ||||
| -rw-r--r-- | src/PlaceLauncherSection.cpp | 6 | ||||
| -rw-r--r-- | src/PlaceLauncherSection.h | 2 | ||||
| -rw-r--r-- | src/PlaceRemote.cpp | 6 | ||||
| -rw-r--r-- | src/PlaceRemote.h | 2 | ||||
| -rw-r--r-- | src/PlacesController.cpp | 2 | ||||
| -rw-r--r-- | src/PlacesHorizontalTile.cpp | 24 | ||||
| -rw-r--r-- | src/PlacesSettings.cpp | 4 | ||||
| -rw-r--r-- | src/PlacesSimpleTile.cpp | 15 | ||||
| -rw-r--r-- | src/PlacesTile.cpp | 39 | ||||
| -rw-r--r-- | src/QuicklistMenuItemCheckmark.cpp | 2 | ||||
| -rw-r--r-- | src/QuicklistMenuItemLabel.cpp | 2 | ||||
| -rw-r--r-- | src/QuicklistMenuItemRadio.cpp | 2 | ||||
| -rw-r--r-- | src/StaticCairoText.cpp | 10 | ||||
| -rw-r--r-- | src/StaticCairoText.h | 5 | 
23 files changed, 118 insertions, 69 deletions
diff --git a/src/IndicatorObjectFactoryRemote.cpp b/src/IndicatorObjectFactoryRemote.cpp index 560a58de4..35d05353f 100644 --- a/src/IndicatorObjectFactoryRemote.cpp +++ b/src/IndicatorObjectFactoryRemote.cpp @@ -537,8 +537,8 @@ on_proxy_signal_received (GDBusProxy *proxy,  }  else if (g_strcmp0 (signal_name, "EntryShowNowChanged") == 0)  { - gchar *id = NULL; - bool show_now_state; + gchar *id = NULL; + gboolean show_now_state;  g_variant_get (parameters, "(sb)", &id, &show_now_state); diff --git a/src/LauncherIcon.cpp b/src/LauncherIcon.cpp index d086fbe5e..7ce4098f8 100644 --- a/src/LauncherIcon.cpp +++ b/src/LauncherIcon.cpp @@ -71,6 +71,7 @@ LauncherIcon::LauncherIcon(Launcher* launcher)  _mouse_inside = false;  _has_visible_window = false;  _tooltip = new nux::Tooltip (); + _tooltip->SinkReference ();  _icon_type = TYPE_NONE;  _sort_priority = 0;  _shortcut = 0; @@ -79,6 +80,7 @@ LauncherIcon::LauncherIcon(Launcher* launcher)  _superkey_label = 0;  _quicklist = new QuicklistView (); + _quicklist->SinkReference ();  _quicklist_is_initialized = false;  _present_time_handle = 0; @@ -133,6 +135,9 @@ LauncherIcon::~LauncherIcon()  if (on_order_changed_connection.connected ())  on_order_changed_connection.disconnect (); + + _quicklist->UnReference (); + _tooltip->UnReference ();  }  bool diff --git a/src/LauncherIcon.h b/src/LauncherIcon.h index 5d5015d5e..818705e11 100644 --- a/src/LauncherIcon.h +++ b/src/LauncherIcon.h @@ -88,6 +88,7 @@ public:  void SetShortcut (guint64 shortcut);  guint64 GetShortcut (); + void SetSortPriority (int priority);  void RecvMouseEnter ();  void RecvMouseLeave (); @@ -182,7 +183,6 @@ protected:  void Unpresent ();  void SetIconType (IconType type); - void SetSortPriority (int priority);  void SetEmblem (nux::BaseTexture *emblem);  void SetSuperkeyLabel (nux::BaseTexture* label); diff --git a/src/PanelController.cpp b/src/PanelController.cpp index 79be56bf3..65432940c 100644 --- a/src/PanelController.cpp +++ b/src/PanelController.cpp @@ -134,8 +134,12 @@ PanelController::OnScreenChanged (int primary_monitor, std::vector<nux::Geometry  (*it)->EnableInputWindow (true);  (*it)->InputWindowEnableStruts (true); + g_debug ("PanelController:: Updated Panel for Monitor %d", i); +  i++;  } + else + break;  }  // Add new ones if needed @@ -181,6 +185,8 @@ PanelController::OnScreenChanged (int primary_monitor, std::vector<nux::Geometry  unity_util_accessible_add_window (window);  _windows.push_back (window); + + g_debug ("PanelController:: Added Panel for Monitor %d", i);  }  } @@ -190,6 +196,7 @@ PanelController::OnScreenChanged (int primary_monitor, std::vector<nux::Geometry  for (sit = it; sit != eit; ++sit)  {  (*sit)->UnReference (); + g_debug ("PanelController:: Removed extra Panel");  }  _windows.erase (it, _windows.end ()); diff --git a/src/PanelHomeButton.cpp b/src/PanelHomeButton.cpp index 81483dead..4a1844f47 100644 --- a/src/PanelHomeButton.cpp +++ b/src/PanelHomeButton.cpp @@ -56,7 +56,7 @@ PanelHomeButton::PanelHomeButton ()  G_CALLBACK (PanelHomeButton::OnIconThemeChanged), this);  UBusServer *ubus = ubus_server_get_default (); - ubus_server_register_interest (ubus, UBUS_LAUNCHER_ICON_URGENT_CHANGED, + _urgent_interest = ubus_server_register_interest (ubus, UBUS_LAUNCHER_ICON_URGENT_CHANGED,  (UBusCallback)&PanelHomeButton::OnLauncherIconUrgentChanged,  this); @@ -67,6 +67,8 @@ PanelHomeButton::~PanelHomeButton ()  {  if (_theme_changed_id)  g_signal_handler_disconnect (gtk_icon_theme_get_default (), _theme_changed_id); + + ubus_server_unregister_interest (ubus_server_get_default (), _urgent_interest);  }  void  diff --git a/src/PanelHomeButton.h b/src/PanelHomeButton.h index 0fd4f29ea..1e285a6a0 100644 --- a/src/PanelHomeButton.h +++ b/src/PanelHomeButton.h @@ -60,6 +60,7 @@ private:  int _urgent_count;  gulong _theme_changed_id; + guint _urgent_interest;  };  #endif // PANEL_HOME_BUTTON_H diff --git a/src/PanelMenuView.cpp b/src/PanelMenuView.cpp index f3cef55e2..c2cb85c9e 100644 --- a/src/PanelMenuView.cpp +++ b/src/PanelMenuView.cpp @@ -100,7 +100,7 @@ PanelMenuView::PanelMenuView (int padding)  _on_winbutton_redraw_signal_connection = _window_buttons->redraw_signal.connect (sigc::mem_fun (this, &PanelMenuView::OnWindowButtonsRedraw));  _panel_titlebar_grab_area = new PanelTitlebarGrabArea (); - _panel_titlebar_grab_area->Reference (); + _panel_titlebar_grab_area->SinkReference ();  _on_titlebargrab_mouse_down_connnection = _panel_titlebar_grab_area->mouse_down.connect (sigc::mem_fun (this, &PanelMenuView::OnMaximizedGrab));  _on_titlebargrab_mouse_doubleleftclick_connnection = _panel_titlebar_grab_area->mouse_doubleleftclick.connect (sigc::mem_fun (this, &PanelMenuView::OnMouseDoubleClicked));  _on_titlebargrab_mouse_middleclick_connnection = _panel_titlebar_grab_area->mouse_middleclick.connect (sigc::mem_fun (this, &PanelMenuView::OnMouseMiddleClicked)); diff --git a/src/PlaceFactoryFile.cpp b/src/PlaceFactoryFile.cpp index 9c37c584b..4f21a1725 100644 --- a/src/PlaceFactoryFile.cpp +++ b/src/PlaceFactoryFile.cpp @@ -17,6 +17,8 @@  */  #include "config.h" +#include <algorithm> +  #include "PlaceFactoryFile.h"  #include "PlaceRemote.h" @@ -120,7 +122,6 @@ PlaceFactoryFile::OnDirectoryEnumerationReady (GObject *source,  if (place->IsValid ())  {  _places.push_back (place); - place_added.emit (place);  }  else  delete place; @@ -142,11 +143,43 @@ PlaceFactoryFile::OnDirectoryEnumerationReady (GObject *source,  return;  } + // Sort them + std::sort (_places.begin (), _places.end (), DoSortThemMister); + + // Signal their creation + std::vector<Place *>::iterator it, eit = _places.end (); + for (it = _places.begin (); it != eit; ++it) + { + place_added.emit (*it); + g_debug ("%s", static_cast<PlaceRemote *> (*it)->GetDBusPath ()); + } +  read_directory = true;  g_object_unref (enumerator);  } +bool +PlaceFactoryFile::DoSortThemMister (Place *aa, Place *bb) +{ +#define FIRST "/com/canonical/unity/applicationsplace" +#define SECOND "/com/canonical/unity/filesplace" + + PlaceRemote *a = static_cast<PlaceRemote *> (aa); + PlaceRemote *b = static_cast<PlaceRemote *> (bb); + + if (g_strcmp0 (a->GetDBusPath (), FIRST) == 0) + return true; + else if (g_strcmp0 (b->GetDBusPath (), FIRST) == 0) + return false; + else if (g_strcmp0 (a->GetDBusPath (), SECOND) == 0) + return true; + else if (g_strcmp0 (b->GetDBusPath (), SECOND) == 0) + return false; + else + return g_strcmp0 (a->GetDBusPath (), b->GetDBusPath ()) == 0; +} +  /*  * C to C++ glue  */ diff --git a/src/PlaceFactoryFile.h b/src/PlaceFactoryFile.h index 880fff7c0..ab9779e2d 100644 --- a/src/PlaceFactoryFile.h +++ b/src/PlaceFactoryFile.h @@ -42,10 +42,12 @@ public:  /* Callbacks, not interesting to others */  void OnDirectoryEnumerationReady (GObject *source,  GAsyncResult *result); - +private: + static bool DoSortThemMister (Place *a, Place *b); +   public:  /* For Debugging */ - bool read_directory;  + bool read_directory;  private:  char *_directory; diff --git a/src/PlaceLauncherSection.cpp b/src/PlaceLauncherSection.cpp index 3d09835b0..b935ff5d7 100644 --- a/src/PlaceLauncherSection.cpp +++ b/src/PlaceLauncherSection.cpp @@ -21,7 +21,8 @@  #include "PlaceLauncherSection.h"  PlaceLauncherSection::PlaceLauncherSection (Launcher *launcher) -: _launcher (launcher) +: _launcher (launcher), + _priority (10000)  {  _factory = PlaceFactory::GetDefault ();  _on_place_added_connection = (sigc::connection) _factory->place_added.connect (sigc::mem_fun (this,  @@ -49,6 +50,7 @@ PlaceLauncherSection::OnPlaceAdded (Place *place)  if (entry->ShowInLauncher ())  {  PlaceLauncherIcon *icon = new PlaceLauncherIcon (_launcher, entry); + icon->SetSortPriority (_priority++);  IconAdded.emit (icon);  }  } @@ -73,9 +75,9 @@ PlaceLauncherSection::PopulateEntries ()  if (entry->ShowInLauncher ())  {  PlaceLauncherIcon *icon = new PlaceLauncherIcon (_launcher, entry); + icon->SetSortPriority (_priority++);  IconAdded.emit (icon);  }  }  }  } - diff --git a/src/PlaceLauncherSection.h b/src/PlaceLauncherSection.h index 1dd0f0f62..ef772ac0d 100644 --- a/src/PlaceLauncherSection.h +++ b/src/PlaceLauncherSection.h @@ -43,6 +43,8 @@ private:  Launcher *_launcher;  PlaceFactory *_factory;  sigc::connection _on_place_added_connection; + + guint32 _priority;  };  #endif // _PLACE_LAUNCHER_SECTION_H_ diff --git a/src/PlaceRemote.cpp b/src/PlaceRemote.cpp index 0902b8a46..f03c19886 100644 --- a/src/PlaceRemote.cpp +++ b/src/PlaceRemote.cpp @@ -204,6 +204,12 @@ PlaceRemote::~PlaceRemote ()  g_object_unref (_activation_proxy);  } +const gchar *  +PlaceRemote::GetDBusPath () +{ + return _dbus_path; +} +  void  PlaceRemote::Connect ()  { diff --git a/src/PlaceRemote.h b/src/PlaceRemote.h index 871a91630..c3ab2157b 100644 --- a/src/PlaceRemote.h +++ b/src/PlaceRemote.h @@ -47,7 +47,7 @@ public:  void OnEntryAdded (GVariant *args);  void OnEntryRemoved (const gchar *dbus_path); - const gchar * GetDBusName (); + const gchar * GetDBusPath ();  void ActivateResult (const char *uri, const char *mimetype); diff --git a/src/PlacesController.cpp b/src/PlacesController.cpp index cb0cbc81c..d4366583b 100644 --- a/src/PlacesController.cpp +++ b/src/PlacesController.cpp @@ -252,7 +252,7 @@ PlacesController::GetWindowSize (int *out_width, int *out_height)  width += tile_width;  width = MAX (width, tile_width * 7); - height = ((width/tile_width) - 3) * tile_width; + height = MIN (rect.height, (style->GetTileHeight () * 5.5) + 12);  _view->SetSizeMode (PlacesView::SIZE_MODE_HOVER);  style->SetDefaultNColumns (6); diff --git a/src/PlacesHorizontalTile.cpp b/src/PlacesHorizontalTile.cpp index 1eb272350..8554073ea 100644 --- a/src/PlacesHorizontalTile.cpp +++ b/src/PlacesHorizontalTile.cpp @@ -47,16 +47,17 @@ PlacesHorizontalTile::PlacesHorizontalTile (const char *icon_name,  _comment = g_strdup_printf ("<small>%s</small>", comment);  int w = (PlacesSettings::GetDefault ()->GetDefaultTileWidth () * 2) - icon_size - 24;//padding + int lines = 0;  nux::HLayout *layout = new nux::HLayout ("", NUX_TRACKER_LOCATION); - layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12)); + layout->AddLayout (new nux::SpaceLayout (6, 6, 0, 0));  _icontex = new IconTexture (_icon, icon_size, defer_icon_loading); - _icontex->SetMinMaxSize (icon_size * 1.5, icon_size); + _icontex->SetMinMaxSize (icon_size, icon_size);  AddChild (_icontex); - layout->AddView (_icontex, 0, nux::eCenter, nux::eFull); + layout->AddView (_icontex, 0, nux::eLeft, nux::eFix); - layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12)); + layout->AddLayout (new nux::SpaceLayout (6, 6, 0, 0));  nux::VLayout *vlayout = new nux::VLayout ("", NUX_TRACKER_LOCATION);  layout->AddView (vlayout, 1, nux::eLeft, nux::eFull); @@ -66,12 +67,14 @@ PlacesHorizontalTile::PlacesHorizontalTile (const char *icon_name,  _cairotext = new nux::StaticCairoText (_label);  _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_LEFT);  _cairotext->SetMaximumWidth (w); + _cairotext->SetLines (-2);  vlayout->AddView (_cairotext, 0, nux::eLeft, nux::eFull); + lines = _cairotext->GetLineCount ();  _cairotext = new nux::StaticCairoText (_comment);  _cairotext->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_END);  _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_LEFT); - _cairotext->SetLines (-3); + _cairotext->SetLines (-1 * (4 - lines));  _cairotext->SetMaximumWidth (w);  _cairotext->SetTextColor (nux::Color (1.0f, 1.0f, 1.0f, 0.8f));  vlayout->AddView (_cairotext, 1, nux::eLeft, nux::eFull); @@ -197,13 +200,12 @@ PlacesHorizontalTile::GetHighlightGeometry ()  {  nux::Geometry base = GetGeometry ();  int width = 0, height = 0; -  _icontex->GetTextureSize (&width, &height); -  - _highlight_geometry.x = 12; - _highlight_geometry.y = 12; - _highlight_geometry.width = width; - _highlight_geometry.height = height; + + _highlight_geometry.x = 6; + _highlight_geometry.y = 6; + _highlight_geometry.width = _icontex->GetMaximumWidth (); + _highlight_geometry.height = base.height - 12;  return _highlight_geometry;  } diff --git a/src/PlacesSettings.cpp b/src/PlacesSettings.cpp index 030678a0c..c20d54e30 100644 --- a/src/PlacesSettings.cpp +++ b/src/PlacesSettings.cpp @@ -20,6 +20,7 @@  #include "gdk/gdk.h"  #include "PlacesSettings.h" +#include "PlacesStyle.h"  #define HOME_EXPANDED "home-expanded" @@ -91,8 +92,7 @@ PlacesSettings::GetFormFactor ()  int  PlacesSettings::GetDefaultTileWidth ()  { - //FIXME: We want to calculate this from DPI - return 140; + return PlacesStyle::GetDefault ()->GetTileWidth ();  }  PlacesSettings::DashBlurType diff --git a/src/PlacesSimpleTile.cpp b/src/PlacesSimpleTile.cpp index 429d6e3a6..c8fbf5118 100644 --- a/src/PlacesSimpleTile.cpp +++ b/src/PlacesSimpleTile.cpp @@ -20,7 +20,7 @@  *  */ -#include "PlacesSettings.h" +#include "PlacesStyle.h"  #include "ubus-server.h"  #include "UBusMessages.h" @@ -40,29 +40,30 @@ PlacesSimpleTile::PlacesSimpleTile (const char *icon_name,  _icon (NULL),  _uri (NULL)  { + PlacesStyle *style = PlacesStyle::GetDefault ();  nux::VLayout *layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);  _label = g_strdup (label);  _icon = g_strdup (icon_name);  _icontex = new IconTexture (_icon, icon_size, defer_icon_loading); - _icontex->SetMinMaxSize (PlacesSettings::GetDefault ()->GetDefaultTileWidth (), icon_size); + _icontex->SetMinMaxSize (style->GetTileWidth (), icon_size);  _icontex->SinkReference ();  AddChild (_icontex); - _cairotext = new nux::StaticCairoText (_label); + _cairotext = new nux::StaticCairoText (""); + _cairotext->SetMaximumWidth (style->GetTileWidth ());  _cairotext->SinkReference (); -  _cairotext->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_START);  _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE); - _cairotext->SetMaximumWidth (140); - + _cairotext->SetText (_label); +   layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));  layout->AddView (_icontex, 0, nux::eCenter, nux::eFull);  layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));  layout->AddView (_cairotext, 0, nux::eCenter, nux::eFull); - SetMinMaxSize (160, 128); + SetMinMaxSize (style->GetTileWidth (), style->GetTileHeight ());  SetLayout (layout); diff --git a/src/PlacesTile.cpp b/src/PlacesTile.cpp index 5112a7093..9e39e34e8 100644 --- a/src/PlacesTile.cpp +++ b/src/PlacesTile.cpp @@ -116,9 +116,7 @@ PlacesTile::DrawHighlight (const char *texid, int width, int height, nux::BaseTe  true);  cairo_fill (cr);  cairo_graphics->BlurSurface (BLUR_SIZE - 2); - - // draw tiled background - // set up clip path +  cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);  cairo_graphics->DrawRoundedRectangle (cr,  1.0, @@ -129,44 +127,21 @@ PlacesTile::DrawHighlight (const char *texid, int width, int height, nux::BaseTe  bg_height,  true);  cairo_clip (cr); - - int w, h; - cairo_surface_t *image; - cairo_pattern_t *pattern; - - cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0); - image = cairo_image_surface_create_from_png (PKGDATADIR"/places-tile-bg-tilable.png"); - w = cairo_image_surface_get_width (image); - h = cairo_image_surface_get_height (image); - - - pattern = cairo_pattern_create_for_surface (image); - cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); - - cairo_set_source (cr, pattern); - - cairo_rectangle (cr, 0, 0, base.width, base.height); - cairo_fill (cr); - - cairo_pattern_destroy (pattern); - cairo_surface_destroy (image); - - // draw the outline -  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);  cairo_graphics->DrawRoundedRectangle (cr,  1.0,  bg_x, -	bg_y, + bg_y,  5.0,  bg_width,  bg_height,  true); - cairo_set_source_rgba (cr, 0.66, 0.66, 0.66, 1.0); - cairo_set_line_width (cr, 1.0); - cairo_stroke (cr); -  + cairo_set_source_rgba (cr, 240/255.0f, 240/255.0f, 240/255.0f, 1.0f); + cairo_fill_preserve (cr); + + cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0); + cairo_stroke (cr);   cairo_destroy (cr); diff --git a/src/QuicklistMenuItemCheckmark.cpp b/src/QuicklistMenuItemCheckmark.cpp index 011a74eb3..ffbd79789 100644 --- a/src/QuicklistMenuItemCheckmark.cpp +++ b/src/QuicklistMenuItemCheckmark.cpp @@ -191,7 +191,7 @@ QuicklistMenuItemCheckmark::Draw (nux::GraphicsEngine& gfxContext,  texture = _normalTexture[0]->GetDeviceTexture ();  } - _color = nux::Colors::Gray; + _color = nux::Color (0.8f, 0.8f, 0.8f, 1.0f);  }  gfxContext.QRP_1Tex (base.x, diff --git a/src/QuicklistMenuItemLabel.cpp b/src/QuicklistMenuItemLabel.cpp index 9182d388b..3dd552ed6 100644 --- a/src/QuicklistMenuItemLabel.cpp +++ b/src/QuicklistMenuItemLabel.cpp @@ -162,7 +162,7 @@ QuicklistMenuItemLabel::Draw (nux::GraphicsEngine& gfxContext,  else  {  texture = _normalTexture[0]->GetDeviceTexture (); - _color = nux::Colors::Gray; + _color = nux::Color (0.8f, 0.8f, 0.8f, 1.0f);  }  gfxContext.QRP_1Tex (base.x, diff --git a/src/QuicklistMenuItemRadio.cpp b/src/QuicklistMenuItemRadio.cpp index 245ecfdbe..1e48d6b01 100644 --- a/src/QuicklistMenuItemRadio.cpp +++ b/src/QuicklistMenuItemRadio.cpp @@ -191,7 +191,7 @@ QuicklistMenuItemRadio::Draw (nux::GraphicsEngine& gfxContext,  texture = _normalTexture[0]->GetDeviceTexture ();  } - _color = nux::Colors::Gray; + _color = nux::Color (0.8f, 0.8f, 0.8f, 1.0f);  }  gfxContext.QRP_1Tex (base.x, diff --git a/src/StaticCairoText.cpp b/src/StaticCairoText.cpp index 88dcd11ea..f0636794a 100644 --- a/src/StaticCairoText.cpp +++ b/src/StaticCairoText.cpp @@ -36,7 +36,8 @@ namespace nux  _fontstring (NULL),  _cairoGraphics (NULL),  _texture2D (NULL), - _lines (-2) + _lines (-2), + _actual_lines (0)  {  _textColor = Color(1.0f, 1.0f, 1.0f, 1.0f); @@ -260,6 +261,11 @@ StaticCairoText::SetFont (const char *fontstring)  sigFontChanged.emit (this);  } +int  +StaticCairoText::GetLineCount () +{ + return _actual_lines; +}  void StaticCairoText::GetTextExtents (int &width, int &height)  { @@ -447,6 +453,8 @@ void StaticCairoText::DrawText (cairo_t* cr,  cairo_move_to (cr, 0.0f, 0.0f);  pango_cairo_show_layout (cr, layout); + _actual_lines = pango_layout_get_line_count (layout); +  // clean up  pango_font_description_free (desc);  g_object_unref (layout); diff --git a/src/StaticCairoText.h b/src/StaticCairoText.h index 1fe4a9ab2..23a8dbc9e 100644 --- a/src/StaticCairoText.h +++ b/src/StaticCairoText.h @@ -86,7 +86,9 @@ namespace nux  void SetTextAlignment (AlignState state);  void SetTextVerticalAlignment (AlignState state);  void SetFont (const char *fontstring); - void SetLines (int lines); + void SetLines (int maximum_lines); + + int GetLineCount ();  void GetTextExtents (int &width, int &height); @@ -113,6 +115,7 @@ namespace nux  int _pre_layout_height;  int _lines; + int _actual_lines;  void GetTextExtents (const TCHAR* font,  int& width,  | 
