Merge remote-tracking branch 'remotes/origin/gui_improvements'

This commit is contained in:
bubnikv 2018-03-05 12:12:40 +01:00
commit 5ea584280c
25 changed files with 20518 additions and 4947 deletions

View file

@ -27,6 +27,8 @@
#include <wx/image.h>
#include <wx/settings.h>
#include "GUI.hpp"
namespace Slic3r {
void GLIndexedVertexArray::load_mesh_flat_shading(const TriangleMesh &mesh)
@ -1144,7 +1146,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
m_data.clear();
// collects items to render
const std::string& title = preview_data.get_legend_title();
auto title = GUI::L_str(preview_data.get_legend_title());
const GCodePreviewData::LegendItemsList& items = preview_data.get_legend_items(tool_colors);
unsigned int items_count = (unsigned int)items.size();
@ -1166,7 +1168,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
unsigned int max_text_height = 0;
for (const GCodePreviewData::LegendItem& item : items)
{
memDC.GetTextExtent(item.text, &w, &h);
memDC.GetTextExtent(GUI::from_u8(item.text), &w, &h);
max_text_width = std::max(max_text_width, (unsigned int)w);
max_text_height = std::max(max_text_height, (unsigned int)h);
}
@ -1243,7 +1245,7 @@ bool _3DScene::LegendTexture::generate(const GCodePreviewData& preview_data, con
memDC.DrawRectangle(wxRect(icon_x_inner, icon_y + 1, px_inner_square, px_inner_square));
// draw text
memDC.DrawText(item.text, text_x, icon_y + text_y_offset);
memDC.DrawText(GUI::from_u8(item.text), text_x, icon_y + text_y_offset);
// update y
icon_y += icon_y_step;

View file

@ -23,8 +23,7 @@ namespace Slic3r { namespace GUI {
// Also, docs for wxEvent::Skip() say "In general, it is recommended to skip all
// non-command events to allow the default handling to take place."
event.Skip();
std::cerr << "calling Field::on_kill_focus from " << m_opt_id<< "\n";
// call the registered function if it is available
// call the registered function if it is available
if (m_on_kill_focus!=nullptr)
m_on_kill_focus();
}

View file

@ -336,7 +336,7 @@ void add_debug_menu(wxMenuBar *menu, int event_language_change)
}
}
});
menu->Append(local_menu, _T("&Localization"));
menu->Append(local_menu, _(L("&Localization")));
//#endif
}
@ -405,11 +405,15 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
val = boost::any_cast<double>(value);
break;
}
case coPercents:
case coFloats:{
double& val = config.opt_float(opt_key, opt_index);
val = boost::any_cast<double>(value);
case coPercents:{
ConfigOptionPercents* vec_new = new ConfigOptionPercents{ boost::any_cast<double>(value) };
config.option<ConfigOptionPercents>(opt_key)->set_at(vec_new, opt_index, opt_index);
break;
}
case coFloats:{
ConfigOptionFloats* vec_new = new ConfigOptionFloats{ boost::any_cast<double>(value) };
config.option<ConfigOptionFloats>(opt_key)->set_at(vec_new, opt_index, opt_index);
break;
}
case coString:
config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
@ -473,7 +477,6 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
void add_created_tab(Tab* panel, PresetBundle *preset_bundle)
{
panel->m_show_btn_incompatible_presets = g_AppConfig->get("show_incompatible_presets").empty();
panel->create_preset_tab(preset_bundle);
// Load the currently selected preset into the GUI, update the preset selection box.
@ -516,7 +519,7 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
comboCtrl->EnablePopupAnimation(false);
comboCtrl->SetPopupControl(popup);
popup->SetStringValue(text);
popup->SetStringValue(from_u8(text));
popup->Bind(wxEVT_CHECKLISTBOX, [popup](wxCommandEvent& evt) { popup->OnCheckListBox(evt); });
popup->Bind(wxEVT_LISTBOX, [popup](wxCommandEvent& evt) { popup->OnListBoxSelection(evt); });
popup->Bind(wxEVT_KEY_DOWN, [popup](wxKeyEvent& evt) { popup->OnKeyEvent(evt); });
@ -527,7 +530,7 @@ void create_combochecklist(wxComboCtrl* comboCtrl, std::string text, std::string
for (const std::string& item : items_str)
{
popup->Append(item);
popup->Append(from_u8(item));
}
for (unsigned int i = 0; i < popup->GetCount(); ++i)

View file

@ -34,6 +34,9 @@ class TabIface;
//! With wxConvUTF8 explicitly specify that the source string is already in UTF-8 encoding
#define _CHB(s) wxGetTranslation(wxString(s, wxConvUTF8)).utf8_str()
// Minimal buffer length for translated string (char buf[MIN_BUF_LENGTH_FOR_L])
#define MIN_BUF_LENGTH_FOR_L 128
namespace GUI {
class Tab;

View file

@ -151,7 +151,12 @@ void OptionsGroup::append_line(const Line& line) {
ConfigOptionDef option = opt.opt;
// add label if any
if (option.label != "") {
auto field_label = new wxStaticText(parent(), wxID_ANY, L_str(option.label) + ":", wxDefaultPosition, wxDefaultSize);
wxString str_label = L_str(option.label);
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
// wxString str_label = (option.label == "Top" || option.label == "Bottom") ?
// wxGETTEXT_IN_CONTEXT("Layers", wxString(option.label.c_str()):
// L_str(option.label);
auto field_label = new wxStaticText(parent(), wxID_ANY, str_label + ":", wxDefaultPosition, wxDefaultSize);
field_label->SetFont(label_font);
sizer->Add(field_label, 0, wxALIGN_CENTER_VERTICAL, 0);
}

View file

@ -113,8 +113,7 @@ PageShp Tab::add_options_page(wxString title, std::string icon, bool is_extruder
// Index of icon in an icon list $self->{icons}.
auto icon_idx = 0;
if (!icon.empty()) {
if (m_icon_index.find(icon) == m_icon_index.end())
icon_idx = -1;
icon_idx = (m_icon_index.find(icon) == m_icon_index.end()) ? -1 : m_icon_index.at(icon);
if (icon_idx == -1) {
// Add a new icon to the icon list.
const auto img_icon = new wxIcon(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG);
@ -779,14 +778,15 @@ void TabPrint::update()
get_field(el)->toggle(have_wipe_tower);
m_recommended_thin_wall_thickness_description_line->SetText(
PresetHints::recommended_thin_wall_thickness(*m_preset_bundle));
from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)));
Thaw();
}
void TabPrint::OnActivate()
{
m_recommended_thin_wall_thickness_description_line->SetText(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle));
m_recommended_thin_wall_thickness_description_line->SetText(
from_u8(PresetHints::recommended_thin_wall_thickness(*m_preset_bundle)));
}
void TabFilament::build()
@ -1055,7 +1055,7 @@ void TabPrinter::build()
btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e){
if (m_event_button_browse > 0){
wxCommandEvent event(m_event_button_browse);
event.SetString(_(L("Button BROWSE was clicked!")));
event.SetString("Button BROWSE was clicked!");
g_wxMainFrame->ProcessWindowEvent(event);
}
// // # look for devices
@ -1090,7 +1090,7 @@ void TabPrinter::build()
btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e) {
if (m_event_button_test > 0){
wxCommandEvent event(m_event_button_test);
event.SetString(_(L("Button TEST was clicked!")));
event.SetString("Button TEST was clicked!");
g_wxMainFrame->ProcessWindowEvent(event);
}
// my $ua = LWP::UserAgent->new;
@ -1194,7 +1194,9 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){
void TabPrinter::build_extruder_pages(){
for (auto extruder_idx = m_extruder_pages.size(); extruder_idx < m_extruders_count; ++extruder_idx){
//# build page
auto page = add_options_page(_(L("Extruder ")) + wxString::Format(_T("%i"), extruder_idx + 1), "funnel.png", true);
char buf[MIN_BUF_LENGTH_FOR_L];
sprintf(buf, _CHB(L("Extruder %d")), extruder_idx + 1);
auto page = add_options_page(from_u8(buf), "funnel.png", true);
m_extruder_pages.push_back(page);
auto optgroup = page->new_optgroup(_(L("Size")));
@ -1624,6 +1626,7 @@ void Tab::update_ui_from_settings()
{
// Show the 'show / hide presets' button only for the print and filament tabs, and only if enabled
// in application preferences.
m_show_btn_incompatible_presets = get_app_config()->get("show_incompatible_presets")[0] == '1' ? true : false;
bool show = m_show_btn_incompatible_presets && m_presets->name().compare("printer") != 0;
show ? m_btn_hide_incompatible_presets->Show() : m_btn_hide_incompatible_presets->Hide();
// If the 'show / hide presets' button is hidden, hide the incompatible presets.

View file

@ -106,7 +106,7 @@ protected:
public:
PresetBundle* m_preset_bundle;
bool m_show_btn_incompatible_presets;
bool m_show_btn_incompatible_presets = false;
PresetCollection* m_presets;
DynamicPrintConfig* m_config;