Custom control : Bug fixing

* OG_CustomCtrl is inherited from the wxPanel instead of the wxControl now.
  As a result, Tab-key is working now for the fields inside the custom control
* Open localized web-page if any exist for labels

+ Fixed update of icons inside the PresetComboBoxes after switching between Dark/Light modes
This commit is contained in:
YuSanka 2020-10-30 12:24:33 +01:00 committed by Oleksandra Yushchenko
parent 32b8be600c
commit b2700a8ac6
4 changed files with 18 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#include "OptionsGroup.hpp"
#include "Plater.hpp"
#include "GUI_App.hpp"
#include "libslic3r/AppConfig.hpp"
#include <wx/utils.h>
#include <boost/algorithm/string/split.hpp>
@ -25,11 +26,16 @@ static wxSize get_bitmap_size(const wxBitmap& bmp)
#endif
}
static wxString get_url(const wxString& path_end)
static wxString get_url(const wxString& path_end, bool get_default = false)
{
if (path_end.IsEmpty())
return wxEmptyString;
return wxString("https://help.prusa3d.com/") + "en" + "/article/" + path_end;
wxString language = wxGetApp().app_config->get("translation_language");
if (language.IsEmpty())
return wxEmptyString;
return wxString("https://help.prusa3d.com/") + language.BeforeFirst('_') + "/article/" + path_end;
}
OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
@ -38,7 +44,7 @@ OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent,
const wxSize& size/* = wxDefaultSize*/,
const wxValidator& val /* = wxDefaultValidator*/,
const wxString& name/* = wxEmptyString*/) :
wxControl(parent, wxID_ANY, pos, size, wxWANTS_CHARS | wxBORDER_NONE),
wxPanel(parent, wxID_ANY, pos, size, /*wxWANTS_CHARS |*/ wxBORDER_NONE | wxTAB_TRAVERSAL),
opt_group(og)
{
if (!wxOSX)
@ -210,6 +216,8 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event)
const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
wxString tooltip;
wxString language = wxGetApp().app_config->get("translation_language");
for (CtrlLine& line : ctrl_lines) {
line.is_focused = is_point_in_rect(pos, line.rect_label);
if (line.is_focused) {
@ -631,11 +639,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBi
bool OG_CustomCtrl::CtrlLine::launch_browser() const
{
if (is_focused && !og_line.label_path.IsEmpty()) {
wxLaunchDefaultBrowser(get_url(og_line.label_path));
return true;
}
return false;
return is_focused && !og_line.label_path.IsEmpty() && wxLaunchDefaultBrowser(get_url(og_line.label_path));
}

View File

@ -25,7 +25,7 @@
namespace Slic3r { namespace GUI {
// Static text shown among the options.
class OG_CustomCtrl :public wxControl
class OG_CustomCtrl :public wxPanel
{
wxFont m_font;
int m_v_gap;

View File

@ -349,6 +349,8 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, bool wide_icons, con
bitmap_key += is_system ? ",syst" : ",nsyst";
bitmap_key += ",h" + std::to_string(icon_height);
if (wxGetApp().dark_mode())
bitmap_key += ",dark";
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {
@ -393,6 +395,8 @@ wxBitmap* PresetComboBox::get_bmp( std::string bitmap_key, const std::string& m
bitmap_key += is_compatible ? ",cmpt" : ",ncmpt";
bitmap_key += is_system ? ",syst" : ",nsyst";
bitmap_key += ",h" + std::to_string(icon_height);
if (wxGetApp().dark_mode())
bitmap_key += ",dark";
wxBitmap* bmp = bitmap_cache().find(bitmap_key);
if (bmp == nullptr) {

View File

@ -1010,6 +1010,7 @@ void Tab::msw_rescale()
void Tab::sys_color_changed()
{
update_tab_ui();
m_presets_choice->msw_rescale();
// update buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)