ENH:update save enable state by event

jira: STUDIO-11156
Change-Id: If3076e987e4a2e6adc27ec851fad4e0dab85324c
This commit is contained in:
zhou.xu 2025-03-26 17:16:49 +08:00 committed by lane.wei
parent bcd72a2217
commit 26a6a413bf
6 changed files with 59 additions and 14 deletions

View File

@ -0,0 +1,5 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.7398 4.84619L9.15381 1.26016C8.98676 1.09311 8.76084 1 8.52533 1H1.88864C1.39708 1 1 1.39845 1 1.88864V12.1114C1 12.6029 1.39845 13 1.88864 13H12.1114C12.6029 13 13 12.6016 13 12.1114V5.47467C13 5.23916 12.9055 5.01324 12.7398 4.84619ZM3.88909 1.88864H6.55637V3.44409H3.88909V1.88864ZM10.1109 12.1114H3.88909V10.1109H10.1109V12.1114ZM12.1114 12.1114H11.0009V9.66727C11.0009 9.42218 10.8024 9.22227 10.5559 9.22227H3.44409C3.19899 9.22227 2.99909 9.42081 2.99909 9.66727V12.1114H1.88864V1.88864H2.99909V3.88909C2.99909 4.13419 3.19763 4.33409 3.44409 4.33409H7C7.24509 4.33409 7.445 4.13555 7.445 3.88909V1.88864H8.52533L12.1114 5.47467V12.1114Z" fill="#909090"/>
<path d="M7.00038 1.36523H3.48145V3.90243H7.00038V1.36523Z" fill="#909090"/>
<path d="M10.5686 9.77148H3.48145V12.5565H10.5686V9.77148Z" fill="#909090"/>
</svg>

After

Width:  |  Height:  |  Size: 933 B

View File

