Added "Modify Shapes Gallery" to the "Window" menu
+ Fixed a non-MSW build (added missed include)
This commit is contained in:
parent
b140709fa8
commit
e6c361ec5e
6 changed files with 32 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "format.hpp"
|
||||
#include "I18N.hpp"
|
||||
|
||||
#include "libslic3r/LocalesUtils.hpp"
|
||||
|
|
|
@ -1413,7 +1413,7 @@ void ObjectList::load_part(ModelObject& model_object, std::vector<ModelVolume*>&
|
|||
|
||||
if (from_galery) {
|
||||
GalleryDialog dlg(this);
|
||||
if (dlg.ShowModal() == wxID_CANCEL)
|
||||
if (dlg.ShowModal() == wxID_CLOSE)
|
||||
return;
|
||||
dlg.get_input_files(input_files);
|
||||
if (input_files.IsEmpty())
|
||||
|
@ -1472,7 +1472,7 @@ void ObjectList::load_modifier(ModelObject& model_object, std::vector<ModelVolum
|
|||
|
||||
if (from_galery) {
|
||||
GalleryDialog dlg(this);
|
||||
if (dlg.ShowModal() == wxID_CANCEL)
|
||||
if (dlg.ShowModal() == wxID_CLOSE)
|
||||
return;
|
||||
dlg.get_input_files(input_files);
|
||||
if (input_files.IsEmpty())
|
||||
|
@ -1684,18 +1684,22 @@ void ObjectList::load_shape_object_from_gallery()
|
|||
|
||||
wxArrayString input_files;
|
||||
GalleryDialog gallery_dlg(this);
|
||||
if (gallery_dlg.ShowModal() == wxID_CANCEL)
|
||||
if (gallery_dlg.ShowModal() == wxID_CLOSE)
|
||||
return;
|
||||
gallery_dlg.get_input_files(input_files);
|
||||
if (input_files.IsEmpty())
|
||||
return;
|
||||
load_shape_object_from_gallery(input_files);
|
||||
}
|
||||
|
||||
void ObjectList::load_shape_object_from_gallery(const wxArrayString& input_files)
|
||||
{
|
||||
std::vector<boost::filesystem::path> paths;
|
||||
for (const auto& file : input_files)
|
||||
paths.push_back(into_path(file));
|
||||
|
||||
assert(!paths.empty());
|
||||
wxString snapshot_label = (paths.size() == 1 ? _L("Add Shape") : _L("Add Shapes")) + ": " +
|
||||
wxString snapshot_label = (paths.size() == 1 ? _L("Add Shape from Gallery") : _L("Add Shapes from Gallery")) + ": " +
|
||||
wxString::FromUTF8(paths.front().filename().string().c_str());
|
||||
for (size_t i = 1; i < paths.size(); ++i)
|
||||
snapshot_label += ", " + wxString::FromUTF8(paths[i].filename().string().c_str());
|
||||
|
|
|
@ -245,6 +245,7 @@ public:
|
|||
void load_generic_subobject(const std::string& type_name, const ModelVolumeType type);
|
||||
void load_shape_object(const std::string &type_name);
|
||||
void load_shape_object_from_gallery();
|
||||
void load_shape_object_from_gallery(const wxArrayString& input_files);
|
||||
void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true);
|
||||
void del_object(const int obj_idx);
|
||||
void del_subobject_item(wxDataViewItem& item);
|
||||
|
|
|
@ -64,7 +64,7 @@ bool GalleryDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& f
|
|||
}
|
||||
|
||||
|
||||
GalleryDialog::GalleryDialog(wxWindow* parent) :
|
||||
GalleryDialog::GalleryDialog(wxWindow* parent, bool modify_gallery/* = false*/) :
|
||||
DPIDialog(parent, wxID_ANY, _L("Shapes Gallery"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
|
@ -90,9 +90,13 @@ GalleryDialog::GalleryDialog(wxWindow* parent) :
|
|||
});
|
||||
#endif
|
||||
|
||||
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK | wxCLOSE);
|
||||
wxButton* ok_btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
|
||||
ok_btn->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(!m_selected_items.empty()); });
|
||||
if (modify_gallery) {
|
||||
ok_btn->SetLabel(_L("Add to bed"));
|
||||
ok_btn->SetToolTip(_L("Add selected shape(s) to the bed"));
|
||||
}
|
||||
|
||||
auto add_btn = [this, buttons]( size_t pos, int& ID, wxString title, wxString tooltip,
|
||||
void (GalleryDialog::* method)(wxEvent&),
|
||||
|
@ -144,7 +148,7 @@ void GalleryDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||
{
|
||||
const int& em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { ID_BTN_ADD_CUSTOM_SHAPE, ID_BTN_DEL_CUSTOM_SHAPE, ID_BTN_REPLACE_CUSTOM_PNG, wxID_OK, wxID_CANCEL });
|
||||
msw_buttons_rescale(this, em, { ID_BTN_ADD_CUSTOM_SHAPE, ID_BTN_DEL_CUSTOM_SHAPE, ID_BTN_REPLACE_CUSTOM_PNG, wxID_OK, wxID_CLOSE });
|
||||
|
||||
wxSize size = wxSize(55 * em, 35 * em);
|
||||
m_list_ctrl->SetMinSize(size);
|
||||
|
|
|
@ -41,7 +41,7 @@ class GalleryDialog : public DPIDialog
|
|||
void update();
|
||||
|
||||
public:
|
||||
GalleryDialog(wxWindow* parent);
|
||||
GalleryDialog(wxWindow* parent, bool modify_gallery = false);
|
||||
~GalleryDialog();
|
||||
|
||||
void get_input_files(wxArrayString& input_files);
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include "MsgDialog.hpp"
|
||||
#include "Notebook.hpp"
|
||||
#include "GUI_Factories.hpp"
|
||||
#include "GUI_ObjectList.hpp"
|
||||
#include "GalleryDialog.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dbt.h>
|
||||
|
@ -1394,6 +1396,18 @@ void MainFrame::init_menubar_as_editor()
|
|||
[this](){return can_change_view(); }, this);
|
||||
}
|
||||
|
||||
windowMenu->AppendSeparator();
|
||||
append_menu_item(windowMenu, wxID_ANY, _L("Modify Shapes Gallery") + "\tCtrl+G", _L("Open the dialog to modify shapes gallery"),
|
||||
[this](wxCommandEvent&) {
|
||||
GalleryDialog dlg(this, true);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
wxArrayString input_files;
|
||||
dlg.get_input_files(input_files);
|
||||
if (!input_files.IsEmpty())
|
||||
m_plater->sidebar().obj_list()->load_shape_object_from_gallery(input_files);
|
||||
}
|
||||
}, "cog", nullptr, []() {return true; }, this);
|
||||
|
||||
windowMenu->AppendSeparator();
|
||||
append_menu_item(windowMenu, wxID_ANY, _L("Print &Host Upload Queue") + "\tCtrl+J", _L("Display the Print Host Upload Queue window"),
|
||||
[this](wxCommandEvent&) { m_printhost_queue_dlg->Show(); }, "upload_queue", nullptr, []() {return true; }, this);
|
||||
|
|
Loading…
Reference in a new issue