mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-21 04:13:50 +00:00
update
This commit is contained in:
@@ -36,14 +36,69 @@ enum CUSTOM_ID
|
|||||||
ID_AMS_NOTEBOOK,
|
ID_AMS_NOTEBOOK,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CenteredTitle::CenteredTitle(wxWindow* parent)
|
||||||
|
: wxControl()
|
||||||
|
{
|
||||||
|
SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
|
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||||
|
Bind(wxEVT_PAINT, [this](wxPaintEvent& e) {
|
||||||
|
wxBufferedPaintDC dc(this);
|
||||||
|
dc.SetBackground(wxBrush(wxColour(38, 46, 48)));
|
||||||
|
dc.Clear();
|
||||||
|
|
||||||
|
dc.SetFont(GetFont());
|
||||||
|
dc.SetTextForeground(*wxWHITE);
|
||||||
|
|
||||||
|
wxFontMetrics fm = dc.GetFontMetrics();
|
||||||
|
int textHeight = fm.ascent + fm.descent;
|
||||||
|
|
||||||
|
wxString text = wxControl::Ellipsize(m_title, dc, wxELLIPSIZE_END, GetClientSize().GetWidth() - FromDIP(8));
|
||||||
|
|
||||||
|
wxRect rect = GetClientRect();
|
||||||
|
int y = rect.y + (rect.height - textHeight) / 2;
|
||||||
|
|
||||||
|
dc.DrawText(text, rect.x + (rect.width - dc.GetTextExtent(text).GetWidth()) / 2, y);
|
||||||
|
});
|
||||||
|
|
||||||
|
// repaint for Ellipsize
|
||||||
|
Bind(wxEVT_SIZE, [this](wxSizeEvent& e) {
|
||||||
|
Refresh();
|
||||||
|
e.Skip();
|
||||||
|
});
|
||||||
|
|
||||||
|
Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||||
|
e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition())));
|
||||||
|
GetParent()->GetEventHandler()->ProcessEvent(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
Bind(wxEVT_LEFT_DCLICK, [this](wxMouseEvent& e) {
|
||||||
|
e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition())));
|
||||||
|
GetParent()->GetEventHandler()->ProcessEvent(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void CenteredTitle::SetTitle(const wxString& title) {
|
||||||
|
m_title = title;
|
||||||
|
RefreshRect(GetClientRect());
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// required for proper height
|
||||||
|
wxSize CenteredTitle::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
return wxSize(10, FromDIP(30));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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 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)
|
void BBLTopbarArt::DrawLabel(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect)
|
||||||
{
|
{
|
||||||
dc.SetFont(m_font);
|
dc.SetFont(m_font);
|
||||||
@@ -71,6 +126,7 @@ void BBLTopbarArt::DrawLabel(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& it
|
|||||||
dc.DrawText(item.GetLabel(), textX, textY);
|
dc.DrawText(item.GetLabel(), textX, textY);
|
||||||
dc.DestroyClippingRegion();
|
dc.DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void BBLTopbarArt::DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect)
|
void BBLTopbarArt::DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect)
|
||||||
{
|
{
|
||||||
@@ -257,23 +313,15 @@ void BBLTopbar::Init(wxFrame* parent)
|
|||||||
m_calib_item = this->AddTool(ID_CALIB, _L("Calibration"), calib_bitmap);
|
m_calib_item = this->AddTool(ID_CALIB, _L("Calibration"), calib_bitmap);
|
||||||
m_calib_item->SetDisabledBitmap(calib_bitmap_inactive);
|
m_calib_item->SetDisabledBitmap(calib_bitmap_inactive);
|
||||||
|
|
||||||
this->AddSpacer(FromDIP(10));
|
this->AddSpacer(FromDIP(25));
|
||||||
this->AddStretchSpacer(1);
|
//this->AddStretchSpacer(1);
|
||||||
|
|
||||||
m_title_item = this->AddLabel(ID_TITLE, "", FromDIP(TOPBAR_TITLE_WIDTH));
|
m_title_ctrl = new CenteredTitle(this);
|
||||||
m_title_item->SetAlignment(wxALIGN_CENTRE);
|
wxAuiToolBarItem* title_item = this->AddControl(m_title_ctrl, "");
|
||||||
|
title_item->SetProportion(1);
|
||||||
|
|
||||||
this->Bind(wxEVT_SIZE, [this](wxSizeEvent& e) {
|
this->AddSpacer(FromDIP(25));
|
||||||
if(m_title_item){
|
//this->AddStretchSpacer(1);
|
||||||
m_title_item->SetMinSize(wxSize(FromDIP(e.GetSize().GetWidth() > FromDIP(700) ? TOPBAR_TITLE_WIDTH : 200), -1));
|
|
||||||
SetTitle(m_title_item->GetLabel());
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
e.Skip();
|
|
||||||
});
|
|
||||||
|
|
||||||
this->AddSpacer(FromDIP(10));
|
|
||||||
this->AddStretchSpacer(1);
|
|
||||||
|
|
||||||
//m_publish_bitmap = create_scaled_bitmap("topbar_publish", nullptr, TOPBAR_ICON_SIZE);
|
//m_publish_bitmap = create_scaled_bitmap("topbar_publish", nullptr, TOPBAR_ICON_SIZE);
|
||||||
//m_publish_item = this->AddTool(ID_PUBLISH, "", m_publish_bitmap);
|
//m_publish_item = this->AddTool(ID_PUBLISH, "", m_publish_bitmap);
|
||||||
@@ -455,12 +503,9 @@ wxMenu* BBLTopbar::GetCalibMenu()
|
|||||||
|
|
||||||
void BBLTopbar::SetTitle(wxString title)
|
void BBLTopbar::SetTitle(wxString title)
|
||||||
{
|
{
|
||||||
wxGCDC dc(this);
|
m_titleText = title;
|
||||||
title = wxControl::Ellipsize(title, dc, wxELLIPSIZE_END, m_title_item->GetMinSize().GetWidth());
|
if (m_title_ctrl)
|
||||||
|
m_title_ctrl->SetTitle(title);
|
||||||
m_title_item->SetLabel(title);
|
|
||||||
m_title_item->SetAlignment(wxALIGN_CENTRE);
|
|
||||||
this->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BBLTopbar::SetMaximizedSize()
|
void BBLTopbar::SetMaximizedSize()
|
||||||
@@ -509,7 +554,8 @@ void BBLTopbar::Rescale() {
|
|||||||
item->SetBitmap(create_scaled_bitmap("calib_sf", this, TOPBAR_ICON_SIZE));
|
item->SetBitmap(create_scaled_bitmap("calib_sf", this, TOPBAR_ICON_SIZE));
|
||||||
item->SetDisabledBitmap(create_scaled_bitmap("calib_sf_inactive", this, TOPBAR_ICON_SIZE));
|
item->SetDisabledBitmap(create_scaled_bitmap("calib_sf_inactive", this, TOPBAR_ICON_SIZE));
|
||||||
|
|
||||||
item = this->FindTool(ID_TITLE);
|
if (m_title_ctrl)
|
||||||
|
m_title_ctrl->SetTitle(m_titleText);
|
||||||
|
|
||||||
/*item = this->FindTool(ID_PUBLISH);
|
/*item = this->FindTool(ID_PUBLISH);
|
||||||
item->SetBitmap(create_scaled_bitmap("topbar_publish", this, TOPBAR_ICON_SIZE));
|
item->SetBitmap(create_scaled_bitmap("topbar_publish", this, TOPBAR_ICON_SIZE));
|
||||||
@@ -574,9 +620,9 @@ void BBLTopbar::OnCloseFrame(wxAuiToolBarEvent& event)
|
|||||||
void BBLTopbar::OnMouseLeftDClock(wxMouseEvent& mouse)
|
void BBLTopbar::OnMouseLeftDClock(wxMouseEvent& mouse)
|
||||||
{
|
{
|
||||||
wxPoint mouse_pos = ::wxGetMousePosition();
|
wxPoint mouse_pos = ::wxGetMousePosition();
|
||||||
|
wxAuiToolBarItem* item = this->FindToolByCurrentPosition();
|
||||||
// check whether mouse is not on any tool item
|
// check whether mouse is not on any tool item
|
||||||
if (this->FindToolByCurrentPosition() != NULL &&
|
if (item != NULL && item->GetWindow() != m_title_ctrl) {
|
||||||
this->FindToolByCurrentPosition() != m_title_item) {
|
|
||||||
mouse.Skip();
|
mouse.Skip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -644,10 +690,10 @@ void BBLTopbar::OnMouseLeftDown(wxMouseEvent& event)
|
|||||||
{
|
{
|
||||||
wxPoint mouse_pos = ::wxGetMousePosition();
|
wxPoint mouse_pos = ::wxGetMousePosition();
|
||||||
wxPoint frame_pos = m_frame->GetScreenPosition();
|
wxPoint frame_pos = m_frame->GetScreenPosition();
|
||||||
|
wxAuiToolBarItem* item = this->FindToolByCurrentPosition();
|
||||||
m_delta = mouse_pos - frame_pos;
|
m_delta = mouse_pos - frame_pos;
|
||||||
|
|
||||||
if (FindToolByCurrentPosition() == NULL
|
if (item == NULL || item->GetWindow() == m_title_ctrl)
|
||||||
|| this->FindToolByCurrentPosition() == m_title_item)
|
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
@@ -737,8 +783,8 @@ WXLRESULT BBLTopbar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam
|
|||||||
{
|
{
|
||||||
switch (nMsg) {
|
switch (nMsg) {
|
||||||
case WM_NCHITTEST: {
|
case WM_NCHITTEST: {
|
||||||
const wxAuiToolBarItem* current_item = this->FindToolByCurrentPosition();
|
wxAuiToolBarItem* item = this->FindToolByCurrentPosition();
|
||||||
if (current_item != nullptr && current_item != m_title_item) {
|
if (item != NULL && item->GetWindow() != m_title_ctrl) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,22 @@
|
|||||||
#include "SelectMachine.hpp"
|
#include "SelectMachine.hpp"
|
||||||
#include "DeviceManager.hpp"
|
#include "DeviceManager.hpp"
|
||||||
|
|
||||||
|
#include <wx/control.h>
|
||||||
|
|
||||||
using namespace Slic3r::GUI;
|
using namespace Slic3r::GUI;
|
||||||
|
|
||||||
|
class CenteredTitle : public wxControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CenteredTitle(wxWindow* parent);
|
||||||
|
void SetTitle(const wxString& title);
|
||||||
|
|
||||||
|
wxSize DoGetBestSize() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_title;
|
||||||
|
};
|
||||||
|
|
||||||
class BBLTopbar : public wxAuiToolBar
|
class BBLTopbar : public wxAuiToolBar
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -70,7 +83,10 @@ private:
|
|||||||
wxMenu m_top_menu;
|
wxMenu m_top_menu;
|
||||||
wxMenu* m_file_menu;
|
wxMenu* m_file_menu;
|
||||||
wxMenu m_calib_menu;
|
wxMenu m_calib_menu;
|
||||||
wxAuiToolBarItem* m_title_item;
|
|
||||||
|
CenteredTitle* m_title_ctrl { nullptr };
|
||||||
|
wxString m_titleText;
|
||||||
|
|
||||||
wxAuiToolBarItem* m_account_item;
|
wxAuiToolBarItem* m_account_item;
|
||||||
wxAuiToolBarItem* m_model_store_item;
|
wxAuiToolBarItem* m_model_store_item;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user