diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-08-19 13:02:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-08-19 18:09:59 +0200 |
commit | 82059a1eb582724cc9fe76932fb6bce2be9b7ea2 (patch) | |
tree | 2cd4a180b43c8be5829677e59924b15b0d172036 | |
parent | 5070c0095433e5169dd4a34b1c6a6469726c197c (diff) |
add a Title label type for base's title windows
Change-Id: I306591e931f7b4be8222cb6160032d7d105c522d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100994
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/vcl/weld.hxx | 1 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 8 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 57 |
3 files changed, 59 insertions, 7 deletions
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index bafc571d2c80..98880ca76f43 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -1914,6 +1914,7 @@ enum class LabelType Normal, Warning, Error, + Title, // this is intended to be used against the background set by set_title_background }; class VCL_DLLPUBLIC Label : virtual public Widget diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 8979efdec4d6..cd4de6bd1e3c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -5491,15 +5491,23 @@ void SalInstanceLabel::set_label_type(weld::LabelType eType) switch (eType) { case weld::LabelType::Normal: + m_xLabel->SetControlForeground(); m_xLabel->SetControlBackground(); break; case weld::LabelType::Warning: + m_xLabel->SetControlForeground(); m_xLabel->SetControlBackground(COL_YELLOW); break; case weld::LabelType::Error: + m_xLabel->SetControlForeground(); m_xLabel->SetControlBackground( m_xLabel->GetSettings().GetStyleSettings().GetHighlightColor()); break; + case weld::LabelType::Title: + m_xLabel->SetControlForeground( + m_xLabel->GetSettings().GetStyleSettings().GetLightColor()); + m_xLabel->SetControlBackground(); + break; } } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index a6ee2e32fe4c..b2b5d59fcc46 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8702,9 +8702,16 @@ namespace } } - gboolean filter_pango_attrs(PangoAttribute *attr, gpointer /*data*/) + gboolean filter_pango_attrs(PangoAttribute *attr, gpointer data) { - return attr->klass->type == PANGO_ATTR_FOREGROUND; + PangoAttrType* pFilterAttrs = static_cast<PangoAttrType*>(data); + while (*pFilterAttrs) + { + if (attr->klass->type == *pFilterAttrs) + return true; + ++pFilterAttrs; + } + return false; } class GtkInstanceEntry : public GtkInstanceWidget, public virtual weld::Entry @@ -8920,7 +8927,13 @@ public: if (rColor == COL_AUTO && !pOrigList) // nothing to do return; - PangoAttrList* pAttrList = pOrigList ? pango_attr_list_filter(pOrigList, filter_pango_attrs, nullptr) : pango_attr_list_new(); + PangoAttrType aFilterAttrs[] = {PANGO_ATTR_FOREGROUND, PANGO_ATTR_INVALID}; + + PangoAttrList* pAttrList = pOrigList + ? pango_attr_list_filter(pOrigList, filter_pango_attrs, &aFilterAttrs) + : nullptr; + if (!pAttrList) + pAttrList = pango_attr_list_new(); if (rColor != COL_AUTO) pango_attr_list_insert(pAttrList, pango_attr_foreground_new(rColor.GetRed()/255.0, rColor.GetGreen()/255.0, rColor.GetBlue()/255.0)); @@ -12518,18 +12531,45 @@ class GtkInstanceLabel : public GtkInstanceWidget, public virtual weld::Label private: GtkLabel* m_pLabel; - void set_text_color(const Color& rColor) + void set_text_background_color(const Color& rColor) { guint16 nRed = rColor.GetRed() << 8; guint16 nGreen = rColor.GetRed() << 8; guint16 nBlue = rColor.GetBlue() << 8; - PangoAttrList* pAttrs = pango_attr_list_new(); + PangoAttrType aFilterAttrs[] = {PANGO_ATTR_BACKGROUND, PANGO_ATTR_INVALID}; + + PangoAttrList* pOrigList = gtk_label_get_attributes(m_pLabel); + PangoAttrList* pAttrs = pOrigList + ? pango_attr_list_filter(pOrigList, filter_pango_attrs, &aFilterAttrs) + : nullptr; + if (!pAttrs) + pAttrs = pango_attr_list_new(); pango_attr_list_insert(pAttrs, pango_attr_background_new(nRed, nGreen, nBlue)); gtk_label_set_attributes(m_pLabel, pAttrs); pango_attr_list_unref(pAttrs); } + void set_bold_text_foreground_color(const Color& rColor) + { + guint16 nRed = rColor.GetRed() << 8; + guint16 nGreen = rColor.GetRed() << 8; + guint16 nBlue = rColor.GetBlue() << 8; + + PangoAttrType aFilterAttrs[] = {PANGO_ATTR_FOREGROUND, PANGO_ATTR_WEIGHT, PANGO_ATTR_INVALID}; + + PangoAttrList* pOrigList = gtk_label_get_attributes(m_pLabel); + PangoAttrList* pAttrs = pOrigList + ? pango_attr_list_filter(pOrigList, filter_pango_attrs, &aFilterAttrs) + : nullptr; + if (!pAttrs) + pAttrs = pango_attr_list_new(); + pango_attr_list_insert(pAttrs, pango_attr_foreground_new(nRed, nGreen, nBlue)); + pango_attr_list_insert(pAttrs, pango_attr_weight_new(PANGO_WEIGHT_BOLD)); + gtk_label_set_attributes(m_pLabel, pAttrs); + pango_attr_list_unref(pAttrs); + } + public: GtkInstanceLabel(GtkLabel* pLabel, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceWidget(GTK_WIDGET(pLabel), pBuilder, bTakeOwnership) @@ -12562,10 +12602,13 @@ public: gtk_label_set_attributes(m_pLabel, nullptr); break; case weld::LabelType::Warning: - set_text_color(COL_YELLOW); + set_text_background_color(COL_YELLOW); break; case weld::LabelType::Error: - set_text_color(Application::GetSettings().GetStyleSettings().GetHighlightColor()); + set_text_background_color(Application::GetSettings().GetStyleSettings().GetHighlightColor()); + break; + case weld::LabelType::Title: + set_bold_text_foreground_color(Application::GetSettings().GetStyleSettings().GetLightColor()); break; } } |