input preferences: Updates code according to Haiku guidelines

These are the changes using tool clang-format with argument --style=haiku and the changes that were not according to guidelines have been removed.

Change-Id: I2d34370e1e0a112da895001bd220bb82b7086e90
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3827
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Saloni
2021-04-06 20:17:29 +00:00
committed by Adrien Destugues
parent e1ae57ab9d
commit 02dabf4bd9
13 changed files with 216 additions and 221 deletions
+3 -2
View File
@@ -36,6 +36,7 @@ InputApplication::InputApplication()
window->Show(); window->Show();
} }
void void
InputApplication::MessageReceived(BMessage* message) InputApplication::MessageReceived(BMessage* message)
{ {
@@ -69,8 +70,8 @@ InputApplication::MessageReceived(BMessage* message)
fWindow->PostMessage(message); fWindow->PostMessage(message);
break; break;
} }
default: default:
BApplication::MessageReceived(message); BApplication::MessageReceived(message);
} }
}; };
+8 -7
View File
@@ -4,7 +4,7 @@
* *
* Author: * Author:
* Preetpal Kaur <[email protected]> * Preetpal Kaur <[email protected]>
*/ */
#include "InputDeviceView.h" #include "InputDeviceView.h"
@@ -86,13 +86,14 @@ struct DeviceListItemView::Renderer {
onto->SetDrawingMode(B_OP_COPY); onto->SetDrawingMode(B_OP_COPY);
BFont font = be_plain_font; BFont font = be_plain_font;
font_height fontInfo; font_height fontInfo;
font.GetHeight(&fontInfo); font.GetHeight(&fontInfo);
onto->SetFont(&font); onto->SetFont(&font);
onto->MovePenTo(point.x + 8, frame.top onto->MovePenTo(point.x + 8,
+ fontInfo.ascent + (frame.Height() frame.top + fontInfo.ascent
- ceilf(fontInfo.ascent + fontInfo.descent)) / 2.0f); + (frame.Height() - ceilf(fontInfo.ascent + fontInfo.descent))
/ 2.0f);
onto->DrawString(fTitle); onto->DrawString(fTitle);
onto->SetHighColor(highColor); onto->SetHighColor(highColor);
@@ -105,6 +106,7 @@ struct DeviceListItemView::Renderer {
width += be_plain_font->StringWidth(fTitle) + 16.0f; width += be_plain_font->StringWidth(fTitle) + 16.0f;
return width; return width;
} }
private: private:
BString fTitle; BString fTitle;
@@ -119,9 +121,8 @@ DeviceListItemView::Update(BView* owner, const BFont* font)
BListItem::Update(owner, font); BListItem::Update(owner, font);
float iconHeight = InputIcons::sBounds.Height() + 1; float iconHeight = InputIcons::sBounds.Height() + 1;
if ((Height() < iconHeight + kITEM_MARGIN * 2)) { if ((Height() < iconHeight + kITEM_MARGIN * 2))
SetHeight(iconHeight + kITEM_MARGIN * 2); SetHeight(iconHeight + kITEM_MARGIN * 2);
}
Renderer renderer; Renderer renderer;
renderer.SetTitle(Label()); renderer.SetTitle(Label());
+1 -2
View File
@@ -1,4 +1,4 @@
/* /*
* Copyright 2020, Haiku, Inc. All rights reserved. * Copyright 2020, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -64,7 +64,6 @@ InputIcons::_LoadBitmap(BResources* resources)
keyboardIcon = new BBitmap(sBounds, 0, B_RGBA32); keyboardIcon = new BBitmap(sBounds, 0, B_RGBA32);
BIconUtils::GetVectorIcon(keyboard, size, &keyboardIcon); BIconUtils::GetVectorIcon(keyboard, size, &keyboardIcon);
} }
} }
+15 -13
View File
@@ -25,6 +25,7 @@
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "InputKeyboard" #define B_TRANSLATION_CONTEXT "InputKeyboard"
InputKeyboard::InputKeyboard(BInputDevice* dev) InputKeyboard::InputKeyboard(BInputDevice* dev)
: :
BView("InputKeyboard", B_WILL_DRAW) BView("InputKeyboard", B_WILL_DRAW)
@@ -55,17 +56,18 @@ InputKeyboard::InputKeyboard(BInputDevice* dev)
.AddGlue() .AddGlue()
.End(); .End();
BSlider* slider = (BSlider* )FindView("key_repeat_rate"); BSlider* slider = (BSlider*)FindView("key_repeat_rate");
if (slider !=NULL) if (slider != NULL)
slider->SetValue(fSettings.KeyboardRepeatRate()); slider->SetValue(fSettings.KeyboardRepeatRate());
slider = (BSlider* )FindView("delay_until_key_repeat"); slider = (BSlider*)FindView("delay_until_key_repeat");
if (slider !=NULL) if (slider != NULL)
slider->SetValue(fSettings.KeyboardRepeatDelay()); slider->SetValue(fSettings.KeyboardRepeatDelay());
fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
} }
void void
InputKeyboard::MessageReceived(BMessage* message) InputKeyboard::MessageReceived(BMessage* message)
{ {
@@ -76,12 +78,12 @@ InputKeyboard::MessageReceived(BMessage* message)
{ {
fSettings.Defaults(); fSettings.Defaults();
slider = (BSlider* )FindView("key_repeat_rate"); slider = (BSlider*)FindView("key_repeat_rate");
if (slider !=NULL) if (slider != NULL)
slider->SetValue(fSettings.KeyboardRepeatRate()); slider->SetValue(fSettings.KeyboardRepeatRate());
slider = (BSlider* )FindView("delay_until_key_repeat"); slider = (BSlider*)FindView("delay_until_key_repeat");
if (slider !=NULL) if (slider != NULL)
slider->SetValue(fSettings.KeyboardRepeatDelay()); slider->SetValue(fSettings.KeyboardRepeatDelay());
fDefaultsButton->SetEnabled(false); fDefaultsButton->SetEnabled(false);
@@ -93,12 +95,12 @@ InputKeyboard::MessageReceived(BMessage* message)
{ {
fSettings.Revert(); fSettings.Revert();
slider = (BSlider* )FindView("key_repeat_rate"); slider = (BSlider*)FindView("key_repeat_rate");
if (slider !=NULL) if (slider != NULL)
slider->SetValue(fSettings.KeyboardRepeatRate()); slider->SetValue(fSettings.KeyboardRepeatRate());
slider = (BSlider* )FindView("delay_until_key_repeat"); slider = (BSlider*)FindView("delay_until_key_repeat");
if (slider !=NULL) if (slider != NULL)
slider->SetValue(fSettings.KeyboardRepeatDelay()); slider->SetValue(fSettings.KeyboardRepeatDelay());
fDefaultsButton->SetEnabled(fSettings.IsDefaultable()); fDefaultsButton->SetEnabled(fSettings.IsDefaultable());
@@ -138,7 +140,7 @@ InputKeyboard::MessageReceived(BMessage* message)
fSettings.SetKeyboardRepeatDelay(delay); fSettings.SetKeyboardRepeatDelay(delay);
slider = (BSlider* )FindView("delay_until_key_repeat"); slider = (BSlider*)FindView("delay_until_key_repeat");
if (slider != NULL) if (slider != NULL)
slider->SetValue(delay); slider->SetValue(delay);
+21 -17
View File
@@ -14,16 +14,16 @@
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h> #include <Catalog.h>
#include <CheckBox.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <Debug.h> #include <Debug.h>
#include <CheckBox.h> #include <LayoutBuilder.h>
#include <Locale.h>
#include <MenuField.h> #include <MenuField.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <LayoutBuilder.h>
#include <Locale.h>
#include <Slider.h>
#include <Screen.h> #include <Screen.h>
#include <Slider.h>
#include <StringView.h> #include <StringView.h>
#include <TabView.h> #include <TabView.h>
@@ -38,7 +38,8 @@
InputMouse::InputMouse(BInputDevice* dev, MouseSettings* settings) InputMouse::InputMouse(BInputDevice* dev, MouseSettings* settings)
: BView("InputMouse", B_WILL_DRAW) :
BView("InputMouse", B_WILL_DRAW)
{ {
fSettings = settings; fSettings = settings;
@@ -63,15 +64,18 @@ InputMouse::InputMouse(BInputDevice* dev, MouseSettings* settings)
.End(); .End();
} }
InputMouse::~InputMouse() InputMouse::~InputMouse()
{ {
} }
void void
InputMouse::MessageReceived(BMessage* message) InputMouse::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case kMsgDefaults: { case kMsgDefaults:
{
fSettings->Defaults(); fSettings->Defaults();
fSettingsView->UpdateFromSettings(); fSettingsView->UpdateFromSettings();
@@ -80,14 +84,14 @@ InputMouse::MessageReceived(BMessage* message)
break; break;
} }
case kMsgRevert: { case kMsgRevert:
{
fSettings->Revert(); fSettings->Revert();
fSettingsView->UpdateFromSettings(); fSettingsView->UpdateFromSettings();
fDefaultsButton->SetEnabled(fSettings->IsDefaultable()); fDefaultsButton->SetEnabled(fSettings->IsDefaultable());
fRevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
break; break;
} }
case kMsgMouseType: case kMsgMouseType:
@@ -120,8 +124,7 @@ InputMouse::MessageReceived(BMessage* message)
case kMsgFollowsMouseMode: case kMsgFollowsMouseMode:
{ {
int32 mode; int32 mode;
if (message->FindInt32("mode_focus_follows_mouse", &mode) if (message->FindInt32("mode_focus_follows_mouse", &mode) == B_OK) {
== B_OK) {
fSettings->SetFocusFollowsMouseMode( fSettings->SetFocusFollowsMouseMode(
(mode_focus_follows_mouse)mode); (mode_focus_follows_mouse)mode);
fDefaultsButton->SetEnabled(fSettings->IsDefaultable()); fDefaultsButton->SetEnabled(fSettings->IsDefaultable());
@@ -132,15 +135,16 @@ InputMouse::MessageReceived(BMessage* message)
case kMsgAcceptFirstClick: case kMsgAcceptFirstClick:
{ {
BHandler *handler; BHandler* handler;
if (message->FindPointer("source", if (message->FindPointer(
reinterpret_cast<void**>(&handler)) == B_OK) { "source", reinterpret_cast<void**>(&handler))
== B_OK) {
bool acceptFirstClick = true; bool acceptFirstClick = true;
BCheckBox *acceptFirstClickBox = BCheckBox* acceptFirstClickBox
dynamic_cast<BCheckBox*>(handler); = dynamic_cast<BCheckBox*>(handler);
if (acceptFirstClickBox) if (acceptFirstClickBox)
acceptFirstClick = acceptFirstClickBox->Value() acceptFirstClick
== B_CONTROL_ON; = acceptFirstClickBox->Value() == B_CONTROL_ON;
fSettings->SetAcceptFirstClick(acceptFirstClick); fSettings->SetAcceptFirstClick(acceptFirstClick);
fDefaultsButton->SetEnabled(fSettings->IsDefaultable()); fDefaultsButton->SetEnabled(fSettings->IsDefaultable());
fRevertButton->SetEnabled(fSettings->IsRevertable()); fRevertButton->SetEnabled(fSettings->IsRevertable());
+9 -10
View File
@@ -4,14 +4,14 @@
* *
* Author: * Author:
* Preetpal Kaur <[email protected]> * Preetpal Kaur <[email protected]>
*/ */
#include "InputTouchpadPref.h" #include "InputTouchpadPref.h"
#include <Entry.h> #include <Entry.h>
#include <FindDirectory.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h>
#include <List.h> #include <List.h>
#include <String.h> #include <String.h>
@@ -53,8 +53,8 @@ TouchpadPref::UpdateSettings()
{ {
BMessage msg; BMessage msg;
msg.AddBool("scroll_twofinger", fSettings.scroll_twofinger); msg.AddBool("scroll_twofinger", fSettings.scroll_twofinger);
msg.AddBool("scroll_twofinger_horizontal", msg.AddBool(
fSettings.scroll_twofinger_horizontal); "scroll_twofinger_horizontal", fSettings.scroll_twofinger_horizontal);
msg.AddFloat("scroll_rightrange", fSettings.scroll_rightrange); msg.AddFloat("scroll_rightrange", fSettings.scroll_rightrange);
msg.AddFloat("scroll_bottomrange", fSettings.scroll_bottomrange); msg.AddFloat("scroll_bottomrange", fSettings.scroll_bottomrange);
msg.AddInt16("scroll_xstepsize", fSettings.scroll_xstepsize); msg.AddInt16("scroll_xstepsize", fSettings.scroll_xstepsize);
@@ -75,7 +75,7 @@ TouchpadPref::Defaults()
status_t status_t
TouchpadPref::GetSettingsPath(BPath &path) TouchpadPref::GetSettingsPath(BPath& path)
{ {
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path); status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
if (status < B_OK) if (status < B_OK)
@@ -99,13 +99,12 @@ TouchpadPref::LoadSettings()
return status; return status;
if (settingsFile.Read(&fSettings, sizeof(touchpad_settings)) if (settingsFile.Read(&fSettings, sizeof(touchpad_settings))
!= sizeof(touchpad_settings)) { != sizeof(touchpad_settings)) {
LOG("failed to load settings\n"); LOG("failed to load settings\n");
return B_ERROR; return B_ERROR;
} }
if (settingsFile.Read(&fWindowPosition, sizeof(BPoint)) if (settingsFile.Read(&fWindowPosition, sizeof(BPoint)) != sizeof(BPoint)) {
!= sizeof(BPoint)) {
LOG("failed to load settings\n"); LOG("failed to load settings\n");
return B_ERROR; return B_ERROR;
} }
@@ -128,13 +127,13 @@ TouchpadPref::SaveSettings()
return status; return status;
if (settingsFile.Write(&fSettings, sizeof(touchpad_settings)) if (settingsFile.Write(&fSettings, sizeof(touchpad_settings))
!= sizeof(touchpad_settings)) { != sizeof(touchpad_settings)) {
LOG("can't save settings\n"); LOG("can't save settings\n");
return B_ERROR; return B_ERROR;
} }
if (settingsFile.Write(&fWindowPosition, sizeof(BPoint)) if (settingsFile.Write(&fWindowPosition, sizeof(BPoint))
!= sizeof(BPoint)) { != sizeof(BPoint)) {
LOG("can't save window position\n"); LOG("can't save window position\n");
return B_ERROR; return B_ERROR;
} }
+39 -45
View File
@@ -46,7 +46,7 @@ TouchpadView::TouchpadView(BRect frame)
{ {
fXTracking = false; fXTracking = false;
fYTracking = false; fYTracking = false;
fOffScreenView = NULL; fOffScreenView = NULL;
fOffScreenBitmap = NULL; fOffScreenBitmap = NULL;
fPrefRect = frame; fPrefRect = frame;
@@ -54,7 +54,6 @@ TouchpadView::TouchpadView(BRect frame)
fPadRect.InsetBy(10, 10); fPadRect.InsetBy(10, 10);
fXScrollRange = fPadRect.Width(); fXScrollRange = fPadRect.Width();
fYScrollRange = fPadRect.Height(); fYScrollRange = fPadRect.Height();
} }
@@ -103,10 +102,11 @@ TouchpadView::MouseUp(BPoint point)
if (GetRightScrollRatio() > kSoftScrollLimit if (GetRightScrollRatio() > kSoftScrollLimit
|| GetBottomScrollRatio() > kSoftScrollLimit) { || GetBottomScrollRatio() > kSoftScrollLimit) {
BAlert* alert = new BAlert(B_TRANSLATE("Please confirm"), BAlert* alert = new BAlert(B_TRANSLATE("Please confirm"),
B_TRANSLATE("The new scroll area is very large and may impede " B_TRANSLATE(
"The new scroll area is very large and may impede "
"normal mouse operation. Do you really want to change it?"), "normal mouse operation. Do you really want to change it?"),
B_TRANSLATE("OK"), B_TRANSLATE("Cancel"), B_TRANSLATE("OK"), B_TRANSLATE("Cancel"), NULL, B_WIDTH_AS_USUAL,
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_WARNING_ALERT);
alert->SetShortcut(1, B_ESCAPE); alert->SetShortcut(1, B_ESCAPE);
result = alert->Go(); result = alert->Go();
} }
@@ -185,7 +185,6 @@ TouchpadView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
} }
void void
TouchpadView::DrawSliders() TouchpadView::DrawSliders()
{ {
@@ -204,7 +203,7 @@ TouchpadView::DrawSliders()
// scroll areas // scroll areas
view->SetHighColor(145, 100, 100); view->SetHighColor(145, 100, 100);
BRect rightRect(fPadRect.left + fXScrollRange, fPadRect.top, BRect rightRect(fPadRect.left + fXScrollRange, fPadRect.top,
fPadRect.right, fPadRect.bottom); fPadRect.right, fPadRect.bottom);
view->FillRoundRect(rightRect, 4, 4); view->FillRoundRect(rightRect, 4, 4);
@@ -237,18 +236,17 @@ TouchpadView::DrawSliders()
// y scroll range line // y scroll range line
view->StrokeLine(BPoint(fPadRect.left, fPadRect.top + fYScrollRange), view->StrokeLine(BPoint(fPadRect.left, fPadRect.top + fYScrollRange),
BPoint(fPadRect.right, fPadRect.top + fYScrollRange)); BPoint(fPadRect.right, fPadRect.top + fYScrollRange));
fYScrollDragZone = BRect(fPadRect.left - dragSize, fYScrollDragZone = BRect(fPadRect.left - dragSize,
fPadRect.top + fYScrollRange - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize,
fPadRect.right + dragSize,
fPadRect.top + fYScrollRange + dragSize); fPadRect.top + fYScrollRange + dragSize);
BRect yscrollDragZone1 = BRect(fPadRect.left - dragSize, BRect yscrollDragZone1 = BRect(fPadRect.left - dragSize,
fPadRect.top + fYScrollRange - dragSize, fPadRect.left + dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.left + dragSize,
fPadRect.top + fYScrollRange + dragSize); fPadRect.top + fYScrollRange + dragSize);
view->FillRect(yscrollDragZone1); view->FillRect(yscrollDragZone1);
BRect yscrollDragZone2 = BRect(fPadRect.right - dragSize, BRect yscrollDragZone2 = BRect(fPadRect.right - dragSize,
fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize,
fPadRect.top + fYScrollRange + dragSize); fPadRect.top + fYScrollRange + dragSize);
view->FillRect(yscrollDragZone2); view->FillRect(yscrollDragZone2);
@@ -387,39 +385,35 @@ TouchpadPrefView::SetupView()
new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fScrollAccelSlider->SetHashMarkCount(7); fScrollAccelSlider->SetHashMarkCount(7);
fScrollAccelSlider->SetLimitLabels(B_TRANSLATE("Slow"), fScrollAccelSlider->SetLimitLabels(
B_TRANSLATE("Fast")); B_TRANSLATE("Slow"), B_TRANSLATE("Fast"));
fScrollAccelSlider->SetExplicitMinSize(BSize(150, B_SIZE_UNSET)); fScrollAccelSlider->SetExplicitMinSize(BSize(150, B_SIZE_UNSET));
fScrollStepXSlider = new BSlider("scroll_stepX", fScrollStepXSlider = new BSlider("scroll_stepX", B_TRANSLATE("Horizontal"),
B_TRANSLATE("Horizontal"), new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
new BMessage(SCROLL_CONTROL_CHANGED),
0, 20, B_HORIZONTAL);
fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fScrollStepXSlider->SetHashMarkCount(7); fScrollStepXSlider->SetHashMarkCount(7);
fScrollStepXSlider->SetLimitLabels(B_TRANSLATE("Slow"), fScrollStepXSlider->SetLimitLabels(
B_TRANSLATE("Fast")); B_TRANSLATE("Slow"), B_TRANSLATE("Fast"));
fScrollStepYSlider = new BSlider("scroll_stepY", fScrollStepYSlider = new BSlider("scroll_stepY", B_TRANSLATE("Vertical"),
B_TRANSLATE("Vertical"),
new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL); new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fScrollStepYSlider->SetHashMarkCount(7); fScrollStepYSlider->SetHashMarkCount(7);
fScrollStepYSlider->SetLimitLabels(B_TRANSLATE("Slow"), fScrollStepYSlider->SetLimitLabels(
B_TRANSLATE("Fast")); B_TRANSLATE("Slow"), B_TRANSLATE("Fast"));
fPadBlockerSlider = new BSlider("padblocker", fPadBlockerSlider
B_TRANSLATE("Keyboard Lock Delay"), = new BSlider("padblocker", B_TRANSLATE("Keyboard Lock Delay"),
new BMessage(PADBLOCK_TIME_CHANGED), 5, 1000, B_HORIZONTAL); new BMessage(PADBLOCK_TIME_CHANGED), 5, 1000, B_HORIZONTAL);
fPadBlockerSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fPadBlockerSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fPadBlockerSlider->SetHashMarkCount(10); fPadBlockerSlider->SetHashMarkCount(10);
fPadBlockerSlider->SetLimitLabels(B_TRANSLATE("Quick"), fPadBlockerSlider->SetLimitLabels(
B_TRANSLATE("Never")); B_TRANSLATE("Quick"), B_TRANSLATE("Never"));
fTwoFingerBox = new BCheckBox(B_TRANSLATE("Two finger scrolling"), fTwoFingerBox = new BCheckBox(B_TRANSLATE("Two finger scrolling"),
new BMessage(SCROLL_CONTROL_CHANGED)); new BMessage(SCROLL_CONTROL_CHANGED));
fTwoFingerHorizontalBox = new BCheckBox( fTwoFingerHorizontalBox = new BCheckBox(B_TRANSLATE("Horizontal scrolling"),
B_TRANSLATE("Horizontal scrolling"),
new BMessage(SCROLL_CONTROL_CHANGED)); new BMessage(SCROLL_CONTROL_CHANGED));
float spacing = be_control_look->DefaultItemSpacing(); float spacing = be_control_look->DefaultItemSpacing();
@@ -443,13 +437,13 @@ TouchpadPrefView::SetupView()
BGroupLayout* scrollPrefLayout = new BGroupLayout(B_HORIZONTAL); BGroupLayout* scrollPrefLayout = new BGroupLayout(B_HORIZONTAL);
scrollPrefLayout->SetSpacing(spacing); scrollPrefLayout->SetSpacing(spacing);
scrollPrefLayout->SetInsets(spacing, scrollPrefLayout->SetInsets(
scrollBox->TopBorderOffset() * 2 + spacing, spacing, spacing); spacing, scrollBox->TopBorderOffset() * 2 + spacing, spacing, spacing);
scrollBox->SetLayout(scrollPrefLayout); scrollBox->SetLayout(scrollPrefLayout);
scrollPrefLayout->AddView(scrollPrefLeftLayout); scrollPrefLayout->AddView(scrollPrefLeftLayout);
scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(spacing scrollPrefLayout->AddItem(
* 1.5)); BSpaceLayoutItem::CreateVerticalStrut(spacing * 1.5));
scrollPrefLayout->AddView(scrollPrefRightLayout); scrollPrefLayout->AddView(scrollPrefRightLayout);
fTapSlider = new BSlider("tap_sens", B_TRANSLATE("Tapping sensitivity"), fTapSlider = new BSlider("tap_sens", B_TRANSLATE("Tapping sensitivity"),
@@ -458,11 +452,11 @@ TouchpadPrefView::SetupView()
fTapSlider->SetHashMarkCount(7); fTapSlider->SetHashMarkCount(7);
fTapSlider->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("High")); fTapSlider->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("High"));
fDefaultButton = new BButton(B_TRANSLATE("Defaults"), fDefaultButton
new BMessage(DEFAULT_SETTINGS)); = new BButton(B_TRANSLATE("Defaults"), new BMessage(DEFAULT_SETTINGS));
fRevertButton = new BButton(B_TRANSLATE("Revert"), fRevertButton
new BMessage(REVERT_SETTINGS)); = new BButton(B_TRANSLATE("Revert"), new BMessage(REVERT_SETTINGS));
fRevertButton->SetEnabled(false); fRevertButton->SetEnabled(false);
@@ -484,12 +478,12 @@ TouchpadPrefView::SetupView()
void void
TouchpadPrefView::SetValues(touchpad_settings* settings) TouchpadPrefView::SetValues(touchpad_settings* settings)
{ {
fTouchpadView->SetValues(settings->scroll_rightrange, fTouchpadView->SetValues(
settings->scroll_bottomrange); settings->scroll_rightrange, settings->scroll_bottomrange);
fTwoFingerBox->SetValue(settings->scroll_twofinger fTwoFingerBox->SetValue(
? B_CONTROL_ON : B_CONTROL_OFF); settings->scroll_twofinger ? B_CONTROL_ON : B_CONTROL_OFF);
fTwoFingerHorizontalBox->SetValue(settings->scroll_twofinger_horizontal fTwoFingerHorizontalBox->SetValue(
? B_CONTROL_ON : B_CONTROL_OFF); settings->scroll_twofinger_horizontal ? B_CONTROL_ON : B_CONTROL_OFF);
fTwoFingerHorizontalBox->SetEnabled(settings->scroll_twofinger); fTwoFingerHorizontalBox->SetEnabled(settings->scroll_twofinger);
fScrollStepXSlider->SetValue(20 - settings->scroll_xstepsize / 2); fScrollStepXSlider->SetValue(20 - settings->scroll_xstepsize / 2);
fScrollStepYSlider->SetValue(20 - settings->scroll_ystepsize / 2); fScrollStepYSlider->SetValue(20 - settings->scroll_ystepsize / 2);
+21 -24
View File
@@ -18,8 +18,8 @@
#include <Control.h> #include <Control.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <SplitView.h>
#include <Screen.h> #include <Screen.h>
#include <SplitView.h>
#include <private/input/InputServerTypes.h> #include <private/input/InputServerTypes.h>
@@ -39,7 +39,7 @@ InputWindow::InputWindow(BRect rect)
: :
BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Input"), B_TITLED_WINDOW, BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Input"), B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
| B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE) | B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE)
{ {
fDeviceListView = new BListView(B_TRANSLATE("Device List")); fDeviceListView = new BListView(B_TRANSLATE("Device List"));
fDeviceListView->SetSelectionMessage(new BMessage(ITEM_SELECTED)); fDeviceListView->SetSelectionMessage(new BMessage(ITEM_SELECTED));
@@ -47,8 +47,8 @@ InputWindow::InputWindow(BRect rect)
BSize(32 + fDeviceListView->StringWidth("Extended PS/2 Mouse 1"), BSize(32 + fDeviceListView->StringWidth("Extended PS/2 Mouse 1"),
B_SIZE_UNSET)); B_SIZE_UNSET));
BScrollView* scrollView = new BScrollView("scrollView", fDeviceListView, BScrollView* scrollView = new BScrollView(
0, false, B_FANCY_BORDER); "scrollView", fDeviceListView, 0, false, B_FANCY_BORDER);
fCardView = new BCardView(); fCardView = new BCardView();
BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10) BLayoutBuilder::Group<>(this, B_HORIZONTAL, 10)
@@ -59,6 +59,7 @@ InputWindow::InputWindow(BRect rect)
FindDevice(); FindDevice();
} }
void void
InputWindow::MessageReceived(BMessage* message) InputWindow::MessageReceived(BMessage* message)
{ {
@@ -81,8 +82,8 @@ InputWindow::MessageReceived(BMessage* message)
case kMsgDefaults: case kMsgDefaults:
case kMsgRevert: case kMsgRevert:
{ {
PostMessage(message, PostMessage(
fCardView->CardLayout()->VisibleItem()->View()); message, fCardView->CardLayout()->VisibleItem()->View());
break; break;
} }
case SCROLL_AREA_CHANGED: case SCROLL_AREA_CHANGED:
@@ -91,15 +92,15 @@ InputWindow::MessageReceived(BMessage* message)
case DEFAULT_SETTINGS: case DEFAULT_SETTINGS:
case REVERT_SETTINGS: case REVERT_SETTINGS:
{ {
PostMessage(message, PostMessage(
fCardView->CardLayout()->VisibleItem()->View()); message, fCardView->CardLayout()->VisibleItem()->View());
break; break;
} }
case kMsgSliderrepeatrate: case kMsgSliderrepeatrate:
case kMsgSliderdelayrate: case kMsgSliderdelayrate:
{ {
PostMessage(message, PostMessage(
fCardView->CardLayout()->VisibleItem()->View()); message, fCardView->CardLayout()->VisibleItem()->View());
break; break;
} }
@@ -114,8 +115,8 @@ InputWindow::MessageReceived(BMessage* message)
AddDevice(device); AddDevice(device);
} else { } else {
for (int i = 0; i < fDeviceListView->CountItems(); i++) { for (int i = 0; i < fDeviceListView->CountItems(); i++) {
DeviceListItemView* item = DeviceListItemView* item
dynamic_cast<DeviceListItemView*>( = dynamic_cast<DeviceListItemView*>(
fDeviceListView->ItemAt(i)); fDeviceListView->ItemAt(i));
if (item != NULL && item->Label() == name) { if (item != NULL && item->Label() == name) {
fDeviceListView->RemoveItem(i); fDeviceListView->RemoveItem(i);
@@ -166,9 +167,8 @@ InputWindow::FindDevice()
while (true) { while (true) {
BInputDevice* dev = (BInputDevice*)devList.ItemAt(i); BInputDevice* dev = (BInputDevice*)devList.ItemAt(i);
if (dev == NULL) { if (dev == NULL)
break; break;
}
i++; i++;
AddDevice(dev); AddDevice(dev);
@@ -183,13 +183,12 @@ InputWindow::AddDevice(BInputDevice* dev)
{ {
BString name = dev->Name(); BString name = dev->Name();
if (dev->Type() == B_POINTING_DEVICE if (dev->Type() == B_POINTING_DEVICE && name.FindFirst("Touchpad") >= 0) {
&& name.FindFirst("Touchpad") >= 0) {
TouchpadPrefView* view = new TouchpadPrefView(dev); TouchpadPrefView* view = new TouchpadPrefView(dev);
fCardView->AddChild(view); fCardView->AddChild(view);
DeviceListItemView* touchpad = new DeviceListItemView( DeviceListItemView* touchpad
name, TOUCHPAD_TYPE); = new DeviceListItemView(name, TOUCHPAD_TYPE);
fDeviceListView->AddItem(touchpad); fDeviceListView->AddItem(touchpad);
} else if (dev->Type() == B_POINTING_DEVICE) { } else if (dev->Type() == B_POINTING_DEVICE) {
MouseSettings* settings; MouseSettings* settings;
@@ -198,17 +197,15 @@ InputWindow::AddDevice(BInputDevice* dev)
InputMouse* view = new InputMouse(dev, settings); InputMouse* view = new InputMouse(dev, settings);
fCardView->AddChild(view); fCardView->AddChild(view);
DeviceListItemView* mouse = new DeviceListItemView( DeviceListItemView* mouse = new DeviceListItemView(name, MOUSE_TYPE);
name, MOUSE_TYPE);
fDeviceListView->AddItem(mouse); fDeviceListView->AddItem(mouse);
} else if (dev->Type() == B_KEYBOARD_DEVICE) { } else if (dev->Type() == B_KEYBOARD_DEVICE) {
InputKeyboard* view = new InputKeyboard(dev); InputKeyboard* view = new InputKeyboard(dev);
fCardView->AddChild(view); fCardView->AddChild(view);
DeviceListItemView* keyboard = new DeviceListItemView( DeviceListItemView* keyboard
name, KEYBOARD_TYPE); = new DeviceListItemView(name, KEYBOARD_TYPE);
fDeviceListView->AddItem(keyboard); fDeviceListView->AddItem(keyboard);
} else { } else
delete dev; delete dev;
}
} }
+6 -5
View File
@@ -6,13 +6,13 @@
* [email protected] * [email protected]
* Jérôme Duval * Jérôme Duval
* Marcus Overhagen * Marcus Overhagen
*/ */
#include "KeyboardSettings.h" #include "KeyboardSettings.h"
#include <FindDirectory.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h>
#include <Path.h> #include <Path.h>
#include <stdio.h> #include <stdio.h>
@@ -33,10 +33,9 @@ KeyboardSettings::KeyboardSettings()
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path); status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
if (status == B_OK) { if (status == B_OK) {
status = path.Append(kb_settings_file); status = path.Append(kb_settings_file);
if (status == B_OK) { if (status == B_OK)
status = file.SetTo(path.Path(), B_READ_ONLY); status = file.SetTo(path.Path(), B_READ_ONLY);
} }
}
} }
@@ -56,6 +55,7 @@ KeyboardSettings::~KeyboardSettings()
return; return;
} }
void void
KeyboardSettings::SetKeyboardRepeatRate(int32 rate) KeyboardSettings::SetKeyboardRepeatRate(int32 rate)
{ {
@@ -73,6 +73,7 @@ KeyboardSettings::SetKeyboardRepeatDelay(bigtime_t delay)
fSettings.key_repeat_delay = delay; fSettings.key_repeat_delay = delay;
} }
void void
KeyboardSettings::Revert() KeyboardSettings::Revert()
{ {
+17 -18
View File
@@ -6,15 +6,15 @@
* [email protected] * [email protected]
* Jérôme Duval * Jérôme Duval
* Marcus Overhagen * Marcus Overhagen
*/ */
#include "KeyboardView.h" #include "KeyboardView.h"
#include <InterfaceDefs.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h> #include <Catalog.h>
#include <InterfaceDefs.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include <Slider.h> #include <Slider.h>
@@ -27,36 +27,36 @@
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "KeyboardView" #define B_TRANSLATION_CONTEXT "KeyboardView"
KeyboardView::KeyboardView() KeyboardView::KeyboardView()
: BGroupView() :
BGroupView()
{ {
// Create the "Key repeat rate" slider... // Create the "Key repeat rate" slider...
fRepeatSlider = new BSlider("key_repeat_rate", fRepeatSlider
B_TRANSLATE("Key repeat rate"), = new BSlider("key_repeat_rate", B_TRANSLATE("Key repeat rate"),
new BMessage(kMsgSliderrepeatrate), new BMessage(kMsgSliderrepeatrate), 20, 300, B_HORIZONTAL);
20, 300, B_HORIZONTAL);
fRepeatSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fRepeatSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fRepeatSlider->SetHashMarkCount(5); fRepeatSlider->SetHashMarkCount(5);
fRepeatSlider->SetLimitLabels(B_TRANSLATE("Slow"),B_TRANSLATE("Fast")); fRepeatSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast"));
fRepeatSlider->SetExplicitMinSize(BSize(200, B_SIZE_UNSET)); fRepeatSlider->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
// Create the "Delay until key repeat" slider... // Create the "Delay until key repeat" slider...
fDelaySlider = new BSlider("delay_until_key_repeat", fDelaySlider = new BSlider("delay_until_key_repeat",
B_TRANSLATE("Delay until key repeat"), B_TRANSLATE("Delay until key repeat"),
new BMessage(kMsgSliderdelayrate), new BMessage(kMsgSliderdelayrate), 250000, 1000000, B_HORIZONTAL);
250000, 1000000, B_HORIZONTAL);
fDelaySlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fDelaySlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fDelaySlider->SetHashMarkCount(4); fDelaySlider->SetHashMarkCount(4);
fDelaySlider->SetLimitLabels(B_TRANSLATE("Short"),B_TRANSLATE("Long")); fDelaySlider->SetLimitLabels(B_TRANSLATE("Short"), B_TRANSLATE("Long"));
// Create the "Typing test area" text box... // Create the "Typing test area" text box...
BTextControl* textcontrol = new BTextControl(NULL, BTextControl* textcontrol = new BTextControl(
B_TRANSLATE("Typing test area"), NULL, B_TRANSLATE("Typing test area"), new BMessage('TTEA'));
new BMessage('TTEA'));
textcontrol->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER); textcontrol->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);
textcontrol->SetExplicitMinSize(BSize( textcontrol->SetExplicitMinSize(
textcontrol->StringWidth(B_TRANSLATE("Typing test area")), B_SIZE_UNSET)); BSize(textcontrol->StringWidth(B_TRANSLATE("Typing test area")),
B_SIZE_UNSET));
// Build the layout // Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
@@ -69,7 +69,6 @@ KeyboardView::KeyboardView()
KeyboardView::~KeyboardView() KeyboardView::~KeyboardView()
{ {
} }
+24 -25
View File
@@ -4,13 +4,13 @@
* *
* Author: * Author:
* Preetpal Kaur <[email protected]> * Preetpal Kaur <[email protected]>
*/ */
#include "MouseSettings.h" #include "MouseSettings.h"
#include <FindDirectory.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <View.h> #include <View.h>
@@ -24,7 +24,7 @@
static const bigtime_t kDefaultClickSpeed = 500000; static const bigtime_t kDefaultClickSpeed = 500000;
static const int32 kDefaultMouseSpeed = 65536; static const int32 kDefaultMouseSpeed = 65536;
static const int32 kDefaultMouseType = 3; // 3 button mouse static const int32 kDefaultMouseType = 3; // 3 button mouse
static const int32 kDefaultAccelerationFactor = 65536; static const int32 kDefaultAccelerationFactor = 65536;
static const bool kDefaultAcceptFirstClick = true; static const bool kDefaultAcceptFirstClick = true;
@@ -74,7 +74,7 @@ MouseSettings::~MouseSettings()
status_t status_t
MouseSettings::_GetSettingsPath(BPath &path) MouseSettings::_GetSettingsPath(BPath& path)
{ {
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path); status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
if (status < B_OK) if (status < B_OK)
@@ -135,15 +135,14 @@ void
MouseSettings::Dump() MouseSettings::Dump()
{ {
printf("type:\t\t%" B_PRId32 " button mouse\n", fSettings.type); printf("type:\t\t%" B_PRId32 " button mouse\n", fSettings.type);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++)
printf("button[%d]: %" B_PRId32 "\n", i, fSettings.map.button[i]); printf("button[%d]: %" B_PRId32 "\n", i, fSettings.map.button[i]);
}
printf("click speed:\t%" B_PRId64 "\n", fSettings.click_speed); printf("click speed:\t%" B_PRId64 "\n", fSettings.click_speed);
printf("accel:\t\t%s\n", fSettings.accel.enabled ? "enabled" : "disabled"); printf("accel:\t\t%s\n", fSettings.accel.enabled ? "enabled" : "disabled");
printf("accel factor:\t%" B_PRId32 "\n", fSettings.accel.accel_factor); printf("accel factor:\t%" B_PRId32 "\n", fSettings.accel.accel_factor);
printf("speed:\t\t%" B_PRId32 "\n", fSettings.accel.speed); printf("speed:\t\t%" B_PRId32 "\n", fSettings.accel.speed);
const char *mode = "unknown"; const char* mode = "unknown";
switch (fMode) { switch (fMode) {
case B_NORMAL_MOUSE: case B_NORMAL_MOUSE:
mode = "click to focus and raise"; mode = "click to focus and raise";
@@ -157,7 +156,7 @@ MouseSettings::Dump()
} }
printf("mouse mode:\t%s\n", mode); printf("mouse mode:\t%s\n", mode);
const char *focus_follows_mouse_mode = "unknown"; const char* focus_follows_mouse_mode = "unknown";
switch (fFocusFollowsMouseMode) { switch (fFocusFollowsMouseMode) {
case B_NORMAL_FOCUS_FOLLOWS_MOUSE: case B_NORMAL_FOCUS_FOLLOWS_MOUSE:
focus_follows_mouse_mode = "normal"; focus_follows_mouse_mode = "normal";
@@ -308,7 +307,7 @@ MouseSettings::Mapping(int32 index) const
void void
MouseSettings::Mapping(mouse_map &map) const MouseSettings::Mapping(mouse_map& map) const
{ {
map = fSettings.map; map = fSettings.map;
} }
@@ -323,7 +322,7 @@ MouseSettings::SetMapping(int32 index, uint32 button)
void void
MouseSettings::SetMapping(mouse_map &map) MouseSettings::SetMapping(mouse_map& map)
{ {
if (set_mouse_map(&map) == B_OK) if (set_mouse_map(&map) == B_OK)
fSettings.map = map; fSettings.map = map;
@@ -355,7 +354,8 @@ MouseSettings::SetAcceptFirstClick(bool accept_first_click)
mouse_settings* mouse_settings*
MouseSettings::GetSettings() { MouseSettings::GetSettings()
{
return &fSettings; return &fSettings;
} }
@@ -389,7 +389,7 @@ MultipleMouseSettings::~MultipleMouseSettings()
status_t status_t
MultipleMouseSettings::GetSettingsPath(BPath &path) MultipleMouseSettings::GetSettingsPath(BPath& path)
{ {
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path); status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
if (status < B_OK) if (status < B_OK)
@@ -423,12 +423,12 @@ MultipleMouseSettings::RetrieveSettings()
ssize_t size = 0; ssize_t size = 0;
while (message.FindString("mouseDevice", i, &deviceName) == B_OK) { while (message.FindString("mouseDevice", i, &deviceName) == B_OK) {
message.FindData("mouseSettings", B_ANY_TYPE, i, message.FindData(
(const void**)&settings, &size); "mouseSettings", B_ANY_TYPE, i, (const void**)&settings, &size);
MouseSettings* mouseSettings MouseSettings* mouseSettings
= new MouseSettings(*settings, deviceName); = new MouseSettings(*settings, deviceName);
fMouseSettingsObject.insert(std::pair<BString, MouseSettings*> fMouseSettingsObject.insert(
(deviceName, mouseSettings)); std::pair<BString, MouseSettings*>(deviceName, mouseSettings));
i++; i++;
} }
} else { } else {
@@ -501,7 +501,6 @@ MultipleMouseSettings::Dump()
itr->second->Dump(); itr->second->Dump();
printf("\n"); printf("\n");
} }
} }
#endif #endif
@@ -509,13 +508,13 @@ MultipleMouseSettings::Dump()
MouseSettings* MouseSettings*
MultipleMouseSettings::AddMouseSettings(BString mouse_name) MultipleMouseSettings::AddMouseSettings(BString mouse_name)
{ {
if(fDeprecatedMouseSettings != NULL) { if (fDeprecatedMouseSettings != NULL) {
MouseSettings* RetrievedSettings = new (std::nothrow) MouseSettings MouseSettings* RetrievedSettings = new(std::nothrow) MouseSettings(
(*(fDeprecatedMouseSettings->GetSettings()), mouse_name); *(fDeprecatedMouseSettings->GetSettings()), mouse_name);
if (RetrievedSettings != NULL) { if (RetrievedSettings != NULL) {
fMouseSettingsObject.insert(std::pair<BString, MouseSettings*> fMouseSettingsObject.insert(std::pair<BString, MouseSettings*>(
(mouse_name, RetrievedSettings)); mouse_name, RetrievedSettings));
return RetrievedSettings; return RetrievedSettings;
} }
@@ -525,12 +524,12 @@ MultipleMouseSettings::AddMouseSettings(BString mouse_name)
if (settings) if (settings)
return settings; return settings;
settings = new (std::nothrow) MouseSettings(mouse_name); settings = new(std::nothrow) MouseSettings(mouse_name);
if (settings == NULL) if (settings == NULL)
return NULL; return NULL;
fMouseSettingsObject.insert(std::pair<BString, MouseSettings*> fMouseSettingsObject.insert(
(mouse_name, settings)); std::pair<BString, MouseSettings*>(mouse_name, settings));
return settings; return settings;
} }
+25 -25
View File
@@ -4,7 +4,7 @@
* *
* Author: * Author:
* Preetpal Kaur <[email protected]> * Preetpal Kaur <[email protected]>
*/ */
#include "MouseView.h" #include "MouseView.h"
@@ -46,13 +46,13 @@ static const int32 kButtonOffsets[][7] = {
}; };
#undef W #undef W
static const rgb_color kButtonTextColor = { 0, 0, 0, 255 }; static const rgb_color kButtonTextColor = {0, 0, 0, 255};
static const rgb_color kMouseShadowColor = { 100, 100, 100, 128 }; static const rgb_color kMouseShadowColor = {100, 100, 100, 128};
static const rgb_color kMouseBodyTopColor = { 0xed, 0xed, 0xed, 255 }; static const rgb_color kMouseBodyTopColor = {0xed, 0xed, 0xed, 255};
static const rgb_color kMouseBodyBottomColor = { 0x85, 0x85, 0x85, 255 }; static const rgb_color kMouseBodyBottomColor = {0x85, 0x85, 0x85, 255};
static const rgb_color kMouseOutlineColor = { 0x51, 0x51, 0x51, 255 }; static const rgb_color kMouseOutlineColor = {0x51, 0x51, 0x51, 255};
static const rgb_color kMouseButtonOutlineColor = { 0xa0, 0xa0, 0xa0, 255 }; static const rgb_color kMouseButtonOutlineColor = {0xa0, 0xa0, 0xa0, 255};
static const rgb_color kButtonPressedColor = { 110, 110, 110, 110 }; static const rgb_color kButtonPressedColor = {110, 110, 110, 110};
static const int32* static const int32*
@@ -77,7 +77,8 @@ getMappingNumber(uint32 mapping)
return i; return i;
} }
MouseView::MouseView(const MouseSettings &settings)
MouseView::MouseView(const MouseSettings& settings)
: :
BView("Mouse", B_PULSE_NEEDED | B_WILL_DRAW), BView("Mouse", B_PULSE_NEEDED | B_WILL_DRAW),
fSettings(settings), fSettings(settings),
@@ -156,7 +157,7 @@ MouseView::MouseUp(BPoint)
void void
MouseView::MouseDown(BPoint where) MouseView::MouseDown(BPoint where)
{ {
BMessage *mouseMsg = Window()->CurrentMessage(); BMessage* mouseMsg = Window()->CurrentMessage();
fButtons = mouseMsg->FindInt32("buttons"); fButtons = mouseMsg->FindInt32("buttons");
int32 modifiers = mouseMsg->FindInt32("modifiers"); int32 modifiers = mouseMsg->FindInt32("modifiers");
if (modifiers & B_CONTROL_KEY) { if (modifiers & B_CONTROL_KEY) {
@@ -165,7 +166,6 @@ MouseView::MouseDown(BPoint where)
else else
fButtons = B_SECONDARY_MOUSE_BUTTON; fButtons = B_SECONDARY_MOUSE_BUTTON;
} }
// Get the current clipping region before requesting any updates. // Get the current clipping region before requesting any updates.
// Otherwise those parts would be excluded from the region. // Otherwise those parts would be excluded from the region.
BRegion clipping; BRegion clipping;
@@ -222,13 +222,13 @@ MouseView::Draw(BRect updateFrame)
BShape mouseShape; BShape mouseShape;
mouseShape.MoveTo(BPoint(16, 12)); mouseShape.MoveTo(BPoint(16, 12));
// left // left
BPoint control[3] = { BPoint(12, 16), BPoint(8, 64), BPoint(32, 64) }; BPoint control[3] = {BPoint(12, 16), BPoint(8, 64), BPoint(32, 64)};
mouseShape.BezierTo(control); mouseShape.BezierTo(control);
// right // right
BPoint control2[3] = { BPoint(56, 64), BPoint(52, 16), BPoint(48, 12) }; BPoint control2[3] = {BPoint(56, 64), BPoint(52, 16), BPoint(48, 12)};
mouseShape.BezierTo(control2); mouseShape.BezierTo(control2);
// top // top
BPoint control3[3] = { BPoint(44, 8), BPoint(20, 8), BPoint(16, 12) }; BPoint control3[3] = {BPoint(44, 8), BPoint(20, 8), BPoint(16, 12)};
mouseShape.BezierTo(control3); mouseShape.BezierTo(control3);
mouseShape.Close(); mouseShape.Close();
@@ -255,7 +255,7 @@ MouseView::Draw(BRect updateFrame)
// bottom button border // bottom button border
BShape buttonsOutline; BShape buttonsOutline;
buttonsOutline.MoveTo(BPoint(13, 27)); buttonsOutline.MoveTo(BPoint(13, 27));
BPoint control4[] = { BPoint(18, 30), BPoint(46, 30), BPoint(51, 27) }; BPoint control4[] = {BPoint(18, 30), BPoint(46, 30), BPoint(51, 27)};
buttonsOutline.BezierTo(control4); buttonsOutline.BezierTo(control4);
SetHighColor(kMouseButtonOutlineColor); SetHighColor(kMouseButtonOutlineColor);
@@ -284,7 +284,7 @@ MouseView::Draw(BRect updateFrame)
// draw mapping number centered over the button // draw mapping number centered over the button
bool pressed = (fButtons & map.button[_ConvertFromVisualOrder(i)]) != 0; bool pressed = (fButtons & map.button[_ConvertFromVisualOrder(i)]) != 0;
// is button currently pressed? // is button currently pressed?
if (pressed) { if (pressed) {
SetDrawingMode(B_OP_ALPHA); SetDrawingMode(B_OP_ALPHA);
SetHighColor(kButtonPressedColor); SetHighColor(kButtonPressedColor);
@@ -305,10 +305,10 @@ MouseView::Draw(BRect updateFrame)
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
SetHighColor(kButtonTextColor); SetHighColor(kButtonTextColor);
DrawString(label, BPoint( DrawString(label,
border.left + (border.Width() - StringWidth(label)) / 2, BPoint(border.left + (border.Width() - StringWidth(label)) / 2,
border.top + fDigitBaseline border.top + fDigitBaseline
+ (border.IntegerHeight() - fDigitHeight) / 2)); + (border.IntegerHeight() - fDigitHeight) / 2));
} }
ClipToPicture(NULL); ClipToPicture(NULL);
@@ -319,7 +319,7 @@ BRect
MouseView::_ButtonsRect() const MouseView::_ButtonsRect() const
{ {
return BRect(0, fScaling * kButtonTop, fScaling * kMouseDownWidth, return BRect(0, fScaling * kButtonTop, fScaling * kMouseDownWidth,
fScaling * (kButtonTop + kMouseDownHeight)); fScaling * (kButtonTop + kMouseDownHeight));
} }
@@ -363,16 +363,16 @@ MouseView::_CreateButtonsPicture()
BShape mouseShape; BShape mouseShape;
mouseShape.MoveTo(BPoint(48, 12)); mouseShape.MoveTo(BPoint(48, 12));
// top // top
BPoint control3[3] = { BPoint(44, 8), BPoint(20, 8), BPoint(16, 12) }; BPoint control3[3] = {BPoint(44, 8), BPoint(20, 8), BPoint(16, 12)};
mouseShape.BezierTo(control3); mouseShape.BezierTo(control3);
// left // left
BPoint control[3] = { BPoint(12, 16), BPoint(13, 27), BPoint(13, 27) }; BPoint control[3] = {BPoint(12, 16), BPoint(13, 27), BPoint(13, 27)};
mouseShape.BezierTo(control); mouseShape.BezierTo(control);
// bottom // bottom
BPoint control4[3] = { BPoint(18, 30), BPoint(46, 30), BPoint(51, 27) }; BPoint control4[3] = {BPoint(18, 30), BPoint(46, 30), BPoint(51, 27)};
mouseShape.BezierTo(control4); mouseShape.BezierTo(control4);
// right // right
BPoint control2[3] = { BPoint(51, 27), BPoint(50, 14), BPoint(48, 12) }; BPoint control2[3] = {BPoint(51, 27), BPoint(50, 14), BPoint(48, 12)};
mouseShape.BezierTo(control2); mouseShape.BezierTo(control2);
mouseShape.Close(); mouseShape.Close();
+27 -28
View File
@@ -37,16 +37,18 @@
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "SettingsView" #define B_TRANSLATION_CONTEXT "SettingsView"
SettingsView::SettingsView(MouseSettings& settings) SettingsView::SettingsView(MouseSettings& settings)
: BBox("main_view"), :
BBox("main_view"),
fSettings(settings) fSettings(settings)
{ {
if (fSettings.MouseType() > 6) if (fSettings.MouseType() > 6)
debugger("Mouse type is invalid"); debugger("Mouse type is invalid");
// Add the "Mouse Type" pop up menu // Add the "Mouse Type" pop up menu
fTypeMenu = new BOptionPopUp("type", B_TRANSLATE("Mouse type:"), fTypeMenu = new BOptionPopUp(
new BMessage(kMsgMouseType)); "type", B_TRANSLATE("Mouse type:"), new BMessage(kMsgMouseType));
fTypeMenu->AddOption(B_TRANSLATE("1-Button"), 1); fTypeMenu->AddOption(B_TRANSLATE("1-Button"), 1);
fTypeMenu->AddOption(B_TRANSLATE("2-Button"), 2); fTypeMenu->AddOption(B_TRANSLATE("2-Button"), 2);
fTypeMenu->AddOption(B_TRANSLATE("3-Button"), 3); fTypeMenu->AddOption(B_TRANSLATE("3-Button"), 3);
@@ -55,9 +57,9 @@ SettingsView::SettingsView(MouseSettings& settings)
fTypeMenu->AddOption(B_TRANSLATE("6-Button"), 6); fTypeMenu->AddOption(B_TRANSLATE("6-Button"), 6);
// Create the "Double-click speed slider... // Create the "Double-click speed slider...
fClickSpeedSlider = new BSlider("double_click_speed", fClickSpeedSlider
B_TRANSLATE("Double-click speed"), new BMessage(kMsgDoubleClickSpeed), = new BSlider("double_click_speed", B_TRANSLATE("Double-click speed"),
0, 1000, B_HORIZONTAL); new BMessage(kMsgDoubleClickSpeed), 0, 1000, B_HORIZONTAL);
fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fClickSpeedSlider->SetHashMarkCount(7); fClickSpeedSlider->SetHashMarkCount(7);
@@ -68,9 +70,9 @@ SettingsView::SettingsView(MouseSettings& settings)
fMouseSpeedSlider->SetHashMarkCount(7); fMouseSpeedSlider->SetHashMarkCount(7);
// Create the "Mouse Acceleration" slider... // Create the "Mouse Acceleration" slider...
fAccelerationSlider = new BSlider("mouse_acceleration", fAccelerationSlider
B_TRANSLATE("Mouse acceleration"), = new BSlider("mouse_acceleration", B_TRANSLATE("Mouse acceleration"),
new BMessage(kMsgAccelerationFactor), 0, 1000, B_HORIZONTAL); new BMessage(kMsgAccelerationFactor), 0, 1000, B_HORIZONTAL);
fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fAccelerationSlider->SetHashMarkCount(7); fAccelerationSlider->SetHashMarkCount(7);
@@ -78,8 +80,7 @@ SettingsView::SettingsView(MouseSettings& settings)
// Create the "Double-click test area" text box... // Create the "Double-click test area" text box...
const char* label = B_TRANSLATE("Double-click test area"); const char* label = B_TRANSLATE("Double-click test area");
BTextControl* doubleClickTextControl = new BTextControl(NULL, BTextControl* doubleClickTextControl = new BTextControl(NULL, label, NULL);
label, NULL);
doubleClickTextControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER); doubleClickTextControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER);
doubleClickTextControl->SetExplicitMinSize( doubleClickTextControl->SetExplicitMinSize(
BSize(StringWidth(label), B_SIZE_UNSET)); BSize(StringWidth(label), B_SIZE_UNSET));
@@ -88,20 +89,19 @@ SettingsView::SettingsView(MouseSettings& settings)
fFocusMenu = new BOptionPopUp("focus_mode", B_TRANSLATE("Focus mode:"), fFocusMenu = new BOptionPopUp("focus_mode", B_TRANSLATE("Focus mode:"),
new BMessage(kMsgMouseFocusMode)); new BMessage(kMsgMouseFocusMode));
const char *focusLabels[] = {B_TRANSLATE_MARK("Click to focus and raise"), const char* focusLabels[] = {B_TRANSLATE_MARK("Click to focus and raise"),
B_TRANSLATE_MARK("Click to focus"), B_TRANSLATE_MARK("Click to focus"),
B_TRANSLATE_MARK("Focus follows mouse")}; B_TRANSLATE_MARK("Focus follows mouse")};
const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_CLICK_TO_FOCUS_MOUSE, const mode_mouse focusModes[]
B_FOCUS_FOLLOWS_MOUSE}; = {B_NORMAL_MOUSE, B_CLICK_TO_FOCUS_MOUSE, B_FOCUS_FOLLOWS_MOUSE};
for (size_t i = 0; i < B_COUNT_OF(focusModes); i++) { for (size_t i = 0; i < B_COUNT_OF(focusModes); i++)
fFocusMenu->AddOption(B_TRANSLATE_NOCOLLECT(focusLabels[i]), fFocusMenu->AddOption(
focusModes[i]); B_TRANSLATE_NOCOLLECT(focusLabels[i]), focusModes[i]);
}
// Add the "Click-through" check box // Add the "Click-through" check box
fAcceptFirstClickBox = new BCheckBox(B_TRANSLATE("Accept first click"), fAcceptFirstClickBox = new BCheckBox(
new BMessage(kMsgAcceptFirstClick)); B_TRANSLATE("Accept first click"), new BMessage(kMsgAcceptFirstClick));
// Build the layout // Build the layout
@@ -157,7 +157,6 @@ SettingsView::SettingsView(MouseSettings& settings)
SettingsView::~SettingsView() SettingsView::~SettingsView()
{ {
} }
@@ -188,15 +187,15 @@ void
SettingsView::UpdateFromSettings() SettingsView::UpdateFromSettings()
{ {
int32 value = int32(fSettings.ClickSpeed() / 1000); int32 value = int32(fSettings.ClickSpeed() / 1000);
// slow = 1000000, fast = 0 // slow = 1000000, fast = 0
fClickSpeedSlider->SetValue(value); fClickSpeedSlider->SetValue(value);
value = int32((log(fSettings.MouseSpeed() / 8192.0) / log(2)) * 1000 / 6); value = int32((log(fSettings.MouseSpeed() / 8192.0) / log(2)) * 1000 / 6);
// slow = 8192, fast = 524287 // slow = 8192, fast = 524287
fMouseSpeedSlider->SetValue(value); fMouseSpeedSlider->SetValue(value);
value = int32(sqrt(fSettings.AccelerationFactor() / 16384.0) * 1000 / 4); value = int32(sqrt(fSettings.AccelerationFactor() / 16384.0) * 1000 / 4);
// slow = 0, fast = 262144 // slow = 0, fast = 262144
fAccelerationSlider->SetValue(value); fAccelerationSlider->SetValue(value);
fTypeMenu->SelectOptionFor(fSettings.MouseType()); fTypeMenu->SelectOptionFor(fSettings.MouseType());
@@ -204,8 +203,8 @@ SettingsView::UpdateFromSettings()
fFocusMenu->SelectOptionFor(fSettings.MouseMode()); fFocusMenu->SelectOptionFor(fSettings.MouseMode());
fAcceptFirstClickBox->SetValue(fSettings.AcceptFirstClick() fAcceptFirstClickBox->SetValue(
? B_CONTROL_ON : B_CONTROL_OFF); fSettings.AcceptFirstClick() ? B_CONTROL_ON : B_CONTROL_OFF);
fAcceptFirstClickBox->SetEnabled(fSettings.MouseMode() fAcceptFirstClickBox->SetEnabled(
!= B_FOCUS_FOLLOWS_MOUSE); fSettings.MouseMode() != B_FOCUS_FOLLOWS_MOUSE);
} }