OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::ConfigWizardIndex Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/ConfigWizard_private.hpp>

Inheritance diagram for Slic3r::GUI::ConfigWizardIndex:
Collaboration diagram for Slic3r::GUI::ConfigWizardIndex:

Classes

struct  Item

Public Member Functions

 ConfigWizardIndex (wxWindow *parent)
void add_page (ConfigWizardPage *page)
void add_label (wxString label, unsigned indent=0)
size_t active_item () const
ConfigWizardPage * active_page () const
bool active_is_last () const
void go_prev ()
void go_next ()
void go_to (size_t i)
void go_to (const ConfigWizardPage *page)
void clear ()
void msw_rescale ()
int em () const

Static Public Attributes

static const size_t NO_ITEM = size_t(-1)

Private Member Functions

int item_height () const
void on_paint (wxPaintEvent &evt)
void on_mouse_move (wxMouseEvent &evt)

Private Attributes

int em_w
int em_h
ScalableBitmap bg
ScalableBitmap bullet_black
ScalableBitmap bullet_blue
ScalableBitmap bullet_white
std::vector< Item > items
size_t item_active
ssize_t item_hover
size_t last_page

Detailed Description

Constructor & Destructor Documentation

◆ ConfigWizardIndex()

Slic3r::GUI::ConfigWizardIndex::ConfigWizardIndex ( wxWindow * parent)
1510 : wxPanel(parent)
1511 , bg(ScalableBitmap(parent, "OrcaSlicer_192px_transparent.png", 192))
1512 , bullet_black(ScalableBitmap(parent, "bullet_black.png"))
1513 , bullet_blue(ScalableBitmap(parent, "bullet_blue.png"))
1514 , bullet_white(ScalableBitmap(parent, "bullet_white.png"))
1517 , last_page((size_t)-1)
1518{
1519#ifndef __WXOSX__
1520 SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
1521#endif //__WXOSX__
1522 SetMinSize(bg.bmp().GetSize());
1523
1524 const wxSize size = GetTextExtent("m");
1525 em_w = size.x;
1526 em_h = size.y;
1527
1528 Bind(wxEVT_PAINT, &ConfigWizardIndex::on_paint, this);
1529 Bind(wxEVT_SIZE, [this](wxEvent& e) { e.Skip(); Refresh(); });
1530 Bind(wxEVT_MOTION, &ConfigWizardIndex::on_mouse_move, this);
1531
1532 Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &evt) {
1533 if (item_hover != -1) {
1534 item_hover = -1;
1535 Refresh();
1536 }
1537 evt.Skip();
1538 });
1539
1540 Bind(wxEVT_LEFT_UP, [this](wxMouseEvent &evt) {
1541 if (item_hover >= 0) { go_to(item_hover); }
1542 });
1543}
ScalableBitmap bullet_black
Definition ConfigWizard_private.hpp:517
ssize_t item_hover
Definition ConfigWizard_private.hpp:523
void go_to(size_t i)
Definition ConfigWizard.cpp:1598
int em_w
Definition ConfigWizard_private.hpp:514
ScalableBitmap bullet_blue
Definition ConfigWizard_private.hpp:518
ScalableBitmap bg
Definition ConfigWizard_private.hpp:516
size_t item_active
Definition ConfigWizard_private.hpp:522
void on_mouse_move(wxMouseEvent &evt)
Definition ConfigWizard.cpp:1691
size_t last_page
Definition ConfigWizard_private.hpp:524
int em_h
Definition ConfigWizard_private.hpp:515
ScalableBitmap bullet_white
Definition ConfigWizard_private.hpp:519
void on_paint(wxPaintEvent &evt)
Definition ConfigWizard.cpp:1642
static const size_t NO_ITEM
Definition ConfigWizard_private.hpp:503
wxMouseEvent
Definition CameraPopup.cpp:47

References bg, bullet_black, bullet_blue, bullet_white, em_h, em_w, go_to(), item_active, item_hover, last_page, NO_ITEM, on_mouse_move(), on_paint(), and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

Member Function Documentation

◆ active_is_last()

bool Slic3r::GUI::ConfigWizardIndex::active_is_last ( ) const
inline
491{ return item_active < items.size() && item_active == last_page; }
std::vector< Item > items
Definition ConfigWizard_private.hpp:521

References item_active, items, and last_page.

◆ active_item()

size_t Slic3r::GUI::ConfigWizardIndex::active_item ( ) const
inline
489{ return item_active; }

References item_active.

◆ active_page()

ConfigWizardPage * Slic3r::GUI::ConfigWizardIndex::active_page ( ) const
1563{
1564 if (item_active >= items.size()) { return nullptr; }
1565
1566 return items[item_active].page;
1567}

References item_active, and items.

Referenced by clear(), and go_to().

Here is the caller graph for this function:

◆ add_label()

void Slic3r::GUI::ConfigWizardIndex::add_label ( wxString label,
unsigned indent = 0 )
1557{
1558 items.emplace_back(Item { std::move(label), indent, nullptr });
1559 Refresh();
1560}
Definition ConfigWizard_private.hpp:506

References items.

◆ add_page()

void Slic3r::GUI::ConfigWizardIndex::add_page ( ConfigWizardPage * page)
1548{
1549 if (!page)
1550 return;
1551 last_page = items.size();
1552 items.emplace_back(Item { page->shortname, page->indent, page });
1553 Refresh();
1554}

References Slic3r::GUI::ConfigWizardPage::indent, items, last_page, and Slic3r::GUI::ConfigWizardPage::shortname.

◆ clear()

void Slic3r::GUI::ConfigWizardIndex::clear ( )
1634{
1635 auto *former_active = active_page();
1636 if (former_active != nullptr) { former_active->Hide(); }
1637
1638 items.clear();
1640}
ConfigWizardPage * active_page() const
Definition ConfigWizard.cpp:1562

References active_page(), item_active, items, and NO_ITEM.

Here is the call graph for this function:

◆ em()

int Slic3r::GUI::ConfigWizardIndex::em ( ) const
inline
501{ return em_w; }

References em_w.

◆ go_next()

void Slic3r::GUI::ConfigWizardIndex::go_next ( )
1584{
1585 // Search for a next item that is a page (not a label, ie. page != nullptr)
1586
1587 if (item_active == NO_ITEM) { return; }
1588
1589 for (size_t i = item_active + 1; i < items.size(); i++) {
1590 if (items[i].page != nullptr) {
1591 go_to(i);
1592 return;
1593 }
1594 }
1595}

References go_to(), item_active, items, and NO_ITEM.

Here is the call graph for this function:

◆ go_prev()

void Slic3r::GUI::ConfigWizardIndex::go_prev ( )
1570{
1571 // Search for a preceiding item that is a page (not a label, ie. page != nullptr)
1572
1573 if (item_active == NO_ITEM) { return; }
1574
1575 for (size_t i = item_active; i > 0; i--) {
1576 if (items[i - 1].page != nullptr) {
1577 go_to(i - 1);
1578 return;
1579 }
1580 }
1581}

References go_to(), item_active, items, and NO_ITEM.

Here is the call graph for this function:

◆ go_to() [1/2]

void Slic3r::GUI::ConfigWizardIndex::go_to ( const ConfigWizardPage * page)
1622{
1623 if (page == nullptr) { return; }
1624
1625 for (size_t i = 0; i < items.size(); i++) {
1626 if (items[i].page == page) {
1627 go_to(i);
1628 return;
1629 }
1630 }
1631}

References go_to(), and items.

Here is the call graph for this function:

◆ go_to() [2/2]

void Slic3r::GUI::ConfigWizardIndex::go_to ( size_t i)
1599{
1600 if (i != item_active
1601 && i < items.size()
1602 && items[i].page != nullptr) {
1603 auto *new_active = items[i].page;
1604 auto *former_active = active_page();
1605 if (former_active != nullptr) {
1606 former_active->Hide();
1607 }
1608
1609 item_active = i;
1610 new_active->Show();
1611
1612 wxCommandEvent evt(EVT_INDEX_PAGE, GetId());
1613 AddPendingEvent(evt);
1614
1615 Refresh();
1616
1617 new_active->on_activate();
1618 }
1619}

References active_page(), item_active, and items.

Referenced by ConfigWizardIndex(), go_next(), go_prev(), and go_to().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ item_height()

int Slic3r::GUI::ConfigWizardIndex::item_height ( ) const
inlineprivate
526{ return std::max(bullet_black.bmp().GetSize().GetHeight(), em_w) + em_w; }

References bullet_black, and em_w.

Referenced by on_mouse_move(), and on_paint().

Here is the caller graph for this function:

◆ msw_rescale()

void Slic3r::GUI::ConfigWizardIndex::msw_rescale ( )
1707{
1708 const wxSize size = GetTextExtent("m");
1709 em_w = size.x;
1710 em_h = size.y;
1711
1712 bg.msw_rescale();
1713 SetMinSize(bg.bmp().GetSize());
1714
1715 bullet_black.msw_rescale();
1716 bullet_blue.msw_rescale();
1717 bullet_white.msw_rescale();
1718 Refresh();
1719}

