コード例 #1
0
    def __startAppearing( self, msg ):
        xPos = graphics.getDesktopSize()[0]
        xPos -= MINI_WIND_SIZE[0]

        yPos = graphics.getDesktopSize()[1]
        # Move up for each visible message, including this one.
        numVisible = len( self.__visibleMessages ) + 1
        yPos -= ( MINI_WIND_SIZE[1] * numVisible )

        # TODO: Add this code back in at some point, when
        # the getStartBarRect() function (or some equivalent)
        # has been added.

        #taskBarPos, taskBarSize = graphics.getStartBarRect()
        #if taskBarPos[1] != 0:
        #    # Startbar is on bottom.
        #    yPos -= pixelsToPoints(taskBarSize[1])
        #if taskBarPos[0] > 0:
        #    # Startbar is on the right.
        #    xPos -= pixelsToPoints(taskBarSize[0])

        newWindow = MiniMessageWindow( msg, xPos, yPos )
        self.__visibleMessages.append( newWindow )
        self.__changingIndex = len(self.__visibleMessages) - 1
        self.__status = self.APPEARING
        self.__roundTopWindow()
コード例 #2
0
    def setPos(self, xPos, yPos):
        """
        Sets the current position of the window to xPos, yPos, which
        should be in points.
        """

        assert xPos <= graphics.getDesktopSize()[0]
        assert yPos <= graphics.getDesktopSize()[1]

        self.__currPos = xPos, yPos
        if self._wind != None:
            self._wind.setPosition(xPos, yPos)
コード例 #3
0
ファイル: windows.py プロジェクト: curaloucura/enso
    def setPos( self, xPos, yPos ):
        """
        Sets the current position of the window to xPos, yPos, which
        should be in points.
        """

        assert xPos <= graphics.getDesktopSize()[0]
        assert yPos <= graphics.getDesktopSize()[1]

        self.__currPos = xPos, yPos
        if self._wind != None:
            self._wind.setPosition( xPos, yPos )
コード例 #4
0
    def draw(self, document):
        """
        Draws the text described by document.

        An updating call; at the end of this method, the displayed
        window should reflect the drawn content.
        """
        if self.__width != graphics.getDesktopSize()[0]:
            del self.__window
            self.__setupWindow()

        width = document.ragWidth + layout.L_MARGIN + layout.R_MARGIN
        height = self.__window.getMaxHeight()
        cr = self.__context

        # Clear the areas where the corners of the rounded rectangle will be.

        cr.save()
        cr.set_source_rgba(0, 0, 0, 0)
        cr.set_operator(cairo.OPERATOR_SOURCE)
        cr.rectangle(width - rounded_rect.CORNER_RADIUS,
                     height - rounded_rect.CORNER_RADIUS,
                     rounded_rect.CORNER_RADIUS,
                     rounded_rect.CORNER_RADIUS)
        cr.rectangle(width - rounded_rect.CORNER_RADIUS,
                     0,
                     rounded_rect.CORNER_RADIUS,
                     rounded_rect.CORNER_RADIUS)
        cr.paint()

        # Draw the background rounded rectangle.
        corners = []
        if document.roundUpperRight:
            corners.append(rounded_rect.UPPER_RIGHT)
        if document.roundLowerRight:
            corners.append(rounded_rect.LOWER_RIGHT)
        if document.roundLowerLeft:
            corners.append(rounded_rect.LOWER_LEFT)

        cr.set_source_rgba(*document.background)
        rounded_rect.drawRoundedRect(context=cr,
                                     rect=(0, 0, width, height),
                                     softenedCorners=corners)
        cr.fill_preserve()
        cr.restore()

        # Next, draw the text.
        document.draw(layout.L_MARGIN,
                      document.shrinkOffset,
                      self.__context)

        width = min(self.__window.getMaxWidth(), width)
        height = min(self.__window.getMaxHeight(), height)

        self.__window.setSize(width, height)
        self.__window.update()
        self.__is_visible = True
