mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
Changed signature of the BitmapTextRenderer
+ Added experimental code for the rendering of the "markuped" text
This commit is contained in:
parent
42f3bfb0f6
commit
4913378dbe
6 changed files with 38 additions and 39 deletions
|
@ -49,9 +49,9 @@ BitmapTextRenderer::~BitmapTextRenderer()
|
||||||
#endif // SUPPORTS_MARKUP
|
#endif // SUPPORTS_MARKUP
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
void BitmapTextRenderer::EnableMarkup(bool enable)
|
void BitmapTextRenderer::EnableMarkup(bool enable)
|
||||||
{
|
{
|
||||||
|
#ifdef SUPPORTS_MARKUP
|
||||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (!m_markupText)
|
if (!m_markupText)
|
||||||
|
@ -63,20 +63,30 @@ void BitmapTextRenderer::EnableMarkup(bool enable)
|
||||||
m_markupText = nullptr;
|
m_markupText = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elseif
|
#else
|
||||||
is_markupText = enable
|
is_markupText = enable;
|
||||||
#endif //wxHAS_GENERIC_DATAVIEWCTRL
|
#endif //wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
}
|
|
||||||
#endif // SUPPORTS_MARKUP
|
#endif // SUPPORTS_MARKUP
|
||||||
|
}
|
||||||
|
|
||||||
bool BitmapTextRenderer::SetValue(const wxVariant &value)
|
bool BitmapTextRenderer::SetValue(const wxVariant &value)
|
||||||
{
|
{
|
||||||
m_value << value;
|
m_value << value;
|
||||||
|
|
||||||
#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
#ifdef SUPPORTS_MARKUP
|
||||||
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
if (m_markupText)
|
if (m_markupText)
|
||||||
m_markupText->SetMarkup(m_value.GetText());
|
m_markupText->SetMarkup(m_value.GetText());
|
||||||
#endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL
|
#else
|
||||||
|
#if defined(__WXGTK__)
|
||||||
|
GValue gvalue = G_VALUE_INIT;
|
||||||
|
g_value_init(&gvalue, G_TYPE_STRING);
|
||||||
|
g_value_set_string(&gvalue, wxGTK_CONV_FONT(str.GetText(), GetOwner()->GetOwner()->GetFont()));
|
||||||
|
g_object_set_property(G_OBJECT(m_renderer/*.GetText()*/), is_markupText ? "markup" : "text", &gvalue);
|
||||||
|
g_value_unset(&gvalue);
|
||||||
|
#endif // __WXGTK__
|
||||||
|
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
|
#endif // SUPPORTS_MARKUP
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -117,10 +127,8 @@ bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
|
||||||
#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
||||||
if (m_markupText)
|
if (m_markupText)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
rect.x += xoffset;
|
rect.x += xoffset;
|
||||||
m_markupText->Render(GetView(), *dc, rect, flags, GetEllipsizeMode());
|
m_markupText->Render(GetView(), *dc, rect, 0, GetEllipsizeMode());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL
|
#endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
|
@ -161,7 +169,7 @@ wxSize BitmapTextRenderer::GetSize() const
|
||||||
|
|
||||||
wxWindow* BitmapTextRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
wxWindow* BitmapTextRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
||||||
{
|
{
|
||||||
if (!can_create_editor_ctrl())
|
if (can_create_editor_ctrl && !can_create_editor_ctrl())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
DataViewBitmapText data;
|
DataViewBitmapText data;
|
||||||
|
@ -261,7 +269,7 @@ wxSize BitmapChoiceRenderer::GetSize() const
|
||||||
|
|
||||||
wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
||||||
{
|
{
|
||||||
if (!can_create_editor_ctrl())
|
if (can_create_editor_ctrl && !can_create_editor_ctrl())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
std::vector<wxBitmap*> icons = get_extruder_color_icons();
|
std::vector<wxBitmap*> icons = get_extruder_color_icons();
|
||||||
|
|
|
@ -61,7 +61,7 @@ class BitmapTextRenderer : public wxDataViewCustomRenderer
|
||||||
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BitmapTextRenderer(wxWindow* parent,
|
BitmapTextRenderer(bool use_markup = false,
|
||||||
wxDataViewCellMode mode =
|
wxDataViewCellMode mode =
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
wxDATAVIEW_CELL_INERT
|
wxDATAVIEW_CELL_INERT
|
||||||
|
@ -74,23 +74,18 @@ public:
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
) :
|
) :
|
||||||
wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align),
|
wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align)
|
||||||
m_parent(parent)
|
|
||||||
{
|
{
|
||||||
#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
|
EnableMarkup(use_markup);
|
||||||
m_markupText = nullptr;
|
|
||||||
#endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL
|
|
||||||
}
|
}
|
||||||
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
|
||||||
~BitmapTextRenderer();
|
~BitmapTextRenderer();
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
void EnableMarkup(bool enable = true);
|
void EnableMarkup(bool enable = true);
|
||||||
#endif // SUPPORTS_MARKUP
|
|
||||||
|
|
||||||
bool SetValue(const wxVariant& value);
|
bool SetValue(const wxVariant& value) override;
|
||||||
bool GetValue(wxVariant& value) const;
|
bool GetValue(wxVariant& value) const override;
|
||||||
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY
|
||||||
virtual wxString GetAccessibleDescription() const override;
|
virtual wxString GetAccessibleDescription() const override;
|
||||||
#endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
#endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
@ -115,15 +110,14 @@ public:
|
||||||
private:
|
private:
|
||||||
DataViewBitmapText m_value;
|
DataViewBitmapText m_value;
|
||||||
bool m_was_unusable_symbol{ false };
|
bool m_was_unusable_symbol{ false };
|
||||||
wxWindow* m_parent{ nullptr };
|
|
||||||
|
|
||||||
std::function<bool()> can_create_editor_ctrl { nullptr };
|
std::function<bool()> can_create_editor_ctrl { nullptr };
|
||||||
|
|
||||||
#ifdef SUPPORTS_MARKUP
|
#ifdef SUPPORTS_MARKUP
|
||||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||||
class wxItemMarkupText* m_markupText;
|
class wxItemMarkupText* m_markupText { nullptr };;
|
||||||
#elseif
|
#else
|
||||||
bool is_markupText;
|
bool is_markupText {false};
|
||||||
#endif
|
#endif
|
||||||
#endif // SUPPORTS_MARKUP
|
#endif // SUPPORTS_MARKUP
|
||||||
};
|
};
|
||||||
|
|
|
@ -277,7 +277,7 @@ void ObjectList::create_objects_ctrl()
|
||||||
|
|
||||||
// column ItemName(Icon+Text) of the view control:
|
// column ItemName(Icon+Text) of the view control:
|
||||||
// And Icon can be consisting of several bitmaps
|
// And Icon can be consisting of several bitmaps
|
||||||
BitmapTextRenderer* bmp_text_renderer = new BitmapTextRenderer(this);
|
BitmapTextRenderer* bmp_text_renderer = new BitmapTextRenderer();
|
||||||
bmp_text_renderer->set_can_create_editor_ctrl_function([this]() {
|
bmp_text_renderer->set_can_create_editor_ctrl_function([this]() {
|
||||||
return m_objects_model->GetItemType(GetSelection()) & (itVolume | itObject);
|
return m_objects_model->GetItemType(GetSelection()) & (itVolume | itObject);
|
||||||
});
|
});
|
||||||
|
|
|
@ -323,7 +323,7 @@ const Option& OptionsSearcher::get_option(size_t pos_in_filter) const
|
||||||
|
|
||||||
const Option& OptionsSearcher::get_option(const std::string& opt_key) const
|
const Option& OptionsSearcher::get_option(const std::string& opt_key) const
|
||||||
{
|
{
|
||||||
auto it = std::upper_bound(options.begin(), options.end(), Option({ boost::nowide::widen(opt_key) }));
|
auto it = std::lower_bound(options.begin(), options.end(), Option({ boost::nowide::widen(opt_key) }));
|
||||||
assert(it != options.end());
|
assert(it != options.end());
|
||||||
|
|
||||||
return options[it - options.begin()];
|
return options[it - options.begin()];
|
||||||
|
|
|
@ -35,7 +35,7 @@ static const std::map<Preset::Type, std::string> type_icon_names = {
|
||||||
{Preset::TYPE_SLA_PRINT, "cog" },
|
{Preset::TYPE_SLA_PRINT, "cog" },
|
||||||
{Preset::TYPE_FILAMENT, "spool" },
|
{Preset::TYPE_FILAMENT, "spool" },
|
||||||
{Preset::TYPE_SLA_MATERIAL, "resin" },
|
{Preset::TYPE_SLA_MATERIAL, "resin" },
|
||||||
{Preset::TYPE_PRINTER, "sla_printer" },
|
{Preset::TYPE_PRINTER, "printer" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string black = "#000000";
|
static std::string black = "#000000";
|
||||||
|
@ -427,7 +427,7 @@ wxString UnsavedChangesModel::GetColumnType(unsigned int col) const
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|
||||||
UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type)
|
UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type)
|
||||||
: DPIDialog(NULL, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
: DPIDialog(nullptr, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
{
|
{
|
||||||
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||||
SetBackgroundColour(bgr_clr);
|
SetBackgroundColour(bgr_clr);
|
||||||
|
@ -440,15 +440,12 @@ UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type)
|
||||||
m_tree->AssociateModel(m_tree_model);
|
m_tree->AssociateModel(m_tree_model);
|
||||||
m_tree_model->SetAssociatedControl(m_tree);
|
m_tree_model->SetAssociatedControl(m_tree);
|
||||||
|
|
||||||
m_tree->AppendToggleColumn(/*L"\u2714"*/"", UnsavedChangesModel::colToggle, wxDATAVIEW_CELL_ACTIVATABLE, 6 * em, wxALIGN_NOT);//2610,11,12 //2714
|
m_tree->AppendColumn(new wxDataViewColumn("", new BitmapTextRenderer(true), UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE));
|
||||||
|
|
||||||
BitmapTextRenderer* renderer = new BitmapTextRenderer(m_tree);
|
m_tree->AppendToggleColumn(L"\u2714", UnsavedChangesModel::colToggle, wxDATAVIEW_CELL_ACTIVATABLE, 6 * em);//2610,11,12 //2714
|
||||||
#ifdef SUPPORTS_MARKUP
|
|
||||||
renderer->EnableMarkup();
|
m_tree->AppendColumn(new wxDataViewColumn("Old value", new BitmapTextRenderer(true), UnsavedChangesModel::colOldValue, 20 * em, wxALIGN_TOP));
|
||||||
#endif
|
m_tree->AppendColumn(new wxDataViewColumn("New value", new BitmapTextRenderer(true), UnsavedChangesModel::colNewValue, 20 * em, wxALIGN_TOP));
|
||||||
m_tree->AppendColumn(new wxDataViewColumn("", renderer, UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE));
|
|
||||||
m_tree->AppendColumn(new wxDataViewColumn("Old value", renderer, UnsavedChangesModel::colOldValue, 20 * em, wxALIGN_TOP));
|
|
||||||
m_tree->AppendColumn(new wxDataViewColumn("New value", renderer, UnsavedChangesModel::colNewValue, 20 * em, wxALIGN_TOP));
|
|
||||||
|
|
||||||
m_tree->Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &UnsavedChangesDialog::item_value_changed, this);
|
m_tree->Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &UnsavedChangesDialog::item_value_changed, this);
|
||||||
|
|
||||||
|
|
|
@ -134,8 +134,8 @@ class UnsavedChangesModel : public wxDataViewModel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
colToggle,
|
|
||||||
colIconText,
|
colIconText,
|
||||||
|
colToggle,
|
||||||
colOldValue,
|
colOldValue,
|
||||||
colNewValue,
|
colNewValue,
|
||||||
colMax
|
colMax
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue