Merge lp:~vanvugt/unity/fix-1010348 into lp:unity

Proposed by Daniel van Vugt
Status: Superseded
Proposed branch: lp:~vanvugt/unity/fix-1010348
Merge into: lp:unity
Diff against target: 48 lines (+30/-1)
1 file modified
launcher/BamfLauncherIcon.cpp (+30/-1)
To merge this branch: bzr merge lp:~vanvugt/unity/fix-1010348
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+109307@code.launchpad.net

This proposal has been superseded by a proposal from 2012-06-10.

Commit message

Fix build failure with Nux 2.x. (LP: #1010348)

Don't depend on Nux 3.x API changes until it becomes necessary.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Can we have unit test for this?

Btw if I remember correctly when you do nux::Color(0xaabbccdd) nux create a nux color with
red = 0xbb
green = 0xcc
blue = 0xdd
alpha = 0xaa

and *not*
red = 0xaa
green = 0xbb
blue = 0xcc
alpha = 0xdd

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Fair question. And the answer is: Not today.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'launcher/BamfLauncherIcon.cpp'
--- launcher/BamfLauncherIcon.cpp 2012-06-01 09:33:15 +0000
+++ launcher/BamfLauncherIcon.cpp 2012-06-08 08:20:24 +0000
@@ -782,6 +782,35 @@
782 }782 }
783}783}
784784
785//
786// ParseColor:
787// Parses a color string in the form: #rrggbbaa, where # and aa are optional.
788//
789// In Nux 3.x, this function is superseded by:
790// nux::color::Color(std::string const& hex)
791// (even though this function is much smaller and faster)
792//
793// I would really like to #if NUX_VERSION <= ... around this code, but
794// no such integer macro seems to exist in the Nux headers.
795//
796static unsigned int ParseColor(const char *str)
797{
798 unsigned int ret = 0;
799 if (str)
800 {
801 const char *hex = str[0] == '#' ? str + 1 : str;
802 int digits = 0, color = 0;
803 if (sscanf(hex, "%x%n", &color, &digits))
804 {
805 if (digits == 8)
806 ret = (unsigned int)color;
807 else if (digits == 6)
808 ret = (unsigned int)color << 8;
809 }
810 }
811 return ret;
812}
813
785void BamfLauncherIcon::UpdateBackgroundColor()814void BamfLauncherIcon::UpdateBackgroundColor()
786{815{
787 bool last_use_custom_bg_color = use_custom_bg_color_;816 bool last_use_custom_bg_color = use_custom_bg_color_;
@@ -792,7 +821,7 @@
792 use_custom_bg_color_ = !color.empty();821 use_custom_bg_color_ = !color.empty();
793822
794 if (use_custom_bg_color_)823 if (use_custom_bg_color_)
795 bg_color_ = nux::Color(color);824 bg_color_ = nux::Color(ParseColor(color.c_str()));
796825
797 if (last_use_custom_bg_color != use_custom_bg_color_ ||826 if (last_use_custom_bg_color != use_custom_bg_color_ ||
798 last_bg_color != bg_color_)827 last_bg_color != bg_color_)