Skip to content

Class for RadioGroup & LabeledStaticBox and improvements for Calibration Dialogs, Windows with wxStaticBoxSizer #9797

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

Merged
merged 18 commits into from
Jun 12, 2025

Conversation

yw4z
Copy link
Contributor

@yw4z yw4z commented Jun 4, 2025

RADIOGROUP CLASS

Screenshot-20250604124056
• Fully featured RadioButton class for hustle free UI creation. just requires a list
m_rbFilamentType = new RadioGroup(this, { _L("PLA"), _L("ABS/ASA"), _L("PETG"), _L("PCTG"), _L("TPU"), _L("PA-CF"), _L("PET-CF"), _L("Custom") }, wxVERTICAL, 2);

• Supports dark mode, keyboard input, hover effects and focus rectangle

• Supports direction for vertical or horizontal orientation

• Supports optional item count limit for row / column. switches to new row / column after given limit reaches depends on choosen direction / orientation

• Supports choosing item with clicking on text

• Matches look between platforms

LABELEDSTATICBOX CLASS

• Adds new LabeledStaticBox class for modernizing wxStaticBoxSizer with to fix dark mode related problems

CALIBRATION DIALOGS

COMMON CHANGES
• Simplifies and matches code format on all calibration dialogs
• Fixes margin and spacing related problems
• Fixes all dark mode problems
• Matches font size
• Parameter boxes > Matches width
• Parameter boxes > Aligns text to left instead center

TEMPERATURE CALIBRATION DIALOG

• No specific changes

Before-After
Screenshot-20250604105152

PRESSURE ADVANCE CALIBRATION DIALOG

• Used horizontal orientation for radio groups
• aligned checkbox with parameter boxes like on sidebar. ant that required so much changes. thats why i removed create_item_checkbox()

Before-After
Screenshot-20250604105219

RETRACTION CALIBRATION DIALOG

• Fixed side text on parameter box for "step: ". previously that used "mm/mm". that was confusing
• Used uppercase for first letter on "Step:" . Not requires new translation

Before-After
Screenshot-20250604121146

INPUT SHAPER FREQUENCY TEST DIALOG

• used single text for X and Y "Start / End" and used parameter boxes alongside like on Printer or Filament settings window. this change requires new translation
• Used lowercase for side text."hz" instead "HZ" . this matches with other parameter boxes

Before-After
Screenshot-20250604105503

INPUT SHAPER DAMP TEST DIALOG

• used single text for "Frequency X / Y" and used parameter boxes alongside like on Printer or Filament settings window. this change requires new translation
• used single text for "Damp Start / End" and used parameter boxes alongside like on Printer or Filament settings window. this change requires new translation
• Used lowercase for side text."hz" instead "HZ" . this matches with other parameter boxes

Before-After
Screenshot-20250604105526

MAX VOLUMETRIC SPEED DIALOG

• Used uppercase for first letter on "Step:" . Not requires new translation

Before-After
Screenshot-20250604121248

VFA TEST DIALOG*

• Used uppercase for first letter on "Step:" . Not requires new translation

Before-After
Screenshot-20250604121335

JUNCTION DEVIATION TEST DIALOG

• No specific changes

Before-After
Screenshot-20250604105636

BED SHAPE DIALOG

Before-After
Screenshot-20250604100856
Screenshot-20250604100842

PHYSICAL PRINTER DIALOG

Before-After
Screenshot-20250605195001
Screenshot-20250605194906

UNSAVED CHANGES DIALOG > FullCompareDialog

Couldnt find how to open this dialog

SAVE PRESET DIALOG

Couldnt find how to open this dialog

@yw4z yw4z changed the title Class for RadioGroup & LabeledStaticBox and improvements for Calibration Dialogs Class for RadioGroup & LabeledStaticBox and improvements for Calibration Dialogs, Windows with StaticBox Jun 4, 2025
@yw4z yw4z mentioned this pull request Jun 4, 2025
@yw4z yw4z changed the title Class for RadioGroup & LabeledStaticBox and improvements for Calibration Dialogs, Windows with StaticBox Class for RadioGroup & LabeledStaticBox and improvements for Calibration Dialogs, Windows with wxStaticBoxSizer Jun 4, 2025
@ianalexis
Copy link
Contributor

at last someone who really understands about gui was able to solve the calibration error.
I had tried to solve it when I developed the InputShaping and Junction Deviation test but without success.
My eyes thank you.

@yw4z
Copy link
Contributor Author

yw4z commented Jun 5, 2025

thanks still i'm trying to fix main UI elements and is assume 1 passed. icons, margins, colors, components etc.. but UI improved nicely and worth the effort

@yw4z yw4z marked this pull request as ready for review June 5, 2025 16:39
@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 7, 2025

linux-radio

The new radio buttons have some weird behavior on Linux. Seems to be related to focus change.

@yw4z
Copy link
Contributor Author

yw4z commented Jun 7, 2025

also looks like LabeledStaticBox not rendering correctly. i will check when i got time

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 7, 2025

image
image

The static box doesn't work well on macOS. Radio works fine though.

