diff options
| author | M Matthew Hydock <mhydock@yahoo.com> | 2025-04-24 14:48:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-24 20:48:08 +0200 |
| commit | be6268a7ecea2ad50cdb78fb661884811a8a28e8 (patch) | |
| tree | ac5846bc109796f84c1d0abe095286de96a5967d /src/render | |
| parent | a9549dbca060b65ae6ec50f9bc68cdf1823d6cbe (diff) | |
groupbar: Add options for setting group bar title font weight (and indicator gap) (#9617)
Diffstat (limited to 'src/render')
| -rw-r--r-- | src/render/OpenGL.cpp | 6 | ||||
| -rw-r--r-- | src/render/OpenGL.hpp | 42 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.cpp | 36 | ||||
| -rw-r--r-- | src/render/decorations/CHyprGroupBarDecoration.hpp | 4 |
4 files changed, 48 insertions, 40 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index d3ac7962..3e9348d6 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -2714,7 +2714,7 @@ SP<CTexture> CHyprOpenGLImpl::loadAsset(const std::string& filename) { return tex; } -SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily, int maxWidth) { +SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily, int maxWidth, int weight) { SP<CTexture> tex = makeShared<CTexture>(); static auto FONT = CConfigValue<std::string>("misc:font_family"); @@ -2732,7 +2732,7 @@ SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col pango_font_description_set_family_static(pangoFD, FONTFAMILY.c_str()); pango_font_description_set_absolute_size(pangoFD, FONTSIZE * PANGO_SCALE); pango_font_description_set_style(pangoFD, italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); - pango_font_description_set_weight(pangoFD, PANGO_WEIGHT_NORMAL); + pango_font_description_set_weight(pangoFD, static_cast<PangoWeight>(weight)); pango_layout_set_font_description(layoutText, pangoFD); cairo_set_source_rgba(CAIRO, COLOR.r, COLOR.g, COLOR.b, COLOR.a); @@ -2763,7 +2763,7 @@ SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col pango_font_description_set_family_static(pangoFD, FONTFAMILY.c_str()); pango_font_description_set_absolute_size(pangoFD, FONTSIZE * PANGO_SCALE); pango_font_description_set_style(pangoFD, italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); - pango_font_description_set_weight(pangoFD, PANGO_WEIGHT_NORMAL); + pango_font_description_set_weight(pangoFD, static_cast<PangoWeight>(weight)); pango_layout_set_font_description(layoutText, pangoFD); pango_layout_set_text(layoutText, text.c_str(), -1); diff --git a/src/render/OpenGL.hpp b/src/render/OpenGL.hpp index 276d5268..414ba103 100644 --- a/src/render/OpenGL.hpp +++ b/src/render/OpenGL.hpp @@ -224,35 +224,35 @@ class CHyprOpenGLImpl { void renderOffToMain(CFramebuffer* off); void bindBackOnMain(); - SP<CTexture> loadAsset(const std::string& file); - SP<CTexture> renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0); + SP<CTexture> loadAsset(const std::string& file); + SP<CTexture> renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0, int weight = 400); - void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {}); + void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {}); - void ensureBackgroundTexturePresence(); + void ensureBackgroundTexturePresence(); - uint32_t getPreferredReadFormat(PHLMONITOR pMonitor); - std::vector<SDRMFormat> getDRMFormats(); - EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); - SP<CEGLSync> createEGLSync(int fence = -1); + uint32_t getPreferredReadFormat(PHLMONITOR pMonitor); + std::vector<SDRMFormat> getDRMFormats(); + EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); + SP<CEGLSync> createEGLSync(int fence = -1); - bool initShaders(); - bool m_bShadersInitialized = false; - SP<SPreparedShaders> m_shaders; + bool initShaders(); + bool m_bShadersInitialized = false; + SP<SPreparedShaders> m_shaders; - SCurrentRenderData m_RenderData; + SCurrentRenderData m_RenderData; - Hyprutils::OS::CFileDescriptor m_iGBMFD; - gbm_device* m_pGbmDevice = nullptr; - EGLContext m_pEglContext = nullptr; - EGLDisplay m_pEglDisplay = nullptr; - EGLDeviceEXT m_pEglDevice = nullptr; - uint failedAssetsNo = 0; + Hyprutils::OS::CFileDescriptor m_iGBMFD; + gbm_device* m_pGbmDevice = nullptr; + EGLContext m_pEglContext = nullptr; + EGLDisplay m_pEglDisplay = nullptr; + EGLDeviceEXT m_pEglDevice = nullptr; + uint failedAssetsNo = 0; - bool m_bReloadScreenShader = true; // at launch it can be set + bool m_bReloadScreenShader = true; // at launch it can be set - std::map<PHLWINDOWREF, CFramebuffer> m_mWindowFramebuffers; - std::map<PHLLSREF, CFramebuffer> m_mLayerFramebuffers; + std::map<PHLWINDOWREF, CFramebuffer> m_mWindowFramebuffers; + std::map<PHLLSREF, CFramebuffer> m_mLayerFramebuffers; std::map<PHLMONITORREF, SMonitorRenderData> m_mMonitorRenderResources; std::map<PHLMONITORREF, CFramebuffer> m_mMonitorBGFBs; diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index 50726514..7eca6d69 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -27,6 +27,7 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(PHLWINDOW pWindow) : IHyprWindo SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() { static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height"); + static auto PINDICATORGAP = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_gap"); static auto PINDICATORHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_height"); static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:enabled"); static auto PRENDERTITLES = CConfigValue<Hyprlang::INT>("group:groupbar:render_titles"); @@ -44,10 +45,10 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() { if (*PENABLED && m_pWindow->m_sWindowData.decorate.valueOrDefault()) { if (*PSTACKED) { - const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0); + const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + *PINDICATORGAP + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0); info.desiredExtents = {{0, (ONEBARHEIGHT * m_dwGroupMembers.size()) + (*PKEEPUPPERGAP * *POUTERGAP)}, {0, 0}}; } else - info.desiredExtents = {{0, *POUTERGAP * (1 + *PKEEPUPPERGAP) + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)}, {0, 0}}; + info.desiredExtents = {{0, *POUTERGAP * (1 + *PKEEPUPPERGAP) + *PINDICATORHEIGHT + *PINDICATORGAP + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)}, {0, 0}}; } else info.desiredExtents = {{0, 0}, {0, 0}}; return info; @@ -105,6 +106,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) { static auto PRENDERTITLES = CConfigValue<Hyprlang::INT>("group:groupbar:render_titles"); static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size"); static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height"); + static auto PINDICATORGAP = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_gap"); static auto PINDICATORHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:indicator_height"); static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:gradients"); static auto PSTACKED = CConfigValue<Hyprlang::INT>("group:groupbar:stacked"); @@ -127,7 +129,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) { const auto ASSIGNEDBOX = assignedBoxGlobal(); - const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0); + const auto ONEBARHEIGHT = *POUTERGAP + *PINDICATORHEIGHT + *PINDICATORGAP + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0); m_fBarWidth = *PSTACKED ? ASSIGNEDBOX.w : (ASSIGNEDBOX.w - *PINNERGAP * (barsToDraw - 1)) / barsToDraw; m_fBarHeight = *PSTACKED ? ((ASSIGNEDBOX.h - *POUTERGAP * *PKEEPUPPERGAP) - *POUTERGAP * (barsToDraw)) / barsToDraw : ASSIGNEDBOX.h - *POUTERGAP * *PKEEPUPPERGAP; @@ -141,7 +143,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) { for (int i = 0; i < barsToDraw; ++i) { const auto WINDOWINDEX = *PSTACKED ? m_dwGroupMembers.size() - i - 1 : i; - CBox rect = {ASSIGNEDBOX.x + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x, + CBox rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x, ASSIGNEDBOX.y + ASSIGNEDBOX.h - floor(yoff) - *PINDICATORHEIGHT - *POUTERGAP - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y, m_fBarWidth, *PINDICATORHEIGHT}; @@ -185,7 +187,7 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) { g_pHyprRenderer->m_sRenderPass.add(makeShared<CRectPassElement>(rectdata)); } - rect = {ASSIGNEDBOX.x + floor(xoff) - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x, + rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x, ASSIGNEDBOX.y + ASSIGNEDBOX.h - floor(yoff) - ONEBARHEIGHT - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y, m_fBarWidth, (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0)}; rect.scale(pMonitor->scale); @@ -235,14 +237,16 @@ void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float const& a) { .emplace_back(makeUnique<CTitleTex>(m_dwGroupMembers[WINDOWINDEX].lock(), Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2L * BAR_TEXT_PAD) * pMonitor->scale}, pMonitor->scale)) .get(); - rect.y += std::ceil(((rect.height - pTitleTex->texSize.y) / 2.0) - (*PTEXTOFFSET * pMonitor->scale)); - rect.height = pTitleTex->texSize.y; - rect.width = pTitleTex->texSize.x; - rect.x += std::round(((m_fBarWidth * pMonitor->scale) / 2.0) - (pTitleTex->texSize.x / 2.0)); + + const auto titleTex = m_dwGroupMembers[WINDOWINDEX] == g_pCompositor->m_lastWindow ? pTitleTex->texActive : pTitleTex->texInactive; + rect.y += std::ceil(((rect.height - titleTex->m_vSize.y) / 2.0) - (*PTEXTOFFSET * pMonitor->scale)); + rect.height = titleTex->m_vSize.y; + rect.width = titleTex->m_vSize.x; + rect.x += std::round(((m_fBarWidth * pMonitor->scale) / 2.0) - (titleTex->m_vSize.x / 2.0)); rect.round(); CTexPassElement::SRenderData data; - data.tex = pTitleTex->tex; + data.tex = titleTex; data.box = rect; data.a = a; g_pHyprRenderer->m_sRenderPass.add(makeShared<CTexPassElement>(data)); @@ -278,13 +282,17 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float static auto PTITLEFONTSIZE = CConfigValue<Hyprlang::INT>("group:groupbar:font_size"); static auto PTEXTCOLOR = CConfigValue<Hyprlang::INT>("group:groupbar:text_color"); + static auto PTITLEFONTWEIGHTACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_active"); + static auto PTITLEFONTWEIGHTINACTIVE = CConfigValue<Hyprlang::CUSTOMTYPE>("group:groupbar:font_weight_inactive"); + + const auto FONTWEIGHTACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTACTIVE.ptr())->getData(); + const auto FONTWEIGHTINACTIVE = (CFontWeightConfigValueData*)(PTITLEFONTWEIGHTINACTIVE.ptr())->getData(); + const CHyprColor COLOR = CHyprColor(*PTEXTCOLOR); const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT; - tex = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2 /* some padding yk */); - - if (tex) - texSize = tex->m_vSize; + texActive = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTACTIVE->m_value); + texInactive = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE * monitorScale, false, FONTFAMILY, bufferSize.x - 2, FONTWEIGHTINACTIVE->m_value); } static void renderGradientTo(SP<CTexture> tex, CGradientValueData* grad) { diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 0cdf8a6b..de087bce 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -12,9 +12,9 @@ class CTitleTex { CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float monitorScale); ~CTitleTex() = default; - SP<CTexture> tex; + SP<CTexture> texActive; + SP<CTexture> texInactive; std::string szContent; - Vector2D texSize; PHLWINDOWREF pWindowOwner; }; |
