mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00

* Upgrade wxWidgets to 3.2.1
Based on prusa3d/PrusaSlicer@9a7e024
Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
* Implement BitmapCache
* update wxExtensions while keeping legacy items
* update dc.DrawBitmap calls to use get_bitmap
* Fix GetSize/Width/Height calls
* update BitmapComboBox
* fix ifndef in wxExtensions.hpp
* update my todos to OcraftyoneTODO
* Get to a compilable state
Everything seems to be working (including the plater). I am not seeing any graphical issues
* fix extruder color icons
* fix crash on opening support tab
* remove GetBmpSize method from DropDown.cpp
* Update TextInput to use bitmap bundles
* update a TODO after testing
* fix the rendering of the icons on combobox
* fix a few todos
* fix WipeTowerDialog.cpp
* Overhaul WipeTowerDialog
Removed simple version of the dialog since BBS removed the functionality but left the code.
Center the table (only seen when the table is smaller than the minimum size of the dialog)
Fix issue where editing a value causes the m_min_flush_label to change colors slightly
Fix an issue where changing a value or running an auto calc changes the disabled value from "-" to "0"
* update a few todos
* Update some todos
* Show dropdown when editing is started
* Update NanoSVG.cmake
Update NanoSVG to work with PR #2780
* Dim the icon on ComboBox when disabled
* solve ObjectDataViewModel todos
leaving colPrint and colEditing cases alone as it does not seem to impact anything
* Update names in wxExtensions
-Rename msw_rescale to sys_color_changed
-Replace GetBmpSize, GetBmpWidth, GetBmpHeight with renamed version (same name without "Bmp")
Both of these changes were also made by PrusaSlicer.
Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* update BitmapCache::from_svg
disable finding bundle in the cache to match load_svg
update to match values used in load_svg
* Update ScalableButton
change the signature and remove functions/vars pertaining to a default bmp
fix TODOs in ScalableButton
Original Commit: Prusa3D/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* fix up some more todos in wxExtensions
* update ScalableBitmap to use bmp bundles
use wxBitmapBundle by default
add flag to use old scaled bitmap function (specifically to solve issue with advanced toggle)
* attempt to fix macos deps build
* fix ubuntu build
* Revert "attempt to fix macos deps build"
Mistakenly made change to wrong file
This reverts commit d9c20b5121
.
* update wxWidgets patch
an attempt to fix macOS build
* Remove duplicate variable from OrcaSlicer.cpp
* Fix macOS build issue
* Fix blank DataViewItem being added to objects list
* Filament ComboBox editor updates
-Add show drop down feature to ObjectTable
-Call finish editing when ComboBox is closed in ObjectList
* remove Apple specific declarations missed during refactor
* delete old wxWidgets patch
* fix ubuntu seg fault
* include patch from #2926
* update patch to include wxWidgets/wxWidgets@991a74c
* fix deps not compiling on Windows
* update WipeTowerDialog
relocates the recalculate button back to its previous position
changes the wording of the tip message label
add spacing below the matrix
* finish patching wxWidgets
from prusa3d/PrusaSlicer@f8477d1 and prusa3d/PrusaSlicer@066b567
Co-authored-by: YuSanka <yusanka@gmail.com>
* fix combobox crash
* revert outside plate changes
---------
Co-authored-by: tamasmeszaros <meszaros.q@gmail.com>
Co-authored-by: YuSanka <yusanka@gmail.com>
191 lines
6.2 KiB
C++
191 lines
6.2 KiB
C++
#ifndef slic3r_GUI_ExtraRenderers_hpp_
|
|
#define slic3r_GUI_ExtraRenderers_hpp_
|
|
|
|
#include <functional>
|
|
|
|
#include <wx/dataview.h>
|
|
|
|
#if wxUSE_MARKUP && wxCHECK_VERSION(3, 1, 1)
|
|
#define SUPPORTS_MARKUP
|
|
#endif
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// DataViewBitmapText: helper class used by BitmapTextRenderer
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class DataViewBitmapText : public wxObject
|
|
{
|
|
public:
|
|
DataViewBitmapText( const wxString &text = wxEmptyString,
|
|
const wxBitmap& bmp = wxNullBitmap) :
|
|
m_text(text),
|
|
m_bmp(bmp)
|
|
{ }
|
|
|
|
DataViewBitmapText(const DataViewBitmapText &other)
|
|
: wxObject(),
|
|
m_text(other.m_text),
|
|
m_bmp(other.m_bmp)
|
|
{ }
|
|
|
|
void SetText(const wxString &text) { m_text = text; }
|
|
wxString GetText() const { return m_text; }
|
|
void SetBitmap(const wxBitmap &bmp) { m_bmp = bmp; }
|
|
const wxBitmap &GetBitmap() const { return m_bmp; }
|
|
|
|
bool IsSameAs(const DataViewBitmapText& other) const {
|
|
return m_text == other.m_text && m_bmp.IsSameAs(other.m_bmp);
|
|
}
|
|
|
|
bool operator==(const DataViewBitmapText& other) const {
|
|
return IsSameAs(other);
|
|
}
|
|
|
|
bool operator!=(const DataViewBitmapText& other) const {
|
|
return !IsSameAs(other);
|
|
}
|
|
|
|
private:
|
|
wxString m_text;
|
|
wxBitmap m_bmp;
|
|
|
|
wxDECLARE_DYNAMIC_CLASS(DataViewBitmapText);
|
|
};
|
|
DECLARE_VARIANT_OBJECT(DataViewBitmapText)
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// BitmapTextRenderer - an editable text box within a DataView item
|
|
// ----------------------------------------------------------------------------
|
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
class BitmapTextRenderer : public wxDataViewRenderer
|
|
#else
|
|
class BitmapTextRenderer : public wxDataViewCustomRenderer
|
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
{
|
|
public:
|
|
BitmapTextRenderer(bool use_markup = false,
|
|
wxDataViewCellMode mode =
|
|
//#ifdef __WXOSX__
|
|
// wxDATAVIEW_CELL_INERT
|
|
//#else
|
|
wxDATAVIEW_CELL_EDITABLE
|
|
//#endif
|
|
|
|
, int align = wxDVR_DEFAULT_ALIGNMENT
|
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
);
|
|
#else
|
|
) :
|
|
wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align)
|
|
{
|
|
EnableMarkup(use_markup);
|
|
}
|
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
|
|
~BitmapTextRenderer();
|
|
|
|
void EnableMarkup(bool enable = true);
|
|
|
|
bool SetValue(const wxVariant& value) override;
|
|
bool GetValue(wxVariant& value) const override;
|
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY
|
|
virtual wxString GetAccessibleDescription() const override;
|
|
#endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
|
|
|
virtual bool Render(wxRect cell, wxDC* dc, int state) override;
|
|
virtual wxSize GetSize() const override;
|
|
|
|
bool HasEditorCtrl() const override
|
|
{
|
|
//#ifdef __WXOSX__
|
|
// return false;
|
|
//#else
|
|
return true;
|
|
//#endif
|
|
}
|
|
wxWindow* CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value) override;
|
|
bool GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value) override;
|
|
bool WasCanceled() const { return m_was_unusable_symbol; }
|
|
|
|
void set_can_create_editor_ctrl_function(std::function<bool()> can_create_fn) { can_create_editor_ctrl = can_create_fn; }
|
|
|
|
private:
|
|
DataViewBitmapText m_value;
|
|
bool m_was_unusable_symbol{ false };
|
|
|
|
std::function<bool()> can_create_editor_ctrl { nullptr };
|
|
|
|
#ifdef SUPPORTS_MARKUP
|
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
|
class wxItemMarkupText* m_markupText { nullptr };;
|
|
#else
|
|
bool is_markupText {false};
|
|
#endif
|
|
#endif // SUPPORTS_MARKUP
|
|
};
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// BitmapChoiceRenderer - Creates an editable ComboBox within a DataView item
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class BitmapChoiceRenderer : public wxDataViewCustomRenderer
|
|
{
|
|
public:
|
|
BitmapChoiceRenderer(wxDataViewCellMode mode =
|
|
//#ifdef __WXOSX__
|
|
// wxDATAVIEW_CELL_INERT
|
|
//#else
|
|
wxDATAVIEW_CELL_EDITABLE
|
|
//#endif
|
|
, int align = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
|
|
) : wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) {}
|
|
|
|
bool SetValue(const wxVariant& value) override;
|
|
bool GetValue(wxVariant& value) const override;
|
|
|
|
virtual bool Render(wxRect cell, wxDC* dc, int state) override;
|
|
virtual wxSize GetSize() const override;
|
|
|
|
bool HasEditorCtrl() const override { return true; }
|
|
wxWindow* CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value) override;
|
|
bool GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value) override;
|
|
|
|
void set_can_create_editor_ctrl_function(std::function<bool()> can_create_fn) { can_create_editor_ctrl = can_create_fn; }
|
|
void set_default_extruder_idx(std::function<int()> default_extruder_idx_fn) { get_default_extruder_idx = default_extruder_idx_fn; }
|
|
void set_has_default_extruder(std::function<bool()> has_default_extruder_fn) { has_default_extruder = has_default_extruder_fn; }
|
|
|
|
private:
|
|
DataViewBitmapText m_value;
|
|
std::function<bool()> can_create_editor_ctrl { nullptr };
|
|
std::function<int()> get_default_extruder_idx{ nullptr };
|
|
std::function<bool()> has_default_extruder{ nullptr };
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// TextRenderer
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class TextRenderer : public wxDataViewCustomRenderer
|
|
{
|
|
public:
|
|
TextRenderer(wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT
|
|
, int align = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
|
|
) : wxDataViewCustomRenderer(wxT("string"), mode, align) {}
|
|
|
|
bool SetValue(const wxVariant& value) override;
|
|
bool GetValue(wxVariant& value) const override;
|
|
|
|
virtual bool Render(wxRect cell, wxDC* dc, int state) override;
|
|
virtual wxSize GetSize() const override;
|
|
|
|
bool HasEditorCtrl() const override { return false; }
|
|
|
|
private:
|
|
wxString m_value;
|
|
};
|
|
|
|
|
|
#endif // slic3r_GUI_ExtraRenderers_hpp_
|