From: daid Date: Fri, 4 May 2012 10:39:23 +0000 (+0200) Subject: Fixed bug where tooltip was still shown when pressing open/save button on project... X-Git-Tag: RC3~13^2~1^2~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=dc54135db5534c8b84b428a500ab4ce57bc9fc75;p=cura.git Fixed bug where tooltip was still shown when pressing open/save button on project planner. Added toolbar buttons for add/remove object in project planner. Added move up/down buttons to project planner. --- diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index 97b9bbc8..2095042f 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -61,6 +61,13 @@ class projectPlanner(wx.Frame): toolbarUtil.NormalButton(self.toolbar, self.OnQuit, 'exit.png', 'Close project planner') self.toolbar.Realize() + + self.toolbar2 = toolbarUtil.Toolbar(self) + toolbarUtil.NormalButton(self.toolbar2, self.OnAddModel, 'object-add.png', 'Add model') + toolbarUtil.NormalButton(self.toolbar2, self.OnRemModel, 'object-remove.png', 'Remove model') + toolbarUtil.NormalButton(self.toolbar2, self.OnMoveUp, 'move-up.png', 'Move model up in print list') + toolbarUtil.NormalButton(self.toolbar2, self.OnMoveDown, 'move-down.png', 'Move model down in print list') + self.toolbar2.Realize() sizer = wx.GridBagSizer(2,2) self.SetSizer(sizer) @@ -71,7 +78,8 @@ class projectPlanner(wx.Frame): self.sliceButton = wx.Button(self, -1, "Slice") self.autoPlaceButton = wx.Button(self, -1, "Auto Place") - sizer.Add(self.toolbar, (0,0), span=(1,3), flag=wx.EXPAND) + sizer.Add(self.toolbar, (0,0), span=(1,1), flag=wx.EXPAND) + sizer.Add(self.toolbar2, (0,1), span=(1,2), flag=wx.EXPAND) sizer.Add(self.preview, (1,0), span=(4,1), flag=wx.EXPAND) sizer.Add(self.listbox, (1,1), span=(1,2), flag=wx.EXPAND) sizer.Add(self.addButton, (2,1), span=(1,1)) @@ -169,6 +177,7 @@ class projectPlanner(wx.Frame): item.swapYZ = cp.get(section, 'swapYZ') == 'True' if cp.has_option(section, 'extruder'): item.extuder = int(cp.get(section, 'extruder'))-1 + self.updateModelTransform(item) i += 1 self.list.append(item) @@ -231,9 +240,36 @@ class projectPlanner(wx.Frame): elif len(self.list) > 0: self.listbox.SetSelection(len(self.list) - 1) self.selection = None - self.OnListSelect(None) self.preview.Refresh() + def OnMoveUp(self, e): + if self.selection == None: + return + i = self.listbox.GetSelection() + if i == 0: + return + self.list.remove(self.selection) + self.list.insert(i-1, self.selection) + self._updateListbox() + self.preview.Refresh() + + def OnMoveDown(self, e): + if self.selection == None: + return + i = self.listbox.GetSelection() + if i == len(self.list) - 1: + return + self.list.remove(self.selection) + self.list.insert(i+1, self.selection) + self._updateListbox() + self.preview.Refresh() + + def _updateListbox(self): + self.listbox.Clear() + for item in self.list: + self.listbox.AppendAndEnsureVisible(os.path.split(item.filename)[1]) + self.listbox.SetSelection(self.list.index(self.selection)) + def OnAutoPlace(self, e): bestAllowedSize = int(self.machineSize.y) bestArea = self._doAutoPlace(bestAllowedSize) diff --git a/Cura/gui/toolbarUtil.py b/Cura/gui/toolbarUtil.py index eba0a0b0..1ec088ef 100644 --- a/Cura/gui/toolbarUtil.py +++ b/Cura/gui/toolbarUtil.py @@ -180,6 +180,7 @@ class NormalButton(buttons.GenBitmapButton): super(NormalButton, self).__init__(parent, id, self.bitmap, size=size) self.helpText = helpText + self.callback = callback self.SetBezelWidth(1) self.SetUseFocusIndicator(False) @@ -187,10 +188,14 @@ class NormalButton(buttons.GenBitmapButton): self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) - self.Bind(wx.EVT_BUTTON, callback) + self.Bind(wx.EVT_BUTTON, self.OnButton) parent.AddControl(self) + def OnButton(self, event): + self.GetParent().OnPopupHide(event) + self.callback(event) + def OnMouseEnter(self, event): self.GetParent().OnPopupDisplay(event) event.Skip() diff --git a/Cura/images/move-down.png b/Cura/images/move-down.png new file mode 100644 index 00000000..5891219e Binary files /dev/null and b/Cura/images/move-down.png differ diff --git a/Cura/images/move-up.png b/Cura/images/move-up.png new file mode 100644 index 00000000..b3d9cef9 Binary files /dev/null and b/Cura/images/move-up.png differ diff --git a/Cura/images/object-add.png b/Cura/images/object-add.png new file mode 100644 index 00000000..1b362dab Binary files /dev/null and b/Cura/images/object-add.png differ diff --git a/Cura/images/object-remove.png b/Cura/images/object-remove.png new file mode 100644 index 00000000..064e523c Binary files /dev/null and b/Cura/images/object-remove.png differ