def HideThread(self): while True: blue.pyos.synchro.SleepWallclock(2000) if not uiutil.IsUnder(uicore.uilib.mouseOver, self): break self.AnimFadeOut()
def AnimSetActive(self, *args): self.state = uiconst.UI_PICKCHILDREN self.opacity = 1.0 self.AnimBlinkCornersIn(sleep=True) blue.synchro.SleepWallclock(2000) if not uiutil.IsUnder(uicore.uilib.mouseOver, self): self.AnimFadeOut()
def CheckPortraitMouseOver(self, portrait, *args): if uicore.uilib.mouseOver is portrait or uiutil.IsUnder( uicore.uilib.mouseOver, portrait): return portrait.sr.mouseOverTimer = None if portrait.hasPhoto: portrait.sr.button.state = uiconst.UI_HIDDEN
def UpdateTimer(self): startTime = self.GetTime() while self.doUpdates: timeNow = self.GetTime() if self.parentTimer.expiryTime is not None: timeLeft = max(0, self.parentTimer.expiryTime - timeNow) self.time.text = FmtTime(timeLeft) if timeLeft == 0: self.doUpdates = False if self.activeBlink is not None: self.activeBlink.Stop() self.time.opacity = 1.0 self.activeBlink = None else: self.time.text = FmtTime(self.timerData.maxTimeout) if self.activeBlink is None: self.activeBlink = uicore.animations.BlinkOut( self.time, duration=1.0, loops=uiconst.ANIM_REPEAT) if startTime + const.SEC < timeNow: if not (uicore.uilib.mouseOver is self or uiutil.IsUnder( uicore.uilib.mouseOver, self.parentTimer)): self.doUpdates = False if self.doUpdates: blue.pyos.synchro.SleepWallclock(200) uicore.animations.FadeOut(self, sleep=True) self.Close()
def OnGlobalClick(self, fromwhere, *etc): if self.colorpar: if uicore.uilib.mouseOver == self.colorpar or uiutil.IsUnder(fromwhere, self.colorpar): log.LogInfo('ColorPreview.OnGlobalClick Ignoring all clicks from colorpar') return 1 self.Cleanup() return 0
def FindFocus(self, browse=0): modal = self.GetModalWindow() if modal: active = modal else: active = self.GetActive() focus = self.GetFocus() if active is None: active = uicore.desktop if focus and hasattr(focus, 'CheckFocusChange'): usedFocusChange = focus.CheckFocusChange(browse) if usedFocusChange: return if focus and uiutil.IsUnder( focus, active) and uiutil.IsVisible(focus) and not browse: uthread.new(self.SetFocus, focus) return tabstops = [] if active: current, tabstops = self.CrawlForTabstops(active) if browse and len(tabstops) > 1: current = current or focus idx = 0 if current in tabstops: idx = browse + tabstops.index(current) if idx < 0: idx = len(tabstops) - 1 elif idx >= len(tabstops): idx = 0 self.SetFocus(tabstops[idx]) return if len(tabstops) and focus != tabstops[0]: self.SetFocus(tabstops[0]) return
def AutoHideThread(self): mouseNotOverTime = blue.os.GetTime() while not self.destroyed: blue.pyos.synchro.Sleep(50) if not self or self.destroyed: return if not self.IsAutoHideActive(): return mo = uicore.uilib.mouseOver if mo == self or uiutil.IsUnder(mo, self): mouseNotOverTime = blue.os.GetTime() continue if sm.GetService( 'neocom').IsSomePanelOpen() or self.isResizingNeocom: mouseNotOverTime = blue.os.GetTime() continue if uicore.layer.menu.children: mouseNotOverTime = blue.os.GetTime() continue if sm.GetService('neocom').IsDraggingButtons(): mouseNotOverTime = blue.os.GetTime() continue if blue.os.GetTime() - mouseNotOverTime > const.SEC: self.HideNeocom() return
def UpdateSoftSliderPortion(self, *args): if uicore.uilib.mouseOver is self or uiutil.IsUnder(uicore.uilib.mouseOver, self): l, t, w, h = self.bitParent.GetAbsolute() portion = max(0.0, min(1.0, (uicore.uilib.x - l) / float(w))) self.ShowSoftLit(portion) else: self.sr.softSlideTimer = None self.ShowSoftLit(0.0)
def _EnforceLootableContainerRestrictions(self, *args): if not self or self.destroyed: return False isAccessRestricted = False if uicore.uilib.mouseOver in ( self, self.restrictedButton) or uiutil.IsUnder( uicore.uilib.mouseOver, self) or uiutil.IsUnder( uicore.uilib.mouseOver, self.restrictedButton): if not self.CheckCanTakeItems(self.invController.itemID): isAccessRestricted = True if isAccessRestricted: self.restrictedFrame.Show() self.restrictedButtonFill.Show() else: self.restrictedFrame.Hide() self.restrictedButtonFill.Hide() return True
def GetActiveStackOrWindow(self, *args): all = self.GetValidWindows() active = self.GetActive() if active: for each in all: if each is active: return each if uiutil.IsUnder(active, each): return each
def OnGlobalMouseDown(self, *args): if self.destroyed: return False for layer in (uicore.layer.utilmenu, uicore.layer.modal): if uiutil.IsUnder(uicore.uilib.mouseOver, layer): return True self.Close() return False
def Kill(self, time=10000): blue.pyos.synchro.SleepWallclock(time) if not self or self.destroyed: return if uicore.uilib.mouseOver == self or uiutil.IsUnder( uicore.uilib.mouseOver, self): self.shouldKill = True return self.CloseNotification()
def HideUtilButtons(self, force=0): mo = uicore.uilib.mouseOver if not force and (mo in self.utilButtons or mo == self or uiutil.IsUnder(mo, self)): return for button in self.utilButtons: button.color.a = 0.0 self.utilButtonsTimer = None
def Confirm(self, starter=None): if self._blockConfirm: self._blockConfirm = 0 return False if uicore.ime.IsVisible(): return focus = self.GetFocus() active = self.GetActive() modal = self.GetModalWindow() if modal: if focus and uiutil.IsUnder(focus, modal): if hasattr(focus, 'Confirm') and focus != starter: return uthread.new(focus.Confirm) if hasattr(modal, 'Confirm') and modal != starter: if not getattr(modal, 'blockconfirmonreturn', 0) or uicore.uilib.Key(uiconst.VK_CONTROL): modal.Confirm() return True else: result = self.GetModalResult(uiconst.ID_OK) modal.SetModalResult(result) return True return False if getattr(focus, 'Confirm', None) and focus != starter: uthread.new(focus.Confirm) return True if hasattr(active, 'IsCurrentDialog') and active.IsCurrentDialog(): active.SetModalResult(uiconst.ID_OK) return True if getattr(active, 'Confirm', None) and active != starter: uthread.new(active.Confirm) return True if focus and focus.HasEventHandler('OnClick'): uthread.new(focus.OnClick, focus) return True if focus: searchFrom = self.GetTopLevelWindowAboveItem(focus) else: searchFrom = uicore.desktop if searchFrom: wnds = [ w for w in searchFrom.Find('trinity.Tr2Sprite2dContainer') + searchFrom.Find('trinity.Tr2Sprite2d') if getattr(w, 'btn_default', 0) == 1 ] if len(wnds): for wnd in wnds: if starter and starter == wnd: continue if uiutil.IsVisible(wnd): if wnd.HasEventHandler('OnClick'): uthread.new(wnd.OnClick, wnd) return True return False
def _CheckIfStillHilited(self): if uiutil.IsUnder(uicore.uilib.mouseOver, self) or uicore.uilib.mouseOver is self: return uicore.animations.FadeOut(self.hilite, duration=0.3) self.hiliteTimer = None for each in (self.removeButton, self.acceptButton, self.rejectButton): if each is not None and each.display: uicore.animations.FadeTo(each, each.opacity, 0.0, duration=0.1, callback=self.HideButtons)
def OnMouseWheel(self, *etc): if getattr(self, 'wheeling', 0): return 1 if len(uicore.layer.menu.children): focus = uicore.registry.GetFocus() if focus and isinstance(focus, uicls.ScrollCore): if not uiutil.IsUnder(focus, uicore.layer.menu): return 1 self.wheeling = 1 self.Scroll(uicore.uilib.dz / 240.0) self.wheeling = 0 self.sr.scrollcontrols.AnimFade() return 1
def CheckMoveActiveState(self, topLevelLeaving=None): modal = self.GetModalWindow(topLevelLeaving) if modal: self.SetFocus(modal) else: if topLevelLeaving is None or topLevelLeaving == self.GetActive(): validWnds = self.GetValidWindows() if validWnds: sortedByIndex = uiutil.SortListOfTuples([ (vwnd.parent.children.index(vwnd), vwnd) for vwnd in validWnds if not getattr(vwnd, 'isImplanted', False) ]) if sortedByIndex: self.SetFocus(sortedByIndex[0]) return focus = self.GetFocus() if focus and topLevelLeaving: if uiutil.IsUnder(focus, topLevelLeaving): focus = None if focus is None: topLevels = [] def CrawlForTopLevelWindows(par): if self.IsTopLevelWindow(par): topLevels.append(par) for child in par.children: if hasattr( child, 'children') and child is not topLevelLeaving: CrawlForTopLevelWindows(child) CrawlForTopLevelWindows(uicore.desktop) if topLevels: for topLevel in topLevels: self.SetFocus(topLevel) focus = self.GetFocus() if focus and uiutil.IsUnder(focus, topLevel): break
def UpdateMyLocation(self): if not uiutil.IsUnder(self, uicore.desktop): return bp = sm.GetService('michelle').GetBallpark() if bp is None or self is None or self.destroyed: self.updatemylocationtimer = None return myball = bp.GetBall(eve.session.shipid) if myball is None: self.updatemylocationtimer = None return size = max(1, self.absoluteRight - self.absoluteLeft) if size == 1: size = max(1, self.absoluteRight - self.absoluteLeft) x = y = None if self.allowAbstract and settings.user.ui.Get('solarsystemmapabstract', 0): if not len(self.orbs): return x, y = self.GetAbstractPosition((myball.x, 0.0, myball.z), 1) elif self.sr.sizefactor is not None and self.sr.sizefactorsize is not None: maxdist = self.GetMaxDist() sizefactor = size / 2 / maxdist * self.fillSize x = FLIPMAP * myball.x * sizefactor / float(size) + 0.5 y = -(myball.z * sizefactor) / float(size) + 0.5 if x is not None and y is not None: self.imhere.sr.x = x self.imhere.sr.y = y self.imhere.state = uiconst.UI_DISABLED scene = sm.GetService('sceneManager').GetRegisteredScene('default') camera = sm.GetService('sceneManager').GetRegisteredCamera('default') if camera is None: return rot = geo2.QuaternionRotationGetYawPitchRoll(camera.rotationAroundParent) look = geo2.QuaternionRotationGetYawPitchRoll(camera.rotationOfInterest) if not self.fov: self.fov = Fov(parent=self.imhere) self.fov.SetRotation(rot[0] + look[0] - pi) actualfov = camera.fieldOfView * (uicore.desktop.width / float(uicore.desktop.height)) degfov = actualfov - pi / 2 self.fov.SetFovAngle(actualfov) if self.showingtempangle: if not self.tempAngleFov: self.tempAngleFov = Fov(parent=self.imhere, state=uiconst.UI_DISABLED, blendMode=trinity.TR2_SBM_ADDX2) self.tempAngleFov.SetColor((0.0, 0.3, 0.0, 1.0)) self.tempAngleFov.display = True self.tempAngleFov.SetRotation(rot[0] + look[0] - pi) angle = self.showingtempangle self.tempAngleFov.SetFovAngle(angle) elif self.tempAngleFov: self.tempAngleFov.display = False self.RefreshOverlays()
def UpdateTimer(self): startTime = self.GetTime() count = 0 while self.doUpdates: timeNow = self.GetTime() for child in self.engagementsContainer.mainCont.children[:]: child.SetTimer() if startTime + const.SEC < timeNow: if not (uicore.uilib.mouseOver is self or uiutil.IsUnder( uicore.uilib.mouseOver, self) or uiutil.IsUnder( uicore.uilib.mouseOver, self.parentTimer)): if count > 2: self.doUpdates = False else: count += 1 else: count = 0 if self.doUpdates: blue.pyos.synchro.SleepWallclock(200) uicore.animations.FadeOut(self, sleep=True) self.Close()
def CursorBlink(self): f = uicore.registry.GetFocus() if f is uicore.desktop or not trinity.app.IsActive(): if self.sr.textcursor: self.sr.textcursor.state = uiconst.UI_HIDDEN self.sr.cursortimer = None return if f and uiutil.IsUnder(self, f) and self.sr.node.cursorPos is not None and self.sr.textcursor is not None: self.sr.textcursor.state = [uiconst.UI_HIDDEN, uiconst.UI_DISABLED][self.sr.textcursor.state == uiconst.UI_HIDDEN] if self.sr.cursortimer is None: self.sr.cursortimer = base.AutoTimer(250, self.CursorBlink) else: self.sr.cursortimer = None self.sr.textcursor.state = uiconst.UI_HIDDEN
def _SetMarks(self, marks): if not uiutil.IsUnder(self, uicore.desktop): return for i in xrange(0, len(marks), 4): id = marks[i] hint = marks[i + 1] size = max(1, self.absoluteRight - self.absoluteLeft) x, y = self.GetCordsByKeyAsPortion(id, size) if x is None or y is None: return if self.sr.marks is None: self.sr.marks = uiprimitives.Container(name='marks', parent=self, align=uiconst.TOALL, pos=(0, 0, 0, 0), idx=0, state=uiconst.UI_DISABLED) mark = uiprimitives.Sprite(parent=self.sr.marks, name='area', left=x - mark.width / 2, top=y - mark.height / 2 + 1, width=128, height=128, state=uiconst.UI_PICKCHILDREN, texturePath='res:/UI/Texture/circle_full.png', color=(1.0, 1.0, 1.0, 0.21)) if hint: uicontrols.EveLabelMedium(text=hint, parent=self.sr.marks, left=mark.left + mark.width, top=mark.top + 2, width=min(128, max(64, size - mark.left - mark.width)), state=uiconst.UI_NORMAL)
def RefreshOverlays(self, update = 0): if not uiutil.IsUnder(self, uicore.desktop): return if self is None or self.destroyed or not uicore.uilib: return size = self.absoluteRight - self.absoluteLeft for each in self.sr.areas.children: if not hasattr(each, 'sr') or getattr(each.sr, 'x', None) is None and getattr(each.sr, 'y', None) is None: continue each.width = each.height = int(each.sr.rad * size * 2) each.left = int(getattr(each.sr, 'x', 0) * size) - each.width / 2 + 1 each.top = int(getattr(each.sr, 'y', 0) * size) - each.height / 2 + 1 for each in self.overlays.children: if not hasattr(each, 'sr') or getattr(each.sr, 'x', None) is None and getattr(each.sr, 'y', None) is None: continue each.left = int(getattr(each.sr, 'x', 0) * size) - each.width / 2 + 1 each.top = int(getattr(each.sr, 'y', 0) * size) - each.height / 2 + 1
def OnGlobalMouseHover(self, obj, *args): if uicore.IsDragging() and (obj == self or uiutil.IsUnder(obj, self.mainCont)): l, t, w, h = self.GetAbsolute() if self.verticalScrollBar.display and h > 0: fraction = self.dragHoverScrollSpeed / float(h) y = uicore.uilib.y - t if y <= self.dragHoverScrollAreaSize: self.ScrollMoveVertical(-fraction) self.verticalScrollBar.AnimFade() elif y > h - self.dragHoverScrollAreaSize: self.ScrollMoveVertical(fraction) self.verticalScrollBar.AnimFade() if self.horizontalScrollBar.display and w > 0: fraction = self.dragHoverScrollSpeed / float(w) x = uicore.uilib.x - l if x <= self.dragHoverScrollAreaSize: self.ScrollMoveHorizontal(-fraction) self.horizontalScrollBar.AnimFade() elif x > w - self.dragHoverScrollAreaSize: self.ScrollMoveHorizontal(fraction) self.horizontalScrollBar.AnimFade() return True
def _GetForm(self, format, parent, retfields=[], reqresult=[], errorcheck=None, tabpanels=[], tabgroup=[], refresh=[], wipe=1): if not uiutil.IsUnder(parent, uicore.desktop): log.LogTraceback( 'Form parent MUST be hooked on the desktop; it is impossible to know the real dimensions of stuff within otherwise.' ) self.retfields = retfields self.reqresult = reqresult self.errorcheck = errorcheck self.tabpanels = tabpanels self.tabgroup = tabgroup self.refresh = refresh if not isinstance(parent, FormWnd): log.LogTraceback( 'Incompatible formparent, please change it to xtriui.FormWnd') self.parent = parent self.parent.sr.panels = {} self.parent.sr.focus = None if wipe: self.retfields = [] self.reqresult = [] self.tabpanels = [] self.tabgroup = [] self.refresh = [] for each in format: self.type = each typeName = self.type['type'] self.leftPush = self.type.get('labelwidth', 0) or 80 self.code = None if typeName == 'errorcheck': self.AddErrorcheck() continue elif typeName == 'data': self.AddData() continue elif typeName == 'tab': self.AddTab() continue elif typeName in ('btline', 'bbline'): self.AddLine() continue elif typeName == 'push': self.AddPush() elif typeName == 'header': self.AddHeader() elif typeName == 'labeltext': self.AddLabeltext() elif typeName == 'text': self.AddText() elif typeName == 'edit': self.AddEdit() elif typeName == 'textedit': self.AddTextedit() elif typeName == 'checkbox': self.AddCheckbox() elif typeName == 'combo': self.AddCombo() elif typeName == 'btnonly': self.AddBtnonly() else: log.LogWarn('Unknown fieldtype in form generator') continue if self.type.has_key('key'): if self.code: self.retfields.append([self.code, self.type]) self.parent.sr.Set(self.type['key'], self.code) else: self.parent.sr.Set(self.type['key'], self.new) if self.type.get('required', 0) == 1: self.reqresult.append([self.code, self.type]) if self.type.get('selectall', 0) == 1 and getattr( self.code, 'SelectAll', None): self.code.SelectAll() if self.type.get('setfocus', 0) == 1: self.parent.sr.focus = self.code if self.type.has_key('stopconfirm') and hasattr( self.code, 'stopconfirm'): self.code.stopconfirm = self.type['stopconfirm'] if self.type.get('frame', 0) == 1: idx = 0 for child in self.new.children: if child.name.startswith('Line'): idx += 1 uiprimitives.Container(name='leftpush', parent=self.new, align=uiconst.TOLEFT, width=6, idx=idx) uiprimitives.Container(name='rightpush', parent=self.new, align=uiconst.TORIGHT, width=6, idx=idx) uiprimitives.Line(parent=self.new, align=uiconst.TOLEFT, idx=idx) uiprimitives.Line(parent=self.new, align=uiconst.TORIGHT, idx=idx) if wipe and len(self.tabgroup): tabs = uicontrols.TabGroup(name='tabparent', parent=self.parent, idx=0) tabs.Startup(self.tabgroup, 'hybrid') maxheight = 0 for panel in self.tabpanels: maxheight = max(maxheight, panel.height) self.parent.height = maxheight + tabs.height else: if len(self.tabpanels): for each in self.tabpanels: each.state = uiconst.UI_HIDDEN self.tabpanels[0].state = uiconst.UI_PICKCHILDREN uix.RefreshHeight(self.parent) uicore.registry.SetFocus(self) return (self.parent, self.retfields, self.reqresult, self.tabpanels, self.errorcheck, self.refresh)
def IsDraggingOverIcons(self): return uiutil.IsUnder(uicore.uilib.mouseOver, self.iconCont) or uicore.uilib.mouseOver == self.iconCont
def OnMouseExit(self, *args): if not uiutil.IsUnder(uicore.uilib.GetMouseOver(), self): self.headerButtons.display = False
def OnGlobalMouseUp(self, *args): if not uiutil.IsUnder(uicore.uilib.mouseOver, self): self.OnMouseExit()
def OnGlobalMouseUp(self, *args): """ This is needed for the bracket to disappear correctly if we click on a bracket, and release outside of it """ if not uiutil.IsUnder(uicore.uilib.mouseOver, self): self.OnMouseExit()
def UpdateSizes(self, absSize=None): if not self._inited: return if not (self.sr and self.sr.mytabs): return if self._resizing: return self._resizing = 1 if not uiutil.IsUnder(self, uicore.desktop): self._resizing = 0 return if absSize: mw, _ = absSize else: mw, _ = self.GetAbsoluteSize() if self.destroyed: return for tab in self.sr.mytabs: tab.UpdateTabSize() totalTabWidth = sum([each.sr.width for each in self.sr.mytabs]) totalSpace = mw - self.leftMargin - self.rightMargin needToShrink = max(0, totalTabWidth - totalSpace) totalShrunk = 0 allMin = 1 for each in self.sr.mytabs: portionOfFull = each.sr.width / float(totalTabWidth) each.portionOfFull = portionOfFull each.width = min( each.sr.width, max(self.minTabsize, each.sr.width - int(needToShrink * portionOfFull))) if each.width > self.minTabsize: allMin = 0 totalShrunk += each.sr.width - each.width needMore = max(0, needToShrink - totalShrunk) while needMore and not allMin: _allMin = 1 for each in self.sr.mytabs: if each.width > self.minTabsize and needMore > 0: each.width -= 1 needMore = max(0, needMore - 1) if each.width > self.minTabsize: _allMin = 0 allMin = _allMin allMin = 1 for each in self.sr.mytabs: if each.width != self.minTabsize: allMin = 0 if self.sr.tabsmenu: self.sr.tabsmenu.Close() self.sr.tabsmenu = None active = self.GetVisible(1) i = 0 i2 = 0 totalWidth = 0 totalVisible = 0 hidden = 0 countActive = None startHiddenIdx = None for each in self.sr.mytabs: if allMin and (hidden or totalWidth + each.width > totalSpace): if each == active: countActive = i2 each.state = uiconst.UI_HIDDEN if hidden == 0: startHiddenIdx = i hidden = 1 i2 += 1 else: each.state = uiconst.UI_NORMAL totalWidth += each.width totalVisible += 1 i += 1 if allMin: if countActive is not None and startHiddenIdx is not None: totalWidth = 0 totalVisible = 0 i = 0 for each in self.sr.mytabs: if i <= countActive: each.state = uiconst.UI_HIDDEN elif startHiddenIdx <= i <= startHiddenIdx + countActive: each.state = uiconst.UI_NORMAL if each.state == uiconst.UI_NORMAL: totalWidth += each.width totalVisible += 1 i += 1 self.totalTabWidth = totalWidth totalVisibleWidth = self.leftMargin leftover = max(0, totalSpace - totalWidth) for each in self.sr.mytabs: if each.state == uiconst.UI_NORMAL: each.width = min( each.sr.width, max(self.minTabsize, each.width + leftover / totalVisible)) totalVisibleWidth += each.width if hidden: self.Prepare_Tabsmenu_() self.sr.tabsmenu.left = totalVisibleWidth self.sr.tabsmenu.state = uiconst.UI_NORMAL for tabgroup in self.sr.linkedrows: if tabgroup != self: tabgroup.UpdateSizes() self._resizing = 0
def OnUilibEvent(self, item, msgID, args): if msgID == uiconst.UI_MOUSEDOWN: if not uiutil.IsUnder(item, self.layer.menu): uiutil.Flush(self.layer.menu) self.registry.SetFocus(item)