References bg, bullet_black, bullet_blue, bullet_white, em_h, and em_w.

◆ on_mouse_move()

void Slic3r::GUI::ConfigWizardIndex::on_mouse_move ( wxMouseEvent & evt)
private
1692{
1693 const wxClientDC dc(this);
1694 const wxPoint pos = evt.GetLogicalPosition(dc);
1695
1696 const ssize_t item_hover_new = pos.y / item_height();
1697
1698 if (item_hover_new < ssize_t(items.size()) && item_hover_new != item_hover) {
1699 item_hover = item_hover_new;
1700 Refresh();
1701 }
1702
1703 evt.Skip();
1704}
int item_height() const
Definition ConfigWizard_private.hpp:526
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References item_height(), item_hover, items, and Slic3r::GUI::wxMouseEvent.

Referenced by ConfigWizardIndex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_paint()

void Slic3r::GUI::ConfigWizardIndex::on_paint ( wxPaintEvent & evt)
private
1643{
1644 const auto size = GetClientSize();
1645 if (size.GetHeight() == 0 || size.GetWidth() == 0) { return; }
1646
1647 wxPaintDC dc(this);
1648
1649 const auto bullet_w = bullet_black.bmp().GetSize().GetWidth();
1650 const auto bullet_h = bullet_black.bmp().GetSize().GetHeight();
1651 const int yoff_icon = bullet_h < em_h ? (em_h - bullet_h) / 2 : 0;
1652 const int yoff_text = bullet_h > em_h ? (bullet_h - em_h) / 2 : 0;
1653 const int yinc = item_height();
1654
1655 int index_width = 0;
1656
1657 unsigned y = 0;
1658 for (size_t i = 0; i < items.size(); i++) {
1659 const Item& item = items[i];
1660 unsigned x = em_w/2 + item.indent * em_w;
1661
1662 if (i == item_active || (item_hover >= 0 && i == (size_t)item_hover)) {
1663 dc.DrawBitmap(bullet_blue.bmp(), x, y + yoff_icon, false);
1664 }
1665 else if (i < item_active) { dc.DrawBitmap(bullet_black.bmp(), x, y + yoff_icon, false); }
1666 else if (i > item_active) { dc.DrawBitmap(bullet_white.bmp(), x, y + yoff_icon, false); }
1667
1668 x += + bullet_w + em_w/2;
1669 const auto text_size = dc.GetTextExtent(item.label);
1670 dc.SetTextForeground(wxGetApp().get_label_clr_default());
1671 dc.DrawText(item.label, x, y + yoff_text);
1672
1673 y += yinc;
1674 index_width = std::max(index_width, (int)x + text_size.x);
1675 }
1676
1677 //draw logo
1678 if (int y = size.y - bg.GetBmpHeight(); y>=0) {
1679 dc.DrawBitmap(bg.bmp(), 0, y, false);
1680 index_width = std::max(index_width, bg.GetBmpWidth() + em_w / 2);
1681 }
1682
1683 if (GetMinSize().x < index_width) {
1684 CallAfter([this, index_width]() {
1685 SetMinSize(wxSize(index_width, GetMinSize().y));
1686 Refresh();
1687 });
1688 }
1689}

References bg, bullet_black, bullet_blue, bullet_white, em_h, em_w, Slic3r::GUI::ConfigWizardIndex::Item::indent, item_active, item_height(), item_hover, items, and Slic3r::GUI::ConfigWizardIndex::Item::label.

Referenced by ConfigWizardIndex().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bg

ScalableBitmap Slic3r::GUI::ConfigWizardIndex::bg
private

◆ bullet_black

ScalableBitmap Slic3r::GUI::ConfigWizardIndex::bullet_black
private

◆ bullet_blue

ScalableBitmap Slic3r::GUI::ConfigWizardIndex::bullet_blue
private

◆ bullet_white

ScalableBitmap Slic3r::GUI::ConfigWizardIndex::bullet_white
private

◆ em_h

int Slic3r::GUI::ConfigWizardIndex::em_h
private

◆ em_w

int Slic3r::GUI::ConfigWizardIndex::em_w
private

◆ item_active

size_t Slic3r::GUI::ConfigWizardIndex::item_active
private

◆ item_hover

ssize_t Slic3r::GUI::ConfigWizardIndex::item_hover
private

◆ items

std::vector<Item> Slic3r::GUI::ConfigWizardIndex::items
private

◆ last_page

size_t Slic3r::GUI::ConfigWizardIndex::last_page
private

◆ NO_ITEM

const size_t Slic3r::GUI::ConfigWizardIndex::NO_ITEM = size_t(-1)
static

The documentation for this class was generated from the following files: