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