Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use monospaced fonts in gcode sections #4747

Merged
merged 4 commits into from
Oct 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libslic3r/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,8 @@ class ConfigOptionDef
bool multiline = false;
// For text input: If true, the GUI text box spans the complete page width.
bool full_width = false;
// For text input: If true, the GUI formats text as code (fixed-width)
bool is_code = false;
// Not editable. Currently only used for the display of the number of threads.
bool readonly = false;
// Height of a multiline GUI text box.
Expand Down
4 changes: 3 additions & 1 deletion src/slic3r/GUI/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ void TextCtrl::BUILD() {

const long style = m_opt.multiline ? wxTE_MULTILINE : wxTE_PROCESS_ENTER/*0*/;
auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, style);
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
temp->SetFont(m_opt.is_code ?
Slic3r::GUI::wxGetApp().code_font():
Slic3r::GUI::wxGetApp().normal_font());

if (! m_opt.multiline && !wxOSX)
// Only disable background refresh for single line input fields, as they are completely painted over by the edit control.
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/FirmwareDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
SetFont(font);
wxFont status_font = font;//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
status_font.MakeBold();
wxFont mono_font(wxFontInfo().Family(wxFONTFAMILY_TELETYPE));
wxFont mono_font = GUI::wxGetApp().code_font();
mono_font.MakeSmaller();

// Create GUI components and layout
Expand Down
6 changes: 6 additions & 0 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ void GUI_App::init_fonts()
m_small_font.SetPointSize(11);
m_bold_font.SetPointSize(13);
#endif /*__WXMAC__*/

// wxSYS_OEM_FIXED_FONT and wxSYS_ANSI_FIXED_FONT use the same as
// DEFAULT in wxGtk. Use the TELETYPE family as a work-around
m_code_font = wxFont(wxFontInfo().Family(wxFONTFAMILY_TELETYPE));
m_code_font.SetPointSize(m_normal_font.GetPointSize());
}

void GUI_App::update_fonts(const MainFrame *main_frame)
Expand All @@ -884,6 +889,7 @@ void GUI_App::update_fonts(const MainFrame *main_frame)
m_small_font = m_normal_font;
m_bold_font = main_frame->normal_font().Bold();
m_em_unit = main_frame->em_unit();
m_code_font.SetPointSize(m_normal_font.GetPointSize());
}

void GUI_App::set_label_clr_modified(const wxColour& clr) {
Expand Down
2 changes: 2 additions & 0 deletions src/slic3r/GUI/GUI_App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class GUI_App : public wxApp
wxFont m_small_font;
wxFont m_bold_font;
wxFont m_normal_font;
wxFont m_code_font;

int m_em_unit; // width of a "m"-symbol in pixels for current system font
// Note: for 100% Scale m_em_unit = 10 -> it's a good enough coefficient for a size setting of controls
Expand Down Expand Up @@ -177,6 +178,7 @@ class GUI_App : public wxApp
const wxFont& small_font() { return m_small_font; }
const wxFont& bold_font() { return m_bold_font; }
const wxFont& normal_font() { return m_normal_font; }
const wxFont& code_font() { return m_code_font; }
int em_unit() const { return m_em_unit; }
wxSize get_min_size() const;
float toolbar_icon_scale(const bool is_limited = false) const;
Expand Down
11 changes: 11 additions & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1790,12 +1790,14 @@ void TabFilament::build()
optgroup = page->new_optgroup(L("Start G-code"), 0);
option = optgroup->get_option("start_filament_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;// 150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("End G-code"), 0);
option = optgroup->get_option("end_filament_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;// 150;
optgroup->append_single_option_line(option);

Expand Down Expand Up @@ -2204,51 +2206,60 @@ void TabPrinter::build_fff()
optgroup = page->new_optgroup(L("Start G-code"), 0);
option = optgroup->get_option("start_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("End G-code"), 0);
option = optgroup->get_option("end_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("Before layer change G-code"), 0);
option = optgroup->get_option("before_layer_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("After layer change G-code"), 0);
option = optgroup->get_option("layer_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("Tool change G-code"), 0);
option = optgroup->get_option("toolchange_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("Between objects G-code (for sequential printing)"), 0);
option = optgroup->get_option("between_objects_gcode");
option.opt.full_width = true;
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("Color Change G-code"), 0);
option = optgroup->get_option("color_change_gcode");
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("Pause Print G-code"), 0);
option = optgroup->get_option("pause_print_gcode");
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

optgroup = page->new_optgroup(L("Template Custom G-code"), 0);
option = optgroup->get_option("template_custom_gcode");
option.opt.is_code = true;
option.opt.height = gcode_field_height;//150;
optgroup->append_single_option_line(option);

Expand Down