Skip to content

Commit

Permalink
prusa3d#316 good size of dialog & content in sync with display scaling.
Browse files Browse the repository at this point in the history
but the html pictures as they blurry if I use a %
  • Loading branch information
supermerill committed Jul 9, 2020
1 parent 245a39a commit 8a5f7bc
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 30 deletions.
4 changes: 2 additions & 2 deletions resources/calibration/bed_leveling/bed_leveling.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<table width="100%">
<tbody>
<tr>
<td>
<td style="text-align: center;">
<h1>Bed Level Calibration</h1>
</td>
<td style="text-align: right;">need: nothing</td>
Expand All @@ -22,7 +22,7 @@ <h2>How it works</h2>
<p>When clicking on the Generate button, the program will create and slice the test print. You have to send it to your printer and print it. After the print end, check the result of each corners and the middle one against the photos below. You will have to tune your printer/firmware to correct the height if needed.</p>
<p>Read the notes and advices below for more information.</p>
<h2>Results</h2>
<table>
<table width="100%">
<tbody>
<tr>
<td><img src="./low_ll.jpg" width="100" height="200" /></td>
Expand Down
2 changes: 1 addition & 1 deletion resources/calibration/bridge_flow/bridge_flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table width="100%">
<tbody>
<tr>
<td>
<td style="text-align: center;">
<h1>Bridge Flow Ratio Calibration</h1>
</td>
<td style="text-align: right;"><strong>
Expand Down
2 changes: 1 addition & 1 deletion resources/calibration/cube/cube.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table width="100%">
<tbody>
<tr>
<td>
<td style="text-align: center;">
<h1>Calibration Cube</h1>
</td>
<td style="text-align: right;"><strong>
Expand Down
4 changes: 2 additions & 2 deletions resources/calibration/filament_flow/filament_flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table width="100%">
<tbody>
<tr>
<td>
<td style="text-align: center;">
<h1>Filament Flow Calibration</h1>
</td>
<td style="text-align: right;"><strong>
Expand All @@ -25,7 +25,7 @@ <h1>Filament Flow Calibration</h1>
After verifying the result with the help of the table below, you have to modify the filament extrusion multiplier in your filament preset (if the -20 is the best, change the multiplier from 1 to 0.8, see the formula below). Don't forget to save it afterwards! You can continue with the 2.5 step if you want a bit more precision.</p>
<h2>Results</h2>
<h4>Example:</h4>
<table>
<table width="100%">
<tbody>
<tr>
<td><img src="./m20.jpg" width="150" height="150" /></td>
Expand Down
4 changes: 2 additions & 2 deletions resources/calibration/filament_temp/filament_temp.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table width="100%">
<tbody>
<tr>
<td>
<td style="text-align: center;">
<h1>Filament Temperature Calibration</h1>
</td>
<td style="text-align: right;"><strong>
Expand All @@ -27,7 +27,7 @@ <h1>Filament Temperature Calibration</h1>
<h2>Results / observation</h2>
<p>The goal is to choose the highest temperature possible that doesn't produce artifacts.</p>
<p>First, you have to analyse the tower. Each floor has the according temperature written on it.</p>
<table>
<table width="100%">
<tbody>
<tr>
<td><img src="./temp_tower_180.jpg" width="400" height="100" /></td>
Expand Down
2 changes: 1 addition & 1 deletion resources/calibration/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Calibrations</title>
</head>
<body>
<h1>Introduction</h1>
<h1 style="text-align: center;">Introduction</h1>
<p>Welcome to the calibration menu. This menu is here to help you print quick & efficient calibrations.</p>
<h2>Why?</h2>
<p>Most printer’s profile should work pretty good with default settings, but if you encounter problems, or if you want to go a step above in quality, you have to ensure that everything is well calibrated. Calibrations can be divided in three groups: printer, filament and slicer.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table width="100%">
<tbody>
<tr>
<td>
<td style="text-align: center;">
<h1>Ironing Pattern Calibration</h1>
</td>
<td style="text-align: right;"><strong>
Expand All @@ -23,7 +23,7 @@ <h1>Ironing Pattern Calibration</h1>
<p><strong>You need to do the filament flow calibration and the bridge flow ratio before this one.</strong> It's better if you have done the filament temperature.</p>
<p>This calibration method will print test samples with various levels of over-bridge flow ratio, between 100 and 125. Choose the lowest value on which the top surface is smooth without rough "holes".</p>
<h2>Results</h2>
<table>
<table width="100%">
<tbody>
<h4>Exemple:</h4>
<tr>
Expand Down
13 changes: 10 additions & 3 deletions src/slic3r/GUI/CalibrationAbstractDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace GUI {
#if ENABLE_SCROLLABLE
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
#else
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
#endif // ENABLE_SCROLLABLE
{
this->gui_app = app;
Expand All @@ -45,10 +45,15 @@ void CalibrationAbstractDialog::create(std::string html_path, wxSize dialog_size

//html
html_viewer = new wxHtmlWindow(this, wxID_ANY,
wxDefaultPosition, dialog_size, wxHW_SCROLLBAR_AUTO);
wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
html_viewer->LoadPage(Slic3r::resources_dir()+ html_path);
main_sizer->Add(html_viewer, 1, wxEXPAND | wxALL, 5);

wxDisplay display(wxDisplay::GetFromWindow(main_frame));
wxRect screen = display.GetClientArea();
dialog_size.x = std::min(int(dialog_size.x * this->scale_factor()), screen.width - 50);
dialog_size.y = std::min(int(dialog_size.y * this->scale_factor()), screen.height - 50);

wxStdDialogButtonSizer* buttons = new wxStdDialogButtonSizer();
create_buttons(buttons);

Expand All @@ -63,6 +68,7 @@ void CalibrationAbstractDialog::create(std::string html_path, wxSize dialog_size

SetSizer(main_sizer);
main_sizer->SetSizeHints(this);
this->SetSize(dialog_size.x, dialog_size.y);
}

void CalibrationAbstractDialog::close_me(wxCommandEvent& event_args) {
Expand Down Expand Up @@ -120,8 +126,9 @@ void CalibrationAbstractDialog::on_dpi_changed(const wxRect& suggested_rect)
{
msw_buttons_rescale(this, em_unit(), { wxID_OK });

wxSize oldSize = this->GetSize();
Layout();
Fit();
this->SetSize(oldSize.x * this->scale_factor() / this->prev_scale_factor(), oldSize.y * this->scale_factor() / this->prev_scale_factor());
Refresh();
}

Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/CalibrationAbstractDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CalibrationAbstractDialog : public DPIDialog
private:
wxPanel* create_header(wxWindow* parent, const wxFont& bold_font);
protected:
void create(std::string html_path, wxSize dialogsize = wxSize(800, 500));
void create(std::string html_path, wxSize dialogsize = wxSize(850, 550));
virtual void create_buttons(wxStdDialogButtonSizer*) = 0;
void on_dpi_changed(const wxRect& suggested_rect) override;
void close_me(wxCommandEvent& event_args);
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/CalibrationBridgeDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CalibrationBridgeDialog : public CalibrationAbstractDialog
{

public:
CalibrationBridgeDialog(GUI_App* app, MainFrame* mainframe) : CalibrationAbstractDialog(app, mainframe, "Bridge calibration") { create("/calibration/bridge_flow/bridge_flow.html", wxSize(600, 300)); }
CalibrationBridgeDialog(GUI_App* app, MainFrame* mainframe) : CalibrationAbstractDialog(app, mainframe, "Bridge calibration") { create("/calibration/bridge_flow/bridge_flow.html", wxSize(850, 400)); }
virtual ~CalibrationBridgeDialog() { }

protected:
Expand Down
35 changes: 21 additions & 14 deletions src/slic3r/GUI/FreeCADDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,14 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)
createSTC();

m_errors = new wxTextCtrl(this, wxID_ANY, "",
wxDefaultPosition, wxSize(600, 100), wxHW_SCROLLBAR_AUTO | wxTE_MULTILINE);
wxDefaultPosition, wxSize(200, 100 * this->scale_factor()), wxHW_SCROLLBAR_AUTO | wxTE_MULTILINE);
m_errors->SetEditable(false);

m_help = new wxTextCtrl(this, wxID_ANY, create_help_text(),
wxDefaultPosition, wxSize(200, 500), wxTE_MULTILINE);
wxDefaultPosition, wxSize(200 * this->scale_factor(), 200), wxTE_MULTILINE);
m_help->SetEditable(false);

//wxBoxSizer *m_icons = new wxBoxSizer(wxHORIZONTAL);
//m_icons->Add(16,16,0,0,0,freecad_icon);

//wxSizerItem* Add(wxSizer * sizer, const wxGBPosition & pos, const wxGBSpan & span = wxDefaultSpan, int flag = 0, int border = 0, wxObject * userData = NULL)
//wxSizerItem* Add(wxSizer * sizer, int proportion = 0, int flag = 0, int border = 0, wxObject * userData = NULL)
main_sizer->Add(m_text, wxGBPosition(1,1), wxGBSpan(2,1), wxEXPAND | wxALL, 2);
//main_sizer->Add(m_icons, wxGBPosition(1, 2), wxGBSpan(1, 1), 0, 2);
//main_sizer->Add(m_help, wxGBPosition(2, 2), wxGBSpan(2, 1), wxEXPAND | wxVERTICAL, 2);
main_sizer->Add(m_help, wxGBPosition(1, 2), wxGBSpan(3, 1), wxEXPAND | wxVERTICAL, 2);
main_sizer->Add(m_errors, wxGBPosition(3, 1), wxGBSpan(1, 1), wxEXPAND | wxHORIZONTAL, 2);

Expand All @@ -245,7 +238,7 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)

wxStdDialogButtonSizer* buttons = new wxStdDialogButtonSizer();

wxButton* bt_new = new wxButton(this, wxID_FILE3, _(L("New")));
wxButton* bt_new = new wxButton(this, wxID_FILE1, _(L("New")));
bt_new->Bind(wxEVT_BUTTON, &FreeCADDialog::new_script, this);
buttons->Add(bt_new);
wxButton* bt_load = new wxButton(this, wxID_FILE2, _(L("Load")));
Expand All @@ -260,7 +253,7 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)
buttons->Add(bt_quick_save);

