Custom Title Bar refactored / gtk support (#345)

This commit is contained in:
mirek-fidler 2026-01-16 19:26:25 +01:00 committed by GitHub
parent 68dbd76e01
commit 241cc4ea9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 1606 additions and 538 deletions

View file

@ -421,26 +421,29 @@ TopWindow& TopWindow::Icon(const Image& smallicon, const Image& _largeicon)
return *this;
}
bool is_custom_titlebar_available__;
bool TopWindow::IsCustomTitleBar() const
{
return custom_titlebar && is_custom_titlebar_available__;
}
TopWindow& TopWindow::CustomTitleBar(int cy)
{
custom_titlebar = is_custom_titlebar_available__;
custom_titlebar_cy = cy;
return *this;
}
// avoid the need to implement custom titlebar in all platforms:
Function<bool (const TopWindow *)> is_custom_titlebar__;
Function<Ctrl *(TopWindow *, Color bk, int)> custom_titlebar_make__;
Event<const TopWindow *, TopWindow::CustomTitleBarMetrics&> custom_titlebar_metrics__ =
[](const TopWindow *, TopWindow::CustomTitleBarMetrics& m) {
m.lm = m.rm = m.height = 0;
m.background = SColorPaper();
};
bool TopWindow::IsCustomTitleBar() const
{
return is_custom_titlebar__(this);
}
Ctrl * TopWindow::CustomTitleBar(Color bk, int min_cy)
{
#ifdef flagNOCUSTOMBAR // suppress custom title bar for testing
return nullptr;
#else
return custom_titlebar_make__(this, bk, min_cy);
#endif
}
TopWindow::CustomTitleBarMetrics TopWindow::GetCustomTitleBarMetrics() const
{
CustomTitleBarMetrics m;
@ -448,17 +451,18 @@ TopWindow::CustomTitleBarMetrics TopWindow::GetCustomTitleBarMetrics() const
return m;
}
static bool sIsDragArea(Ctrl& w, Point p)
bool Ctrl::MouseActiveCtrl(Ctrl *w, Point p)
{
for(Ctrl& q : w)
if(q.GetScreenRect().Contains(p))
return q.IsIgnoreMouse() || sIsDragArea(q, p);
return false;
for(Ctrl *q = w->GetLastChild(); q; q = q->GetPrev())
if(q->GetScreenRect().Contains(p))
return MouseActiveCtrl(q, p);
return w->IsMouseActive();
}
bool TopWindow::IsCustomTitleBarDragArea(Point p)
{
return sIsDragArea(*this, p + GetScreenRect().TopLeft());
return !MouseActiveCtrl(this, p + GetScreenRect().TopLeft());
}
TopWindow& TopWindow::ToolWindow(bool b)
@ -545,8 +549,6 @@ TopWindow::TopWindow()
dokeys = true;
fullscreen = frameless = urgent = false;
close_rejects = false;
custom_titlebar = false;
custom_titlebar_cy = 0;
}
TopWindow::~TopWindow()