Skip to content

Commit

Permalink
Fix link button sizing for non-windows platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed Feb 24, 2023
1 parent 8e11a11 commit 5bbe3a9
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 78 deletions.
149 changes: 74 additions & 75 deletions TransformIt/dialog_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,124 +17,123 @@

class ConfigDialogBase ( wx.Dialog ):

def __init__( self, parent ):
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Transform It", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )
def __init__( self, parent ):
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Transform It", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_DIALOG_STYLE )

self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )

bSizer1 = wx.BoxSizer( wx.VERTICAL )
bSizer1 = wx.BoxSizer( wx.VERTICAL )

self.m_panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
bSizer3 = wx.BoxSizer( wx.VERTICAL )
self.m_panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
bSizer3 = wx.BoxSizer( wx.VERTICAL )

fgSizer1 = wx.FlexGridSizer( 0, 3, 0, 0 )
fgSizer1.SetFlexibleDirection( wx.BOTH )
fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
fgSizer1 = wx.FlexGridSizer( 0, 3, 0, 0 )
fgSizer1.SetFlexibleDirection( wx.BOTH )
fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )

self.m_staticText1 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Horizontal (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText1.Wrap( -1 )
self.m_staticText1 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Horizontal (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText1.Wrap( -1 )

fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
fgSizer1.Add( self.m_staticText1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )

self.m_horizontalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_horizontalScale.SetDigits( 2 )
fgSizer1.Add( self.m_horizontalScale, 0, wx.EXPAND|wx.ALL, 5 )
self.m_horizontalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_horizontalScale.SetDigits( 2 )
fgSizer1.Add( self.m_horizontalScale, 0, wx.EXPAND|wx.ALL, 5 )

self.m_horizontalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 )
fgSizer1.Add( self.m_horizontalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
self.m_horizontalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 )
fgSizer1.Add( self.m_horizontalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )


fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )
fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )

self.m_linkButton = LinkToggle(self.m_panel)
self.m_linkButton.SetToolTip( u"Preserve aspect ratio" )
self.m_linkButton.SetMinSize( wx.Size( 28,16 ) )
self.m_linkButton = LinkToggle(self.m_panel)
self.m_linkButton.SetToolTip( u"Preserve aspect ratio" )

fgSizer1.Add( self.m_linkButton, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )
fgSizer1.Add( self.m_linkButton, 0, wx.ALIGN_CENTER_HORIZONTAL, 5 )


fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )
fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )

