]> git.lyx.org Git - lyx.git/blobdiff - src/BranchList.C
minimal effort implementation of:
[lyx.git] / src / BranchList.C
index 1900d956c3fd4becd2daaf7ccebba049bc81e4ce..75f183a0aa50408d45a42738b7c6289c617605c3 100644 (file)
 #include <config.h>
 
 #include "BranchList.h"
+#include "LColor.h"
+#include "frontends/lyx_gui.h"
+#include <algorithm>
 
 using std::string;
 
 
+Branch::Branch()
+{
+       lyx_gui::getRGBColor(LColor::background, color_);
+}
+
+
 string const & Branch::getBranch() const
 {
        return branch_;
@@ -42,18 +51,28 @@ bool Branch::setSelected(bool b)
 }
 
 
-string const & Branch::getColor() const
+lyx::RGBColor const & Branch::getColor() const
 {
        return color_;
 }
 
 
-void Branch::setColor(string const & c)
+void Branch::setColor(lyx::RGBColor const & c)
 {
        color_ = c;
 }
 
 
+void Branch::setColor(string const & c)
+{
+       if (c.size() == 7 && c[0] == '#')
+               color_ = lyx::RGBColor(c);
+       else
+               // no color set or invalid color - use normal background
+               lyx_gui::getRGBColor(LColor::background, color_);
+}
+
+
 Branch * BranchList::find(std::string const & name)
 {
        List::iterator it =
@@ -90,7 +109,6 @@ bool BranchList::add(string const & s)
                        Branch br;
                        br.setBranch(name);
                        br.setSelected(false);
-                       br.setColor("none");
                        list.push_back(br);
                }
                if (j == string::npos)