@ -180,19 +180,19 @@ void BBLTopbarArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& i
}
}
BBLTopbar::BBLTopbar(wxFrame* parent)
BBLTopbar::BBLTopbar(wxFrame* parent)
: wxAuiToolBar(parent, ID_TOOL_BAR, wxDefaultPosition, wxDefaultSize, wxAUI_TB_TEXT | wxAUI_TB_HORZ_TEXT)
{
{
Init(parent);
}
BBLTopbar::BBLTopbar(wxWindow* pwin, wxFrame* parent)
: wxAuiToolBar(pwin, ID_TOOL_BAR, wxDefaultPosition, wxDefaultSize, wxAUI_TB_TEXT | wxAUI_TB_HORZ_TEXT)
{
: wxAuiToolBar(pwin, ID_TOOL_BAR, wxDefaultPosition, wxDefaultSize, wxAUI_TB_TEXT | wxAUI_TB_HORZ_TEXT)
{
Init(parent);
}
void BBLTopbar::Init(wxFrame* parent)
void BBLTopbar::Init(wxFrame* parent)
{
SetArtProvider(new BBLTopbarArt());
m_frame = parent;
@ -230,8 +230,9 @@ void BBLTopbar::Init(wxFrame* parent)
this->AddSpacer(FromDIP(10));
wxBitmap save_bitmap = create_scaled_bitmap("topbar_save", nullptr, TOPBAR_ICON_SIZE);
wxAuiToolBarItem* save_btn = this->AddTool(wxID_SAVE, "", save_bitmap);
m_save_item = this->AddTool(wxID_SAVE, "", save_bitmap);
wxBitmap save_inactive_bitmap = create_scaled_bitmap("topbar_save_inactive", nullptr, TOPBAR_ICON_SIZE);
m_save_item->SetDisabledBitmap(save_inactive_bitmap);
this->AddSpacer(FromDIP(10));
wxBitmap undo_bitmap = create_scaled_bitmap("topbar_undo", nullptr, TOPBAR_ICON_SIZE);
@ -348,6 +349,7 @@ void BBLTopbar::OnSaveProject(wxAuiToolBarEvent& event)
MainFrame* main_frame = dynamic_cast<MainFrame*>(m_frame);
Plater* plater = main_frame->plater();
plater->save_project();
EnableSaveItem(false);
}
void BBLTopbar::OnUndo(wxAuiToolBarEvent& event)
@ -364,6 +366,30 @@ void BBLTopbar::OnRedo(wxAuiToolBarEvent& event)
plater->redo();
}
void BBLTopbar::EnableSaveItem(bool enable)
{
if (m_save_item) {
this->EnableTool(m_save_item->GetId(), enable);
Refresh();
}
}
void BBLTopbar::EnableUndoItem(bool enable)
{
if (m_undo_item) {
this->EnableTool(m_undo_item->GetId(), enable);
Refresh();
}
}
void BBLTopbar::EnableRedoItem(bool enable)
{
if (m_redo_item) {
this->EnableTool(m_redo_item->GetId(), enable);
Refresh();
}
}
void BBLTopbar::EnableUndoRedoItems()
{
this->EnableTool(m_undo_item->GetId(), true);
@ -636,7 +662,7 @@ void BBLTopbar::OnMouseLeftDown(wxMouseEvent& event)
wxPoint frame_pos = m_frame->GetScreenPosition();
m_delta = mouse_pos - frame_pos;
if (FindToolByCurrentPosition() == NULL
if (FindToolByCurrentPosition() == NULL
|| this->FindToolByCurrentPosition() == m_title_item)
{
CaptureMouse();
@ -646,7 +672,7 @@ void BBLTopbar::OnMouseLeftDown(wxMouseEvent& event)
return;
#endif // __WXMSW__
}
event.Skip();
}
@ -674,7 +700,7 @@ void BBLTopbar::OnMouseMotion(wxMouseEvent& event)
if (event.Dragging() && event.LeftIsDown())
{
// leave max state and adjust position
// leave max state and adjust position
if (m_frame->IsMaximized()) {
wxRect rect = m_frame->GetRect();
// Filter unexcept mouse move

View File

@ -39,7 +39,7 @@ public:
void OnPublishClicked(wxAuiToolBarEvent &event);
wxAuiToolBarItem* FindToolByCurrentPosition();
void SetFileMenu(wxMenu* file_menu);
void AddDropDownSubMenu(wxMenu* sub_menu, const wxString& title);
void AddDropDownMenuItem(wxMenuItem* menu_item);
@ -49,6 +49,9 @@ public:
void SetMaximizedSize();
void SetWindowSize();
void EnableSaveItem(bool enable);
void EnableUndoItem(bool enable);
void EnableRedoItem(bool enable);
void EnableUndoRedoItems();
void DisableUndoRedoItems();
@ -68,8 +71,9 @@ private:
wxAuiToolBarItem* m_title_item;
wxAuiToolBarItem* m_account_item;
wxAuiToolBarItem* m_model_store_item;
wxAuiToolBarItem *m_publish_item;
wxAuiToolBarItem *m_save_item;
wxAuiToolBarItem* m_undo_item;
wxAuiToolBarItem* m_redo_item;
wxAuiToolBarItem* m_calib_item;

View File

@ -688,7 +688,13 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
evt.IsShown() ? manger->start_refresher() : manger->stop_refresher();
}
});
Bind(wxEVT_IDLE, ([this](wxIdleEvent &e) {
if (m_topbar && m_plater) {
m_topbar->EnableSaveItem(can_save());
m_topbar->EnableUndoItem(m_plater->can_undo());
m_topbar->EnableRedoItem(m_plater->can_redo());
}
}));
#ifdef _MSW_DARK_MODE
wxGetApp().UpdateDarkUIWin(this);
#endif // _MSW_DARK_MODE

View File

@ -14337,6 +14337,10 @@ void Plater::export_toolpaths_to_obj() const
p->preview->get_canvas3d()->export_toolpaths_to_obj(into_u8(path).c_str());
}
bool Plater::is_empty_project() {
return model().objects.empty();
}
bool Plater::is_multi_extruder_ams_empty()
{
std::vector<std::string> extruder_ams_count_str = p->config->option<ConfigOptionStrings>("extruder_ams_count", true)->values;

View File

@ -338,7 +338,7 @@ public:
void set_using_exported_file(bool exported_file) {
m_exported_file = exported_file;
}
bool is_empty_project();
bool is_multi_extruder_ams_empty();
// BBS
wxString get_project_name();