self.m_staticText2 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Vertical (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText2.Wrap( -1 )
self.m_staticText2 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Vertical (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText2.Wrap( -1 )

fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
fgSizer1.Add( self.m_staticText2, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )

self.m_verticalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_verticalScale.SetDigits( 2 )
self.m_verticalScale.Enable( False )
self.m_verticalScale = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_verticalScale.SetDigits( 2 )
self.m_verticalScale.Enable( False )

fgSizer1.Add( self.m_verticalScale, 0, wx.EXPAND|wx.ALL, 5 )
fgSizer1.Add( self.m_verticalScale, 0, wx.EXPAND|wx.ALL, 5 )

self.m_verticalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_verticalMirror.Enable( False )
self.m_verticalMirror = wx.CheckBox( self.m_panel, wx.ID_ANY, u"Mirror", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_verticalMirror.Enable( False )

fgSizer1.Add( self.m_verticalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
fgSizer1.Add( self.m_verticalMirror, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )

self.m_staticText3 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Rotation (deg)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText3.Wrap( -1 )
self.m_staticText3 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Rotation (deg)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText3.Wrap( -1 )

fgSizer1.Add( self.m_staticText3, 0, wx.ALL, 5 )
fgSizer1.Add( self.m_staticText3, 0, wx.ALL, 5 )

self.m_rotation = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, -360, 360, 0, 5 )
self.m_rotation.SetDigits( 2 )
fgSizer1.Add( self.m_rotation, 0, wx.ALL|wx.EXPAND, 5 )
self.m_rotation = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, -360, 360, 0, 5 )
self.m_rotation.SetDigits( 2 )
fgSizer1.Add( self.m_rotation, 0, wx.ALL|wx.EXPAND, 5 )

self.m_staticText4 = wx.StaticText( self.m_panel, wx.ID_ANY, u"(positive - cw)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText4.Wrap( -1 )
self.m_staticText4 = wx.StaticText( self.m_panel, wx.ID_ANY, u"(positive - cw)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText4.Wrap( -1 )

fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
fgSizer1.Add( self.m_staticText4, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )

self.m_staticText5 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Shape width (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText5.Wrap( -1 )
self.m_staticText5 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Shape width (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText5.Wrap( -1 )

fgSizer1.Add( self.m_staticText5, 0, wx.ALL, 5 )
fgSizer1.Add( self.m_staticText5, 0, wx.ALL, 5 )

self.m_shapeWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_shapeWidth.SetDigits( 2 )
fgSizer1.Add( self.m_shapeWidth, 0, wx.ALL, 5 )
self.m_shapeWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_shapeWidth.SetDigits( 2 )
fgSizer1.Add( self.m_shapeWidth, 0, wx.ALL, 5 )


fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )
fgSizer1.Add( ( 0, 0), 1, wx.EXPAND, 5 )

self.m_staticText6 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Track width (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText6.Wrap( -1 )
self.m_staticText6 = wx.StaticText( self.m_panel, wx.ID_ANY, u"Track width (%)", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText6.Wrap( -1 )

fgSizer1.Add( self.m_staticText6, 0, wx.ALL, 5 )
fgSizer1.Add( self.m_staticText6, 0, wx.ALL, 5 )

self.m_trackWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_trackWidth.SetDigits( 2 )
fgSizer1.Add( self.m_trackWidth, 0, wx.ALL, 5 )
self.m_trackWidth = wx.SpinCtrlDouble( self.m_panel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 1, 10000, 100, 5 )
self.m_trackWidth.SetDigits( 2 )
fgSizer1.Add( self.m_trackWidth, 0, wx.ALL, 5 )


bSizer3.Add( fgSizer1, 1, wx.EXPAND, 5 )
bSizer3.Add( fgSizer1, 1, wx.EXPAND, 5 )

self.m_staticline1 = wx.StaticLine( self.m_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
bSizer3.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )
self.m_staticline1 = wx.StaticLine( self.m_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
bSizer3.Add( self.m_staticline1, 0, wx.EXPAND |wx.ALL, 5 )

m_sdbSizer1 = wx.StdDialogButtonSizer()
self.m_sdbSizer1OK = wx.Button( self.m_panel, wx.ID_OK )
m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
self.m_sdbSizer1Cancel = wx.Button( self.m_panel, wx.ID_CANCEL )
m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
m_sdbSizer1.Realize();
m_sdbSizer1 = wx.StdDialogButtonSizer()
self.m_sdbSizer1OK = wx.Button( self.m_panel, wx.ID_OK )
m_sdbSizer1.AddButton( self.m_sdbSizer1OK )
self.m_sdbSizer1Cancel = wx.Button( self.m_panel, wx.ID_CANCEL )
m_sdbSizer1.AddButton( self.m_sdbSizer1Cancel )
m_sdbSizer1.Realize();

bSizer3.Add( m_sdbSizer1, 0, wx.BOTTOM|wx.EXPAND, 5 )
bSizer3.Add( m_sdbSizer1, 0, wx.BOTTOM|wx.EXPAND, 5 )


self.m_panel.SetSizer( bSizer3 )
self.m_panel.Layout()
bSizer3.Fit( self.m_panel )
bSizer1.Add( self.m_panel, 1, wx.EXPAND, 5 )
self.m_panel.SetSizer( bSizer3 )
self.m_panel.Layout()
bSizer3.Fit( self.m_panel )
bSizer1.Add( self.m_panel, 1, wx.EXPAND, 5 )


self.SetSizer( bSizer1 )
self.Layout()
bSizer1.Fit( self )
self.SetSizer( bSizer1 )
self.Layout()
bSizer1.Fit( self )

self.Centre( wx.BOTH )
self.Centre( wx.BOTH )

def __del__( self ):
pass
def __del__( self ):
pass


8 changes: 7 additions & 1 deletion TransformIt/link_toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ def __init__(self, parent):
super().__init__(parent,
label=wx.BitmapBundle(link_image),
style=wx.BU_EXACTFIT)
self.SetSizeHints(self.Size)
sz: wx.Size = link_image.GetSize()
wxport = wx.PlatformInformation().PortIdName
if wxport == "wxMSW":
sz.IncBy(10, 8)
else:
sz.IncBy(20, 8)
self.SetMinClientSize(sz)
self.SetValue(True)
4 changes: 2 additions & 2 deletions config_dialog_base.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="indent_with_spaces">1</property>
<property name="internationalize">0</property>
<property name="name">config_dialog</property>
<property name="namespace"></property>
Expand Down Expand Up @@ -377,7 +377,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">28,16</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_linkButton</property>
<property name="pane_border">1</property>
Expand Down

0 comments on commit 5bbe3a9

Please sign in to comment.