groupbar: fix missing ellipsize for text

fixes #8938
This commit is contained in:
Vaxry 2025-01-04 00:25:01 +01:00
parent 2e6e0e9278
commit 60f069d540
3 changed files with 27 additions and 21 deletions

View file

@ -2555,7 +2555,7 @@ SP<CTexture> CHyprOpenGLImpl::loadAsset(const std::string& filename) {
return tex; return tex;
} }
SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily) { SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col, int pt, bool italic, const std::string& fontFamily, int maxWidth) {
SP<CTexture> tex = makeShared<CTexture>(); SP<CTexture> tex = makeShared<CTexture>();
static auto FONT = CConfigValue<std::string>("misc:font_family"); static auto FONT = CConfigValue<std::string>("misc:font_family");
@ -2580,6 +2580,12 @@ SP<CTexture> CHyprOpenGLImpl::renderText(const std::string& text, CHyprColor col
int textW = 0, textH = 0; int textW = 0, textH = 0;
pango_layout_set_text(layoutText, text.c_str(), -1); pango_layout_set_text(layoutText, text.c_str(), -1);
if (maxWidth > 0) {
pango_layout_set_width(layoutText, maxWidth * PANGO_SCALE);
pango_layout_set_ellipsize(layoutText, PANGO_ELLIPSIZE_END);
}
pango_layout_get_size(layoutText, &textW, &textH); pango_layout_get_size(layoutText, &textW, &textH);
textW /= PANGO_SCALE; textW /= PANGO_SCALE;
textH /= PANGO_SCALE; textH /= PANGO_SCALE;

View file

@ -217,32 +217,32 @@ class CHyprOpenGLImpl {
void renderOffToMain(CFramebuffer* off); void renderOffToMain(CFramebuffer* off);
void bindBackOnMain(); void bindBackOnMain();
SP<CTexture> loadAsset(const std::string& file); 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 = ""); SP<CTexture> renderText(const std::string& text, CHyprColor col, int pt, bool italic = false, const std::string& fontFamily = "", int maxWidth = 0);
void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {}); void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {});
uint32_t getPreferredReadFormat(PHLMONITOR pMonitor); uint32_t getPreferredReadFormat(PHLMONITOR pMonitor);
std::vector<SDRMFormat> getDRMFormats(); std::vector<SDRMFormat> getDRMFormats();
EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs);
SP<CEGLSync> createEGLSync(int fenceFD); SP<CEGLSync> createEGLSync(int fenceFD);
bool waitForTimelinePoint(SP<CSyncTimeline> timeline, uint64_t point); bool waitForTimelinePoint(SP<CSyncTimeline> timeline, uint64_t point);
SCurrentRenderData m_RenderData; SCurrentRenderData m_RenderData;
GLint m_iCurrentOutputFb = 0; GLint m_iCurrentOutputFb = 0;
int m_iGBMFD = -1; int m_iGBMFD = -1;
gbm_device* m_pGbmDevice = nullptr; gbm_device* m_pGbmDevice = nullptr;
EGLContext m_pEglContext = nullptr; EGLContext m_pEglContext = nullptr;
EGLDisplay m_pEglDisplay = nullptr; EGLDisplay m_pEglDisplay = nullptr;
EGLDeviceEXT m_pEglDevice = nullptr; EGLDeviceEXT m_pEglDevice = nullptr;
uint failedAssetsNo = 0; 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<PHLWINDOWREF, CFramebuffer> m_mWindowFramebuffers;
std::map<PHLLSREF, CFramebuffer> m_mLayerFramebuffers; std::map<PHLLSREF, CFramebuffer> m_mLayerFramebuffers;
std::map<PHLMONITORREF, SMonitorRenderData> m_mMonitorRenderResources; std::map<PHLMONITORREF, SMonitorRenderData> m_mMonitorRenderResources;
std::map<PHLMONITORREF, CFramebuffer> m_mMonitorBGFBs; std::map<PHLMONITORREF, CFramebuffer> m_mMonitorBGFBs;

View file

@ -223,7 +223,7 @@ CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize, const float
const CHyprColor COLOR = CHyprColor(*PTEXTCOLOR); const CHyprColor COLOR = CHyprColor(*PTEXTCOLOR);
const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT; const auto FONTFAMILY = *PTITLEFONTFAMILY != STRVAL_EMPTY ? *PTITLEFONTFAMILY : *FALLBACKFONT;
tex = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE, false, FONTFAMILY); tex = g_pHyprOpenGL->renderText(pWindow->m_szTitle, COLOR, *PTITLEFONTSIZE, false, FONTFAMILY, bufferSize.x - 2 /* some padding yk */);
if (tex) if (tex)
texSize = tex->m_vSize; texSize = tex->m_vSize;