Patch by Lucasz Zemczak which fixes font sensitiveness issues in Mouse

preflet. Thank you!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20659 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2007-04-11 21:06:35 +00:00
parent 2a17be44d7
commit 41d7b9a54c
3 changed files with 121 additions and 58 deletions

View File

@ -56,6 +56,7 @@ MouseWindow::MouseWindow(BRect _rect)
rect.OffsetBy(button->Bounds().Width() + kItemSpace, 0); rect.OffsetBy(button->Bounds().Width() + kItemSpace, 0);
fRevertButton = new BButton(rect, "revert", "Revert", new BMessage(kMsgRevert)); fRevertButton = new BButton(rect, "revert", "Revert", new BMessage(kMsgRevert));
fRevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
fRevertButton->ResizeToPreferred();
view->AddChild(fRevertButton); view->AddChild(fRevertButton);
SetPulseRate(100000); SetPulseRate(100000);
@ -72,10 +73,15 @@ MouseWindow::MouseWindow(BRect _rect)
rect.bottom -= 20; rect.bottom -= 20;
BPoint position = fSettings.WindowPosition(); BPoint position = fSettings.WindowPosition();
if (!rect.Contains(position)) { if (!rect.Contains(BRect(position,
Bounds().OffsetBySelf(position).RightBottom()))) {
// center window on screen as it doesn't fit on the saved position // center window on screen as it doesn't fit on the saved position
position.x = (rect.Width() - Bounds().Width()) / 2; position.x = (rect.Width() - Bounds().Width()) / 2;
position.y = (rect.Height() - Bounds().Height()) / 2; position.y = (rect.Height() - Bounds().Height()) / 2;
if (position.x < 0)
position.x = 0;
if (position.y < 0)
position.y = 15;
} }
MoveTo(position); MoveTo(position);
} }

View File