@yw4z
Copy link
Contributor Author

yw4z commented Jun 7, 2025

should i switch to wxWindow for LabeledStaticBox instead dealing with wxStaticBox. i think border will always be a problem on linux. looks like paint event didnt even used

i assume creating a sizer in that wxWindow and using that will get job done
example from OptionsGroup.cpp

LabeledStaticBox * stb = new LabeledStaticBox(m_parent, _(title));
this->stb = stb;
sizer = new wxStaticBoxSizer(stb, wxVERTICAL); 

will look like but might require a bit more change on various areas

LabeledStaticBox * stb = new LabeledStaticBox(m_parent, _(title));
this->stb = stb;
sizer = new wxBoxSizer(stb->GetSizer() , wxVERTICAL); 

i assume dc.clear() also cleans other elements except icons on RadioGroup for linux

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 8, 2025

i assume dc.clear() also cleans other elements except icons on RadioGroup for linux

What does dc.clear() actually do in those focus events? Also is it normal to do any drawing outside render function?

@yw4z
Copy link
Contributor Author

yw4z commented Jun 8, 2025

clears all draw (focus rectangle in this case) and re draws it. but i will try move and resize method instead clearing
i tried switching to wxWindow for LabeledStaticBox but got a problem while setting parent
Screenshot-20250608114135

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 8, 2025

clears all draw (focus rectangle in this case) and re draws it

Is there any function like refresh that do similar thing?

@yw4z
Copy link
Contributor Author

yw4z commented Jun 8, 2025

last commit should fix problems for RadioGroup

What you think about LabeledStaticBox

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 8, 2025

Maybe use wxPanel instead as suggested in https://forums.wxwidgets.org/viewtopic.php?t=25978

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 8, 2025

linux-radio-focus-highlight

The focus highlight box does not work properly on Linux.

@yw4z
Copy link
Contributor Author

yw4z commented Jun 8, 2025

it catches wxEVT_SET_FOCUS and wxEVT_KILL_FOCUS but looks like m_focus_rect not updating, at least we got better results compared to previous one

do you this SetDoubleBuffered(true); can cause this

or it tries to refresh before defining m_focus_rect . maybe adding a condition will fix that

@yw4z
Copy link
Contributor Author

yw4z commented Jun 8, 2025

switched wxPanel to wxWindow for RadioGroup
i found HasFocus() not working on wxPanel with Linux
also added 2 overrides these ensures focus-ability on linux. let me know if they are unnecessary

    bool AcceptsFocus()             const override { return true; }
    bool AcceptsFocusFromKeyboard() const override { return true; }

@yw4z
Copy link
Contributor Author

yw4z commented Jun 8, 2025

last commit should fix LabeledStaticBox for macOS

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 9, 2025

macOS:
image

Linux:
linux-radio-focus-highlight-2

@yw4z
Copy link
Contributor Author

yw4z commented Jun 9, 2025

what a rabbit hole :)

LabeledStaticBox
macOS starts render at wrong position and gets wrong size for rectangle or it draws border outside of rectangle. both easily fixable with some overrides
maybe macos returns start point of staticbox's border for window position

RadioGroup
i lost about linux. looks like it captures events but not in correct way. probably i cant fix without testing on linux

what you suggest? i dont want to annoy you for each commit

i found this for macOS to edit control margins

#include <wx/osx/core/private.h>
#include <Cocoa/Cocoa.h>

void AdjustContentViewMargins(wxStaticBox* staticBox, float width = 0.0, float height = 0.0) {
    NSBox* nativeBox = (NSBox*)staticBox->GetHandle();
    if (nativeBox) {
        NSSize margins = [nativeBox contentViewMargins];
        [nativeBox setContentViewMargins:NSMakeSize(width, height)];
        staticBox->GetParent()->Layout();
    }
}
#endif

#ifdef __WXOSX_COCOA__
    AdjustContentViewMargins(staticbox_to_control, 0.0, 0.0); // Set to zero margins
#endif

@Noisyfox
Copy link
Collaborator

I'll try doing some debugging on Linux in the next few days.

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 10, 2025

I actually think it works well enough on Linux. I'll focus on macOS first.

@yw4z
Copy link
Contributor Author

yw4z commented Jun 10, 2025

Great, events needs some fine tuning on linux for RadioGroup but it completely ignores painting on LabeledStaticBox. i saw some recommends using GTK styling. not sure how to do that

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 10, 2025

i found this for macOS to edit control margins

You know what:
image

wxwidgets actually does the same thing for its staticbox impl. I think we could do that too. I'll give this a quick test.

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 10, 2025

Hmmmm wait... You didn't use wxpanel as the parent of the new static box. This should already been applied then?

@yw4z
Copy link
Contributor Author

yw4z commented Jun 10, 2025

nope i didnt switched that because it broke combability with OptionGroup.cpp. i assume we have to use wxStaticBox to keep things working otherwise we have to fix new problems.

i read ContentViewMargin defaults to (5,5) after creation maybe we have to override it second time

here i added required changes to a separate branch because changes makes impossible to revert if we want to

https://github.com/yw4z/OrcaSlicer/tree/staticbox-as-window

