hrev44733 adds 7 changesets to branch 'master' old head: ab4ed6e33b8352e0dde973812b968238bf926d06 new head: 6218c8f7eaa451d45fc8febf94dd4051f33ef731 ---------------------------------------------------------------------------- a0e61cd: Implement BeOS style scrollbar knobs. Not hooked up to a setting yet. 51e2ba8: Variable name refactoring. They are knobs, not marks 4b5a686: Add the scrollbar constants enum to the header. Also make some minor tweaks in ScrollBar.cpp 928ffe6: Allow the user to select the scrollbar setting graphically. This uses custom controls to allow the user to choose between single and double arrows and none, dots, or line knob styles in a graphical fashion copied from BeOS Scrollbar preflet. 84256e0: Move the 'Look and feel' tab first 6408201: Line the boxes up, at least for the default font size 6218c8f: Scroll bars is 2 words [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 8 files changed, 681 insertions(+), 49 deletions(-) headers/os/interface/ScrollBar.h | 6 + src/kits/interface/ScrollBar.cpp | 64 ++++ src/preferences/appearance/APRWindow.cpp | 8 +- src/preferences/appearance/FakeScrollBar.cpp | 348 +++++++++++++++++++ src/preferences/appearance/FakeScrollBar.h | 46 +++ src/preferences/appearance/Jamfile | 1 + .../appearance/LookAndFeelSettingsView.cpp | 227 ++++++++++-- .../appearance/LookAndFeelSettingsView.h | 30 +- ############################################################################ Commit: a0e61cdf4cb705110db0bb2138334e852a2d014d URL: http://cgit.haiku-os.org/haiku/commit/?id=a0e61cd Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Nov 1 00:27:47 2012 UTC Implement BeOS style scrollbar knobs. Not hooked up to a setting yet. ---------------------------------------------------------------------------- diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index 971c596..a5c67f6 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -1152,6 +1152,66 @@ BScrollBar::Draw(BRect updateRect) FillRect(rect); } } + + bool square = false; + int32 hextent = 0; + int32 vextent = 0; + + if (square) { + hextent = 2; + vextent = 2; + } else { + hextent = 1; + vextent = 3; + } + + // draw the marks on the scrollbar thumb + int32 flags = 0; + if (!enabled) + flags |= BControlLook::B_DISABLED; + + float hmiddle = rect.Width() / 2; + float vmiddle = rect.Height() / 2; + + BRect middleMark = BRect( + rect.left + hmiddle + - (fOrientation == B_HORIZONTAL ? hextent : vextent), + rect.top + vmiddle + - (fOrientation == B_HORIZONTAL ? vextent : hextent), + rect.left + hmiddle + + (fOrientation == B_HORIZONTAL ? hextent : vextent), + rect.top + vmiddle + + (fOrientation == B_HORIZONTAL ? vextent : hextent)); + + if (fOrientation == B_HORIZONTAL) { + BRect leftMark = middleMark.OffsetByCopy(hextent * -4, 0); + if (leftMark.left > rect.left + hextent) { + be_control_look->DrawButtonBackground(this, leftMark, updateRect, + normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); + } + + BRect rightMark = middleMark.OffsetByCopy(hextent * 4, 0); + if (rightMark.right < rect.right - hextent) { + be_control_look->DrawButtonBackground(this, rightMark, updateRect, + normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); + } + } else { + BRect topMark = middleMark.OffsetByCopy(0, hextent * -4); + if (topMark.top > rect.top + vextent) { + be_control_look->DrawButtonBackground(this, topMark, updateRect, + normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); + } + + BRect bottomMark = middleMark.OffsetByCopy(0, hextent * 4); + if (bottomMark.bottom < rect.bottom - vextent) { + be_control_look->DrawButtonBackground(this, bottomMark, updateRect, + normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); + } + } + + // draw middle mark last because it modifies middleMark + be_control_look->DrawButtonBackground(this, middleMark, updateRect, + normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } ############################################################################ Commit: 51e2ba81f1f98fefaba618049b2df9202b93b561 URL: http://cgit.haiku-os.org/haiku/commit/?id=51e2ba8 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Nov 1 00:57:26 2012 UTC Variable name refactoring. They are knobs, not marks ---------------------------------------------------------------------------- diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index a5c67f6..1050dcb 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -1173,7 +1173,7 @@ BScrollBar::Draw(BRect updateRect) float hmiddle = rect.Width() / 2; float vmiddle = rect.Height() / 2; - BRect middleMark = BRect( + BRect middleKnob = BRect( rect.left + hmiddle - (fOrientation == B_HORIZONTAL ? hextent : vextent), rect.top + vmiddle @@ -1184,33 +1184,33 @@ BScrollBar::Draw(BRect updateRect) + (fOrientation == B_HORIZONTAL ? vextent : hextent)); if (fOrientation == B_HORIZONTAL) { - BRect leftMark = middleMark.OffsetByCopy(hextent * -4, 0); - if (leftMark.left > rect.left + hextent) { - be_control_look->DrawButtonBackground(this, leftMark, updateRect, + BRect leftKnob = middleKnob.OffsetByCopy(hextent * -4, 0); + if (leftKnob.left > rect.left + hextent) { + be_control_look->DrawButtonBackground(this, leftKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } - BRect rightMark = middleMark.OffsetByCopy(hextent * 4, 0); - if (rightMark.right < rect.right - hextent) { - be_control_look->DrawButtonBackground(this, rightMark, updateRect, + BRect rightKnob = middleKnob.OffsetByCopy(hextent * 4, 0); + if (rightKnob.right < rect.right - hextent) { + be_control_look->DrawButtonBackground(this, rightKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } } else { - BRect topMark = middleMark.OffsetByCopy(0, hextent * -4); - if (topMark.top > rect.top + vextent) { - be_control_look->DrawButtonBackground(this, topMark, updateRect, + BRect topKnob = middleKnob.OffsetByCopy(0, hextent * -4); + if (topKnob.top > rect.top + vextent) { + be_control_look->DrawButtonBackground(this, topKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } - BRect bottomMark = middleMark.OffsetByCopy(0, hextent * 4); - if (bottomMark.bottom < rect.bottom - vextent) { - be_control_look->DrawButtonBackground(this, bottomMark, updateRect, + BRect bottomKnob = middleKnob.OffsetByCopy(0, hextent * 4); + if (bottomKnob.bottom < rect.bottom - vextent) { + be_control_look->DrawButtonBackground(this, bottomKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } } - // draw middle mark last because it modifies middleMark - be_control_look->DrawButtonBackground(this, middleMark, updateRect, + // draw middle mark last because it modifies middleKnob + be_control_look->DrawButtonBackground(this, middleKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } ############################################################################ Commit: 4b5a6861f2752fef9d2e48b8d8ab0d92ac4dfa09 URL: http://cgit.haiku-os.org/haiku/commit/?id=4b5a686 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Nov 2 03:57:11 2012 UTC Add the scrollbar constants enum to the header. Also make some minor tweaks in ScrollBar.cpp ---------------------------------------------------------------------------- diff --git a/headers/os/interface/ScrollBar.h b/headers/os/interface/ScrollBar.h index c70acbe..d9e709e 100644 --- a/headers/os/interface/ScrollBar.h +++ b/headers/os/interface/ScrollBar.h @@ -19,6 +19,12 @@ #define DISABLES_ON_WINDOW_DEACTIVATION 1 +enum { + KNOB_STYLE_NONE = 0, + KNOB_STYLE_DOTS, + KNOB_STYLE_LINES +}; + class BScrollBar : public BView { public: BScrollBar(BRect frame, const char* name, diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index 1050dcb..56fab7b 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -846,6 +846,7 @@ BScrollBar::Draw(BRect updateRect) EndLineArray(); } else StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); bool enabled = fPrivateData->fEnabled && fMin < fMax @@ -1153,7 +1154,11 @@ BScrollBar::Draw(BRect updateRect) } } - bool square = false; + if (fPrivateData->fScrollBarInfo.knob == KNOB_STYLE_NONE) + return; + + // draw the scrollbar thumb knobs + bool square = fPrivateData->fScrollBarInfo.knob == KNOB_STYLE_DOTS; int32 hextent = 0; int32 vextent = 0; @@ -1165,7 +1170,6 @@ BScrollBar::Draw(BRect updateRect) vextent = 3; } - // draw the marks on the scrollbar thumb int32 flags = 0; if (!enabled) flags |= BControlLook::B_DISABLED; @@ -1209,7 +1213,7 @@ BScrollBar::Draw(BRect updateRect) } } - // draw middle mark last because it modifies middleKnob + // draw middle knob last because it modifies middleKnob be_control_look->DrawButtonBackground(this, middleKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } ############################################################################ Commit: 928ffe6dee3b7d183f0a9dfef02d0aae28232364 URL: http://cgit.haiku-os.org/haiku/commit/?id=928ffe6 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Nov 2 03:58:26 2012 UTC Allow the user to select the scrollbar setting graphically. This uses custom controls to allow the user to choose between single and double arrows and none, dots, or line knob styles in a graphical fashion copied from BeOS Scrollbar preflet. ---------------------------------------------------------------------------- diff --git a/src/preferences/appearance/FakeScrollBar.cpp b/src/preferences/appearance/FakeScrollBar.cpp new file mode 100644 index 0000000..61a5c74 --- /dev/null +++ b/src/preferences/appearance/FakeScrollBar.cpp @@ -0,0 +1,348 @@ +/* + * Copyright 2010-2012 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT license. + * + * Authors: + * DarkWyrm <bpmagic@xxxxxxxxxxxxxxx> + * John Scipione <jscipione@xxxxxxxxx> + */ + + +#include "FakeScrollBar.h" + +#include <Box.h> +#include <ControlLook.h> +#include <Message.h> +#include <ScrollBar.h> +#include <Shape.h> +#include <Size.h> +#include <Window.h> + + +typedef enum { + ARROW_LEFT = 0, + ARROW_RIGHT, + ARROW_UP, + ARROW_DOWN, + ARROW_NONE +} arrow_direction; + + +FakeScrollBar::FakeScrollBar(bool drawArrows, bool doubleArrows, + int32 knobStyle, BMessage* message) + : + BControl("FakeScrollBar", NULL, message, B_WILL_DRAW), + fDrawArrows(drawArrows), + fDoubleArrows(doubleArrows), + fKnobStyle(knobStyle) +{ + SetExplicitMinSize(BSize(160, 20)); + SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 20)); +} + + +FakeScrollBar::~FakeScrollBar(void) +{ +} + + +void +FakeScrollBar::Draw(BRect updateRect) +{ + BRect bounds = Bounds(); + + rgb_color normal = ui_color(B_PANEL_BACKGROUND_COLOR); + + if (Value() == B_CONTROL_ON) + SetHighColor(ui_color(B_CONTROL_MARK_COLOR)); + else + SetHighColor(normal); + + // Draw the selected border (2px) + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); + + // draw a gap (1px) + SetHighColor(normal); + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); + + // draw a border around control (1px) + SetHighColor(tint_color(normal, B_DARKEN_1_TINT)); + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); + + BRect thumbBG = bounds; + BRect bgRect = bounds; + + if (fDrawArrows) { + // draw arrows + SetDrawingMode(B_OP_OVER); + + BRect buttonFrame(bounds.left, bounds.top, + bounds.left + bounds.Height(), bounds.bottom); + + _DrawArrowButton(ARROW_LEFT, fDoubleArrows, buttonFrame, updateRect); + + if (fDoubleArrows) { + buttonFrame.OffsetBy(bounds.Height() + 1, 0.0); + _DrawArrowButton(ARROW_RIGHT, fDoubleArrows, buttonFrame, + updateRect); + + buttonFrame.OffsetTo(bounds.right - ((bounds.Height() * 2) + 1), + bounds.top); + _DrawArrowButton(ARROW_LEFT, fDoubleArrows, buttonFrame, + updateRect); + + thumbBG.left += bounds.Height() * 2 + 2; + thumbBG.right -= bounds.Height() * 2 + 2; + } else { + thumbBG.left += bounds.Height() + 1; + thumbBG.right -= bounds.Height() + 1; + } + + buttonFrame.OffsetTo(bounds.right - bounds.Height(), bounds.top); + _DrawArrowButton(ARROW_RIGHT, fDoubleArrows, buttonFrame, updateRect); + + SetDrawingMode(B_OP_COPY); + + bgRect = bounds.InsetByCopy(48, 0); + } else + bgRect = bounds.InsetByCopy(16, 0); + + // fill background besides the thumb + BRect leftOfThumb(thumbBG.left, thumbBG.top, bgRect.left - 1, + thumbBG.bottom); + BRect rightOfThumb(bgRect.right + 1, thumbBG.top, thumbBG.right, + thumbBG.bottom); + + be_control_look->DrawScrollBarBackground(this, leftOfThumb, + rightOfThumb, updateRect, normal, 0, B_HORIZONTAL); + + // Draw scroll thumb + + // fill the clickable surface of the thumb + be_control_look->DrawButtonBackground(this, bgRect, updateRect, + normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); + + if (fKnobStyle == KNOB_STYLE_NONE) + return; + + // draw the scrollbar thumb knobs + bool square = fKnobStyle == KNOB_STYLE_DOTS; + int32 hextent = 0; + int32 vextent = 0; + + if (square) { + hextent = 2; + vextent = 2; + } else { + hextent = 1; + vextent = 3; + } + + float hmiddle = bgRect.Width() / 2; + float vmiddle = bgRect.Height() / 2; + + BRect middleKnob = BRect(bgRect.left + hmiddle - hextent, + bgRect.top + vmiddle - vextent, + bgRect.left + hmiddle + hextent, + bgRect.top + vmiddle + vextent); + + BRect leftKnob = middleKnob.OffsetByCopy(hextent * -4, 0); + if (leftKnob.left > bgRect.left + hextent) { + be_control_look->DrawButtonBackground(this, leftKnob, updateRect, + normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); + } + + BRect rightKnob = middleKnob.OffsetByCopy(hextent * 4, 0); + if (rightKnob.right < bgRect.right - hextent) { + be_control_look->DrawButtonBackground(this, rightKnob, updateRect, + normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); + } + + // draw middle knob last because it modifies middleKnob + be_control_look->DrawButtonBackground(this, middleKnob, updateRect, + normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); +} + + +void +FakeScrollBar::MouseDown(BPoint point) +{ + BControl::MouseDown(point); +} + + +void +FakeScrollBar::MouseMoved(BPoint point, uint32 transit, + const BMessage* message) +{ + BControl::MouseMoved(point, transit, message); +} + + +void +FakeScrollBar::MouseUp(BPoint point) +{ + SetValue(B_CONTROL_ON); + Invoke(); + + Invalidate(); + + BControl::MouseUp(point); +} + + +void +FakeScrollBar::SetValue(int32 value) +{ + if (value != Value()) { + BControl::SetValueNoUpdate(value); + Invalidate(); + } + + if (!value) + return; + + BView* parent = Parent(); + BView* child = NULL; + + if (parent != NULL) { + // If the parent is a BBox, the group parent is the parent of the BBox + BBox* box = dynamic_cast<BBox*>(parent); + + if (box && box->LabelView() == this) + parent = box->Parent(); + + if (parent != NULL) { + BBox* box = dynamic_cast<BBox*>(parent); + + // If the parent is a BBox, skip the label if there is one + if (box && box->LabelView()) + child = parent->ChildAt(1); + else + child = parent->ChildAt(0); + } else + child = Window()->ChildAt(0); + } else if (Window()) + child = Window()->ChildAt(0); + + while (child) { + FakeScrollBar* scrollbar = dynamic_cast<FakeScrollBar*>(child); + + if (scrollbar != NULL && (scrollbar != this)) + scrollbar->SetValue(B_CONTROL_OFF); + else { + // If the child is a BBox, check if the label is a scrollbarbutton + BBox* box = dynamic_cast<BBox*>(child); + + if (box && box->LabelView()) { + scrollbar = dynamic_cast<FakeScrollBar*>(box->LabelView()); + + if (scrollbar != NULL && (scrollbar != this)) + scrollbar->SetValue(B_CONTROL_OFF); + } + } + + child = child->NextSibling(); + } + + //ASSERT(Value() == B_CONTROL_ON); +} + + +// #pragma mark - + + +void +FakeScrollBar::SetDoubleArrows(bool doublearrows) +{ + fDoubleArrows = doublearrows; + Invalidate(); +} + + +void +FakeScrollBar::SetKnobStyle(uint32 style) +{ + fKnobStyle = style; + Invalidate(); +} + + +void +FakeScrollBar::SetFromScrollBarInfo(const scroll_bar_info &info) +{ + fDoubleArrows = info.double_arrows; + fKnobStyle = info.knob; + Invalidate(); +} + + +// #pragma mark - + + +void +FakeScrollBar::_DrawArrowButton(int32 direction, bool doubleArrows, BRect r, + const BRect& updateRect) +{ + if (!updateRect.Intersects(r)) + return; + + rgb_color c = ui_color(B_PANEL_BACKGROUND_COLOR); + rgb_color light = tint_color(c, B_LIGHTEN_MAX_TINT); + rgb_color dark = tint_color(c, B_DARKEN_1_TINT); + rgb_color darker = tint_color(c, B_DARKEN_2_TINT); + rgb_color normal = c; + rgb_color arrow = tint_color(c, + (B_DARKEN_MAX_TINT + B_DARKEN_4_TINT) / 2.0); + + BPoint tri1, tri2, tri3; + float hInset = r.Width() / 3; + float vInset = r.Height() / 3; + r.InsetBy(hInset, vInset); + + switch (direction) { + case ARROW_LEFT: + tri1.Set(r.right, r.top); + tri2.Set(r.right - r.Width() / 1.33, (r.top + r.bottom + 1) / 2); + tri3.Set(r.right, r.bottom + 1); + break; + + case ARROW_RIGHT: + tri1.Set(r.left, r.bottom + 1); + tri2.Set(r.left + r.Width() / 1.33, (r.top + r.bottom + 1) / 2); + tri3.Set(r.left, r.top); + break; + + case ARROW_UP: + tri1.Set(r.left, r.bottom); + tri2.Set((r.left + r.right + 1) / 2, r.bottom - r.Height() / 1.33); + tri3.Set(r.right + 1, r.bottom); + break; + + default: + tri1.Set(r.left, r.top); + tri2.Set((r.left + r.right + 1) / 2, r.top + r.Height() / 1.33); + tri3.Set(r.right + 1, r.top); + break; + } + + r.InsetBy(-(hInset - 1), -(vInset - 1)); + BRect temp(r.InsetByCopy(-1, -1)); + be_control_look->DrawButtonBackground(this, temp, updateRect, + normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); + + BShape arrowShape; + arrowShape.MoveTo(tri1); + arrowShape.LineTo(tri2); + arrowShape.LineTo(tri3); + + SetHighColor(arrow); + SetPenSize(ceilf(hInset / 2.0)); + StrokeShape(&arrowShape); + SetPenSize(1.0); +} diff --git a/src/preferences/appearance/FakeScrollBar.h b/src/preferences/appearance/FakeScrollBar.h new file mode 100644 index 0000000..383b3bc --- /dev/null +++ b/src/preferences/appearance/FakeScrollBar.h @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2012 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT license. + * + * Authors: + * DarkWyrm <bpmagic@xxxxxxxxxxxxxxx> + * John Scipione <jscipione@xxxxxxxxx> + */ +#ifndef FAKE_SCROLL_BAR_H +#define FAKE_SCROLL_BAR_H + + +#include <Control.h> + + +class FakeScrollBar : public BControl { +public: + FakeScrollBar(bool drawArrows, bool doubleArrows, + int32 knobStyle, BMessage* message); + ~FakeScrollBar(void); + + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, + const BMessage *message); + virtual void MouseUp(BPoint point); + + virtual void Draw(BRect updateRect); + + virtual void SetValue(int32 value); + + void SetDoubleArrows(bool doublearrows); + void SetKnobStyle(uint32 style); + + void SetFromScrollBarInfo(const scroll_bar_info &info); + +private: + void _DrawArrowButton(int32 direction, + bool doubleArrows, BRect r, + const BRect& updateRect); + + bool fDrawArrows; + bool fDoubleArrows; + int32 fKnobStyle; +}; + +#endif // FAKE_SCROLL_BAR_H diff --git a/src/preferences/appearance/Jamfile b/src/preferences/appearance/Jamfile index 45904f7..1c287a9 100644 --- a/src/preferences/appearance/Jamfile +++ b/src/preferences/appearance/Jamfile @@ -10,6 +10,7 @@ Preference Appearance : APRMain.cpp AntialiasingSettingsView.cpp LookAndFeelSettingsView.cpp + FakeScrollBar.cpp FontSelectionView.cpp FontView.cpp APRView.cpp diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index 5720764..577e83d 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.cpp +++ b/src/preferences/appearance/LookAndFeelSettingsView.cpp @@ -3,8 +3,9 @@ * Distributed under the terms of the MIT license. * * Authors: - * Alexander von Gluck, kallisti5@xxxxxxxxxxx * Stephan AÃmus <superstippi@xxxxxx> + * Alexander von Gluck <kallisti5@xxxxxxxxxxx> + * John Scipione <jscipione@xxxxxxxxx> * Ryan Leavengood <leavengood@xxxxxxxxx> */ @@ -22,15 +23,22 @@ #include <GridLayoutBuilder.h> #include <GroupLayoutBuilder.h> #include <InterfaceDefs.h> +#include <LayoutBuilder.h> #include <Locale.h> #include <MenuField.h> #include <MenuItem.h> #include <PopUpMenu.h> +#include <RadioButton.h> +#include <ScrollBar.h> +#include <StringView.h> +#include <Size.h> #include <Slider.h> #include <SpaceLayoutItem.h> +#include <StringView.h> #include <TextView.h> #include "APRWindow.h" +#include "FakeScrollBar.h" #undef B_TRANSLATION_CONTEXT @@ -40,9 +48,17 @@ static const int32 kMsgSetDecor = 'deco'; static const int32 kMsgDecorInfo = 'idec'; -static const int32 kMsgDoubleScrollbarArrows = 'dsba'; -static const bool kDefaultDoubleScrollbarArrowsSetting = false; +static const int32 kMsgDoubleScrollBarArrows = 'dsba'; + +static const int32 kMsgArrowStyleSingle = 'mass'; +static const int32 kMsgArrowStyleDouble = 'masd'; + +static const int32 kMsgKnobStyleNone = 'mksn'; +static const int32 kMsgKnobStyleDots = 'mksd'; +static const int32 kMsgKnobStyleLines = 'mksl'; + +static const bool kDefaultDoubleScrollBarArrowsSetting = false; // #pragma mark - @@ -53,8 +69,7 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name) BView(name, 0), fDecorInfoButton(NULL), fDecorMenuField(NULL), - fDecorMenu(NULL), - fDoubleScrollbarArrowsCheckBox(NULL) + fDecorMenu(NULL) { // Decorator menu _BuildDecorMenu(); @@ -64,24 +79,78 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name) fDecorInfoButton = new BButton(B_TRANSLATE("About"), new BMessage(kMsgDecorInfo)); - fDoubleScrollbarArrowsCheckBox = new BCheckBox("doubleScrollbarArrows", - B_TRANSLATE("Use double scrollbar arrows"), - new BMessage(kMsgDoubleScrollbarArrows)); - - fSavedDoubleArrowsValue = _GetDoubleScrollbarArrowsSetting(); - fDoubleScrollbarArrowsCheckBox->SetValue(fSavedDoubleArrowsValue); + // scrollbar arrow style + BBox* arrowStyleBox = new BBox("arrow style"); + arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style")); + + fSavedDoubleArrowsValue = _DoubleScrollBarArrows(); + + fArrowStyleSingle = new FakeScrollBar(true, false, KNOB_STYLE_LINES, + new BMessage(kMsgArrowStyleSingle)); + fArrowStyleDouble = new FakeScrollBar(true, true, KNOB_STYLE_LINES, + new BMessage(kMsgArrowStyleDouble)); + + BView* arrowStyleView; + arrowStyleView = BLayoutBuilder::Group<>() + .AddGroup(B_VERTICAL, 0) + .Add(new BStringView("single", B_TRANSLATE("Single:"))) + .Add(fArrowStyleSingle) + .Add(new BStringView("spacer", "")) + .Add(new BStringView("double", B_TRANSLATE("Double:"))) + .Add(fArrowStyleDouble) + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .End() + .View(); + arrowStyleBox->AddChild(arrowStyleView); + + // scrollbar knob style + fSavedKnobStyleValue = _ScrollBarKnobStyle(); + + BBox* knobStyleBox = new BBox("knob style"); + knobStyleBox->SetLabel(B_TRANSLATE("Knob style")); + + fKnobStyleNone = new FakeScrollBar(false, false, KNOB_STYLE_NONE, + new BMessage(kMsgKnobStyleNone)); + fKnobStyleDots = new FakeScrollBar(false, false, KNOB_STYLE_DOTS, + new BMessage(kMsgKnobStyleDots)); + fKnobStyleLines = new FakeScrollBar(false, false, KNOB_STYLE_LINES, + new BMessage(kMsgKnobStyleLines)); + + BView* knobStyleView; + knobStyleView = BLayoutBuilder::Group<>() + .AddGroup(B_VERTICAL, 0) + .Add(fKnobStyleNone) + .Add(new BStringView("spacer", "")) + .Add(fKnobStyleDots) + .Add(new BStringView("spacer", "")) + .Add(fKnobStyleLines) + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .End() + .View(); + knobStyleBox->AddChild(knobStyleView); SetLayout(new BGroupLayout(B_VERTICAL)); // control layout - AddChild(BGridLayoutBuilder(10, 10) - .Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0) - .Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0) - .Add(fDecorInfoButton, 2, 0) - - .Add(fDoubleScrollbarArrowsCheckBox, 0, 3, 2) - .Add(BSpaceLayoutItem::CreateGlue(), 0, 4, 2) - .SetInsets(10, 10, 10, 10) + AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING) + .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING) + .Add(BGridLayoutBuilder(B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING) + .Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0) + .Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0) + .Add(fDecorInfoButton, 2, 0) + ) + .Add(new BStringView("label", B_TRANSLATE("Scrollbars:"))) + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) + .Add(arrowStyleBox) + .Add(knobStyleBox) + .End() + .AddGlue() + .End() + .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) ); // TODO : Decorator Preview Image? } @@ -102,7 +171,30 @@ LookAndFeelSettingsView::AttachedToWindow() fDecorMenu->SetTargetForItems(this); fDecorInfoButton->SetTarget(this); - fDoubleScrollbarArrowsCheckBox->SetTarget(this); + fArrowStyleSingle->SetTarget(this); + fArrowStyleDouble->SetTarget(this); + fKnobStyleNone->SetTarget(this); + fKnobStyleDots->SetTarget(this); + fKnobStyleLines->SetTarget(this); + + if (fSavedDoubleArrowsValue) + fArrowStyleDouble->SetValue(B_CONTROL_ON); + else + fArrowStyleSingle->SetValue(B_CONTROL_ON); + + switch (fSavedKnobStyleValue) { + case KNOB_STYLE_NONE: + fKnobStyleNone->SetValue(B_CONTROL_ON); + break; + + case KNOB_STYLE_DOTS: + fKnobStyleDots->SetValue(B_CONTROL_ON); + break; + + case KNOB_STYLE_LINES: + fKnobStyleLines->SetValue(B_CONTROL_ON); + break; + } } @@ -117,6 +209,7 @@ LookAndFeelSettingsView::MessageReceived(BMessage *msg) _SetDecor(newDecor); break; } + case kMsgDecorInfo: { DecorInfo* decor = fDecorUtility.FindDecorator(fCurrentDecor); @@ -145,8 +238,25 @@ LookAndFeelSettingsView::MessageReceived(BMessage *msg) break; } - case kMsgDoubleScrollbarArrows: - _SetDoubleScrollbarArrowsSetting(fDoubleScrollbarArrowsCheckBox->Value()); + + case kMsgArrowStyleSingle: + _SetDoubleScrollBarArrows(false); + break; + + case kMsgArrowStyleDouble: + _SetDoubleScrollBarArrows(true); + break; + + case kMsgKnobStyleNone: + _SetScrollBarKnobStyle(KNOB_STYLE_NONE); + break; + + case kMsgKnobStyleDots: + _SetScrollBarKnobStyle(KNOB_STYLE_DOTS); + break; + + case kMsgKnobStyleLines: + _SetScrollBarKnobStyle(KNOB_STYLE_LINES); break; default: @@ -221,7 +331,7 @@ LookAndFeelSettingsView::_AdoptInterfaceToCurrentDecor() bool -LookAndFeelSettingsView::_GetDoubleScrollbarArrowsSetting() +LookAndFeelSettingsView::_DoubleScrollBarArrows() { scroll_bar_info info; get_scroll_bar_info(&info); @@ -231,42 +341,84 @@ LookAndFeelSettingsView::_GetDoubleScrollbarArrowsSetting() void -LookAndFeelSettingsView::_SetDoubleScrollbarArrowsSetting(bool value) +LookAndFeelSettingsView::_SetDoubleScrollBarArrows(bool on) { scroll_bar_info info; get_scroll_bar_info(&info); - info.double_arrows = value; + info.double_arrows = on; set_scroll_bar_info(&info); + if (on) + fArrowStyleDouble->SetValue(B_CONTROL_ON); + else + fArrowStyleSingle->SetValue(B_CONTROL_ON); + Window()->PostMessage(kMsgUpdate); } +int32 +LookAndFeelSettingsView::_ScrollBarKnobStyle() +{ + scroll_bar_info info; + get_scroll_bar_info(&info); + + return info.knob; +} + + void -LookAndFeelSettingsView::SetDefaults() +LookAndFeelSettingsView::_SetScrollBarKnobStyle(int32 knobStyle) { - _SetDecor(fDecorUtility.DefaultDecorator()); - _SetDoubleScrollbarArrowsSetting(kDefaultDoubleScrollbarArrowsSetting); - fDoubleScrollbarArrowsCheckBox->SetValue( - kDefaultDoubleScrollbarArrowsSetting); + scroll_bar_info info; + get_scroll_bar_info(&info); + + info.knob = knobStyle; + set_scroll_bar_info(&info); + + switch (knobStyle) { + case KNOB_STYLE_NONE: + fKnobStyleNone->SetValue(B_CONTROL_ON); + break; + + case KNOB_STYLE_DOTS: + fKnobStyleDots->SetValue(B_CONTROL_ON); + break; + + case KNOB_STYLE_LINES: + fKnobStyleLines->SetValue(B_CONTROL_ON); + break; + } + + Window()->PostMessage(kMsgUpdate); } bool LookAndFeelSettingsView::IsDefaultable() { - return fCurrentDecor != fDecorUtility.DefaultDecorator()->Name() || - fDoubleScrollbarArrowsCheckBox->Value() != - kDefaultDoubleScrollbarArrowsSetting; + return fCurrentDecor != fDecorUtility.DefaultDecorator()->Name() + || _DoubleScrollBarArrows() != false + || _ScrollBarKnobStyle() != KNOB_STYLE_DOTS; +} + + +void +LookAndFeelSettingsView::SetDefaults() +{ + _SetDecor(fDecorUtility.DefaultDecorator()); + _SetDoubleScrollBarArrows(false); + _SetScrollBarKnobStyle(KNOB_STYLE_DOTS); } bool LookAndFeelSettingsView::IsRevertable() { - return fCurrentDecor != fSavedDecor || - fDoubleScrollbarArrowsCheckBox->Value() != fSavedDoubleArrowsValue; + return fCurrentDecor != fSavedDecor + || _DoubleScrollBarArrows() != fSavedDoubleArrowsValue + || _ScrollBarKnobStyle() != fSavedKnobStyleValue; } @@ -274,6 +426,6 @@ void LookAndFeelSettingsView::Revert() { _SetDecor(fSavedDecor); - _SetDoubleScrollbarArrowsSetting(fSavedDoubleArrowsValue); - fDoubleScrollbarArrowsCheckBox->SetValue(fSavedDoubleArrowsValue); + _SetScrollBarKnobStyle(fSavedKnobStyleValue); + _SetDoubleScrollBarArrows(fSavedDoubleArrowsValue); } diff --git a/src/preferences/appearance/LookAndFeelSettingsView.h b/src/preferences/appearance/LookAndFeelSettingsView.h index 3214be3..db2b5bd 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.h +++ b/src/preferences/appearance/LookAndFeelSettingsView.h @@ -2,9 +2,10 @@ * Copyright 2010-2012 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT license. * - * Authors: - * Alexander von Gluck, kallisti5@xxxxxxxxxxx + * Authors: * Stephan AÃmus <superstippi@xxxxxx> + * Alexander von Gluck <kallisti5@xxxxxxxxxxx> + * John Scipione <jscipione@xxxxxxxxx> * Ryan Leavengood <leavengood@xxxxxxxxx> */ #ifndef LOOK_AND_FEEL_SETTINGS_VIEW_H @@ -20,7 +21,7 @@ class BButton; class BCheckBox; class BMenuField; class BPopUpMenu; - +class FakeScrollBar; class LookAndFeelSettingsView : public BView { public: @@ -30,10 +31,11 @@ public: virtual void AttachedToWindow(); virtual void MessageReceived(BMessage* message); - void SetDefaults(); - void Revert(); bool IsDefaultable(); + void SetDefaults(); + bool IsRevertable(); + void Revert(); private: void _SetDecor(const BString& name); @@ -42,8 +44,12 @@ private: void _BuildDecorMenu(); void _AdoptToCurrentDecor(); void _AdoptInterfaceToCurrentDecor(); - bool _GetDoubleScrollbarArrowsSetting(); - void _SetDoubleScrollbarArrowsSetting(bool value); + + bool _DoubleScrollBarArrows(); + void _SetDoubleScrollBarArrows(bool on); + + int32 _ScrollBarKnobStyle(); + void _SetScrollBarKnobStyle(int32 knobStyle); private: DecorInfoUtility fDecorUtility; @@ -51,11 +57,19 @@ private: BButton* fDecorInfoButton; BMenuField* fDecorMenuField; BPopUpMenu* fDecorMenu; - BCheckBox* fDoubleScrollbarArrowsCheckBox; + + FakeScrollBar* fArrowStyleSingle; + FakeScrollBar* fArrowStyleDouble; + + FakeScrollBar* fKnobStyleNone; + FakeScrollBar* fKnobStyleDots; + FakeScrollBar* fKnobStyleLines; BString fSavedDecor; BString fCurrentDecor; + bool fSavedDoubleArrowsValue; + int32 fSavedKnobStyleValue; }; #endif // LOOK_AND_FEEL_SETTINGS_VIEW_H ############################################################################ Commit: 84256e0ab187662bc1385bbbc155ff8f6134b38f URL: http://cgit.haiku-os.org/haiku/commit/?id=84256e0 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Nov 2 04:14:28 2012 UTC Move the 'Look and feel' tab first ---------------------------------------------------------------------------- diff --git a/src/preferences/appearance/APRWindow.cpp b/src/preferences/appearance/APRWindow.cpp index 41cedcc..301887b 100644 --- a/src/preferences/appearance/APRWindow.cpp +++ b/src/preferences/appearance/APRWindow.cpp @@ -50,19 +50,19 @@ APRWindow::APRWindow(BRect frame) BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); + fLookAndFeelSettings = new LookAndFeelSettingsView( + B_TRANSLATE("Look and feel")); + fFontSettings = new FontView(B_TRANSLATE("Fonts")); fColorsView = new APRView(B_TRANSLATE("Colors")); - fLookAndFeelSettings = new LookAndFeelSettingsView( - B_TRANSLATE("Look and feel")); - fAntialiasingSettings = new AntialiasingSettingsView( B_TRANSLATE("Antialiasing")); + tabView->AddTab(fLookAndFeelSettings); tabView->AddTab(fFontSettings); tabView->AddTab(fColorsView); - tabView->AddTab(fLookAndFeelSettings); tabView->AddTab(fAntialiasingSettings); _UpdateButtons(); ############################################################################ Commit: 6408201e33d7de8a6e48748d9a68577bd1d89837 URL: http://cgit.haiku-os.org/haiku/commit/?id=6408201 Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Nov 2 04:43:22 2012 UTC Line the boxes up, at least for the default font size ---------------------------------------------------------------------------- diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index 577e83d..a3aa090 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.cpp +++ b/src/preferences/appearance/LookAndFeelSettingsView.cpp @@ -92,12 +92,13 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name) BView* arrowStyleView; arrowStyleView = BLayoutBuilder::Group<>() - .AddGroup(B_VERTICAL, 0) + .AddGroup(B_VERTICAL, 1) .Add(new BStringView("single", B_TRANSLATE("Single:"))) .Add(fArrowStyleSingle) .Add(new BStringView("spacer", "")) .Add(new BStringView("double", B_TRANSLATE("Double:"))) .Add(fArrowStyleDouble) + .Add(BSpaceLayoutItem::CreateVerticalStrut(0)) .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .End() ############################################################################ Revision: hrev44733 Commit: 6218c8f7eaa451d45fc8febf94dd4051f33ef731 URL: http://cgit.haiku-os.org/haiku/commit/?id=6218c8f Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Nov 2 04:50:39 2012 UTC Scroll bars is 2 words ---------------------------------------------------------------------------- diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index a3aa090..6a2e57f 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.cpp +++ b/src/preferences/appearance/LookAndFeelSettingsView.cpp @@ -143,7 +143,7 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name) .Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0) .Add(fDecorInfoButton, 2, 0) ) - .Add(new BStringView("label", B_TRANSLATE("Scrollbars:"))) + .Add(new BStringView("label", B_TRANSLATE("Scroll bars:"))) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .Add(arrowStyleBox) .Add(knobStyleBox)