* Applied patch by hamish to fix layouting the clock.
* This closes #7937, thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42663 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -98,7 +98,7 @@ TAnalogClock::MouseDown(BPoint point)
|
|||||||
BView::MouseDown(point);
|
BView::MouseDown(point);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InMinuteHand(point)) {
|
if (InMinuteHand(point)) {
|
||||||
fMinuteDragging = true;
|
fMinuteDragging = true;
|
||||||
fDirty = true;
|
fDirty = true;
|
||||||
@@ -124,7 +124,7 @@ TAnalogClock::MouseUp(BPoint point)
|
|||||||
BView::MouseUp(point);
|
BView::MouseUp(point);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fHourDragging || fMinuteDragging) {
|
if (fHourDragging || fMinuteDragging) {
|
||||||
int32 hour, minute, second;
|
int32 hour, minute, second;
|
||||||
GetTime(&hour, &minute, &second);
|
GetTime(&hour, &minute, &second);
|
||||||
@@ -160,7 +160,7 @@ TAnalogClock::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TAnalogClock::FrameResized(float, float)
|
TAnalogClock::DoLayout()
|
||||||
{
|
{
|
||||||
BRect bounds = Bounds();
|
BRect bounds = Bounds();
|
||||||
|
|
||||||
@@ -168,8 +168,7 @@ TAnalogClock::FrameResized(float, float)
|
|||||||
// (important when drawing with B_SUBPIXEL_PRECISE)
|
// (important when drawing with B_SUBPIXEL_PRECISE)
|
||||||
fCenterX = floorf((bounds.left + bounds.right) / 2 + 0.5) + 0.5;
|
fCenterX = floorf((bounds.left + bounds.right) / 2 + 0.5) + 0.5;
|
||||||
fCenterY = floorf((bounds.top + bounds.bottom) / 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 = floorf((MIN(bounds.Width(), bounds.Height()) / 2.0)) - 5.5;
|
||||||
fRadius -= 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -202,7 +201,7 @@ TAnalogClock::SetTime(int32 hour, int32 minute, int32 second)
|
|||||||
// don't set the time if the hands are in a drag action
|
// don't set the time if the hands are in a drag action
|
||||||
if (fHourDragging || fMinuteDragging || fTimeChangeIsOngoing)
|
if (fHourDragging || fMinuteDragging || fTimeChangeIsOngoing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fHours == hour && fMinutes == minute && fSeconds == second)
|
if (fHours == hour && fMinutes == minute && fSeconds == second)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -254,7 +253,7 @@ TAnalogClock::DrawClock()
|
|||||||
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
SetHighColor(background);
|
SetHighColor(background);
|
||||||
FillRect(bounds);
|
FillRect(bounds);
|
||||||
|
|
||||||
bounds.Set(fCenterX - fRadius, fCenterY - fRadius,
|
bounds.Set(fCenterX - fRadius, fCenterY - fRadius,
|
||||||
fCenterX + fRadius, fCenterY + fRadius);
|
fCenterX + fRadius, fCenterY + fRadius);
|
||||||
|
|
||||||
@@ -459,7 +458,7 @@ TAnalogClock::_DrawHands(float x, float y, float radius,
|
|||||||
offsetY = (radius * 0.95) * cosf((fSeconds * M_PI) / 30.0);
|
offsetY = (radius * 0.95) * cosf((fSeconds * M_PI) / 30.0);
|
||||||
StrokeLine(BPoint(x, y), BPoint(x + offsetX, y - offsetY));
|
StrokeLine(BPoint(x, y), BPoint(x + offsetX, y - offsetY));
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the center knob
|
// draw the center knob
|
||||||
SetHighColor(knobColor);
|
SetHighColor(knobColor);
|
||||||
FillEllipse(BPoint(x, y), radius * 0.06, radius * 0.06);
|
FillEllipse(BPoint(x, y), radius * 0.06, radius * 0.06);
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ public:
|
|||||||
virtual void MouseUp(BPoint point);
|
virtual void MouseUp(BPoint point);
|
||||||
virtual void MouseMoved(BPoint point, uint32 transit,
|
virtual void MouseMoved(BPoint point, uint32 transit,
|
||||||
const BMessage* message);
|
const BMessage* message);
|
||||||
virtual void FrameResized(float, float);
|
virtual void DoLayout();
|
||||||
|
|
||||||
virtual BSize MaxSize();
|
virtual BSize MaxSize();
|
||||||
virtual BSize MinSize();
|
virtual BSize MinSize();
|
||||||
virtual BSize PreferredSize();
|
virtual BSize PreferredSize();
|
||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
int32 fMinutes;
|
int32 fMinutes;
|
||||||
int32 fSeconds;
|
int32 fSeconds;
|
||||||
bool fDirty;
|
bool fDirty;
|
||||||
|
|
||||||
float fCenterX;
|
float fCenterX;
|
||||||
float fCenterY;
|
float fCenterY;
|
||||||
float fRadius;
|
float fRadius;
|
||||||
@@ -70,7 +70,7 @@ private:
|
|||||||
bool fDrawSecondHand;
|
bool fDrawSecondHand;
|
||||||
bool fInteractive;
|
bool fInteractive;
|
||||||
|
|
||||||
bool fTimeChangeIsOngoing;
|
bool fTimeChangeIsOngoing;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user