X-Git-Url: http://git.maemo.org/git/?p=watersofshiloah;a=blobdiff_plain;f=src%2Fpresenter.py;h=45df0793e45959e7448e1eac4519d68b1e6676a7;hp=9f336a11587cd31e024c9bbdccaedb455c178059;hb=b1e464affa3d62cd135faf66b8ba3a8edeead743;hpb=e713a0eebcc255c16bb8d1728368940bdac6f8d3 diff --git a/src/presenter.py b/src/presenter.py index 9f336a1..45df079 100644 --- a/src/presenter.py +++ b/src/presenter.py @@ -2,7 +2,6 @@ import logging import gobject import pango -import cairo import gtk import util.misc as misc_utils @@ -59,16 +58,10 @@ class NavigationBox(gobject.GObject): if self._clickPosition == self._NO_POSITION: return "" - if self._isPortrait: - delta = ( - newCoord[0] - self._clickPosition[0], - - (newCoord[1] - self._clickPosition[1]) - ) - else: - delta = ( - newCoord[1] - self._clickPosition[1], - - (newCoord[0] - self._clickPosition[0]) - ) + delta = ( + newCoord[0] - self._clickPosition[0], + - (newCoord[1] - self._clickPosition[1]) + ) absDelta = (abs(delta[0]), abs(delta[1])) if max(*absDelta) < self.MINIMUM_MOVEMENT: return "clicking" @@ -160,12 +153,8 @@ class StreamPresenter(object): self._title = title self._subtitle = subtitle - if self._isPortrait: - backWidth = self._backgroundImage.get_width() - backHeight = self._backgroundImage.get_height() - else: - backHeight = self._backgroundImage.get_width() - backWidth = self._backgroundImage.get_height() + backWidth = self._backgroundImage.get_width() + backHeight = self._backgroundImage.get_height() self._image.set_size_request(backWidth, backHeight) self._image.queue_draw() @@ -173,15 +162,11 @@ class StreamPresenter(object): @misc_utils.log_exception(_moduleLogger) def _on_expose(self, widget, event): cairoContext = self._image.window.cairo_create() - if not self._isPortrait: - cairoContext.transform(cairo.Matrix(0, 1, 1, 0, 0, 0)) self._draw_presenter(cairoContext) def _draw_presenter(self, cairoContext): rect = self._image.get_allocation() self._dims = rect.width, rect.height - startContent = 30, self._dims[1] - 125 - endContent = self._dims[0] - 30, self._dims[1] - 5 # Blank things cairoContext.rectangle( @@ -202,6 +187,25 @@ class StreamPresenter(object): ) cairoContext.paint() + pangoContext = self._image.create_pango_context() + + titleLayout = pango.Layout(pangoContext) + titleLayout.set_markup("%s" % self._subtitle) + textWidth, textHeight = titleLayout.get_pixel_size() + subtitleTextX = self._dims[0] / 2 - textWidth / 2 + subtitleTextY = self._dims[1] - textHeight - self._buttonImage.get_height() + 10 + + subtitleLayout = pango.Layout(pangoContext) + subtitleLayout.set_markup("%s" % self._title) + textWidth, textHeight = subtitleLayout.get_pixel_size() + textX = self._dims[0] / 2 - textWidth / 2 + textY = subtitleTextY - textHeight + + xPadding = min((self._dims[0] - textWidth) / 2 - 5, 5) + yPadding = 5 + startContent = xPadding, textY - yPadding + endContent = self._dims[0] - xPadding, self._dims[1] - yPadding + # Control background cairoContext.rectangle( startContent[0], @@ -214,24 +218,13 @@ class StreamPresenter(object): # title if self._title or self._subtitle: - pangoContext = self._image.create_pango_context() - textLayout = pango.Layout(pangoContext) - - textLayout.set_markup(self._subtitle) - textWidth, textHeight = textLayout.get_pixel_size() - subtitleTextX = self._dims[0] / 2 - textWidth / 2 - subtitleTextY = self._dims[1] - textHeight - self._buttonImage.get_height() + 10 cairoContext.move_to(subtitleTextX, subtitleTextY) cairoContext.set_source_rgb(0, 0, 0) - cairoContext.show_layout(textLayout) + cairoContext.show_layout(titleLayout) - textLayout.set_markup(self._title) - textWidth, textHeight = textLayout.get_pixel_size() - textX = self._dims[0] / 2 - textWidth / 2 - textY = subtitleTextY - textHeight cairoContext.move_to(textX, textY) cairoContext.set_source_rgb(0, 0, 0) - cairoContext.show_layout(textLayout) + cairoContext.show_layout(subtitleLayout) self._draw_state(cairoContext)