mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 14:13:57 -06:00
ConfigWizard: Draw logo inside OnPaint instead of use of wxStaticBitmap
This commit is contained in:
parent
c9dffd0c89
commit
9154ebb165
2 changed files with 10 additions and 21 deletions
|
@ -1606,25 +1606,17 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
|
||||||
, item_hover(NO_ITEM)
|
, item_hover(NO_ITEM)
|
||||||
, last_page((size_t)-1)
|
, last_page((size_t)-1)
|
||||||
{
|
{
|
||||||
|
#ifndef __WXOSX__
|
||||||
|
SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
|
||||||
|
#endif //__WXOSX__
|
||||||
SetMinSize(bg.bmp().GetSize());
|
SetMinSize(bg.bmp().GetSize());
|
||||||
|
|
||||||
const wxSize size = GetTextExtent("m");
|
const wxSize size = GetTextExtent("m");
|
||||||
em_w = size.x;
|
em_w = size.x;
|
||||||
em_h = size.y;
|
em_h = size.y;
|
||||||
|
|
||||||
// Add logo bitmap.
|
|
||||||
// This could be done in on_paint() along with the index labels, but I've found it tricky
|
|
||||||
// to get the bitmap rendered well on all platforms with transparent background.
|
|
||||||
// In some cases it didn't work at all. And so wxStaticBitmap is used here instead,
|
|
||||||
// because it has all the platform quirks figured out.
|
|
||||||
auto *sizer = new wxBoxSizer(wxVERTICAL);
|
|
||||||
logo = new wxStaticBitmap(this, wxID_ANY, bg.bmp());
|
|
||||||
sizer->AddStretchSpacer();
|
|
||||||
sizer->Add(logo);
|
|
||||||
SetSizer(sizer);
|
|
||||||
logo_height = logo->GetBitmap().GetHeight();
|
|
||||||
|
|
||||||
Bind(wxEVT_PAINT, &ConfigWizardIndex::on_paint, this);
|
Bind(wxEVT_PAINT, &ConfigWizardIndex::on_paint, this);
|
||||||
|
Bind(wxEVT_SIZE, [this](wxEvent& e) { e.Skip(); Refresh(); });
|
||||||
Bind(wxEVT_MOTION, &ConfigWizardIndex::on_mouse_move, this);
|
Bind(wxEVT_MOTION, &ConfigWizardIndex::on_mouse_move, this);
|
||||||
|
|
||||||
Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &evt) {
|
Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &evt) {
|
||||||
|
@ -1769,6 +1761,12 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
||||||
y += yinc;
|
y += yinc;
|
||||||
index_width = std::max(index_width, (int)x + text_size.x);
|
index_width = std::max(index_width, (int)x + text_size.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//draw logo
|
||||||
|
if (int y = size.y - bg.GetBmpHeight(); y>=0) {
|
||||||
|
dc.DrawBitmap(bg.bmp(), 0, y, false);
|
||||||
|
index_width = std::max(index_width, bg.GetBmpWidth() + em_w / 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (GetMinSize().x < index_width) {
|
if (GetMinSize().x < index_width) {
|
||||||
CallAfter([this, index_width]() {
|
CallAfter([this, index_width]() {
|
||||||
|
@ -1776,11 +1774,6 @@ void ConfigWizardIndex::on_paint(wxPaintEvent & evt)
|
||||||
Refresh();
|
Refresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int)y + logo_height > size.GetHeight())
|
|
||||||
logo->Hide();
|
|
||||||
else
|
|
||||||
logo->Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigWizardIndex::on_mouse_move(wxMouseEvent &evt)
|
void ConfigWizardIndex::on_mouse_move(wxMouseEvent &evt)
|
||||||
|
@ -1806,7 +1799,6 @@ void ConfigWizardIndex::msw_rescale()
|
||||||
|
|
||||||
bg.msw_rescale();
|
bg.msw_rescale();
|
||||||
SetMinSize(bg.bmp().GetSize());
|
SetMinSize(bg.bmp().GetSize());
|
||||||
logo->SetBitmap(bg.bmp());
|
|
||||||
|
|
||||||
bullet_black.msw_rescale();
|
bullet_black.msw_rescale();
|
||||||
bullet_blue.msw_rescale();
|
bullet_blue.msw_rescale();
|
||||||
|
|
|
@ -512,15 +512,12 @@ private:
|
||||||
ScalableBitmap bullet_black;
|
ScalableBitmap bullet_black;
|
||||||
ScalableBitmap bullet_blue;
|
ScalableBitmap bullet_blue;
|
||||||
ScalableBitmap bullet_white;
|
ScalableBitmap bullet_white;
|
||||||
wxStaticBitmap* logo;
|
|
||||||
|
|
||||||
std::vector<Item> items;
|
std::vector<Item> items;
|
||||||
size_t item_active;
|
size_t item_active;
|
||||||
ssize_t item_hover;
|
ssize_t item_hover;
|
||||||
size_t last_page;
|
size_t last_page;
|
||||||
|
|
||||||
int logo_height;
|
|
||||||
|
|
||||||
int item_height() const { return std::max(bullet_black.bmp().GetSize().GetHeight(), em_w) + em_w; }
|
int item_height() const { return std::max(bullet_black.bmp().GetSize().GetHeight(), em_w) + em_w; }
|
||||||
|
|
||||||
void on_paint(wxPaintEvent &evt);
|
void on_paint(wxPaintEvent &evt);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue