Angus Leeming a écrit :
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
The patch looks good but I am wondering if this solution is not a bit too complicated. Why not just define some const string in hexa and let the frontend take care of the rest?

Just for clarification, this would mean replacing x11name by this RGB value in ColorEntry:

class ColorEntry {
        ColorEntry(
                string rgb_hexa = "#000000",
                string const guiname_ = "",
                string const latexname_ = "",
                string const lyxname_ = "");

Georg's solution may look complicated, but it's just a refactoring of existing,
working code. A real RGBColor class has real advantages, not least being type
safe. We (you :)) should strive to remove kludges, not add to them!

Further, a real Color lends itself to easy manipulation; the fact that we have
to separately define the colours of inset button and borders is a real ugliness!

Note that we could add optional hsv offset members to ColorEntry and let QColor in the case of Qt do the manipulation. The idea is that Qt will do color manipulation anyway so why doing it twice at difference location? At the end, what's on sreen is what Qt shows, isn't it? This pseudo code will summarize my idea. The advantage of it is that you can for example authorize the manipulation of the button background but all other button related colors would be set automatically.

class ColorEntry {
    ColorEntry(
        string rgb_hexa = "#000000",
        string const guiname_ = "",
        string const latexname_ = "",
        string const lyxname_ = "",
        int h_offset = 0,
        int s_offset = 0,
        int v_offset = 0);

    string const & get_rbg() const;
    void set_rbg(string const & rgb_hexa);
    void const & get_hsv_offset(int & ho, int & so, int & vo) const;

private:
    string rgb_;
    int const h_offset_;
    int const s_offset_;
    int const v_offset_;
    string const guiname_;
    string const latexname_;
    string const lyxname_;
};

class LQColor: public QColor
{
        LQColor(ColorEntry const ce): QColor(ce.get_rbg()) {
                if (ce.h_offset != 0
                        || ce.s_offset != 0
                        || ce.v_offset != 0) {

                        convertTo(QColor::Hsv);
                        int h, s, v, ho, so, vo;                
                        getHsv(&h,&s,&v);
                        ce.get_hsv_offset(ho,so,vo);
                        setHsv(&(h += ho), &(s += so), &(v += so));
        }
}

What do you think?

À demain!

A+
Abdel.

PS: A+ means "A plus tard" or "See you later"

Angus



Reply via email to