Appearance Prefs: Add scroll bar knob setting
Check values before setting them in SetFromScrollBarInfo Pin arrow and knob settings to the top so they are aligned Adjust vertical spacing on single/double to match knob style height Only draw arrows on single/double FakeScrollBar Change-Id: I6be89f86181a87808ba5201caf88a33c4414d4c8
This commit is contained in:
parent
ec1b18c58a
commit
0988f80fed
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2012 Haiku, Inc. All rights reserved.
|
* Copyright 2010-2015 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
* DarkWyrm, bpmagic@columbus.rr.com
|
||||||
* John Scipione <jscipione@gmail.com>
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -27,13 +27,23 @@ typedef enum {
|
|||||||
ARROW_NONE
|
ARROW_NONE
|
||||||
} arrow_direction;
|
} arrow_direction;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
KNOB_NONE = 0,
|
||||||
|
KNOB_DOTS,
|
||||||
|
KNOB_LINES
|
||||||
|
} knob_style;
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - FakeScrollBar
|
||||||
|
|
||||||
|
|
||||||
FakeScrollBar::FakeScrollBar(bool drawArrows, bool doubleArrows,
|
FakeScrollBar::FakeScrollBar(bool drawArrows, bool doubleArrows,
|
||||||
BMessage* message)
|
uint32 knobStyle, BMessage* message)
|
||||||
:
|
:
|
||||||
BControl("FakeScrollBar", NULL, message, B_WILL_DRAW | B_NAVIGABLE),
|
BControl("FakeScrollBar", NULL, message, B_WILL_DRAW | B_NAVIGABLE),
|
||||||
fDrawArrows(drawArrows),
|
fDrawArrows(drawArrows),
|
||||||
fDoubleArrows(doubleArrows)
|
fDoubleArrows(doubleArrows),
|
||||||
|
fKnobStyle(knobStyle)
|
||||||
{
|
{
|
||||||
// add some height to draw the ring around the scroll bar
|
// add some height to draw the ring around the scroll bar
|
||||||
float height = B_H_SCROLL_BAR_HEIGHT + 8;
|
float height = B_H_SCROLL_BAR_HEIGHT + 8;
|
||||||
@ -78,11 +88,19 @@ FakeScrollBar::Draw(BRect updateRect)
|
|||||||
SetHighColor(tint_color(base, B_DARKEN_1_TINT));
|
SetHighColor(tint_color(base, B_DARKEN_1_TINT));
|
||||||
StrokeRect(rect);
|
StrokeRect(rect);
|
||||||
rect.InsetBy(1, 1);
|
rect.InsetBy(1, 1);
|
||||||
SetHighColor(base);
|
|
||||||
|
|
||||||
be_control_look->DrawScrollBar(this, rect, updateRect, base,
|
if (fDrawArrows) {
|
||||||
flags, B_HORIZONTAL, fDoubleArrows);
|
be_control_look->DrawScrollBar(this, rect, updateRect, base,
|
||||||
float less = floorf(rect.Width() / 3); // thumb takes up 1/3 full width
|
flags, B_HORIZONTAL, fDoubleArrows);
|
||||||
|
} else {
|
||||||
|
// do not draw scroll bar arrows, fake the border
|
||||||
|
rgb_color borderColor = tint_color(base, B_DARKEN_2_TINT);
|
||||||
|
rgb_color navigation = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
|
||||||
|
SetHighColor(IsFocus() ? navigation : borderColor);
|
||||||
|
StrokeRect(rect);
|
||||||
|
rect.InsetBy(1, 1);
|
||||||
|
}
|
||||||
|
float less = floorf(rect.Width() / 4); // thumb takes up 3/4 width
|
||||||
BRect thumbRect(rect.left + less, rect.top, rect.right - less, rect.bottom);
|
BRect thumbRect(rect.left + less, rect.top, rect.right - less, rect.bottom);
|
||||||
be_control_look->DrawScrollBarThumb(this, rect, thumbRect, updateRect, base,
|
be_control_look->DrawScrollBarThumb(this, rect, thumbRect, updateRect, base,
|
||||||
flags, B_HORIZONTAL, fKnobStyle);
|
flags, B_HORIZONTAL, fKnobStyle);
|
||||||
@ -90,29 +108,29 @@ FakeScrollBar::Draw(BRect updateRect)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FakeScrollBar::MouseDown(BPoint point)
|
FakeScrollBar::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
BControl::MouseDown(point);
|
BControl::MouseDown(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FakeScrollBar::MouseMoved(BPoint point, uint32 transit,
|
FakeScrollBar::MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* message)
|
const BMessage* dragMessage)
|
||||||
{
|
{
|
||||||
BControl::MouseMoved(point, transit, message);
|
BControl::MouseMoved(where, transit, dragMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FakeScrollBar::MouseUp(BPoint point)
|
FakeScrollBar::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
SetValue(B_CONTROL_ON);
|
SetValue(B_CONTROL_ON);
|
||||||
Invoke();
|
Invoke();
|
||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
|
||||||
BControl::MouseUp(point);
|
BControl::MouseUp(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +142,7 @@ FakeScrollBar::SetValue(int32 value)
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!value)
|
if (value == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BView* parent = Parent();
|
BView* parent = Parent();
|
||||||
@ -147,10 +165,10 @@ FakeScrollBar::SetValue(int32 value)
|
|||||||
child = parent->ChildAt(0);
|
child = parent->ChildAt(0);
|
||||||
} else
|
} else
|
||||||
child = Window()->ChildAt(0);
|
child = Window()->ChildAt(0);
|
||||||
} else if (Window())
|
} else if (Window() != NULL)
|
||||||
child = Window()->ChildAt(0);
|
child = Window()->ChildAt(0);
|
||||||
|
|
||||||
while (child) {
|
while (child != NULL) {
|
||||||
FakeScrollBar* scrollbar = dynamic_cast<FakeScrollBar*>(child);
|
FakeScrollBar* scrollbar = dynamic_cast<FakeScrollBar*>(child);
|
||||||
|
|
||||||
if (scrollbar != NULL && (scrollbar != this))
|
if (scrollbar != NULL && (scrollbar != this))
|
||||||
@ -174,12 +192,12 @@ FakeScrollBar::SetValue(int32 value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FakeScrollBar::SetDoubleArrows(bool doubleArrows)
|
FakeScrollBar::SetDoubleArrows(bool doubleArrows)
|
||||||
{
|
{
|
||||||
|
if (fDoubleArrows == doubleArrows)
|
||||||
|
return;
|
||||||
|
|
||||||
fDoubleArrows = doubleArrows;
|
fDoubleArrows = doubleArrows;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
@ -188,6 +206,9 @@ FakeScrollBar::SetDoubleArrows(bool doubleArrows)
|
|||||||
void
|
void
|
||||||
FakeScrollBar::SetKnobStyle(uint32 knobStyle)
|
FakeScrollBar::SetKnobStyle(uint32 knobStyle)
|
||||||
{
|
{
|
||||||
|
if (fKnobStyle == knobStyle)
|
||||||
|
return;
|
||||||
|
|
||||||
fKnobStyle = knobStyle;
|
fKnobStyle = knobStyle;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
@ -196,13 +217,16 @@ FakeScrollBar::SetKnobStyle(uint32 knobStyle)
|
|||||||
void
|
void
|
||||||
FakeScrollBar::SetFromScrollBarInfo(const scroll_bar_info &info)
|
FakeScrollBar::SetFromScrollBarInfo(const scroll_bar_info &info)
|
||||||
{
|
{
|
||||||
|
if (fDoubleArrows == info.double_arrows && (int32)fKnobStyle == info.knob)
|
||||||
|
return;
|
||||||
|
|
||||||
fDoubleArrows = info.double_arrows;
|
fDoubleArrows = info.double_arrows;
|
||||||
fKnobStyle = info.knob;
|
fKnobStyle = info.knob;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - Private methods
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2012 Haiku, Inc. All rights reserved.
|
* Copyright 2010-2015 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* DarkWyrm <bpmagic@columbus.rr.com>
|
* DarkWyrm, bpmagic@columbus.rr.com
|
||||||
* John Scipione <jscipione@gmail.com>
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
#ifndef FAKE_SCROLL_BAR_H
|
#ifndef FAKE_SCROLL_BAR_H
|
||||||
#define FAKE_SCROLL_BAR_H
|
#define FAKE_SCROLL_BAR_H
|
||||||
@ -16,7 +16,7 @@
|
|||||||
class FakeScrollBar : public BControl {
|
class FakeScrollBar : public BControl {
|
||||||
public:
|
public:
|
||||||
FakeScrollBar(bool drawArrows, bool doubleArrows,
|
FakeScrollBar(bool drawArrows, bool doubleArrows,
|
||||||
BMessage* message);
|
uint32 knobStyle, BMessage* message);
|
||||||
~FakeScrollBar(void);
|
~FakeScrollBar(void);
|
||||||
|
|
||||||
virtual void MouseDown(BPoint point);
|
virtual void MouseDown(BPoint point);
|
||||||
@ -39,7 +39,7 @@ private:
|
|||||||
|
|
||||||
bool fDrawArrows;
|
bool fDrawArrows;
|
||||||
bool fDoubleArrows;
|
bool fDoubleArrows;
|
||||||
int32 fKnobStyle;
|
uint32 fKnobStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FAKE_SCROLL_BAR_H
|
#endif // FAKE_SCROLL_BAR_H
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2012 Haiku, Inc. All rights reserved.
|
* Copyright 2010-2015 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus, superstippi@gmx.de
|
||||||
* Alexander von Gluck <kallisti5@unixzen.com>
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
* John Scipione <jscipione@gmail.com>
|
* Ryan Leavengood, leavengood@gmail.com
|
||||||
* Ryan Leavengood <leavengood@gmail.com>
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
|
#include <RadioButton.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <Size.h>
|
#include <Size.h>
|
||||||
@ -44,6 +45,13 @@
|
|||||||
// This was not renamed to keep from breaking translations
|
// This was not renamed to keep from breaking translations
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
KNOB_NONE = 0,
|
||||||
|
KNOB_DOTS,
|
||||||
|
KNOB_LINES
|
||||||
|
} knob_style;
|
||||||
|
|
||||||
|
|
||||||
static const int32 kMsgSetDecor = 'deco';
|
static const int32 kMsgSetDecor = 'deco';
|
||||||
static const int32 kMsgDecorInfo = 'idec';
|
static const int32 kMsgDecorInfo = 'idec';
|
||||||
|
|
||||||
@ -59,7 +67,7 @@ static const int32 kMsgKnobStyleLines = 'mksl';
|
|||||||
static const bool kDefaultDoubleScrollBarArrowsSetting = false;
|
static const bool kDefaultDoubleScrollBarArrowsSetting = false;
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - LookAndFeelSettingsView
|
||||||
|
|
||||||
|
|
||||||
LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
|
LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
|
||||||
@ -67,7 +75,16 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
|
|||||||
BView(name, 0),
|
BView(name, 0),
|
||||||
fDecorInfoButton(NULL),
|
fDecorInfoButton(NULL),
|
||||||
fDecorMenuField(NULL),
|
fDecorMenuField(NULL),
|
||||||
fDecorMenu(NULL)
|
fDecorMenu(NULL),
|
||||||
|
fSavedDecor(NULL),
|
||||||
|
fCurrentDecor(NULL),
|
||||||
|
fArrowStyleSingle(NULL),
|
||||||
|
fArrowStyleDouble(NULL),
|
||||||
|
fKnobStyleNone(NULL),
|
||||||
|
fKnobStyleDots(NULL),
|
||||||
|
fKnobStyleLines(NULL),
|
||||||
|
fSavedKnobStyleValue(_ScrollBarKnobStyle()),
|
||||||
|
fSavedDoubleArrowsValue(_DoubleScrollBarArrows())
|
||||||
{
|
{
|
||||||
// Decorator menu
|
// Decorator menu
|
||||||
_BuildDecorMenu();
|
_BuildDecorMenu();
|
||||||
@ -81,43 +98,72 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
|
|||||||
BBox* arrowStyleBox = new BBox("arrow style");
|
BBox* arrowStyleBox = new BBox("arrow style");
|
||||||
arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style"));
|
arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style"));
|
||||||
|
|
||||||
fSavedDoubleArrowsValue = _DoubleScrollBarArrows();
|
fArrowStyleSingle = new FakeScrollBar(true, false, _ScrollBarKnobStyle(),
|
||||||
|
|
||||||
fArrowStyleSingle = new FakeScrollBar(true, false,
|
|
||||||
new BMessage(kMsgArrowStyleSingle));
|
new BMessage(kMsgArrowStyleSingle));
|
||||||
fArrowStyleDouble = new FakeScrollBar(true, true,
|
fArrowStyleDouble = new FakeScrollBar(true, true, _ScrollBarKnobStyle(),
|
||||||
new BMessage(kMsgArrowStyleDouble));
|
new BMessage(kMsgArrowStyleDouble));
|
||||||
|
|
||||||
BView* arrowStyleView;
|
BView* arrowStyleView = BLayoutBuilder::Group<>(B_VERTICAL, 1)
|
||||||
arrowStyleView = BLayoutBuilder::Group<>()
|
.AddStrut(B_USE_DEFAULT_SPACING)
|
||||||
.AddGroup(B_VERTICAL, 1)
|
.Add(new BStringView("single", B_TRANSLATE("Single:")))
|
||||||
.Add(new BStringView("single", B_TRANSLATE("Single:")))
|
.Add(fArrowStyleSingle)
|
||||||
.Add(fArrowStyleSingle)
|
.AddStrut(B_USE_DEFAULT_SPACING)
|
||||||
.AddStrut(B_USE_DEFAULT_SPACING)
|
.AddStrut(B_USE_DEFAULT_SPACING)
|
||||||
.Add(new BStringView("double", B_TRANSLATE("Double:")))
|
.Add(new BStringView("double", B_TRANSLATE("Double:")))
|
||||||
.Add(fArrowStyleDouble)
|
.Add(fArrowStyleDouble)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
.AddStrut(B_USE_DEFAULT_SPACING)
|
||||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
.AddStrut(B_USE_SMALL_SPACING)
|
||||||
.End()
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
.View();
|
.View();
|
||||||
arrowStyleBox->AddChild(arrowStyleView);
|
arrowStyleBox->AddChild(arrowStyleView);
|
||||||
arrowStyleBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
arrowStyleBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
||||||
B_ALIGN_VERTICAL_CENTER));
|
B_ALIGN_VERTICAL_CENTER));
|
||||||
arrowStyleBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
arrowStyleBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||||
|
|
||||||
BStringView* scrollBarLabel
|
// scrollbar knob style
|
||||||
= new BStringView("scroll bar", B_TRANSLATE("Scroll bar:"));
|
BBox* knobStyleBox = new BBox("knob style");
|
||||||
scrollBarLabel->SetExplicitAlignment(
|
knobStyleBox->SetLabel(B_TRANSLATE("Knob style"));
|
||||||
BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
|
|
||||||
|
fKnobStyleNone = new FakeScrollBar(false, false, KNOB_NONE,
|
||||||
|
new BMessage(kMsgKnobStyleNone));
|
||||||
|
fKnobStyleDots = new FakeScrollBar(false, false, KNOB_DOTS,
|
||||||
|
new BMessage(kMsgKnobStyleDots));
|
||||||
|
fKnobStyleLines = new FakeScrollBar(false, false, KNOB_LINES,
|
||||||
|
new BMessage(kMsgKnobStyleLines));
|
||||||
|
|
||||||
|
BView* knobStyleView;
|
||||||
|
knobStyleView = BLayoutBuilder::Group<>(B_VERTICAL, 0)
|
||||||
|
.Add(new BStringView("none", B_TRANSLATE("None:")))
|
||||||
|
.Add(fKnobStyleNone)
|
||||||
|
.AddStrut(B_USE_DEFAULT_SPACING)
|
||||||
|
.Add(new BStringView("none", B_TRANSLATE("Dots:")))
|
||||||
|
.Add(fKnobStyleDots)
|
||||||
|
.AddStrut(B_USE_DEFAULT_SPACING)
|
||||||
|
.Add(new BStringView("none", B_TRANSLATE("Lines:")))
|
||||||
|
.Add(fKnobStyleLines)
|
||||||
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
|
.View();
|
||||||
|
knobStyleBox->AddChild(knobStyleView);
|
||||||
|
|
||||||
// control layout
|
// control layout
|
||||||
BLayoutBuilder::Grid<>(this, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
|
.AddGrid(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||||
.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
|
.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
|
||||||
.Add(fDecorInfoButton, 2, 0)
|
.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
|
||||||
.Add(scrollBarLabel, 0, 1)
|
.Add(fDecorInfoButton, 2, 0)
|
||||||
.Add(arrowStyleBox, 1, 1)
|
.End()
|
||||||
.AddGlue(0, 2)
|
.Add(new BStringView("scroll bar", B_TRANSLATE("Scroll bar:")))
|
||||||
|
.AddGroup(B_HORIZONTAL)
|
||||||
|
.AddGroup(B_VERTICAL)
|
||||||
|
.Add(arrowStyleBox)
|
||||||
|
.AddGlue()
|
||||||
|
.End()
|
||||||
|
.AddGroup(B_VERTICAL)
|
||||||
|
.Add(knobStyleBox)
|
||||||
|
.AddGlue()
|
||||||
|
.End()
|
||||||
|
.End()
|
||||||
|
.AddGlue()
|
||||||
.SetInsets(B_USE_WINDOW_SPACING);
|
.SetInsets(B_USE_WINDOW_SPACING);
|
||||||
|
|
||||||
// TODO : Decorator Preview Image?
|
// TODO : Decorator Preview Image?
|
||||||
@ -141,22 +187,40 @@ LookAndFeelSettingsView::AttachedToWindow()
|
|||||||
fDecorInfoButton->SetTarget(this);
|
fDecorInfoButton->SetTarget(this);
|
||||||
fArrowStyleSingle->SetTarget(this);
|
fArrowStyleSingle->SetTarget(this);
|
||||||
fArrowStyleDouble->SetTarget(this);
|
fArrowStyleDouble->SetTarget(this);
|
||||||
|
fKnobStyleNone->SetTarget(this);
|
||||||
|
fKnobStyleDots->SetTarget(this);
|
||||||
|
fKnobStyleLines->SetTarget(this);
|
||||||
|
|
||||||
if (fSavedDoubleArrowsValue)
|
if (fSavedDoubleArrowsValue)
|
||||||
fArrowStyleDouble->SetValue(B_CONTROL_ON);
|
fArrowStyleDouble->SetValue(B_CONTROL_ON);
|
||||||
else
|
else
|
||||||
fArrowStyleSingle->SetValue(B_CONTROL_ON);
|
fArrowStyleSingle->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
|
switch (fSavedKnobStyleValue) {
|
||||||
|
case KNOB_DOTS:
|
||||||
|
fKnobStyleDots->SetValue(B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KNOB_LINES:
|
||||||
|
fKnobStyleLines->SetValue(B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case KNOB_NONE:
|
||||||
|
fKnobStyleNone->SetValue(B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LookAndFeelSettingsView::MessageReceived(BMessage *msg)
|
LookAndFeelSettingsView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (msg->what) {
|
switch (message->what) {
|
||||||
case kMsgSetDecor:
|
case kMsgSetDecor:
|
||||||
{
|
{
|
||||||
BString newDecor;
|
BString newDecor;
|
||||||
if (msg->FindString("decor", &newDecor) == B_OK)
|
if (message->FindString("decor", &newDecor) == B_OK)
|
||||||
_SetDecor(newDecor);
|
_SetDecor(newDecor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -181,9 +245,10 @@ LookAndFeelSettingsView::MessageReceived(BMessage *msg)
|
|||||||
infoText.ReplaceFirst("%decorAuthors", authorsText.String());
|
infoText.ReplaceFirst("%decorAuthors", authorsText.String());
|
||||||
infoText.ReplaceFirst("%decorLic", decor->LicenseName().String());
|
infoText.ReplaceFirst("%decorLic", decor->LicenseName().String());
|
||||||
infoText.ReplaceFirst("%decorURL", decor->SupportURL().String());
|
infoText.ReplaceFirst("%decorURL", decor->SupportURL().String());
|
||||||
infoText.ReplaceFirst("%decorDesc", decor->ShortDescription().String());
|
infoText.ReplaceFirst("%decorDesc",
|
||||||
|
decor->ShortDescription().String());
|
||||||
|
|
||||||
BAlert *infoAlert = new BAlert(B_TRANSLATE("About decorator"),
|
BAlert* infoAlert = new BAlert(B_TRANSLATE("About decorator"),
|
||||||
infoText.String(), B_TRANSLATE("OK"));
|
infoText.String(), B_TRANSLATE("OK"));
|
||||||
infoAlert->SetFlags(infoAlert->Flags() | B_CLOSE_ON_ESCAPE);
|
infoAlert->SetFlags(infoAlert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
infoAlert->Go();
|
infoAlert->Go();
|
||||||
@ -199,8 +264,20 @@ LookAndFeelSettingsView::MessageReceived(BMessage *msg)
|
|||||||
_SetDoubleScrollBarArrows(true);
|
_SetDoubleScrollBarArrows(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kMsgKnobStyleNone:
|
||||||
|
_SetScrollBarKnobStyle(KNOB_NONE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgKnobStyleDots:
|
||||||
|
_SetScrollBarKnobStyle(KNOB_DOTS);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgKnobStyleLines:
|
||||||
|
_SetScrollBarKnobStyle(KNOB_LINES);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(msg);
|
BView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -286,6 +363,9 @@ LookAndFeelSettingsView::_SetDoubleScrollBarArrows(bool doubleArrows)
|
|||||||
scroll_bar_info info;
|
scroll_bar_info info;
|
||||||
get_scroll_bar_info(&info);
|
get_scroll_bar_info(&info);
|
||||||
|
|
||||||
|
if (info.double_arrows == doubleArrows)
|
||||||
|
return;
|
||||||
|
|
||||||
info.double_arrows = doubleArrows;
|
info.double_arrows = doubleArrows;
|
||||||
set_scroll_bar_info(&info);
|
set_scroll_bar_info(&info);
|
||||||
|
|
||||||
@ -298,11 +378,56 @@ LookAndFeelSettingsView::_SetDoubleScrollBarArrows(bool doubleArrows)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
LookAndFeelSettingsView::_ScrollBarKnobStyle()
|
||||||
|
{
|
||||||
|
scroll_bar_info info;
|
||||||
|
get_scroll_bar_info(&info);
|
||||||
|
|
||||||
|
return info.knob;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LookAndFeelSettingsView::_SetScrollBarKnobStyle(int32 knobStyle)
|
||||||
|
{
|
||||||
|
scroll_bar_info info;
|
||||||
|
get_scroll_bar_info(&info);
|
||||||
|
|
||||||
|
if (info.knob == knobStyle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
info.knob = knobStyle;
|
||||||
|
set_scroll_bar_info(&info);
|
||||||
|
|
||||||
|
switch (knobStyle) {
|
||||||
|
case KNOB_DOTS:
|
||||||
|
fKnobStyleDots->SetValue(B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KNOB_LINES:
|
||||||
|
fKnobStyleLines->SetValue(B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case KNOB_NONE:
|
||||||
|
fKnobStyleNone->SetValue(B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fArrowStyleSingle->SetKnobStyle(knobStyle);
|
||||||
|
fArrowStyleDouble->SetKnobStyle(knobStyle);
|
||||||
|
|
||||||
|
Window()->PostMessage(kMsgUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LookAndFeelSettingsView::IsDefaultable()
|
LookAndFeelSettingsView::IsDefaultable()
|
||||||
{
|
{
|
||||||
return fCurrentDecor != fDecorUtility.DefaultDecorator()->Name()
|
return fCurrentDecor != fDecorUtility.DefaultDecorator()->Name()
|
||||||
|| _DoubleScrollBarArrows() != false;
|
|| _DoubleScrollBarArrows() != false
|
||||||
|
|| _ScrollBarKnobStyle() != KNOB_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -311,6 +436,7 @@ LookAndFeelSettingsView::SetDefaults()
|
|||||||
{
|
{
|
||||||
_SetDecor(fDecorUtility.DefaultDecorator());
|
_SetDecor(fDecorUtility.DefaultDecorator());
|
||||||
_SetDoubleScrollBarArrows(false);
|
_SetDoubleScrollBarArrows(false);
|
||||||
|
_SetScrollBarKnobStyle(KNOB_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -318,7 +444,8 @@ bool
|
|||||||
LookAndFeelSettingsView::IsRevertable()
|
LookAndFeelSettingsView::IsRevertable()
|
||||||
{
|
{
|
||||||
return fCurrentDecor != fSavedDecor
|
return fCurrentDecor != fSavedDecor
|
||||||
|| _DoubleScrollBarArrows() != fSavedDoubleArrowsValue;
|
|| _DoubleScrollBarArrows() != fSavedDoubleArrowsValue
|
||||||
|
|| _ScrollBarKnobStyle() != fSavedKnobStyleValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -328,5 +455,6 @@ LookAndFeelSettingsView::Revert()
|
|||||||
if (IsRevertable()) {
|
if (IsRevertable()) {
|
||||||
_SetDecor(fSavedDecor);
|
_SetDecor(fSavedDecor);
|
||||||
_SetDoubleScrollBarArrows(fSavedDoubleArrowsValue);
|
_SetDoubleScrollBarArrows(fSavedDoubleArrowsValue);
|
||||||
|
_SetScrollBarKnobStyle(fSavedKnobStyleValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2012 Haiku, Inc. All rights reserved.
|
* Copyright 2010-2015 Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus, superstippi@gmx.de
|
||||||
* Alexander von Gluck <kallisti5@unixzen.com>
|
* Alexander von Gluck, kallisti5@unixzen.com
|
||||||
* John Scipione <jscipione@gmail.com>
|
* Ryan Leavengood, leavengood@gmail.com
|
||||||
* Ryan Leavengood <leavengood@gmail.com>
|
* John Scipione, jscipione@gmail.com
|
||||||
*/
|
*/
|
||||||
#ifndef LOOK_AND_FEEL_SETTINGS_VIEW_H
|
#ifndef LOOK_AND_FEEL_SETTINGS_VIEW_H
|
||||||
#define LOOK_AND_FEEL_SETTINGS_VIEW_H
|
#define LOOK_AND_FEEL_SETTINGS_VIEW_H
|
||||||
@ -48,20 +48,28 @@ private:
|
|||||||
bool _DoubleScrollBarArrows();
|
bool _DoubleScrollBarArrows();
|
||||||
void _SetDoubleScrollBarArrows(bool doubleArrows);
|
void _SetDoubleScrollBarArrows(bool doubleArrows);
|
||||||
|
|
||||||
|
int32 _ScrollBarKnobStyle();
|
||||||
|
void _SetScrollBarKnobStyle(int32 knobStyle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DecorInfoUtility fDecorUtility;
|
DecorInfoUtility fDecorUtility;
|
||||||
|
|
||||||
BButton* fDecorInfoButton;
|
BButton* fDecorInfoButton;
|
||||||
BMenuField* fDecorMenuField;
|
BMenuField* fDecorMenuField;
|
||||||
BPopUpMenu* fDecorMenu;
|
BPopUpMenu* fDecorMenu;
|
||||||
|
BString fSavedDecor;
|
||||||
|
BString fCurrentDecor;
|
||||||
|
|
||||||
FakeScrollBar* fArrowStyleSingle;
|
FakeScrollBar* fArrowStyleSingle;
|
||||||
FakeScrollBar* fArrowStyleDouble;
|
FakeScrollBar* fArrowStyleDouble;
|
||||||
|
|
||||||
BString fSavedDecor;
|
FakeScrollBar* fKnobStyleNone;
|
||||||
BString fCurrentDecor;
|
FakeScrollBar* fKnobStyleDots;
|
||||||
|
FakeScrollBar* fKnobStyleLines;
|
||||||
|
|
||||||
|
int32 fSavedKnobStyleValue;
|
||||||
bool fSavedDoubleArrowsValue;
|
bool fSavedDoubleArrowsValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // LOOK_AND_FEEL_SETTINGS_VIEW_H
|
#endif // LOOK_AND_FEEL_SETTINGS_VIEW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user