From: smorloc Date: Fri, 25 Jan 2013 03:20:12 +0000 (-0500) Subject: Dynamic columns in left left pane (for testing) X-Git-Tag: 13.03~64^2~5 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=00e4524261f5c1a86e56846c5b3a3877d644ec98;p=cura.git Dynamic columns in left left pane (for testing) --- diff --git a/Cura/gui/configBase.py b/Cura/gui/configBase.py index 38493b41..caedc4e1 100644 --- a/Cura/gui/configBase.py +++ b/Cura/gui/configBase.py @@ -30,10 +30,12 @@ class configPanelBase(wx.Panel): configPanel = wx.Panel(parent); leftConfigPanel = wx.Panel(configPanel) rightConfigPanel = wx.Panel(configPanel) + sizer = wx.GridBagSizer(2, 2) leftConfigPanel.SetSizer(sizer) sizer = wx.GridBagSizer(2, 2) rightConfigPanel.SetSizer(sizer) + sizer = wx.BoxSizer(wx.HORIZONTAL) configPanel.SetSizer(sizer) sizer.Add(leftConfigPanel, border=35, flag=wx.RIGHT) @@ -42,28 +44,34 @@ class configPanelBase(wx.Panel): rightConfigPanel.main = self return leftConfigPanel, rightConfigPanel, configPanel - def CreateSimpleConfigTab(self, nb, name): - leftConfigPanel, configPanel = self.CreateSimpleConfigPanel(nb) - nb.AddPage(configPanel, name) - return leftConfigPanel - - def CreateSimpleConfigPanel(self, parent): - configPanel = wx.lib.scrolledpanel.ScrolledPanel(parent) + def CreateDynamicConfigTab(self, nb, name): + configPanel = wx.lib.scrolledpanel.ScrolledPanel(nb) + #configPanel = wx.Panel(nb); leftConfigPanel = wx.Panel(configPanel) - + rightConfigPanel = wx.Panel(configPanel) + sizer = wx.GridBagSizer(2, 2) leftConfigPanel.SetSizer(sizer) sizer.AddGrowableCol(1) + sizer = wx.GridBagSizer(2, 2) + rightConfigPanel.SetSizer(sizer) + sizer.AddGrowableCol(1) + sizer = wx.BoxSizer(wx.HORIZONTAL) + sizer.Add(leftConfigPanel, proportion=1, border=35, flag=wx.EXPAND) + sizer.Add(rightConfigPanel, proportion=1, flag=wx.EXPAND) configPanel.SetSizer(sizer) - sizer.Add(leftConfigPanel, 1, wx.EXPAND) configPanel.SetAutoLayout(1) - configPanel.SetupScrolling() + configPanel.SetupScrolling(scroll_x=False, scroll_y=True) leftConfigPanel.main = self - return leftConfigPanel, configPanel + rightConfigPanel.main = self + + nb.AddPage(configPanel, name) + + return leftConfigPanel, rightConfigPanel, configPanel def OnPopupDisplay(self, setting): self.popup.setting = setting @@ -99,6 +107,32 @@ class configPanelBase(wx.Panel): setting.SetValue(profile.getPreference(setting.configName)) self.Update() + def XXXgetLabelColumnWidth(self): + maxWidth = 0 + for setting in self.settingControlList: + maxWidth = max(maxWidth, setting.label.GetWidth()) + + def XXXsetLabelColumnWidth(self, newWidth): + for setting in self.settingControlList: + setting.label.SetWidth(newWidth) + + def getLabelColumnWidth(self, panel): + maxWidth = 0 + for child in panel.GetChildren(): + if isinstance(child, wx.lib.stattext.GenStaticText): + maxWidth = max(maxWidth, child.GetSize()[0]) + return maxWidth + + def setLabelColumnWidth(self, panel, width): + for child in panel.GetChildren(): + if isinstance(child, wx.lib.stattext.GenStaticText): + size = child.GetSize() + size[0] = width + #child.SetSize(size) + child.SetBestSize(size) + #child.GetContainingSizer().Layout() + #child.SetBackgroundColour('Green') + class TitleRow(): def __init__(self, panel, name): "Add a title row to the configuration panel" @@ -150,6 +184,11 @@ class SettingRow(): self.ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnMouseExit) flag = wx.EXPAND + # Set the minimum size of control to something other than the humungous default + minSize = self.ctrl.GetMinSize() + minSize[0] = 50 + self.ctrl.SetMinSize(minSize) + sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=10) sizer.Add(self.ctrl, (x,y+1), flag=wx.ALIGN_BOTTOM|flag) sizer.SetRows(x+1) diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 9c92c5f9..37b45a3f 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -209,7 +209,7 @@ class mainWindow(wx.Frame): sizer.Add(loadButton4, (1,4), flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=5) sizer.Add(sliceButton, (1,1+self.extruderCount), flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=5) sizer.Add(printButton, (1,2+self.extruderCount), flag=wx.RIGHT|wx.BOTTOM|wx.TOP, border=5) - + # Main window sizer sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) @@ -265,16 +265,13 @@ class mainWindow(wx.Frame): self.normalSettingsPanel.Show(not isSimple) self.simpleSettingsPanel.Show(isSimple) + self.leftPane.Layout() for i in self.normalModeOnlyItems: i.Enable(not isSimple) self.switchToQuickprintMenuItem.Enable(not isSimple) self.switchToNormalMenuItem.Enable(isSimple) - self.normalSettingsPanel.Layout() - self.simpleSettingsPanel.Layout() - self.leftPane.GetSizer().Layout() - # Set splitter sash position & size if isSimple: # Save normal mode sash @@ -291,7 +288,7 @@ class mainWindow(wx.Frame): # Enabled sash self.splitter.SetSashSize(4) - + def OnPreferences(self, e): prefDialog = preferencesDialog.preferencesDialog(self) prefDialog.Centre() @@ -563,12 +560,11 @@ class normalSettingsPanel(configBase.configPanelBase): super(normalSettingsPanel, self).__init__(parent) #Main tabs - nb = wx.Notebook(self) - self.SetSizer(wx.BoxSizer(wx.VERTICAL)) - self.GetSizer().Add(nb, 1, wx.EXPAND) + self.nb = wx.Notebook(self) + self.SetSizer(wx.BoxSizer(wx.HORIZONTAL)) + self.GetSizer().Add(self.nb, 1, wx.EXPAND) - (left) = self.CreateSimpleConfigTab(nb, 'Print config') - right = left + (left, right, self.printPanel) = self.CreateDynamicConfigTab(self.nb, 'Print config') configBase.TitleRow(left, "Quality") c = configBase.SettingRow(left, "Layer height (mm)", 'layer_height', '0.2', 'Layer height in millimeters.\n0.2 is a good value for quick prints.\n0.1 gives high quality prints.') @@ -612,8 +608,13 @@ class normalSettingsPanel(configBase.configPanelBase): c = configBase.SettingRow(right, "Packing Density", 'filament_density', '1.00', 'Packing density of your filament. This should be 1.00 for PLA and 0.85 for ABS') validators.validFloat(c, 0.5, 1.5) - (left) = self.CreateSimpleConfigTab(nb, 'Advanced config') - right = left + leftWidth = self.getLabelColumnWidth(left) + rightWidth = self.getLabelColumnWidth(right) + maxWidth = max(leftWidth, rightWidth) + self.setLabelColumnWidth(left, maxWidth) + self.setLabelColumnWidth(right, maxWidth) + + (left, right, self.advancedPanel) = self.CreateDynamicConfigTab(self.nb, 'Advanced config') configBase.TitleRow(left, "Machine size") c = configBase.SettingRow(left, "Nozzle size (mm)", 'nozzle_size', '0.4', 'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.') @@ -656,16 +657,73 @@ class normalSettingsPanel(configBase.configPanelBase): c = configBase.SettingRow(right, "Duplicate outlines", 'enable_skin', False, 'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.') #Plugin page - self.pluginPanel = pluginPanel.pluginPanel(nb) + self.pluginPanel = pluginPanel.pluginPanel(self.nb) if len(self.pluginPanel.pluginList) > 0: - nb.AddPage(self.pluginPanel, "Plugins") + self.nb.AddPage(self.pluginPanel, "Plugins") else: self.pluginPanel.Show(False) #Alteration page - self.alterationPanel = alterationPanel.alterationPanel(nb) - nb.AddPage(self.alterationPanel, "Start/End-GCode") + self.alterationPanel = alterationPanel.alterationPanel(self.nb) + self.nb.AddPage(self.alterationPanel, "Start/End-GCode") + + self.Bind(wx.EVT_SIZE, self.OnSize) + def OnSize(self, e): + # Make the size of the Notebook control the same size as this control + self.nb.SetSize(self.GetSize()) + + # Propegate the OnSize() event (just in case) + e.Skip() + + # Perform out resize magic + self.UpdateSize(self.printPanel) + self.UpdateSize(self.advancedPanel) + + def UpdateSize(self, configPanel): + sizer = configPanel.GetSizer() + + # Pseudocde + # if horizontal: + # if width(col1) < best_width(col1) || width(col2) < best_width(col2): + # switch to vertical + # else: + # if width(col1) > (best_width(col1) + best_width(col1)): + # switch to horizontal + # + + col1 = configPanel.Children[0] + colSize1 = col1.GetSize() + colBestSize1 = col1.GetBestSize() + col2 = configPanel.Children[1] + colSize2 = col2.GetSize() + colBestSize2 = col2.GetBestSize() + + orientation = sizer.GetOrientation() + + if orientation == wx.HORIZONTAL: + if (colSize1[0] <= colBestSize1[0]) or (colSize2[0] <= colBestSize2[0]): + configPanel.Freeze() + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(configPanel.Children[0], flag=wx.EXPAND) + sizer.Add(configPanel.Children[1], flag=wx.EXPAND) + configPanel.SetSizer(sizer) + #sizer.Layout() + configPanel.Layout() + self.Layout() + configPanel.Thaw() + else: + if colSize1[0] > (colBestSize1[0] + colBestSize2[0]): + configPanel.Freeze() + sizer = wx.BoxSizer(wx.HORIZONTAL) + sizer.Add(configPanel.Children[0], proportion=1, border=35, flag=wx.EXPAND) + sizer.Add(configPanel.Children[1], proportion=1, flag=wx.EXPAND) + configPanel.SetSizer(sizer) + #sizer.Layout() + configPanel.Layout() + self.Layout() + configPanel.Thaw() + def updateProfileToControls(self): super(normalSettingsPanel, self).updateProfileToControls() self.alterationPanel.updateProfileToControls()