コード例 #5
0
    def draw( self, document ):
        """
        Draws the text described by document.

        An updating call; at the end of this method, the displayed
        window should reflect the drawn content.
        """
        if self.__width != graphics.getDesktopSize()[0]:
            del self.__window
            self.__setupWindow()

        width = document.ragWidth + layout.L_MARGIN + layout.R_MARGIN
        height = self.__window.getMaxHeight()
        cr = self.__context

        # Clear the areas where the corners of the rounded rectangle will be.

        cr.save()
        cr.set_source_rgba( 0, 0, 0, 0 )
        cr.set_operator( cairo.OPERATOR_SOURCE )
        cr.rectangle( width - rounded_rect.CORNER_RADIUS,
                      height - rounded_rect.CORNER_RADIUS,
                      rounded_rect.CORNER_RADIUS,
                      rounded_rect.CORNER_RADIUS )
        cr.rectangle( width - rounded_rect.CORNER_RADIUS,
                      0,
                      rounded_rect.CORNER_RADIUS,
                      rounded_rect.CORNER_RADIUS )
        cr.paint()

        # Draw the background rounded rectangle.
        corners = []
        if document.roundUpperRight:
            corners.append( rounded_rect.UPPER_RIGHT )
        if document.roundLowerRight:
            corners.append( rounded_rect.LOWER_RIGHT )
        if document.roundLowerLeft:
            corners.append( rounded_rect.LOWER_LEFT )

        cr.set_source_rgba( *document.background )
        rounded_rect.drawRoundedRect( context = cr,
                                      rect = ( 0, 0, width, height ),
                                      softenedCorners = corners )
        cr.fill_preserve()
        cr.restore()

        # Next, draw the text.
        document.draw( layout.L_MARGIN,
                       document.shrinkOffset,
                       self.__context )

        width = min( self.__window.getMaxWidth(), width )
        height = min( self.__window.getMaxHeight(), height )

        self.__window.setSize( width, height )
        self.__window.update()
        self.__is_visible = True
コード例 #6
0
    def __init__(self, msgMan, eventManager):
        """
        Initializes the PrimaryMessage singleton
        """

        # Instantiate the underlying MessageWindow to the
        # maxsize suggested by the module constants.
        width = min(PRIM_MSG_WIDTH, graphics.getDesktopSize()[0] - 1)

        height = min(MAX_MSG_HEIGHT, graphics.getDesktopSize()[1] - 1)

        maxSize = (width, height)
        MessageWindow.__init__(self, maxSize)

        self.__evtManager = eventManager
        self.__msgManager = msgMan
        self.__msg = None
        self.__waiting = False
        self.__animating = False
コード例 #7
0
ファイル: primarywindow.py プロジェクト: curaloucura/enso
    def __init__( self, msgMan, eventManager ):
        """
        Initializes the PrimaryMessage singleton
        """

        # Instantiate the underlying MessageWindow to the
        # maxsize suggested by the module constants.
        width = min( PRIM_MSG_WIDTH,
                     graphics.getDesktopSize()[0]-1 )

        height = min( MAX_MSG_HEIGHT,
                      graphics.getDesktopSize()[1]-1 )

        maxSize = ( width, height )
        MessageWindow.__init__( self, maxSize )

        self.__evtManager = eventManager
        self.__msgManager = msgMan
        self.__msg = None
        self.__waiting = False
        self.__animating = False
コード例 #8
0
    def __position( self ):
        """
        Centers the message window horizontally using the current size.
        """
        
        desksize = graphics.getDesktopSize()

        xPos = ( desksize[0] - self.getSize()[0] ) / 2
        # Set the height based on the "maximum" height, so that the
        # message always appears at the same vertical offset from the
        # top of the screen.
        yPos = ( desksize[1] - self.getMaxSize()[1] ) / 2
        self.setPos( xPos, yPos )
コード例 #9
0
 def __setupWindow( self, height=None, position=None ):
     # Use the maximum width that we can, i.e., the desktop width.
     if height is not None:
         self.__height = height
     if position is not None:
         self.__xPos, self.__yPos = position
     self.__width, _ = graphics.getDesktopSize()
     left, top = graphics.getDesktopOffset()
     try:
         self.__window = TransparentWindow(self.__xPos + left, self.__yPos,
             self.__width, self.__height )
     except Exception, e:
         print e
コード例 #10
0
ファイル: linewindows.py プロジェクト: cwsquared/enso
    def __init__(self, height, position):
        """
        Creates the underlying TransparentWindow and Cairo context.

        Position and height should be in pixels.
        """

        # Use the maximum width that we can, i.e., the desktop width.
        width = graphics.getDesktopSize()[0]

        xPos, yPos = position
        self.__window = TransparentWindow(xPos, yPos, width, height)
        self.__context = self.__window.makeCairoContext()
コード例 #11
0
ファイル: linewindows.py プロジェクト: jparris/enso
    def __init__(self, height, position):
        """
        Creates the underlying TransparentWindow and Cairo context.

        Position and height should be in pixels.
        """

        # Use the maximum width that we can, i.e., the desktop width.
        width = graphics.getDesktopSize()[0]

        xPos, yPos = position
        self.__window = TransparentWindow(xPos, yPos, width, height)
        self.__context = self.__window.makeCairoContext()
コード例 #12
0
 def __setupWindow(self, height=None, position=None):
     # Use the maximum width that we can, i.e., the desktop width.
     if height is not None:
         self.__height = height
     if position is not None:
         self.__xPos, self.__yPos = position
     self.__width, _ = graphics.getDesktopSize()
     left, top = graphics.getDesktopOffset()
     try:
         self.__window = TransparentWindow(self.__xPos + left, self.__yPos,
                                           self.__width, self.__height)
     except Exception as e:
         logging.error(e)
     self.__context = self.__window.makeCairoContext()
     self.__is_visible = True
コード例 #13
0
ファイル: layout.py プロジェクト: cwsquared/enso
def _updateStyleSizes( styles, size ):
    """
    Updates all size-related style elements to those suggested
    when the font is of 'size' points.

    styles should be a style registry.
    """

    width = graphics.getDesktopSize()[0]
    styles.update(
        "document",
        font_size = "%fpt" % size,
        width = "%fpt" % width,
        margin_top = "%fpt" % (TOP_MARGIN_FACTOR * size),
        margin_bottom = "%fpt" % (BOTTOM_MARGIN_FACTOR *size),
        line_height = "%fpt" % size,
        )
コード例 #14
0
def _updateStyleSizes(styles, size):
    """
    Updates all size-related style elements to those suggested
    when the font is of 'size' points.

    styles should be a style registry.
    """

    styles.update(
        "document",
        font_size="%fpt" % size,
        # NOTE: getDesktopSize() is cached value, updated only on
        # quasimodeStart event
        width="%fpt" % graphics.getDesktopSize()[0],
        margin_top="%fpt" % (TOP_MARGIN_FACTOR * size),
        margin_bottom="%fpt" % (BOTTOM_MARGIN_FACTOR * size),
        line_height="%fpt" % size,
    )
コード例 #15
0
    def __init__(self, height, position):
        """
        Creates the underlying TransparentWindow and Cairo context.

        Position and height should be in pixels.
        """

        # Use the maximum width that we can, i.e., the desktop width.
        desk_width, desk_height = graphics.getDesktopSize()
        desk_left, desk_top = graphics.getDesktopOffset()

        xPos, yPos = position
        if yPos + height > desk_height:
            pass
        self.__window = TransparentWindow(
            xPos + desk_left, yPos + desk_top, desk_width, desk_height - desk_top - yPos)
        self.__context = self.__window.makeCairoContext()
        self.__is_visible = False
        self.__animatingShow = False
        self.__animatingHide = False
        self.__timeSinceDismissal = 0
        self.__evtManager = EventManager.get()