def CreateSpriteObject(self, *args, **kwds):
        kwds['state'] = uiconst.UI_DISABLED
        sprite = Sprite(*args, **kwds)
        while not sprite.texture.atlasTexture or sprite.texture.atlasTexture.isLoading:
            blue.pyos.synchro.Sleep(1)

        sprite.width = sprite.texture.atlasTexture.width
        sprite.height = sprite.texture.atlasTexture.height
        return sprite
Esempio n. 2
0
    def CreateSpriteObject(self, *args, **kwds):
        kwds['state'] = uiconst.UI_DISABLED
        sprite = Sprite(*args, **kwds)
        while not sprite.texture.atlasTexture or sprite.texture.atlasTexture.isLoading:
            blue.pyos.synchro.Sleep(1)

        sprite.width = sprite.texture.atlasTexture.width
        sprite.height = sprite.texture.atlasTexture.height
        return sprite
    def AddBackground(self, where, s):
        for i, side in enumerate(['top', 'left', 'right', 'bottom']):
            if s['border-%s-width' % side]:
                align = [
                    uiconst.TOTOP, uiconst.TOLEFT, uiconst.TORIGHT,
                    uiconst.TOBOTTOM
                ][i]
                Line(parent=where,
                     align=align,
                     weight=s['border-%s-width' % side],
                     color=s['border-%s-color' % side],
                     idx=0)

        if s['background-image'] and where.sr.background:
            browser = GetBrowser(self)
            currentURL = None
            if browser:
                currentURL = browser.sr.currentURL
            texture, tWidth, tHeight = sm.GetService(
                'browserImage').GetTextureFromURL(
                    s['background-image'],
                    currentURL,
                    fromWhere='VirtualTable::AddBackground')
            pic = Sprite()
            pic.left = pic.top = 0
            pic.width = tWidth
            pic.height = tHeight
            pic.texture = texture
            row = Container(name='row',
                            align=uiconst.TOTOP,
                            pos=(0, 0, 0, tHeight),
                            clipChildren=1)
            if s['background-repeat'] in ('repeat', 'repeat-x'):
                for x in xrange(max(where.width / tWidth, 2) + 1):
                    row.children.append(pic.CopyTo())
                    pic.left += pic.width

            else:
                row.children.append(pic.CopyTo())
            if s['background-repeat'] in ('repeat', 'repeat-y'):
                for y in xrange(max(where.height / tHeight, 2) + 1):
                    row.height = min(where.height - tHeight * y, row.height)
                    where.sr.background.children.append(row.CopyTo())

            else:
                where.sr.background.children.append(row.CopyTo())
        if s['background-color']:
            Fill(parent=where, color=s['background-color'])
    def AddBackground(self, where, s):
        for i, side in enumerate(['top',
         'left',
         'right',
         'bottom']):
            if s['border-%s-width' % side]:
                align = [uiconst.TOTOP,
                 uiconst.TOLEFT,
                 uiconst.TORIGHT,
                 uiconst.TOBOTTOM][i]
                Line(parent=where, align=align, weight=s['border-%s-width' % side], color=s['border-%s-color' % side], idx=0)

        if s['background-image'] and where.sr.background:
            browser = GetBrowser(self)
            currentURL = None
            if browser:
                currentURL = browser.sr.currentURL
            texture, tWidth, tHeight = sm.GetService('browserImage').GetTextureFromURL(s['background-image'], currentURL, fromWhere='VirtualTable::AddBackground')
            pic = Sprite()
            pic.left = pic.top = 0
            pic.width = tWidth
            pic.height = tHeight
            pic.texture = texture
            row = Container(name='row', align=uiconst.TOTOP, pos=(0,
             0,
             0,
             tHeight), clipChildren=1)
            if s['background-repeat'] in ('repeat', 'repeat-x'):
                for x in xrange(max(where.width / tWidth, 2) + 1):
                    row.children.append(pic.CopyTo())
                    pic.left += pic.width

            else:
                row.children.append(pic.CopyTo())
            if s['background-repeat'] in ('repeat', 'repeat-y'):
                for y in xrange(max(where.height / tHeight, 2) + 1):
                    row.height = min(where.height - tHeight * y, row.height)
                    where.sr.background.children.append(row.CopyTo())

            else:
                where.sr.background.children.append(row.CopyTo())
        if s['background-color']:
            Fill(parent=where, color=s['background-color'])