buttons->AddSpacer(30);
wxButton* bt_create_geometry = new wxButton(this, wxID_FILE1, _(L("Generate")));
wxButton* bt_create_geometry = new wxButton(this, wxID_APPLY, _(L("Generate")));
bt_create_geometry->Bind(wxEVT_BUTTON, &FreeCADDialog::create_geometry, this);
buttons->Add(bt_create_geometry);

Expand All @@ -276,6 +269,14 @@ FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)
SetSizer(main_sizer);
main_sizer->SetSizeHints(this);

wxSize dialog_size(800 * this->scale_factor(), 600 * this->scale_factor());
wxDisplay display(wxDisplay::GetFromWindow(main_frame));
wxRect screen = display.GetClientArea();
dialog_size.x = std::min(dialog_size.x, screen.width - 50);
dialog_size.y = std::min(dialog_size.y, screen.height - 50);

this->SetSize(dialog_size);

//set keyboard shortcut
wxAcceleratorEntry entries[6];
//entries[0].Set(wxACCEL_CTRL, (int) 'X', bt_create_geometry->GetId());
Expand Down Expand Up @@ -611,7 +612,7 @@ void FreeCADDialog::on_key_type(wxKeyEvent& event)
void FreeCADDialog::createSTC()
{
m_text = new wxStyledTextCtrl(this, wxID_ANY,
wxDefaultPosition, wxSize(600,400), wxHW_SCROLLBAR_AUTO);
wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);