main...yw4z:OrcaSlicer:staticbox-as-window

Currently i only corrected parents for Junction Deviation Dialog. other dialogs will not work properly

Screenshot-20250610162610

i think we have to change parents of controls automatically when they added to sizer to make OptionGroup work
only way i found track sizer changes wxEVT_SIZE event but its not a proper method
other option using a timer to track child controls of sizer but i didnt like it either

@Noisyfox
Copy link
Collaborator

Noisyfox commented Jun 10, 2025

I managed to solve the issue by setting the native NSBox's border width to 0 on macOS:

void staticbox_remove_margin(wxStaticBox* sb) {
    NSBox* nativeBox = (NSBox*)sb->GetHandle();
    [nativeBox setBoxType:NSBoxCustom];
    [nativeBox setBorderWidth:0];
}

image

And I also have to set m_pos = {0,0}; too otherwise the left side misses 1px:
image

The reason is the position is actually (-1, -1) for default position.

@Noisyfox
Copy link
Collaborator

nope i didnt switched that because it broke combability with OptionGroup.cpp. i assume we have to use wxStaticBox to keep things working otherwise we have to fix new problems.

i read ContentViewMargin defaults to (5,5) after creation maybe we have to override it second time

here i added required changes to a separate branch because changes makes impossible to revert if we want to

https://github.com/yw4z/OrcaSlicer/tree/staticbox-as-window

main...yw4z:OrcaSlicer:staticbox-as-window

Currently i only corrected parents for Junction Deviation Dialog. other dialogs will not work properly

Screenshot-20250610162610

i think we have to change parents of controls automatically when they added to sizer to make OptionGroup work only way i found track sizer changes wxEVT_SIZE event but its not a proper method other option using a timer to track child controls of sizer but i didnt like it either

I think you could try using wxpanel instead of wxwindow as the parent?

@yw4z
Copy link
Contributor Author

yw4z commented Jun 10, 2025

looks like macOS adding extra spacing inside staticbox to all edges . normally title and contents aligns on left. looks great anyway

Problems starts to appear when using LabeledStaticBox(based on wxPanel) on OptionGroup

do you think we really need to make that switch because it completely broke controls generated by option group

macOS looks ok but i cant comment about linux

@Noisyfox
Copy link
Collaborator

I think current impl looks good enough, since issues on macOS has now been fixed.

@yw4z
Copy link
Contributor Author

yw4z commented Jun 10, 2025

yep thats why i asked. should we exclude paint event from linux

@yw4z
Copy link
Contributor Author

yw4z commented Jun 10, 2025

i can simplify code calibration dialogs with using wxFlexGridSizer for layout. that will remove requirement of calculating text width , simplifies margins and removes unnecessary sizers

    auto start_PA_sizer = new wxBoxSizer(wxHORIZONTAL);
    auto start_pa_text = new wxStaticText(this, wxID_ANY, start_pa_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
    m_tiStartPA = new TextInput(this, "", "", "", wxDefaultPosition, ti_size, wxTE_PROCESS_ENTER);
    m_tiStartPA->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
    start_PA_sizer->Add(start_pa_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(2));
    start_PA_sizer->Add(m_tiStartPA  , 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(2));
    settings_sizer->Add(start_PA_sizer, 0, wxLEFT, FromDIP(3));

with wxFlexGridSizer(row_count, 2, FromDIP(4) , FromDIP(20));

    auto start_pa_text = new wxStaticText(this, wxID_ANY, start_pa_str);
    m_tiStartPA = new TextInput(this, "", "", "", wxDefaultPosition, ti_size, wxTE_PROCESS_ENTER);
    m_tiStartPA->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
    f_sizer->Add(start_pa_text, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL);
    f_sizer->Add(m_tiStartPA);

@Noisyfox
Copy link
Collaborator

yep thats why i asked. should we exclude paint event from linux

I haven't looked at that yet. Will give it a look tonight.

@Noisyfox
Copy link
Collaborator

I don't know why LabeledStaticBox paint event is not fired on Linux. I guess we could leave it there.

@yw4z
Copy link
Contributor Author

yw4z commented Jun 11, 2025

i read some gtk controls not create paint events. i think it draws natively
is that possible to create a wxWindow in that LabeledStaticBox class and cover staticbox's border and label. i think it has to be click thru and center of it should be masked. ofc its not a good solution

@Noisyfox
Copy link
Collaborator

is that possible to create a wxWindow in that LabeledStaticBox class and cover staticbox's border and label.

I don't think so because the native box will clip its child.

Copy link
Collaborator

@Noisyfox Noisyfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@Noisyfox Noisyfox merged commit 8fff1ca into SoftFever:main Jun 12, 2025
11 checks passed
ianalexis added a commit to ianalexis/OrcaSlicer that referenced this pull request Jun 12, 2025
Updated images with new style from commit 8fff1ca (pr: SoftFever#9797)
ianalexis added a commit to ianalexis/OrcaSlicer that referenced this pull request Jun 12, 2025
Updated images with new style from commit 8fff1ca (pr: SoftFever#9797)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants