Action Item #569

PiClock updates

Added by Hammel over 3 years ago. Updated 10 months ago.

Status:ClosedStart date:09 Mar 2017
Priority:ImmediateDue date:
Assignee:Hammel% Done:

100%

Category:-
Target version:PiBox - 1.1.0 - Upgrades
Severity:05 - Very Low

Description

Now that I know more about scaling in Cairo I can do some needed updates to PiClock.

  1. Switch to gdk_pixbuf to load the image, thereby supporting more file types (see launcher: git diff -r c71a4a45 -r 7be3c7f6, in do_drawing())
  2. Use libpibox to get screen dimensions (same, but in createwindow() - see call to piboxGetDisplayWidth())
  3. Scale the images to fit the window using gdk_pixbuf scaling function (also in do_drawing())
  4. Look at this code to see how to create a shadow from an image. This can be used to draw shadows under the hands, though getting the light direction correct could be difficult.

The scaling will make the clock fit on any display.

Associated revisions

Revision c05d759a
Added by Hammel 10 months ago

RM #569: Switch to using GdkPixbuf for scaling images so analog clock will properly fit in to any display. Reduce font
size in test theme to match size of system theme so calendar fits better on small (RPi 7" touch) screens.

Revision c05d759a
Added by Hammel 10 months ago

RM #569: Switch to using GdkPixbuf for scaling images so analog clock will properly fit in to any display. Reduce font
size in test theme to match size of system theme so calendar fits better on small (RPi 7" touch) screens.

History

#1 Updated by Hammel over 3 years ago

  • Project changed from PiBox to piclock

#2 Updated by Hammel over 3 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Scaling process

  • Compute scaled percentage of face to fit it's drawing area the first time it is used.
  • Use percentage to scale hands and overlay the first time they are used.
  • Scale only once, then set flag to say scaling has been done.
  • Gen the cairo surface after the scaling has been done and save it.

Scaling should be done on the gdk_pixbuf and then the new pixbuf replaces the old one. The pixbuf is then used as a source for a cairo surface.

This will require moving the bottom half of loadtheme into the widget code, which is really where it belongs anyway.

#3 Updated by Hammel over 2 years ago

  • Severity changed from 02 - High to 05 - Very Low

#4 Updated by Hammel almost 2 years ago

  • Target version changed from 0.12.0 to 1.1.0 - Upgrades

#5 Updated by Hammel 10 months ago

  • Description updated (diff)

#6 Updated by Hammel 10 months ago

  • Status changed from In Progress to Closed
  • % Done changed from 10 to 100

This was a little easier than I expected. I didn't need to ask libpibox for dimensions since the analog clock is in a widget and I can get window sizes at realize time.

The only problem is that scaling the hands doesn't quite work because the x/y center offset (around which rotations are handled) doesn't quite work if scaled by the same amount. There is some squiggly math problem there that I didn't feel like digging into because the displays work on a standard monitor and the Pi touchscreen just fine.

Changes committed and pushed.

Closing issue.

Also available in: Atom PDF