Author: axeld Date: 2011-08-21 18:24:19 +0200 (Sun, 21 Aug 2011) New Revision: 42663 Changeset: https://dev.haiku-os.org/changeset/42663 Ticket: https://dev.haiku-os.org/ticket/7937 Modified: haiku/trunk/src/preferences/time/AnalogClock.cpp haiku/trunk/src/preferences/time/AnalogClock.h Log: * Applied patch by hamish to fix layouting the clock. * This closes #7937, thanks! Modified: haiku/trunk/src/preferences/time/AnalogClock.cpp =================================================================== --- haiku/trunk/src/preferences/time/AnalogClock.cpp 2011-08-21 16:00:45 UTC (rev 42662) +++ haiku/trunk/src/preferences/time/AnalogClock.cpp 2011-08-21 16:24:19 UTC (rev 42663) @@ -98,7 +98,7 @@ BView::MouseDown(point); return; } - + if (InMinuteHand(point)) { fMinuteDragging = true; fDirty = true; @@ -124,7 +124,7 @@ BView::MouseUp(point); return; } - + if (fHourDragging || fMinuteDragging) { int32 hour, minute, second; GetTime(&hour, &minute, &second); @@ -160,7 +160,7 @@ void -TAnalogClock::FrameResized(float, float) +TAnalogClock::DoLayout() { BRect bounds = Bounds(); @@ -168,8 +168,7 @@ // (important when drawing with B_SUBPIXEL_PRECISE) fCenterX = floorf((bounds.left + bounds.right) / 2 + 0.5) + 0.5; fCenterY = floorf((bounds.top + bounds.bottom) / 2 + 0.5) + 0.5; - fRadius = floorf((MIN(bounds.Width(), bounds.Height()) / 2.0)) - 2.5; - fRadius -= 3; + fRadius = floorf((MIN(bounds.Width(), bounds.Height()) / 2.0)) - 5.5; } @@ -202,7 +201,7 @@ // don't set the time if the hands are in a drag action if (fHourDragging || fMinuteDragging || fTimeChangeIsOngoing) return; - + if (fHours == hour && fMinutes == minute && fSeconds == second) return; @@ -254,7 +253,7 @@ rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR); SetHighColor(background); FillRect(bounds); - + bounds.Set(fCenterX - fRadius, fCenterY - fRadius, fCenterX + fRadius, fCenterY + fRadius); @@ -459,7 +458,7 @@ offsetY = (radius * 0.95) * cosf((fSeconds * M_PI) / 30.0); StrokeLine(BPoint(x, y), BPoint(x + offsetX, y - offsetY)); } - + // draw the center knob SetHighColor(knobColor); FillEllipse(BPoint(x, y), radius * 0.06, radius * 0.06); Modified: haiku/trunk/src/preferences/time/AnalogClock.h =================================================================== --- haiku/trunk/src/preferences/time/AnalogClock.h 2011-08-21 16:00:45 UTC (rev 42662) +++ haiku/trunk/src/preferences/time/AnalogClock.h 2011-08-21 16:24:19 UTC (rev 42663) @@ -27,8 +27,8 @@ virtual void MouseUp(BPoint point); virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* message); - virtual void FrameResized(float, float); - + virtual void DoLayout(); + virtual BSize MaxSize(); virtual BSize MinSize(); virtual BSize PreferredSize(); @@ -60,7 +60,7 @@ int32 fMinutes; int32 fSeconds; bool fDirty; - + float fCenterX; float fCenterY; float fRadius; @@ -70,7 +70,7 @@ bool fDrawSecondHand; bool fInteractive; - bool fTimeChangeIsOngoing; + bool fTimeChangeIsOngoing; };