1466{
1467 wxSize size = GetSize();
1468 auto tmp_lib_colour =
m_info.material_colour;
1470
1473
1474
1475 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1477 dc.DrawRoundedRectangle(FromDIP(2), FromDIP(2), size.x - FromDIP(4), size.y - FromDIP(3),
m_radius);
1478
1479 if (tmp_lib_colour.GetLuminance() < 0.6) {
1482 }
1483 else {
1486 }
1487
1488 if (
m_info.material_remain < 50) {
1491 }
1492
1493 if (tmp_lib_colour.Alpha() == 0) {
1496 }
1497
1498
1500 temp_bitmap_third = temp_bitmap_brand;
1501 }
1502
1503 dc.SetPen(wxPen(tmp_lib_colour, 1, wxPENSTYLE_SOLID));
1504 dc.SetBrush(wxBrush(tmp_lib_colour));
1505
1506
1507 auto alpha =
m_info.material_colour.Alpha();
1509 int curr_height =
height * float(
m_info.material_remain * 1.0 / 100.0);
1510 if (curr_height != 0) { curr_height = std::max(curr_height, FromDIP(2)); }
1512
1513 int top =
height - curr_height;
1514
1516 wxRect color_rect(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(1));
1517 if ((
m_info.ctype == 0 ||
m_info.ctype == 1) &&
m_info.material_cols.size() > 1 && alpha != 0) {
1520 }
1521 else {
1522 int cols_size =
static_cast<int>(
m_info.material_cols.size());
1523 for (int i = 0; i < cols_size; i++) {
1524 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1525 dc.SetBrush(wxBrush(
m_info.material_cols[i]));
1526 int x = color_rect.x + color_rect.width * i / cols_size;
1527 int next_x = color_rect.x + color_rect.width * (i + 1) / cols_size;
1528 dc.DrawRectangle(x, color_rect.y, next_x - x, color_rect.height);
1529 }
1530 }
1531 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1532 dc.SetBrush(wxBrush(tmp_lib_colour));
1533 }
1534 else {
1535 dc.DrawRoundedRectangle(color_rect.x, color_rect.y, color_rect.width, color_rect.height,
m_radius - 1);
1536 }
1537 if (alpha == 0) {
1539 }
1540 else if (alpha != 255 && alpha != 254) {
1543 }
1545 }
1546
1548
1551 dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y));
1553 dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y));
1554 }
1555 }
1556
1557 dc.SetPen(wxPen(wxColour(130, 130, 128), 1, wxPENSTYLE_SOLID));
1558 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1559#ifdef __APPLE__
1560 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(1),
m_radius);
1561#else
1562 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(1),
m_radius);
1563#endif
1566
1567 if (tmp_lib_colour.Alpha() == 0) {
1568 dc.SetPen(wxPen(wxColour(tmp_lib_colour.Red(), tmp_lib_colour.Green(), tmp_lib_colour.Blue(), 128), 3, wxPENSTYLE_SOLID));
1569 }
1570 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1571#ifdef __APPLE__
1572 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(2), 0);
1573#else
1574 dc.DrawRoundedRectangle(0, 0, size.x, size.y,
m_radius);
1575#endif
1576
1577 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1578 dc.SetBrush(wxBrush(tmp_lib_colour));
1579 }
1580
1583 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1584#ifdef __APPLE__
1585 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(2), 0);
1586#else
1587 dc.DrawRoundedRectangle(0, 0, size.x, size.y,
m_radius);
1588#endif
1589 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1590 dc.SetBrush(wxBrush(tmp_lib_colour));
1591 }
1592 return;
1593 }
1594
1595 if (curr_height >= FromDIP(1)) {
1596
1597
1598 if (alpha == 0) {
1600 }
1601 else if (alpha != 255 && alpha != 254) {
1603 std::string rgb = (tmp_lib_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString();
1604 if (rgb.size() == 9) {
1605
1606 rgb = rgb.substr(0, rgb.size() - 2);
1607 }
1608 float alpha_f = 0.7 * tmp_lib_colour.Alpha() / 255.0;
1609 std::vector<std::string> replace;
1610 replace.push_back(rgb);
1611 std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f);
1612 replace.push_back(fill_replace);
1613 m_bitmap_transparent = ScalableBitmap(
this,
"transparent_ams_lib", 76,
false,
false,
true, replace);
1615
1616 }
1618 }
1619
1620 if (
m_info.material_cols.size() > 1) {
1621 auto left = FromDIP(2);
1622 float total_width = size.x - FromDIP(4);
1623 int gwidth = std::round(total_width / (
m_info.material_cols.size() - 1));
1624
1626 for (
int i = 0; i <
m_info.material_cols.size() - 1; i++) {
1627
1628 if ((left + gwidth) > (size.x)) {
1629 gwidth = (size.x) - left;
1630 }
1631
1632 auto rect = wxRect(left, height - curr_height, gwidth, curr_height);
1635 }
1636 }
1637 else {
1638
1639 gwidth = std::round(total_width /
m_info.material_cols.size());
1640 for (
int i = 0; i <
m_info.material_cols.size(); i++) {
1641 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1642 dc.SetBrush(wxBrush(
m_info.material_cols[i]));
1643 if (i == 0 || i ==
m_info.material_cols.size() - 1) {
1644#ifdef __APPLE__
1645 dc.DrawRoundedRectangle(left + gwidth * i - FromDIP(1), height - curr_height, gwidth, curr_height,
m_radius);
1646#else
1647 dc.DrawRoundedRectangle(left + gwidth * i, height - curr_height, gwidth, curr_height,
m_radius - 1);
1648#endif
1649
1650 int dr_gwidth = std::round(gwidth * 0.6);
1651 if (i == 0) {
1652 dc.DrawRectangle(left + gwidth - dr_gwidth, height - curr_height, dr_gwidth, curr_height);
1653 }
1654 else {
1655 dc.DrawRectangle(left + gwidth*i, height - curr_height, dr_gwidth, curr_height);
1656 }
1657 }
1658 else {
1659 dc.DrawRectangle(left + gwidth * i, height - curr_height, gwidth, curr_height);
1660 }
1661 }
1662
1664 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1665 dc.SetBrush(wxBrush(tmp_lib_colour));
1666 }
1667 else {
1668 dc.SetPen(wxPen(tmp_lib_colour, 1, wxPENSTYLE_SOLID));
1669 dc.SetBrush(wxBrush(tmp_lib_colour));
1670 }
1671 }
1672 }
1673 else {
1674 auto brush = dc.GetBrush();
1675 if (alpha != 0 && alpha != 255 && alpha != 254) dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1676 dc.DrawRoundedRectangle(FromDIP(2), FromDIP(1) + top, size.x - FromDIP(4), curr_height,
m_radius - 1);
1677 dc.SetBrush(brush);
1678 }
1679 }
1680
1681 if (top > 2) {
1682 if (curr_height >= FromDIP(1)) {
1683
1684 if (alpha != 255 && alpha != 254) {
1685 dc.SetPen(wxPen(*wxWHITE));
1686 dc.SetBrush(wxBrush(*wxWHITE));
1687#ifdef __APPLE__
1688 dc.DrawRoundedRectangle(FromDIP(2), FromDIP(1) , size.x - FromDIP(4), top,
m_radius);
1689#else
1690 dc.DrawRoundedRectangle(FromDIP(2), FromDIP(1) , size.x - FromDIP(4), top,
m_radius - 1);
1691#endif
1692 }
1693 if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) {
1694 dc.SetPen(wxPen(wxColour(130, 129, 128), 1, wxPENSTYLE_SOLID));
1695 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1696 if (
m_info.material_cols.size() <= 1){
1697 dc.DrawLine(FromDIP(2), top, size.x - FromDIP(4), top);
1698 }
1699 }
1700 }
1701 else {
1702 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1703 if (tmp_lib_colour.Red() > 238 && tmp_lib_colour.Green() > 238 && tmp_lib_colour.Blue() > 238) {
1704 dc.SetPen(wxPen(wxColour(130, 129, 128), 2, wxPENSTYLE_SOLID));
1705 }
1706 else {
1707 dc.SetPen(wxPen(tmp_lib_colour, 2, wxPENSTYLE_SOLID));
1708 }
1709
1710#ifdef __APPLE__
1711 dc.DrawLine(FromDIP(5), FromDIP(4) + height - FromDIP(2), size.x - FromDIP(5), FromDIP(4) + height - FromDIP(2));
1712 dc.DrawLine(FromDIP(6), FromDIP(4) + height - FromDIP(1), size.x - FromDIP(6), FromDIP(4) + height - FromDIP(1));
1713#else
1714
1715 dc.DrawLine(FromDIP(2), height - FromDIP(1), size.x - FromDIP(4), height - FromDIP(1));
1716#endif
1717 }
1718 }
1719
1720
1721 dc.SetPen(wxPen(wxColour(130, 130, 128), 1, wxPENSTYLE_SOLID));
1722 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1723#ifdef __APPLE__
1724 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(1),
m_radius);
1725#else
1726 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(1),
m_radius);
1727#endif
1728
1731
1732 if (tmp_lib_colour.Alpha() == 0) {
1733 dc.SetPen(wxPen(wxColour(tmp_lib_colour.Red(), tmp_lib_colour.Green(), tmp_lib_colour.Blue(), 128), 3, wxPENSTYLE_SOLID));
1734 }
1735 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1736#ifdef __APPLE__
1737 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(2), 0);
1738#else
1739 dc.DrawRoundedRectangle(0, 0, size.x, size.y,
m_radius);
1740#endif
1741 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1742 dc.SetBrush(wxBrush(tmp_lib_colour));
1743 }
1744
1747 dc.SetBrush(wxBrush(*wxTRANSPARENT_BRUSH));
1748#ifdef __APPLE__
1749 dc.DrawRoundedRectangle(FromDIP(1), FromDIP(1), size.x - FromDIP(2), size.y - FromDIP(2), 0);
1750#else
1751 dc.DrawRoundedRectangle(0, 0, size.x, size.y,
m_radius);
1752#endif
1753 dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
1754 dc.SetBrush(wxBrush(tmp_lib_colour));
1755 }
1756
1758
1760 {
1762 dc.DrawBitmap(temp_bitmap_third.bmp(), (size.x - temp_bitmap_third.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_third.GetBmpSize().y));
1764 dc.DrawBitmap(temp_bitmap_brand.bmp(), (size.x - temp_bitmap_brand.GetBmpSize().x) / 2, (size.y - FromDIP(10) - temp_bitmap_brand.GetBmpSize().y));
1765 }
1766 }
1767}
#define AMS_CONTROL_BRAND_COLOUR
Definition AMSItem.hpp:36
static wxFont Body_13
Definition Label.hpp:54
double m_radius
Definition AMSItem.hpp:560
bool transparent_changed
Definition AMSItem.hpp:508
bool m_view_only
Definition AMSItem.hpp:565
bool m_disable_mode
Definition AMSItem.hpp:564
void fill_gradient_rect_east(wxDC &dc, const wxRect &rect, const wxColour &from, const wxColour &to)
Definition FilamentBitmapUtils.cpp:76
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
void change_the_opacity(wxColour &colour)
Definition DeviceManager.cpp:6154