This commit is contained in:
yw4z
2026-03-16 15:10:36 +03:00
parent e1d844f71a
commit 3eac0a86e4
2 changed files with 11 additions and 43 deletions

View File

@@ -52,12 +52,12 @@ CenteredTitle::CenteredTitle(wxWindow* parent)
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, wxMax(0, 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) // is ellipsized int x = rect.x + (ellipsized != m_title) // is ellipsized
? FromDIP(4) // fixed left when clipped ? FromDIP(4) // align to left when clipped
: (rect.width - dc.GetTextExtent(m_title).GetWidth()) / 2; // centered when full : (rect.width - dc.GetTextExtent(m_title).GetWidth()) / 2; // centered when has available space
dc.DrawText(ellipsized, x, y); dc.DrawText(ellipsized, x, y);
}); });
@@ -80,8 +80,7 @@ CenteredTitle::CenteredTitle(wxWindow* parent)
void CenteredTitle::SetTitle(const wxString& title) { void CenteredTitle::SetTitle(const wxString& title) {
m_title = title; m_title = title;
RefreshRect(GetClientRect()); Refresh();
Update();
} }
// required for proper height // required for proper height
@@ -94,41 +93,10 @@ wxSize CenteredTitle::DoGetBestSize() const
class BBLTopbarArt : public wxAuiDefaultToolBarArt class BBLTopbarArt : public wxAuiDefaultToolBarArt
{ {
public: public:
//virtual void DrawLabel(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect) wxOVERRIDE;
virtual void DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) wxOVERRIDE; virtual void DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) wxOVERRIDE;
virtual void DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect) wxOVERRIDE; virtual void DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect) wxOVERRIDE;
}; };
/*
void BBLTopbarArt::DrawLabel(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect)
{
dc.SetFont(m_font);
#ifdef __WINDOWS__
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
#else
dc.SetTextForeground(*wxWHITE);
#endif
int textWidth = 0, textHeight = 0;
dc.GetTextExtent(item.GetLabel(), &textWidth, &textHeight);
wxRect clipRect = rect;
clipRect.width -= 1;
dc.SetClippingRegion(clipRect);
int textX, textY;
if (textWidth < rect.GetWidth()) {
textX = rect.x + 1 + (rect.width - textWidth) / 2;
}
else {
textX = rect.x + 1;
}
textY = rect.y + (rect.height - textHeight) / 2;
dc.DrawText(item.GetLabel(), textX, textY);
dc.DestroyClippingRegion();
}
*/
void BBLTopbarArt::DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) void BBLTopbarArt::DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect)
{ {
dc.SetBrush(wxBrush(wxColour(38, 46, 48))); dc.SetBrush(wxBrush(wxColour(38, 46, 48)));
@@ -399,11 +367,11 @@ void BBLTopbar::OnOpenProject(wxAuiToolBarEvent& event)
plater->load_project(); plater->load_project();
} }
void BBLTopbar::show_publish_button(bool show) //void BBLTopbar::show_publish_button(bool show)
{ //{
this->EnableTool(m_publish_item->GetId(), show); // this->EnableTool(m_publish_item->GetId(), show);
Refresh(); // Refresh();
} //}
void BBLTopbar::OnSaveProject(wxAuiToolBarEvent& event) void BBLTopbar::OnSaveProject(wxAuiToolBarEvent& event)
{ {

View File

@@ -44,7 +44,7 @@ public:
void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); void OnMouseCaptureLost(wxMouseCaptureLostEvent& event);
void OnMenuClose(wxMenuEvent& event); void OnMenuClose(wxMenuEvent& event);
void OnOpenProject(wxAuiToolBarEvent& event); void OnOpenProject(wxAuiToolBarEvent& event);
void show_publish_button(bool show); //void show_publish_button(bool show);
void OnSaveProject(wxAuiToolBarEvent& event); void OnSaveProject(wxAuiToolBarEvent& event);
void OnUndo(wxAuiToolBarEvent& event); void OnUndo(wxAuiToolBarEvent& event);
void OnRedo(wxAuiToolBarEvent& event); void OnRedo(wxAuiToolBarEvent& event);
@@ -90,7 +90,7 @@ private:
wxAuiToolBarItem* m_account_item; wxAuiToolBarItem* m_account_item;
wxAuiToolBarItem* m_model_store_item; wxAuiToolBarItem* m_model_store_item;
wxAuiToolBarItem *m_publish_item; //wxAuiToolBarItem *m_publish_item;
wxAuiToolBarItem* m_undo_item; wxAuiToolBarItem* m_undo_item;
wxAuiToolBarItem* m_redo_item; wxAuiToolBarItem* m_redo_item;
wxAuiToolBarItem* m_calib_item; wxAuiToolBarItem* m_calib_item;