mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 03:43:52 +00:00
Update BBLTopbar.cpp
This commit is contained in:
@@ -51,13 +51,12 @@ CenteredTitle::CenteredTitle(wxWindow* parent)
|
|||||||
wxFontMetrics fm = dc.GetFontMetrics();
|
wxFontMetrics fm = dc.GetFontMetrics();
|
||||||
int textHeight = fm.ascent + fm.descent;
|
int textHeight = fm.ascent + fm.descent;
|
||||||
|
|
||||||
wxRect rect = GetClientRect();
|
wxRect rect = GetClientRect();
|
||||||
|
|
||||||
wxString ellipsized = wxControl::Ellipsize(m_title, dc, wxELLIPSIZE_END, rect.GetWidth() - FromDIP(8));
|
wxString ellipsized = wxControl::Ellipsize(m_title, dc, wxELLIPSIZE_END, rect.GetWidth() - FromDIP(8));
|
||||||
|
|
||||||
int y = rect.y + (rect.height - textHeight) / 2;
|
int y = rect.y + (rect.height - textHeight) / 2;
|
||||||
int x = rect.x + (ellipsized != m_title)
|
int x = rect.x + (ellipsized != m_title) // is ellipsized
|
||||||
? FromDIP(4) // fixed left when clipped
|
? FromDIP(4) // fixed left when clipped
|
||||||
: (rect.width - dc.GetTextExtent(m_title).GetWidth()) / 2; // centered when full
|
: (rect.width - dc.GetTextExtent(m_title).GetWidth()) / 2; // centered when full
|
||||||
|
|
||||||
dc.DrawText(ellipsized, x, y);
|
dc.DrawText(ellipsized, x, y);
|
||||||
@@ -69,15 +68,14 @@ CenteredTitle::CenteredTitle(wxWindow* parent)
|
|||||||
e.Skip();
|
e.Skip();
|
||||||
});
|
});
|
||||||
|
|
||||||
Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
auto forwardMouseEvent = [this](wxMouseEvent& e) {
|
||||||
|
if (e.LeftDown() && e.GetClickCount() > 1) return; // prevent duplicate event
|
||||||
e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition())));
|
e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition())));
|
||||||
GetParent()->GetEventHandler()->ProcessEvent(e);
|
GetParent()->GetEventHandler()->ProcessEvent(e);
|
||||||
});
|
};
|
||||||
|
|
||||||
Bind(wxEVT_LEFT_DCLICK, [this](wxMouseEvent& e) {
|
Bind(wxEVT_LEFT_DOWN, forwardMouseEvent);
|
||||||
e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition())));
|
Bind(wxEVT_LEFT_DCLICK, forwardMouseEvent);
|
||||||
GetParent()->GetEventHandler()->ProcessEvent(e);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenteredTitle::SetTitle(const wxString& title) {
|
void CenteredTitle::SetTitle(const wxString& title) {
|
||||||
|
|||||||
Reference in New Issue
Block a user