def __init__(self, ctx=None): if not ctx: import gui ctx = gui.ctx() assert ctx, "no gui context" self.ctx = ctx ctx.curSelectedSong_updateEvent.register(self._updateHandler)
def setupSongEditWindow(): from SongEdit import SongEdit import gui ctx = gui.ctx() if not getattr(ctx, "songEdit", None): ctx.songEdit = SongEdit(ctx) setupWindow(ctx.songEdit, windowName="songEditWindow", title="Song edit")
def select(self, index=None): self.deselect() if index is None: if len(control.guiObjectList) == 0: return index = 0 self.index = index guiObj = control.guiObjectList[index].nativeGuiObject guiObj.setBackgroundColor_( NSColor.selectedTextBackgroundColor()) # special handling for gui.ctx().curSelectedSong if control.guiObjectList[ index].subjectObject.__class__.__name__ == "Song": import gui gui.ctx().curSelectedSong = control.guiObjectList[ index].subjectObject def doScrollUpdate(): if not guiObj.window(): return # window closed or removed from window in the meantime objFrame = guiObj.frame() visibleFrame = scrollview.contentView( ).documentVisibleRect() if objFrame.origin.y < visibleFrame.origin.y: scrollview.contentView().scrollToPoint_( (0, objFrame.origin.y)) elif objFrame.origin.y + objFrame.size.height > visibleFrame.origin.y + visibleFrame.size.height: scrollview.contentView().scrollToPoint_( (0, objFrame.origin.y + objFrame.size.height - scrollview.contentSize().height)) scrollview.reflectScrolledClipView_( scrollview.contentView()) do_in_mainthread(doScrollUpdate, wait=False)
def onMouseDown(ev): subjectObj = control.subjectObject # special handling for gui.ctx().curSelectedSong if subjectObj.__class__.__name__ == "Song": import gui gui.ctx().curSelectedSong = subjectObj
def select(self, index=None): self.deselect() if index is None: if len(control.guiObjectList) == 0: return index = 0 self.index = index guiObj = control.guiObjectList[index].nativeGuiObject guiObj.setBackgroundColor_(NSColor.selectedTextBackgroundColor()) # special handling for gui.ctx().curSelectedSong if control.guiObjectList[index].subjectObject.__class__.__name__ == "Song": import gui gui.ctx().curSelectedSong = control.guiObjectList[index].subjectObject def doScrollUpdate(): if not guiObj.window(): return # window closed or removed from window in the meantime objFrame = guiObj.frame() visibleFrame = scrollview.contentView().documentVisibleRect() if objFrame.origin.y < visibleFrame.origin.y: scrollview.contentView().scrollToPoint_((0, objFrame.origin.y)) elif objFrame.origin.y + objFrame.size.height > visibleFrame.origin.y + visibleFrame.size.height: scrollview.contentView().scrollToPoint_( (0, objFrame.origin.y + objFrame.size.height - scrollview.contentSize().height) ) scrollview.reflectScrolledClipView_(scrollview.contentView()) do_in_mainthread(doScrollUpdate, wait=False)