mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
FIX: something
Change-Id: I2923786337f97f4297b0444522c620891aa2ad90 Jira: STUDIO-9725 filament menu delete icon Jira: STUDIO-9785 StaticGroup border color Jira: STUDIO-9716 update badge icon Jira: STUDIO-9815 click printer/bed panel for combobox Jira: STUDIO-9867 label with for single noozle Jira: STUDIO-9739 ams page up/down (cherry picked from commit 1cde0b844a97f3420db4999927f05a833b92b0fb)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<svg width="19" height="18" viewBox="0 0 19 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0.410156 0H18.4102V18L9.09255 8.93403L0.410156 0Z" fill="#00AE42"/>
|
||||
<path d="M16.7686 3.1416C16.9574 3.3304 16.9574 3.63568 16.7686 3.82247L11.4662 9.12687C11.2774 9.31567 10.9721 9.31567 10.7853 9.12687L8.05175 6.39534C7.86296 6.20654 7.86296 5.90125 8.05175 5.71446C8.24055 5.52767 8.54584 5.52566 8.73263 5.71446L11.1227 8.10455L16.0857 3.1416C16.2745 2.9528 16.5798 2.9528 16.7666 3.1416H16.7686Z" fill="white"/>
|
||||
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 0H14C16.2091 0 18 1.79086 18 4V18L8.2784 8.45085L0 0Z" fill="#ACACAC"/>
|
||||
<path d="M16.3579 3.1416C16.5467 3.3304 16.5467 3.63568 16.3579 3.82247L11.0555 9.12687C10.8667 9.31567 10.5614 9.31567 10.3747 9.12687L7.64111 6.39534C7.45231 6.20654 7.45231 5.90125 7.64111 5.71446C7.82991 5.52767 8.1352 5.52566 8.32198 5.71446L10.7121 8.10455L15.675 3.1416C15.8638 2.9528 16.1691 2.9528 16.3559 3.1416H16.3579Z" fill="white"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 530 B After Width: | Height: | Size: 534 B |
3
resources/images/page_down.svg
Normal file
3
resources/images/page_down.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.99984 11.7394C5.74282 11.7394 4.53729 11.2401 3.64845 10.3512C2.7596 9.46238 2.26025 8.25685 2.26025 6.99984C2.26025 5.74282 2.7596 4.53729 3.64845 3.64845C4.53729 2.7596 5.74282 2.26025 6.99984 2.26025C8.25685 2.26025 9.46238 2.7596 10.3512 3.64845C11.2401 4.53729 11.7394 5.74282 11.7394 6.99984C11.7394 8.25685 11.2401 9.46238 10.3512 10.3512C9.46238 11.2401 8.25685 11.7394 6.99984 11.7394ZM6.99984 1.1665C5.45274 1.1665 3.96901 1.78109 2.87505 2.87505C1.78109 3.96901 1.1665 5.45274 1.1665 6.99984C1.1665 8.54693 1.78109 10.0307 2.87505 11.1246C3.96901 12.2186 5.45274 12.8332 6.99984 12.8332C8.54693 12.8332 10.0307 12.2186 11.1246 11.1246C12.2186 10.0307 12.8332 8.54693 12.8332 6.99984C12.8332 5.45274 12.2186 3.96901 11.1246 2.87505C10.0307 1.78109 8.54693 1.1665 6.99984 1.1665ZM4.24268 6.65804L6.61247 9.02783C6.82666 9.24202 7.17301 9.24202 7.38493 9.02783L9.757 6.65804C9.97119 6.44385 9.97119 6.09749 9.757 5.88558C9.54281 5.67367 9.19645 5.67139 8.98454 5.88558L7.00212 7.868L5.01969 5.88558C4.8055 5.67139 4.45915 5.67139 4.24723 5.88558C4.03532 6.09977 4.03304 6.44613 4.24723 6.65804H4.24268Z" fill="#6B6B6B"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
3
resources/images/page_up.svg
Normal file
3
resources/images/page_up.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M6.99984 2.26025C8.25685 2.26025 9.46238 2.7596 10.3512 3.64845C11.2401 4.53729 11.7394 5.74282 11.7394 6.99984C11.7394 8.25685 11.2401 9.46238 10.3512 10.3512C9.46238 11.2401 8.25685 11.7394 6.99984 11.7394C5.74282 11.7394 4.53729 11.2401 3.64845 10.3512C2.7596 9.46238 2.26025 8.25685 2.26025 6.99984C2.26025 5.74282 2.7596 4.53729 3.64845 3.64845C4.53729 2.7596 5.74282 2.26025 6.99984 2.26025ZM6.99984 12.8332C8.54693 12.8332 10.0307 12.2186 11.1246 11.1246C12.2186 10.0307 12.8332 8.54693 12.8332 6.99984C12.8332 5.45274 12.2186 3.96901 11.1246 2.87505C10.0307 1.78109 8.54693 1.1665 6.99984 1.1665C5.45274 1.1665 3.96901 1.78109 2.87505 2.87505C1.78109 3.96901 1.1665 5.45274 1.1665 6.99984C1.1665 8.54693 1.78109 10.0307 2.87505 11.1246C3.96901 12.2186 5.45274 12.8332 6.99984 12.8332ZM9.757 7.34163L7.38721 4.97184C7.17301 4.75765 6.82666 4.75765 6.61475 4.97184L4.24268 7.34163C4.02848 7.55583 4.02848 7.90218 4.24268 8.11409C4.45687 8.32601 4.80322 8.32829 5.01514 8.11409L6.99756 6.13167L8.97998 8.11409C9.19417 8.32829 9.54053 8.32829 9.75244 8.11409C9.96436 7.8999 9.96663 7.55355 9.75244 7.34163H9.757Z" fill="#6B6B6B"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -765,9 +765,9 @@ static void generic_exception_handle()
|
||||
std::terminate();
|
||||
//throw;
|
||||
} catch (const std::exception& ex) {
|
||||
wxLogError(format_wxstr(_L("OrcaSlicer got an unhandled exception: %1%"), ex.what()));
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Uncaught exception: %1%") % ex.what();
|
||||
flush_logs();
|
||||
wxLogError(format_wxstr(_L("OrcaSlicer got an unhandled exception: %1%"), ex.what()));
|
||||
throw;
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1481,7 +1481,7 @@ void MenuFactory::create_filament_action_menu(bool init, int active_filament_men
|
||||
if (init) {
|
||||
append_menu_item(
|
||||
menu, wxID_ANY, _L("Delete"), _L("Delete this filament"), [](wxCommandEvent&) {
|
||||
plater()->sidebar().delete_filament(-2); }, "menu_delete", nullptr,
|
||||
plater()->sidebar().delete_filament(-2); }, "", nullptr,
|
||||
[]() { return plater()->sidebar().combos_filament().size() > 1; }, m_parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
|
||||
m_remote_proto = 0;
|
||||
m_model_download_support = false;
|
||||
}
|
||||
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
|
||||
Enable(obj && obj->is_info_ready() && obj->m_push_count > 0);
|
||||
if (machine == m_machine) {
|
||||
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_proto || m_remote_proto))) {
|
||||
auto fs = m_image_grid->GetFileSystem();
|
||||
|
||||
@@ -171,7 +171,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||
m_remote_proto = 0;
|
||||
m_device_busy = false;
|
||||
}
|
||||
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
|
||||
Enable(obj && obj->is_info_ready() && obj->m_push_count > 0);
|
||||
if (machine == m_machine) {
|
||||
if (m_last_state == MEDIASTATE_IDLE && IsEnabled())
|
||||
Play();
|
||||
|
||||
@@ -352,12 +352,14 @@ struct ExtruderGroup : StaticGroup
|
||||
ExtruderGroup(wxWindow * parent, int index, wxString const &title);
|
||||
wxStaticBoxSizer *sizer = nullptr;
|
||||
ScalableButton * btn_edit = nullptr;
|
||||
ComboBox * combo_nozzle = nullptr;
|
||||
ComboBox * combo_flow = nullptr;
|
||||
AMSPreview * ams[4] = {nullptr};
|
||||
wxStaticText *ams_not_installed_msg{nullptr};
|
||||
ScalableButton *up_down_btn{nullptr};
|
||||
ScalableButton * btn_up{nullptr};
|
||||
ScalableButton * btn_down{nullptr};
|
||||
wxBoxSizer *hsizer_ams { nullptr };
|
||||
bool is_upward{false};
|
||||
int page_cur{0};
|
||||
int page_num{3};
|
||||
int ams_n4 = 0;
|
||||
int ams_n1 = 0;
|
||||
|
||||
@@ -375,7 +377,9 @@ struct ExtruderGroup : StaticGroup
|
||||
{
|
||||
if (btn_edit)
|
||||
btn_edit->msw_rescale();
|
||||
combo_nozzle->Rescale();
|
||||
btn_up->msw_rescale();
|
||||
btn_down->msw_rescale();
|
||||
combo_flow->Rescale();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -911,22 +915,22 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
|
||||
: StaticGroup(parent, wxID_ANY, title)
|
||||
{
|
||||
SetFont(Label::Body_10);
|
||||
SetForegroundColour("#909090");
|
||||
ShowBadge(true);
|
||||
|
||||
// Nozzle
|
||||
wxStaticText *label_nozzle = new wxStaticText(this, wxID_ANY, _L("Flow"));
|
||||
label_nozzle->SetFont(Label::Body_14);
|
||||
label_nozzle->SetForegroundColour("#262E30");
|
||||
auto combo_nozzle = new ComboBox(this, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
|
||||
combo_nozzle->GetDropDown().SetUseContentWidth(true);
|
||||
combo_nozzle->Bind(wxEVT_COMBOBOX, [this, index, combo_nozzle](wxCommandEvent &evt) {
|
||||
wxStaticText *label_flow = new wxStaticText(this, wxID_ANY, _L("Flow"));
|
||||
label_flow->SetFont(Label::Body_14);
|
||||
label_flow->SetForegroundColour("#262E30");
|
||||
if (index >= 0) label_flow->SetMinSize({FromDIP(80), -1});
|
||||
auto combo_flow = new ComboBox(this, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY);
|
||||
combo_flow->GetDropDown().SetUseContentWidth(true);
|
||||
combo_flow->Bind(wxEVT_COMBOBOX, [this, index, combo_flow](wxCommandEvent &evt) {
|
||||
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
|
||||
printer_tab->set_extruder_volume_type(index, NozzleVolumeType(intptr_t(combo_nozzle->GetClientData(evt.GetInt()))));
|
||||
printer_tab->set_extruder_volume_type(index, NozzleVolumeType(intptr_t(combo_flow->GetClientData(evt.GetInt()))));
|
||||
if (GUI::wxGetApp().plater())
|
||||
GUI::wxGetApp().plater()->update_machine_sync_status();
|
||||
});
|
||||
this->combo_nozzle = combo_nozzle;
|
||||
this->combo_flow = combo_flow;
|
||||
|
||||
// AMS
|
||||
wxStaticText *label_ams = new wxStaticText(this, wxID_ANY, _L("AMS"));
|
||||
@@ -946,7 +950,7 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
|
||||
});
|
||||
|
||||
auto hovered = std::make_shared<wxWindow *>();
|
||||
for (wxWindow *w : std::initializer_list<wxWindow *>{this, label_nozzle, combo_nozzle, btn_edit, label_ams}) {
|
||||
for (wxWindow *w : std::initializer_list<wxWindow *>{this, label_flow, combo_flow, btn_edit, label_ams}) {
|
||||
w->Bind(wxEVT_ENTER_WINDOW, [w, hovered, this](wxMouseEvent &evt) { *hovered = w; btn_edit->SetBitmap_("edit"); });
|
||||
w->Bind(wxEVT_LEAVE_WINDOW, [w, hovered, this](wxMouseEvent &evt) { if (*hovered == w) { btn_edit->SetBitmap_("dot"); *hovered = nullptr; } });
|
||||
}
|
||||
@@ -969,15 +973,25 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title
|
||||
if (btn_edit)
|
||||
hsizer_ams->Add(btn_edit, 0, wxLEFT | wxALIGN_CENTER, FromDIP(2));
|
||||
|
||||
up_down_btn = new ScalableButton(this, wxID_ANY, "dot");
|
||||
up_down_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
|
||||
is_upward = !is_upward;
|
||||
btn_up = new ScalableButton(this, wxID_ANY, "page_up", "", {-1, FromDIP(14)});
|
||||
btn_up->SetBackgroundColour(*wxWHITE);
|
||||
btn_up->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
|
||||
if (page_cur > 0)
|
||||
--page_cur;
|
||||
update_ams();
|
||||
});
|
||||
btn_down = new ScalableButton(this, wxID_ANY, "page_down", "", {-1, FromDIP(14)});
|
||||
btn_down->SetBackgroundColour(*wxWHITE);
|
||||
btn_down->Bind(wxEVT_COMMAND_BUTTON_CLICKED, [this, index](auto &evt) {
|
||||
if (page_cur + 1 < page_num)
|
||||
++page_cur;
|
||||
update_ams();
|
||||
});
|
||||
|
||||
|
||||
wxBoxSizer * hsizer_nozzle = new wxBoxSizer(wxHORIZONTAL);
|
||||
hsizer_nozzle->Add(label_nozzle, 2, wxALIGN_CENTER);
|
||||
hsizer_nozzle->Add(combo_nozzle, 3, wxEXPAND);
|
||||
hsizer_nozzle->Add(label_flow, 2, wxALIGN_CENTER);
|
||||
hsizer_nozzle->Add(combo_flow, 3, wxEXPAND);
|
||||
if (index < 0) {
|
||||
label_ams->Hide();
|
||||
ams_not_installed_msg->Hide();
|
||||
@@ -999,8 +1013,8 @@ void ExtruderGroup::update_ams()
|
||||
{
|
||||
int display_capacity = 8;
|
||||
|
||||
if (ams_n4 * 4 + ams_n1 * 2 <= 8)
|
||||
is_upward = false;
|
||||
//if (ams_n4 * 4 + ams_n1 * 2 <= 8)
|
||||
// is_upward = false;
|
||||
|
||||
std::vector<wxColour> colors = {
|
||||
wxColour(255, 110, 100),
|
||||
@@ -1009,7 +1023,7 @@ void ExtruderGroup::update_ams()
|
||||
wxColour(170, 111, 252)
|
||||
};
|
||||
|
||||
bool display_front_ams = !is_upward;
|
||||
bool display_front_ams = false; //!is_upward;
|
||||
size_t i = 0;
|
||||
for (; i < ams_n4 && i < 4; ++i) {
|
||||
display_capacity -= 4;
|
||||
@@ -1051,7 +1065,7 @@ void ExtruderGroup::update_ams()
|
||||
|
||||
if (i == 0) {
|
||||
ams_not_installed_msg->Show();
|
||||
up_down_btn->Hide();
|
||||
btn_up->Hide();
|
||||
for (AMSPreview *a : ams) {
|
||||
a->Close();
|
||||
}
|
||||
@@ -1059,12 +1073,15 @@ void ExtruderGroup::update_ams()
|
||||
ams_not_installed_msg->Hide();
|
||||
for (; i < 4; ++i) { ams[i]->Close(); }
|
||||
if (display_capacity < 0) {
|
||||
up_down_btn->Show();
|
||||
btn_up->Show();
|
||||
} else {
|
||||
up_down_btn->Hide();
|
||||
btn_up->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
btn_up->Show(page_cur > 0);
|
||||
btn_down->Show(page_cur + 1 < page_num);
|
||||
|
||||
while (hsizer_ams->GetItemCount() > 2)
|
||||
hsizer_ams->Remove(2);
|
||||
if (ams_not_installed_msg->IsShown()) {
|
||||
@@ -1076,9 +1093,19 @@ void ExtruderGroup::update_ams()
|
||||
if (ams[i]->IsShown())
|
||||
hsizer_ams->Add(this->ams[i], 0, wxLEFT, FromDIP(4));
|
||||
}
|
||||
if (up_down_btn->IsShown()) {
|
||||
if (btn_up->IsShown() || btn_down->IsShown()) {
|
||||
hsizer_ams->AddStretchSpacer(1);
|
||||
hsizer_ams->Add(up_down_btn, 0, wxALIGN_CENTER);
|
||||
if (btn_up->IsShown() && btn_down->IsShown()) {
|
||||
auto vsizer_btn = new wxBoxSizer(wxVERTICAL);
|
||||
auto size = btn_up->GetSize();
|
||||
vsizer_btn->Add(btn_up, 0);
|
||||
vsizer_btn->Add(btn_down, 0);
|
||||
hsizer_ams->Add(vsizer_btn, 0, wxALIGN_CENTER | wxLEFT, FromDIP(2));
|
||||
} else if (btn_up->IsShown()) {
|
||||
hsizer_ams->Add(btn_up, 0, wxALIGN_CENTER | wxLEFT, FromDIP(2));
|
||||
} else {
|
||||
hsizer_ams->Add(btn_down, 0, wxALIGN_CENTER | wxLEFT, FromDIP(2));
|
||||
}
|
||||
}
|
||||
|
||||
sizer->Layout();
|
||||
@@ -1160,7 +1187,7 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
|
||||
auto clear_all_sync_status = [this]() {
|
||||
panel_printer_preset->ShowBadge(false);
|
||||
panel_printer_bed->ShowBadge(false);
|
||||
left_extruder->ShowBadge(false);
|
||||
//left_extruder->ShowBadge(false);
|
||||
right_extruder->ShowBadge(false);
|
||||
single_extruder->ShowBadge(false);
|
||||
};
|
||||
@@ -1413,6 +1440,9 @@ Sidebar::Sidebar(Plater *parent)
|
||||
p->panel_printer_preset->SetCornerRadius(8);
|
||||
p->panel_printer_preset->SetBorderColor(wxColour("#CECECE"));
|
||||
p->panel_printer_preset->SetMinSize(PRINTER_PANEL_SIZE_SMALL);
|
||||
p->panel_printer_preset->Bind(wxEVT_LEFT_DOWN, [this](auto & evt) {
|
||||
p->combo_printer->wxEvtHandler::ProcessEvent(evt);
|
||||
});
|
||||
|
||||
ScalableButton *edit_btn = new ScalableButton(p->panel_printer_preset, wxID_ANY, "dot");
|
||||
edit_btn->SetToolTip(_L("Click to edit preset"));
|
||||
@@ -1426,6 +1456,10 @@ Sidebar::Sidebar(Plater *parent)
|
||||
|
||||
ScalableBitmap bitmap_printer(p->panel_printer_preset, "printer_placeholder", 48);
|
||||
p->image_printer = new wxStaticBitmap(p->panel_printer_preset, wxID_ANY, bitmap_printer.bmp(), wxDefaultPosition, PRINTER_THUMBNAIL_SIZE, 0);
|
||||
p->image_printer->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
|
||||
p->combo_printer->wxEvtHandler::ProcessEvent(evt);
|
||||
});
|
||||
|
||||
PlaterPresetComboBox *combo_printer = new PlaterPresetComboBox(p->panel_printer_preset, Preset::TYPE_PRINTER);
|
||||
combo_printer->SetWindowStyle(combo_printer->GetWindowStyle() & ~wxALIGN_MASK | wxALIGN_CENTER_HORIZONTAL);
|
||||
combo_printer->SetBorderWidth(0);
|
||||
@@ -1453,6 +1487,9 @@ Sidebar::Sidebar(Plater *parent)
|
||||
p->panel_printer_bed->SetCornerRadius(8);
|
||||
p->panel_printer_bed->SetBorderColor(wxColour("#CECECE"));
|
||||
p->panel_printer_bed->SetMinSize(PRINTER_PANEL_SIZE_SMALL);
|
||||
p->panel_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
|
||||
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
|
||||
});
|
||||
|
||||
ScalableButton *wiki_bed = new ScalableButton(p->panel_printer_bed, wxID_ANY, "dot");
|
||||
wiki_bed->Bind(wxEVT_BUTTON, [](wxCommandEvent) {
|
||||
@@ -1461,6 +1498,9 @@ Sidebar::Sidebar(Plater *parent)
|
||||
|
||||
ScalableBitmap bitmap_bed(p->panel_printer_bed, "printer_placeholder", 32);
|
||||
p->image_printer_bed = new wxStaticBitmap(p->panel_printer_bed, wxID_ANY, bitmap_bed.bmp(), wxDefaultPosition, wxDefaultSize, 0);
|
||||
p->image_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
|
||||
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
|
||||
});
|
||||
|
||||
p->combo_printer_bed = new ComboBox(p->panel_printer_bed, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY | wxALIGN_CENTER_HORIZONTAL);
|
||||
p->combo_printer_bed->SetBorderWidth(0);
|
||||
|
||||
@@ -192,7 +192,9 @@ void PresetComboBox::update_selection()
|
||||
* there is no presets added to the list.
|
||||
* So, select last combobox item ("Add/Remove preset")
|
||||
*/
|
||||
validate_selection();
|
||||
//validate_selection();
|
||||
if (m_last_selected == INT_MAX)
|
||||
m_last_selected == 1;
|
||||
|
||||
SetSelection(m_last_selected);
|
||||
#ifdef __WXMSW__
|
||||
|
||||
@@ -23,7 +23,7 @@ StaticBox::StaticBox()
|
||||
{
|
||||
border_color = StateColor(
|
||||
std::make_pair(0xF0F0F1, (int) StateColor::Disabled),
|
||||
std::make_pair(0x303A3C, (int) StateColor::Normal));
|
||||
std::make_pair(0xCECECE, (int) StateColor::Normal));
|
||||
}
|
||||
|
||||
StaticBox::StaticBox(wxWindow* parent,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
StaticGroup::StaticGroup(wxWindow *parent, wxWindowID id, const wxString &label)
|
||||
: wxStaticBox(parent, id, label)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
SetForegroundColour("#CECECE");
|
||||
#ifdef __WXMSW__
|
||||
Bind(wxEVT_PAINT, &StaticGroup::OnPaint, this);
|
||||
#else
|
||||
@@ -30,4 +32,29 @@ void StaticGroup::OnPaint(wxPaintEvent &evt)
|
||||
}
|
||||
}
|
||||
|
||||
void StaticGroup::PaintForeground(wxDC &dc, const struct tagRECT &rc)
|
||||
{
|
||||
wxStaticBox::PaintForeground(dc, rc);
|
||||
auto mdc = dynamic_cast<wxMemoryDC *>(&dc);
|
||||
auto image = mdc->GetSelectedBitmap().ConvertToImage();
|
||||
// Found border coords
|
||||
int top = 0;
|
||||
int left = 0;
|
||||
int right = rc.right - 1;
|
||||
int bottom = rc.bottom - 1;
|
||||
auto blue = GetBackgroundColour().Blue();
|
||||
while (image.GetBlue(0, top) == blue) ++top;
|
||||
while (image.GetBlue(left, top) != blue) ++left; // --left; // fix start
|
||||
while (image.GetBlue(right, top) != blue) --right; ++right;
|
||||
while (image.GetBlue(0, bottom) == blue) --bottom;
|
||||
// Draw border with foreground color
|
||||
wxPoint polygon[] = { {left, top}, {0, top}, {0, bottom}, {rc.right - 1, bottom}, {rc.right - 1, top}, {right, top} };
|
||||
dc.SetPen(wxPen(GetForegroundColour(), 1));
|
||||
for (int i = 1; i < 6; ++i) {
|
||||
if (i == 4) // fix bottom right corner
|
||||
++polygon[i - 1].y;
|
||||
dc.DrawLine(polygon[i - 1], polygon[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
private:
|
||||
#ifdef __WXMSW__
|
||||
void OnPaint(wxPaintEvent &evt);
|
||||
void PaintForeground(wxDC &dc, const struct tagRECT &rc) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user