@ -71,16 +71,55 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
fTypeMenu->AddItem(new BMenuItem("3-Button", new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem("3-Button", new BMessage(kMsgMouseType)));
BMenuField *field = new BMenuField(BRect(7, 8, 155, 190), "mouse_type", "Mouse type:", fTypeMenu); BMenuField *field = new BMenuField(BRect(7, 8, 155, 190), "mouse_type", "Mouse type:", fTypeMenu);
field->ResizeToPreferred(); field->SetDivider(field->StringWidth(field->Label()) + kItemSpace);
field->SetAlignment(B_ALIGN_RIGHT); field->SetAlignment(B_ALIGN_RIGHT);
AddChild(field); AddChild(field);
fMouseView = new MouseView(BRect(7, 28, 155, 190), fSettings); BFont font = be_plain_font;
fMouseView->ResizeToPreferred(); float length = font.StringWidth("Mouse type: [3-Button]") + 20;
fMouseView->MoveBy((142 - fMouseView->Bounds().Width()) / 2, fLeftArea.Set(8, 7, length + 8, 198);
(108 - fMouseView->Bounds().Height()) / 2); if (fLeftArea.Width() < 125)
AddChild(fMouseView); fLeftArea.right = fLeftArea.left + 125;
fRightArea.Set(fLeftArea.right + 10, 11, 200, 7);
// Create the "Double-click speed slider...
fClickSpeedSlider = new BSlider(fRightArea, "double_click_speed", "Double-click speed",
new BMessage(kMsgDoubleClickSpeed), 0, 1000);
fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fClickSpeedSlider->SetHashMarkCount(5);
fClickSpeedSlider->SetLimitLabels("Slow", "Fast");
AddChild(fClickSpeedSlider);
length = fClickSpeedSlider->Bounds().Height() + 6;
fDoubleClickBmpPoint.y = fRightArea.top +
(length - fDoubleClickBitmap->Bounds().Height()) / 2;
fRightArea.top += length;
// Create the "Mouse Speed" slider...
fMouseSpeedSlider = new BSlider(fRightArea, "mouse_speed", "Mouse Speed",
new BMessage(kMsgMouseSpeed), 0, 1000);
fMouseSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fMouseSpeedSlider->SetHashMarkCount(7);
fMouseSpeedSlider->SetLimitLabels("Slow", "Fast");
AddChild(fMouseSpeedSlider);
fSpeedBmpPoint.y = fRightArea.top +
(length - fSpeedBitmap->Bounds().Height()) / 2;
fRightArea.top += length;
// Create the "Mouse Acceleration" slider...
fAccelerationSlider = new BSlider(fRightArea, "mouse_acceleration", "Mouse Acceleration",
new BMessage(kMsgAccelerationFactor), 0, 1000);
fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fAccelerationSlider->SetHashMarkCount(5);
fAccelerationSlider->SetLimitLabels("Slow", "Fast");
AddChild(fAccelerationSlider);
fAccelerationBmpPoint.y = fRightArea.top +
(length - fAccelerationBitmap->Bounds().Height()) / 2;
fRightArea.top += length - 3;
// Add the "Focus follows mouse" pop up menu // Add the "Focus follows mouse" pop up menu
fFocusMenu = new BPopUpMenu("Disabled"); fFocusMenu = new BPopUpMenu("Disabled");
@ -95,48 +134,52 @@ SettingsView::SettingsView(BRect rect, MouseSettings &settings)
fFocusMenu->AddItem(new BMenuItem(focusLabels[i], message)); fFocusMenu->AddItem(new BMenuItem(focusLabels[i], message));
} }
BRect frame(165, 208, 440, 200); BRect frame(fRightArea.left, fRightArea.top + 10, fRightArea.left +
field = new BMenuField(frame, "ffm", "Focus follows mouse:", fFocusMenu); font.StringWidth("Focus follows mouse:") +
font.StringWidth(focusLabels[0]) + 30, 200);
field = new BMenuField(frame, "ffm", "Focus follows mouse:", fFocusMenu, true);
field->SetDivider(field->StringWidth(field->Label()) + kItemSpace); field->SetDivider(field->StringWidth(field->Label()) + kItemSpace);
field->SetAlignment(B_ALIGN_RIGHT); field->SetAlignment(B_ALIGN_RIGHT);
AddChild(field); AddChild(field);
// Create the "Double-click speed slider... // Finalize the areas
frame.Set(166, 11, 328, 50); fRightArea.bottom = fRightArea.top;
fClickSpeedSlider = new BSlider(frame, "double_click_speed", "Double-click speed", fRightArea.top = 11;
new BMessage(kMsgDoubleClickSpeed), 0, 1000); fRightArea.right = frame.right + 8;
fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); if (fRightArea.Width() < 200)
fClickSpeedSlider->SetHashMarkCount(5); fRightArea.right = fRightArea.left + 200;
fClickSpeedSlider->SetLimitLabels("Slow", "Fast"); fLeftArea.bottom = fRightArea.bottom;
AddChild(fClickSpeedSlider);
// Create the "Mouse Speed" slider... // Position mouse bitmaps
frame.Set(166,76,328,125); fDoubleClickBmpPoint.x = fRightArea.right - fDoubleClickBitmap->Bounds().right - 15;
fMouseSpeedSlider = new BSlider(frame, "mouse_speed", "Mouse Speed", fSpeedBmpPoint.x = fRightArea.right - fSpeedBitmap->Bounds().right - 15;
new BMessage(kMsgMouseSpeed), 0, 1000); fAccelerationBmpPoint.x = fRightArea.right - fAccelerationBitmap->Bounds().right - 15;
fMouseSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fMouseSpeedSlider->SetHashMarkCount(7);
fMouseSpeedSlider->SetLimitLabels("Slow", "Fast");
AddChild(fMouseSpeedSlider);
// Create the "Mouse Acceleration" slider... // Resize sliders to equal size
frame.Set(166, 141, 328, 190); length = fRightArea.left - 5;
fAccelerationSlider = new BSlider(frame, "mouse_acceleration", "Mouse Acceleration", fClickSpeedSlider->ResizeTo(fDoubleClickBmpPoint.x - length - 11,
new BMessage(kMsgAccelerationFactor), 0, 1000); fClickSpeedSlider->Bounds().Height());
fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fMouseSpeedSlider->ResizeTo(fSpeedBmpPoint.x - length,
fAccelerationSlider->SetHashMarkCount(5); fMouseSpeedSlider->Bounds().Height());
fAccelerationSlider->SetLimitLabels("Slow", "Fast"); fAccelerationSlider->ResizeTo(fAccelerationBmpPoint.x - length,
AddChild(fAccelerationSlider); fAccelerationSlider->Bounds().Height());
// Mouse image...
frame.Set(0, 0, 148, 162);
fMouseView = new MouseView(frame, fSettings);
fMouseView->ResizeToPreferred();
fMouseView->MoveBy((fLeftArea.right - fMouseView->Bounds().Width()) / 2,
(fLeftArea.bottom - fMouseView->Bounds().Height()) / 2);
AddChild(fMouseView);
// Create the "Double-click test area" text box... // Create the "Double-click test area" text box...
frame = Bounds(); frame.Set(fLeftArea.left, fLeftArea.bottom + 10, fLeftArea.right, 0);
frame.left = frame.left + 9;
frame.right = frame.right - 230;
frame.top = frame.bottom - 30;
BTextControl *textControl = new BTextControl(frame, "double_click_test_area", NULL, BTextControl *textControl = new BTextControl(frame, "double_click_test_area", NULL,
"Double-click test area", NULL); "Double-click test area", NULL);
textControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER); textControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);
AddChild(textControl); AddChild(textControl);
ResizeTo(fRightArea.right + 5, fLeftArea.bottom + 60);
} }
@ -158,11 +201,10 @@ SettingsView::AttachedToWindow()
void void
SettingsView::GetPreferredSize(float *_width, float *_height) SettingsView::GetPreferredSize(float *_width, float *_height)
{ {
// ToDo: fixed values for now
if (_width) if (_width)
*_width = 397 - 22; *_width = fRightArea.right + 5;
if (_height) if (_height)
*_height = 293 - 55; *_height = fLeftArea.bottom + 60;
} }
@ -173,36 +215,47 @@ SettingsView::Draw(BRect updateFrame)
SetHighColor(120, 120, 120); SetHighColor(120, 120, 120);
SetLowColor(255, 255, 255); SetLowColor(255, 255, 255);
// Line above the test area // Line above the test area
StrokeLine(BPoint(8, 198), BPoint(149, 198), B_SOLID_HIGH); fLeft = fLeftArea.LeftBottom();
StrokeLine(BPoint(8, 199), BPoint(149, 199), B_SOLID_LOW); fRight = fLeftArea.RightBottom();
StrokeLine(fLeft, fRight, B_SOLID_HIGH);
fLeft.y++; fRight.y++;
StrokeLine(fLeft, fRight, B_SOLID_LOW);
// Line above focus follows mouse // Line above focus follows mouse
StrokeLine(BPoint(164, 198), BPoint(367, 198), B_SOLID_HIGH); fLeft = fRightArea.LeftBottom();
StrokeLine(BPoint(164, 199), BPoint(367, 199), B_SOLID_LOW); fRight = fRightArea.RightBottom();
StrokeLine(fLeft, fRight, B_SOLID_HIGH);
fLeft.y++; fRight.y++;
StrokeLine(fLeft, fRight, B_SOLID_LOW);
// Line in the middle // Line in the middle
StrokeLine(BPoint(156, 10), BPoint(156, 230), B_SOLID_HIGH); fLeft = fLeftArea.RightTop();
StrokeLine(BPoint(157, 11), BPoint(157, 230), B_SOLID_LOW); fRight = fLeftArea.RightBottom();
fLeft.x += 5;
fRight.x += 5;
StrokeLine(fLeft, fRight, B_SOLID_HIGH);
fLeft.x++; fRight.x++;
StrokeLine(fLeft, fRight, B_SOLID_LOW);
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
// Draw the icons // Draw the icons
BPoint doubleClickBmpPoint(344, 16);
if (fDoubleClickBitmap != NULL if (fDoubleClickBitmap != NULL
&& updateFrame.Intersects(BRect(doubleClickBmpPoint, && updateFrame.Intersects(BRect(fDoubleClickBmpPoint,
doubleClickBmpPoint + fDoubleClickBitmap->Bounds().RightBottom()))) fDoubleClickBmpPoint + fDoubleClickBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fDoubleClickBitmap, doubleClickBmpPoint); DrawBitmapAsync(fDoubleClickBitmap, fDoubleClickBmpPoint);
BPoint speedBmpPoint(333, 90);
if (fSpeedBitmap != NULL if (fSpeedBitmap != NULL
&& updateFrame.Intersects(BRect(speedBmpPoint, && updateFrame.Intersects(BRect(fSpeedBmpPoint,
speedBmpPoint + fSpeedBitmap->Bounds().RightBottom()))) fSpeedBmpPoint + fSpeedBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fSpeedBitmap, speedBmpPoint); DrawBitmapAsync(fSpeedBitmap, fSpeedBmpPoint);
BPoint accelerationBmpPoint(333, 155);
if (fAccelerationBitmap != NULL if (fAccelerationBitmap != NULL
&& updateFrame.Intersects(BRect(accelerationBmpPoint, && updateFrame.Intersects(BRect(fAccelerationBmpPoint,
accelerationBmpPoint + fAccelerationBitmap->Bounds().RightBottom()))) fAccelerationBmpPoint + fAccelerationBitmap->Bounds().RightBottom())))
DrawBitmapAsync(fAccelerationBitmap, accelerationBmpPoint); DrawBitmapAsync(fAccelerationBitmap, fAccelerationBmpPoint);
SetDrawingMode(B_OP_COPY); SetDrawingMode(B_OP_COPY);

View File

@ -52,6 +52,10 @@ class SettingsView : public BBox {
BSlider *fClickSpeedSlider, *fMouseSpeedSlider, *fAccelerationSlider; BSlider *fClickSpeedSlider, *fMouseSpeedSlider, *fAccelerationSlider;
BBitmap *fDoubleClickBitmap, *fSpeedBitmap, *fAccelerationBitmap; BBitmap *fDoubleClickBitmap, *fSpeedBitmap, *fAccelerationBitmap;
BRect fLeftArea, fRightArea;
BPoint fLeft, fRight;
BPoint fDoubleClickBmpPoint, fSpeedBmpPoint, fAccelerationBmpPoint;
}; };
#endif /* SETTINGS_VIEW_H */ #endif /* SETTINGS_VIEW_H */