//m_text->SetMarginWidth(MARGIN_LINE_NUMBERS, 50);
m_text->StyleSetForeground(wxSTC_STYLE_LINENUMBER, wxColour(75, 75, 75));
Expand All @@ -624,6 +625,7 @@ void FreeCADDialog::createSTC()
m_text->SetIndentationGuides(wxSTC_IV_LOOKFORWARD);
m_text->SetBackSpaceUnIndents(true);
m_text->SetTabIndents(true);
m_text->SetZoom(int((this->scale_factor() - 1) * 10));

m_text->SetWrapMode(wxSTC_WRAP_WORD);

Expand Down Expand Up @@ -668,10 +670,15 @@ void FreeCADDialog::createSTC()

void FreeCADDialog::on_dpi_changed(const wxRect& suggested_rect)
{
msw_buttons_rescale(this, em_unit(), { wxID_OK });
msw_buttons_rescale(this, em_unit(), { wxID_FILE1, wxID_FILE2, wxID_FILE3, wxID_FILE4, wxID_APPLY, wxID_CLOSE });

m_errors->SetMinSize(wxSize(200, 100 * this->scale_factor()));
m_help->SetMinSize(wxSize(200 * this->scale_factor(), 200));
m_text->SetZoom(int((this->scale_factor() - 1) * 10));

wxSize oldSize = this->GetSize();
Layout();
Fit();
this->SetSize(oldSize.x * this->scale_factor() / this->prev_scale_factor(), oldSize.y * this->scale_factor() / this->prev_scale_factor());
Refresh();
}

Expand Down

0 comments on commit 8a5f7bc

Please sign in to comment.