From e49510df49a78fac5332b0b355d9913363874ede Mon Sep 17 00:00:00 2001 From: "Joseph R. Prostko" Date: Thu, 1 Nov 2012 11:50:50 -0400 Subject: [PATCH 01/19] Updated GCC2 and GCC4 optional packages * These were updated again due to recent changes to the buildtools * Packages are based on btrev43045, whereas the previous set was based on btrev43040 +alpha 4 (GCC2 package needed to match recent date versioning change to configure script) --- build/jam/OptionalPackages | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index 52e822a9f0..8d61299e51 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -658,21 +658,21 @@ if [ IsOptionalHaikuImagePackageAdded DevelopmentBase ] # gcc and binutils if $(HAIKU_GCC_VERSION[1]) = 2 || $(isHybridBuild) { InstallOptionalHaikuImagePackage - gcc-2.95.3-r1a4-x86-gcc2-2012-10-12.zip - : $(baseURL)/gcc-2.95.3-r1a4-x86-gcc2-2012-10-12.zip ; + gcc-2.95.3-r1a4-x86-gcc2-2012-11-01.zip + : $(baseURL)/gcc-2.95.3-r1a4-x86-gcc2-2012-11-01.zip ; } if $(HAIKU_GCC_VERSION[1]) = 2 { # symlink to the appropriate system/lib[/gcc2] folder AddSymlinkToHaikuHybridImage - develop abi x86 gcc2 tools gcc-2.95.3-haiku-121012 lib + develop abi x86 gcc2 tools gcc-2.95.3-haiku-121101 lib : /system/lib libstdc++.r4.so : : true ; } if $(HAIKU_GCC_VERSION[1]) = 4 || $(isHybridBuild) { InstallOptionalHaikuImagePackage - gcc-4.6.3-r1a4-x86-gcc4-2012-10-18.zip - : $(baseURL)/gcc-4.6.3-r1a4-x86-gcc4-2012-10-18.zip ; + gcc-4.6.3-r1a4-x86-gcc4-2012-11-01.zip + : $(baseURL)/gcc-4.6.3-r1a4-x86-gcc4-2012-11-01.zip ; } if $(HAIKU_GCC_VERSION[1]) = 4 { @@ -684,7 +684,7 @@ if [ IsOptionalHaikuImagePackageAdded DevelopmentBase ] local libs = libstdc++.so libsupc++.so ; for lib in $(libs) { AddSymlinkToHaikuHybridImage - develop abi x86 gcc4 tools gcc-4.6.3-haiku-121018 lib + develop abi x86 gcc4 tools gcc-4.6.3-haiku-121101 lib : /system/lib $(lib) : : true ; } } From ab4ed6e33b8352e0dde973812b968238bf926d06 Mon Sep 17 00:00:00 2001 From: "Joseph R. Prostko" Date: Thu, 1 Nov 2012 16:31:10 -0400 Subject: [PATCH 02/19] Update Puri optional package for libpng update * Puri wouldn't work after the update to libpng 1.5 * It was still looking for libpng.so.1.4 * Not intended for r1alpha4 branch, as it's still on libpng 1.4 --- build/jam/OptionalPackages | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages index 8d61299e51..01b1fb7b20 100644 --- a/build/jam/OptionalPackages +++ b/build/jam/OptionalPackages @@ -1651,8 +1651,8 @@ if [ IsOptionalHaikuImagePackageAdded Puri ] { Echo "No optional package Puri for gcc2" ; } else { InstallOptionalHaikuImagePackage - puri-0.3.9.1-r1a4-x86-gcc4-2012-08-31.zip - : $(baseURL)/puri-0.3.9.1-r1a4-x86-gcc4-2012-08-31.zip ; + puri-0.3.9.1-x86-gcc4-2012-11-01.zip + : $(baseURL)/puri-0.3.9.1-x86-gcc4-2012-11-01.zip ; AddSymlinkToHaikuImage home config settings deskbar Applications : /boot/apps/Puri/Puri ; } From a0e61cdf4cb705110db0bb2138334e852a2d014d Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 31 Oct 2012 20:27:47 -0400 Subject: [PATCH 03/19] Implement BeOS style scrollbar knobs. Not hooked up to a setting yet. --- src/kits/interface/ScrollBar.cpp | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index 971c59676e..a5c67f6672 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); } From 51e2ba81f1f98fefaba618049b2df9202b93b561 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 31 Oct 2012 20:57:26 -0400 Subject: [PATCH 04/19] Variable name refactoring. They are knobs, not marks --- src/kits/interface/ScrollBar.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index a5c67f6672..1050dcbb6c 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); } From 4b5a6861f2752fef9d2e48b8d8ab0d92ac4dfa09 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 1 Nov 2012 23:57:11 -0400 Subject: [PATCH 05/19] Add the scrollbar constants enum to the header. Also make some minor tweaks in ScrollBar.cpp --- headers/os/interface/ScrollBar.h | 6 ++++++ src/kits/interface/ScrollBar.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/headers/os/interface/ScrollBar.h b/headers/os/interface/ScrollBar.h index c70acbe88f..d9e709ebd5 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 1050dcbb6c..56fab7ba38 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); } From 928ffe6dee3b7d183f0a9dfef02d0aae28232364 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 1 Nov 2012 23:58:26 -0400 Subject: [PATCH 06/19] 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. --- src/preferences/appearance/FakeScrollBar.cpp | 348 ++++++++++++++++++ src/preferences/appearance/FakeScrollBar.h | 46 +++ src/preferences/appearance/Jamfile | 1 + .../appearance/LookAndFeelSettingsView.cpp | 232 ++++++++++-- .../appearance/LookAndFeelSettingsView.h | 30 +- 5 files changed, 609 insertions(+), 48 deletions(-) create mode 100644 src/preferences/appearance/FakeScrollBar.cpp create mode 100644 src/preferences/appearance/FakeScrollBar.h diff --git a/src/preferences/appearance/FakeScrollBar.cpp b/src/preferences/appearance/FakeScrollBar.cpp new file mode 100644 index 0000000000..61a5c74215 --- /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 + * John Scipione + */ + + +#include "FakeScrollBar.h" + +#include +#include +#include +#include +#include +#include +#include + + +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(parent); + + if (box && box->LabelView() == this) + parent = box->Parent(); + + if (parent != NULL) { + BBox* box = dynamic_cast(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(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(child); + + if (box && box->LabelView()) { + scrollbar = dynamic_cast(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 0000000000..383b3bcbfd --- /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 + * John Scipione + */ +#ifndef FAKE_SCROLL_BAR_H +#define FAKE_SCROLL_BAR_H + + +#include + + +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 45904f7a26..1c287a91ac 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 5720764d89..577e83da3f 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@unixzen.com * Stephan Aßmus + * Alexander von Gluck + * John Scipione * Ryan Leavengood */ @@ -22,15 +23,22 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include +#include #include #include +#include #include #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)); + // scrollbar arrow style + BBox* arrowStyleBox = new BBox("arrow style"); + arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style")); - fSavedDoubleArrowsValue = _GetDoubleScrollbarArrowsSetting(); - fDoubleScrollbarArrowsCheckBox->SetValue(fSavedDoubleArrowsValue); + 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::_SetScrollBarKnobStyle(int32 knobStyle) +{ + 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() + || _DoubleScrollBarArrows() != false + || _ScrollBarKnobStyle() != KNOB_STYLE_DOTS; +} + + void LookAndFeelSettingsView::SetDefaults() { _SetDecor(fDecorUtility.DefaultDecorator()); - _SetDoubleScrollbarArrowsSetting(kDefaultDoubleScrollbarArrowsSetting); - fDoubleScrollbarArrowsCheckBox->SetValue( - kDefaultDoubleScrollbarArrowsSetting); -} - - -bool -LookAndFeelSettingsView::IsDefaultable() -{ - return fCurrentDecor != fDecorUtility.DefaultDecorator()->Name() || - fDoubleScrollbarArrowsCheckBox->Value() != - kDefaultDoubleScrollbarArrowsSetting; + _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 3214be3924..db2b5bddea 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@unixzen.com + * Authors: * Stephan Aßmus + * Alexander von Gluck + * John Scipione * Ryan Leavengood */ #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 From 84256e0ab187662bc1385bbbc155ff8f6134b38f Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 00:14:28 -0400 Subject: [PATCH 07/19] Move the 'Look and feel' tab first --- src/preferences/appearance/APRWindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/preferences/appearance/APRWindow.cpp b/src/preferences/appearance/APRWindow.cpp index 41cedcc95c..301887bcf8 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(); From 6408201e33d7de8a6e48748d9a68577bd1d89837 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 00:43:22 -0400 Subject: [PATCH 08/19] Line the boxes up, at least for the default font size --- src/preferences/appearance/LookAndFeelSettingsView.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index 577e83da3f..a3aa090626 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() From 6218c8f7eaa451d45fc8febf94dd4051f33ef731 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 00:50:39 -0400 Subject: [PATCH 09/19] Scroll bars is 2 words --- src/preferences/appearance/LookAndFeelSettingsView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index a3aa090626..6a2e57fcae 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) From 12a7abb6fab98e7f21d5b5bee418bd7b172d6e10 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 01:50:15 -0400 Subject: [PATCH 10/19] Make the fake scrollbar controls navigatable by the keyboard --- src/preferences/appearance/FakeScrollBar.cpp | 36 ++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/preferences/appearance/FakeScrollBar.cpp b/src/preferences/appearance/FakeScrollBar.cpp index 61a5c74215..cd791ccf79 100644 --- a/src/preferences/appearance/FakeScrollBar.cpp +++ b/src/preferences/appearance/FakeScrollBar.cpp @@ -31,7 +31,7 @@ typedef enum { FakeScrollBar::FakeScrollBar(bool drawArrows, bool doubleArrows, int32 knobStyle, BMessage* message) : - BControl("FakeScrollBar", NULL, message, B_WILL_DRAW), + BControl("FakeScrollBar", NULL, message, B_WILL_DRAW | B_NAVIGABLE), fDrawArrows(drawArrows), fDoubleArrows(doubleArrows), fKnobStyle(knobStyle) @@ -53,16 +53,32 @@ FakeScrollBar::Draw(BRect updateRect) rgb_color normal = ui_color(B_PANEL_BACKGROUND_COLOR); - if (Value() == B_CONTROL_ON) - SetHighColor(ui_color(B_CONTROL_MARK_COLOR)); - else - SetHighColor(normal); + if (IsFocus()) { + // draw the focus indicator + SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR)); + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); - // Draw the selected border (2px) - StrokeRect(bounds); - bounds.InsetBy(1.0, 1.0); - StrokeRect(bounds); - bounds.InsetBy(1.0, 1.0); + // Draw the selected border (1px) + if (Value() == B_CONTROL_ON) + SetHighColor(ui_color(B_CONTROL_MARK_COLOR)); + else + SetHighColor(normal); + + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); + } else { + // Draw the selected border (2px) + if (Value() == B_CONTROL_ON) + SetHighColor(ui_color(B_CONTROL_MARK_COLOR)); + else + SetHighColor(normal); + + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); + StrokeRect(bounds); + bounds.InsetBy(1.0, 1.0); + } // draw a gap (1px) SetHighColor(normal); From 82fc1a8f3cffc2f2d3c251278984c30a907a81f9 Mon Sep 17 00:00:00 2001 From: threedeyes <3dEyes@gmail.com> Date: Fri, 2 Nov 2012 12:34:39 +0000 Subject: [PATCH 11/19] NTFS: Fix - Tracker faults when 'Show volumes on desktop' mode enabled. +alpha 4 --- .../file_systems/ntfs/fake_attributes.c | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c b/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c index be029521f6..39a3019b7e 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c +++ b/src/add-ons/kernel/file_systems/ntfs/fake_attributes.c @@ -28,6 +28,7 @@ int32 kFreeTypeCookie = 0x87654321; char *kFailBackMime = {"application/octet-stream"}; char *kDirectoryMime = {"application/x-vnd.Be-directory"}; +char *kAttrTypeName = {"BEOS:TYPE"}; status_t set_mime(vnode *node, const char *filename) @@ -35,7 +36,7 @@ status_t set_mime(vnode *node, const char *filename) struct ext_mime *p; int32 namelen; int32 ext_len; - node->mime = kFailBackMime; + node->mime = NULL; if (filename == NULL) { @@ -56,7 +57,10 @@ status_t set_mime(vnode *node, const char *filename) if (!strcasecmp(filename + namelen - ext_len, p->extension)) break; } - node->mime = p->mime; + if(p->mime==NULL) + node->mime = kFailBackMime; + else + node->mime = p->mime; return B_NO_ERROR; } @@ -189,8 +193,8 @@ fake_read_attrib_dir(fs_volume *_vol, fs_vnode *_node, void *_cookie, entry->d_ino = node->vnid; entry->d_dev = ns->id; - entry->d_reclen = sizeof(struct dirent) + 10; - strcpy(entry->d_name, "BEOS:TYPE"); + entry->d_reclen = sizeof(struct dirent) + strlen(kAttrTypeName); + strcpy(entry->d_name, kAttrTypeName); } *cookie = kCloseTypeCookie; @@ -207,24 +211,19 @@ fake_create_attrib(fs_volume *_vol, fs_vnode *_node, const char* name, uint32 type, int openMode, void** _cookie) { nspace *ns = (nspace *)_vol->private_volume; - int result = B_NO_ERROR; - + LOCK_VOL(ns); TRACE("fake_create_attrib - ENTER (name = [%s])\n",name); - if (strcmp(name, "BEOS:TYPE") != 0) - goto exit; - - *_cookie = &kSetTypeCookie; + if (strcmp(name, kAttrTypeName) == 0) + *_cookie = &kSetTypeCookie; -exit: - - TRACE("fake_create_attrib - EXIT, result is %s\n", strerror(result)); + TRACE("fake_create_attrib - EXIT\n"); UNLOCK_VOL(ns); - return result; + return B_NO_ERROR; } status_t @@ -232,18 +231,16 @@ fake_open_attrib(fs_volume *_vol, fs_vnode *_node, const char *name, int openMode, void **_cookie) { nspace *ns = (nspace *)_vol->private_volume; - int result = B_NO_ERROR; - + status_t result = B_NO_ERROR; + LOCK_VOL(ns); TRACE("fake_open_attrib - ENTER (name = [%s])\n",name); - if (strcmp(name, "BEOS:TYPE") != 0) - goto exit; - - *_cookie = &kSetTypeCookie; - -exit: + if (strcmp(name, kAttrTypeName) == 0) + *_cookie = &kSetTypeCookie; + else + result = ENOENT; TRACE("fake_open_attrib - EXIT, result is %s\n", strerror(result)); From 1d910b5e2b7c39148f496bb6e6a3fa2134c957f2 Mon Sep 17 00:00:00 2001 From: threedeyes <3dEyes@gmail.com> Date: Fri, 2 Nov 2012 12:52:00 +0000 Subject: [PATCH 12/19] NTFS: More fixes for #8332 * Generate name for unnamed volumes +alpha 4 --- .../kernel/file_systems/ntfs/fs_func.c | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ntfs/fs_func.c b/src/add-ons/kernel/file_systems/ntfs/fs_func.c index 82188287ad..da58cbd791 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fs_func.c +++ b/src/add-ons/kernel/file_systems/ntfs/fs_func.c @@ -36,6 +36,7 @@ #include #include +#include #include "attributes.h" #include "fake_attributes.h" @@ -43,11 +44,11 @@ #include "ntfs.h" #include "volume_util.h" -static const char* kNTFSUntitled = {"NTFS Untitled"}; +static const char* kNTFSUnnamed = {"NTFS Unnamed"}; typedef struct identify_cookie { NTFS_BOOT_SECTOR boot; - char label[256]; + char label[MAX_PATH]; } identify_cookie; @@ -257,10 +258,11 @@ fs_identify_partition(int fd, partition_data *partition, void **_cookie) return -1; } - strcpy(cookie->label, kNTFSUntitled); + cookie->label[0]='\0'; + memcpy(&cookie->boot, &boot, 512); - // try get path for device - if (ioctl(fd, B_GET_PATH_FOR_DEVICE, devpath)) { + // get path for device + if (ioctl(fd, B_GET_PATH_FOR_DEVICE, devpath) != 0) { // try mount ntVolume = utils_mount_volume(devpath, MS_RDONLY | MS_RECOVER); if (ntVolume != NULL) { @@ -270,7 +272,26 @@ fs_identify_partition(int fd, partition_data *partition, void **_cookie) } } - memcpy(&cookie->boot, &boot, 512); + // generate a more or less descriptive name for unnamed volume + if (cookie->label[0]=='\0') { + double size; + off_t diskSize = sle64_to_cpu(boot.number_of_sectors) + * le16_to_cpu(boot.bpb.bytes_per_sector); + off_t divisor = 1ULL << 40; + char unit = 'T'; + if (diskSize < divisor) { + divisor = 1UL << 30; + unit = 'G'; + if (diskSize < divisor) { + divisor = 1UL << 20; + unit = 'M'; + } + } + + size = (double)((10 * diskSize + divisor - 1) / divisor); + snprintf(cookie->label, MAX_PATH - 1, "%g %cB NTFS File System", + size / 10, unit); + } *_cookie = cookie; @@ -468,7 +489,7 @@ fs_rfsstat(fs_volume *_vol, struct fs_info *fss) break; } if (i < 0) - strcpy(fss->volume_name, kNTFSUntitled); + strcpy(fss->volume_name, kNTFSUnnamed); else fss->volume_name[i + 1] = 0; From 009fd2571533728ad3b0da9430341b4b7cff46e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 26 Oct 2012 22:13:26 +0200 Subject: [PATCH 13/19] Added BMessage::Append(), and new(std::nothrow_t). * Append() copies all fields from the specified message. * The nothrow operator new allows you to add BMessages to a BObjectList. --- headers/os/app/Message.h | 7 ++++++- src/kits/app/Message.cpp | 41 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h index 2920a1a3a2..c64fdd7fc0 100644 --- a/headers/os/app/Message.h +++ b/headers/os/app/Message.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2010, Haiku Inc. All Rights Reserved. + * Copyright 2005-2012, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -9,6 +9,8 @@ #define _MESSAGE_H +#include + #include #include #include @@ -146,6 +148,8 @@ class BMessage { const void *data, ssize_t numBytes, bool isFixedSize = true, int32 count = 1); + status_t Append(const BMessage &message); + // Removing data status_t RemoveData(const char *name, int32 index = 0); status_t RemoveName(const char *name); @@ -268,6 +272,7 @@ class BMessage { void *operator new(size_t size); void *operator new(size_t, void *pointer); + void *operator new(size_t, const std::nothrow_t &noThrow); void operator delete(void *pointer, size_t size); // Private, reserved, or obsolete diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index a4af4651c1..4b9e5dbaee 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2011, Haiku Inc. All rights reserved. + * Copyright 2005-2012, Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -245,8 +245,15 @@ void * BMessage::operator new(size_t size) { DEBUG_FUNCTION_ENTER2; - void *pointer = sMsgCache->Get(size); - return pointer; + return sMsgCache->Get(size); +} + + +void * +BMessage::operator new(size_t size, const std::nothrow_t &noThrow) +{ + DEBUG_FUNCTION_ENTER2; + return sMsgCache->Get(size); } @@ -2622,6 +2629,34 @@ BMessage::AddFlat(const char *name, BFlattenable *object, int32 count) } +status_t +BMessage::Append(const BMessage &other) +{ + field_header *field = other.fFields; + for (uint32 i = 0; i < other.fHeader->field_count; i++, field++) { + const char *name = (const char *)(other.fData + field->offset); + const void *data = (const void *)(other.fData + field->offset + + field->name_length); + bool isFixed = (field->flags & FIELD_FLAG_FIXED_SIZE) != 0; + size_t size = field->data_size / field->count; + + for (uint32 j = 0; j < field->count; j++) { + if (!isFixed) + size = *(uint32 *)data; + + status_t status = AddData(name, field->type, data, size, + isFixed != 0, 1); + if (status != B_OK) + return status; + + data = (const void *)((const char *)data + size + + (isFixed ? 0 : sizeof(uint32))); + } + } + return B_OK; +} + + status_t BMessage::FindAlignment(const char *name, BAlignment *alignment) const { From 87e70090190405210aee50782485af39f0395f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 2 Nov 2012 23:35:43 +0100 Subject: [PATCH 14/19] Style cleanup. --- headers/os/app/Message.h | 673 ++++++++++++++++++++++----------------- 1 file changed, 381 insertions(+), 292 deletions(-) diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h index c64fdd7fc0..7b3b9f61c0 100644 --- a/headers/os/app/Message.h +++ b/headers/os/app/Message.h @@ -21,6 +21,7 @@ #include /* For convenience */ #include /* For convenience */ + class BAlignment; class BBlockCache; class BMessenger; @@ -47,344 +48,432 @@ enum { // app-defined specifiers start at B_SPECIFIERS_END + 1 }; + class BMessage { - public: - uint32 what; +public: + uint32 what; - BMessage(); - BMessage(uint32 what); - BMessage(const BMessage &other); - virtual ~BMessage(); + BMessage(); + BMessage(uint32 what); + BMessage(const BMessage& other); + virtual ~BMessage(); - BMessage &operator=(const BMessage &other); + BMessage& operator=(const BMessage& other); - // Statistics and misc info - status_t GetInfo(type_code typeRequested, int32 index, - char **nameFound, type_code *typeFound, - int32 *countFound = NULL) const; - status_t GetInfo(const char *name, type_code *typeFound, - int32 *countFound = NULL) const; - status_t GetInfo(const char *name, type_code *typeFound, - bool *fixedSize) const; - status_t GetInfo(const char *name, type_code *typeFound, - int32 *countFound, bool *fixedSize) const; + // Statistics and misc info + status_t GetInfo(type_code typeRequested, int32 index, + char** nameFound, type_code* typeFound, + int32* countFound = NULL) const; + status_t GetInfo(const char* name, type_code* typeFound, + int32* countFound = NULL) const; + status_t GetInfo(const char* name, type_code* typeFound, + bool* fixedSize) const; + status_t GetInfo(const char* name, type_code* typeFound, + int32* countFound, bool* fixedSize) const; - int32 CountNames(type_code type) const; - bool IsEmpty() const; - bool IsSystem() const; - bool IsReply() const; - void PrintToStream() const; + int32 CountNames(type_code type) const; + bool IsEmpty() const; + bool IsSystem() const; + bool IsReply() const; + void PrintToStream() const; - status_t Rename(const char *oldEntry, const char *newEntry); + status_t Rename(const char* oldEntry, + const char* newEntry); - // Delivery info - bool WasDelivered() const; - bool IsSourceWaiting() const; - bool IsSourceRemote() const; - BMessenger ReturnAddress() const; - const BMessage *Previous() const; - bool WasDropped() const; - BPoint DropPoint(BPoint *offset = NULL) const; + // Delivery info + bool WasDelivered() const; + bool IsSourceWaiting() const; + bool IsSourceRemote() const; + BMessenger ReturnAddress() const; + const BMessage* Previous() const; + bool WasDropped() const; + BPoint DropPoint(BPoint* offset = NULL) const; - // Replying - status_t SendReply(uint32 command, BHandler *replyTo = NULL); - status_t SendReply(BMessage *reply, BHandler *replyTo = NULL, - bigtime_t timeout = B_INFINITE_TIMEOUT); - status_t SendReply(BMessage *reply, BMessenger replyTo, - bigtime_t timeout = B_INFINITE_TIMEOUT); + // Replying + status_t SendReply(uint32 command, + BHandler* replyTo = NULL); + status_t SendReply(BMessage* reply, + BHandler* replyTo = NULL, + bigtime_t timeout = B_INFINITE_TIMEOUT); + status_t SendReply(BMessage* reply, BMessenger replyTo, + bigtime_t timeout = B_INFINITE_TIMEOUT); - status_t SendReply(uint32 command, BMessage *replyToReply); - status_t SendReply(BMessage *the_reply, BMessage *replyToReply, - bigtime_t sendTimeout = B_INFINITE_TIMEOUT, - bigtime_t replyTimeout = B_INFINITE_TIMEOUT); + status_t SendReply(uint32 command, + BMessage* replyToReply); + status_t SendReply(BMessage* reply, + BMessage* replyToReply, + bigtime_t sendTimeout = B_INFINITE_TIMEOUT, + bigtime_t replyTimeout + = B_INFINITE_TIMEOUT); - // Flattening data - ssize_t FlattenedSize() const; - status_t Flatten(char *buffer, ssize_t size) const; - status_t Flatten(BDataIO *stream, ssize_t *size = NULL) const; - status_t Unflatten(const char *flatBuffer); - status_t Unflatten(BDataIO *stream); + // Flattening data + ssize_t FlattenedSize() const; + status_t Flatten(char* buffer, ssize_t size) const; + status_t Flatten(BDataIO* stream, + ssize_t* size = NULL) const; + status_t Unflatten(const char* flatBuffer); + status_t Unflatten(BDataIO* stream); - // Specifiers (scripting) - status_t AddSpecifier(const char *property); - status_t AddSpecifier(const char *property, int32 index); - status_t AddSpecifier(const char *property, int32 index, int32 range); - status_t AddSpecifier(const char *property, const char *name); - status_t AddSpecifier(const BMessage *specifier); + // Specifiers (scripting) + status_t AddSpecifier(const char* property); + status_t AddSpecifier(const char* property, int32 index); + status_t AddSpecifier(const char* property, int32 index, + int32 range); + status_t AddSpecifier(const char* property, + const char* name); + status_t AddSpecifier(const BMessage* specifier); - status_t SetCurrentSpecifier(int32 index); - status_t GetCurrentSpecifier(int32 *index, - BMessage *specifier = NULL, int32 *what = NULL, - const char **property = NULL) const; - bool HasSpecifiers() const; - status_t PopSpecifier(); + status_t SetCurrentSpecifier(int32 index); + status_t GetCurrentSpecifier(int32* index, + BMessage* specifier = NULL, + int32* what = NULL, + const char** property = NULL) const; + bool HasSpecifiers() const; + status_t PopSpecifier(); - // Adding data - status_t AddAlignment(const char* name, - const BAlignment& alignment); - status_t AddRect(const char *name, BRect aRect); - status_t AddPoint(const char *name, BPoint aPoint); - status_t AddSize(const char* name, BSize aSize); - status_t AddString(const char *name, const char *aString); - status_t AddString(const char *name, const BString &aString); - status_t AddInt8(const char *name, int8 value); - status_t AddUInt8(const char *name, uint8 value); - status_t AddInt16(const char *name, int16 value); - status_t AddUInt16(const char *name, uint16 value); - status_t AddInt32(const char *name, int32 value); - status_t AddUInt32(const char *name, uint32 value); - status_t AddInt64(const char *name, int64 value); - status_t AddUInt64(const char *name, uint64 value); - status_t AddBool(const char *name, bool aBoolean); - status_t AddFloat(const char *name, float aFloat); - status_t AddDouble(const char *name, double aDouble); - status_t AddPointer(const char *name, const void *aPointer); - status_t AddMessenger(const char *name, BMessenger messenger); - status_t AddRef(const char *name, const entry_ref *ref); - status_t AddMessage(const char *name, const BMessage *message); - status_t AddFlat(const char *name, BFlattenable *object, - int32 count = 1); - status_t AddData(const char *name, type_code type, - const void *data, ssize_t numBytes, - bool isFixedSize = true, int32 count = 1); + // Adding data + status_t AddAlignment(const char* name, + const BAlignment& alignment); + status_t AddRect(const char* name, BRect rect); + status_t AddPoint(const char* name, BPoint point); + status_t AddSize(const char* name, BSize size); + status_t AddString(const char* name, const char* string); + status_t AddString(const char* name, + const BString& string); + status_t AddInt8(const char* name, int8 value); + status_t AddUInt8(const char* name, uint8 value); + status_t AddInt16(const char* name, int16 value); + status_t AddUInt16(const char* name, uint16 value); + status_t AddInt32(const char* name, int32 value); + status_t AddUInt32(const char* name, uint32 value); + status_t AddInt64(const char* name, int64 value); + status_t AddUInt64(const char* name, uint64 value); + status_t AddBool(const char* name, bool value); + status_t AddFloat(const char* name, float value); + status_t AddDouble(const char* name, double value); + status_t AddPointer(const char* name, + const void* pointer); + status_t AddMessenger(const char* name, + BMessenger messenger); + status_t AddRef(const char* name, const entry_ref* ref); + status_t AddMessage(const char* name, + const BMessage* message); + status_t AddFlat(const char* name, BFlattenable* object, + int32 count = 1); + status_t AddData(const char* name, type_code type, + const void* data, ssize_t numBytes, + bool isFixedSize = true, int32 count = 1); - status_t Append(const BMessage &message); + status_t Append(const BMessage& message); - // Removing data - status_t RemoveData(const char *name, int32 index = 0); - status_t RemoveName(const char *name); - status_t MakeEmpty(); + // Removing data + status_t RemoveData(const char* name, int32 index = 0); + status_t RemoveName(const char* name); + status_t MakeEmpty(); - // Finding data - status_t FindAlignment(const char* name, - BAlignment* alignment) const; - status_t FindAlignment(const char* name, int32 index, - BAlignment* alignment) const; + // Finding data + status_t FindAlignment(const char* name, + BAlignment* alignment) const; + status_t FindAlignment(const char* name, int32 index, + BAlignment* alignment) const; - status_t FindRect(const char *name, BRect *rect) const; - status_t FindRect(const char *name, int32 index, BRect *rect) const; - status_t FindPoint(const char *name, BPoint *point) const; - status_t FindPoint(const char *name, int32 index, BPoint *point) const; + status_t FindRect(const char* name, BRect* rect) const; + status_t FindRect(const char* name, int32 index, + BRect* rect) const; + status_t FindPoint(const char* name, + BPoint* point) const; + status_t FindPoint(const char* name, int32 index, + BPoint* point) const; - status_t FindSize(const char *name, BSize* size) const; - status_t FindSize(const char *name, - int32 index, BSize* size) const; + status_t FindSize(const char* name, BSize* size) const; + status_t FindSize(const char* name, int32 index, + BSize* size) const; - status_t FindString(const char *name, const char **string) const; - status_t FindString(const char *name, int32 index, const char **string) const; - status_t FindString(const char *name, BString *string) const; - status_t FindString(const char *name, int32 index, BString *string) const; - status_t FindInt8(const char *name, int8 *value) const; - status_t FindInt8(const char *name, int32 index, int8 *value) const; - status_t FindUInt8(const char *name, uint8 *value) const; - status_t FindUInt8(const char *name, int32 index, uint8 *value) const; - status_t FindInt16(const char *name, int16 *value) const; - status_t FindInt16(const char *name, int32 index, int16 *value) const; - status_t FindUInt16(const char *name, uint16 *value) const; - status_t FindUInt16(const char *name, int32 index, uint16 *value) const; - status_t FindInt32(const char *name, int32 *value) const; - status_t FindInt32(const char *name, int32 index, int32 *value) const; - status_t FindUInt32(const char *name, uint32 *value) const; - status_t FindUInt32(const char *name, int32 index, uint32 *value) const; - status_t FindInt64(const char *name, int64 *value) const; - status_t FindInt64(const char *name, int32 index, int64 *value) const; - status_t FindUInt64(const char *name, uint64 *value) const; - status_t FindUInt64(const char *name, int32 index, uint64 *value) const; - status_t FindBool(const char *name, bool *value) const; - status_t FindBool(const char *name, int32 index, bool *value) const; - status_t FindFloat(const char *name, float *value) const; - status_t FindFloat(const char *name, int32 index, float *value) const; - status_t FindDouble(const char *name, double *value) const; - status_t FindDouble(const char *name, int32 index, double *value) const; - status_t FindPointer(const char *name, void **pointer) const; - status_t FindPointer(const char *name, int32 index, void **pointer) const; - status_t FindMessenger(const char *name, BMessenger *messenger) const; - status_t FindMessenger(const char *name, int32 index, BMessenger *messenger) const; - status_t FindRef(const char *name, entry_ref *ref) const; - status_t FindRef(const char *name, int32 index, entry_ref *ref) const; - status_t FindMessage(const char *name, BMessage *message) const; - status_t FindMessage(const char *name, int32 index, BMessage *message) const; - status_t FindFlat(const char *name, BFlattenable *object) const; - status_t FindFlat(const char *name, int32 index, BFlattenable *object) const; - status_t FindData(const char *name, type_code type, - const void **data, ssize_t *numBytes) const; - status_t FindData(const char *name, type_code type, int32 index, - const void **data, ssize_t *numBytes) const; + status_t FindString(const char* name, + const char** string) const; + status_t FindString(const char* name, int32 index, + const char** string) const; + status_t FindString(const char* name, + BString* string) const; + status_t FindString(const char* name, int32 index, + BString* string) const; + status_t FindInt8(const char* name, int8* value) const; + status_t FindInt8(const char* name, int32 index, + int8* value) const; + status_t FindUInt8(const char* name, uint8* value) const; + status_t FindUInt8(const char* name, int32 index, + uint8* value) const; + status_t FindInt16(const char* name, int16* value) const; + status_t FindInt16(const char* name, int32 index, + int16* value) const; + status_t FindUInt16(const char* name, + uint16* value) const; + status_t FindUInt16(const char* name, int32 index, + uint16* value) const; + status_t FindInt32(const char* name, int32* value) const; + status_t FindInt32(const char* name, int32 index, + int32* value) const; + status_t FindUInt32(const char* name, + uint32* value) const; + status_t FindUInt32(const char* name, int32 index, + uint32* value) const; + status_t FindInt64(const char* name, int64* value) const; + status_t FindInt64(const char* name, int32 index, + int64* value) const; + status_t FindUInt64(const char* name, + uint64* value) const; + status_t FindUInt64(const char* name, int32 index, + uint64* value) const; + status_t FindBool(const char* name, bool* value) const; + status_t FindBool(const char* name, int32 index, + bool* value) const; + status_t FindFloat(const char* name, float* value) const; + status_t FindFloat(const char* name, int32 index, + float* value) const; + status_t FindDouble(const char* name, + double* value) const; + status_t FindDouble(const char* name, int32 index, + double* value) const; + status_t FindPointer(const char* name, + void** pointer) const; + status_t FindPointer(const char* name, int32 index, + void** pointer) const; + status_t FindMessenger(const char* name, + BMessenger* messenger) const; + status_t FindMessenger(const char* name, int32 index, + BMessenger* messenger) const; + status_t FindRef(const char* name, entry_ref* ref) const; + status_t FindRef(const char* name, int32 index, + entry_ref* ref) const; + status_t FindMessage(const char* name, + BMessage* message) const; + status_t FindMessage(const char* name, int32 index, + BMessage* message) const; + status_t FindFlat(const char* name, + BFlattenable* object) const; + status_t FindFlat(const char* name, int32 index, + BFlattenable* object) const; + status_t FindData(const char* name, type_code type, + const void** data, ssize_t* numBytes) const; + status_t FindData(const char* name, type_code type, + int32 index, const void** data, + ssize_t* numBytes) const; - // Replacing data - status_t ReplaceAlignment(const char* name, - const BAlignment& alignment); - status_t ReplaceAlignment(const char* name, int32 index, - const BAlignment& alignment); + // Replacing data + status_t ReplaceAlignment(const char* name, + const BAlignment& alignment); + status_t ReplaceAlignment(const char* name, int32 index, + const BAlignment& alignment); - status_t ReplaceRect(const char *name, BRect aRect); - status_t ReplaceRect(const char *name, int32 index, BRect aRect); + status_t ReplaceRect(const char* name, BRect rect); + status_t ReplaceRect(const char* name, int32 index, + BRect rect); - status_t ReplacePoint(const char *name, BPoint aPoint); - status_t ReplacePoint(const char *name, int32 index, BPoint aPoint); - status_t ReplaceSize(const char* name, BSize aSize); - status_t ReplaceSize(const char* name, int32 index, BSize aSize); + status_t ReplacePoint(const char* name, BPoint aPoint); + status_t ReplacePoint(const char* name, int32 index, + BPoint aPoint); + status_t ReplaceSize(const char* name, BSize aSize); + status_t ReplaceSize(const char* name, int32 index, + BSize aSize); - status_t ReplaceString(const char *name, const char *aString); - status_t ReplaceString(const char *name, int32 index, const char *aString); - status_t ReplaceString(const char *name, const BString &aString); - status_t ReplaceString(const char *name, int32 index, const BString &aString); - status_t ReplaceInt8(const char *name, int8 value); - status_t ReplaceInt8(const char *name, int32 index, int8 value); - status_t ReplaceUInt8(const char *name, uint8 value); - status_t ReplaceUInt8(const char *name, int32 index, uint8 value); - status_t ReplaceInt16(const char *name, int16 value); - status_t ReplaceInt16(const char *name, int32 index, int16 value); - status_t ReplaceUInt16(const char *name, uint16 value); - status_t ReplaceUInt16(const char *name, int32 index, uint16 value); - status_t ReplaceInt32(const char *name, int32 value); - status_t ReplaceInt32(const char *name, int32 index, int32 value); - status_t ReplaceUInt32(const char *name, uint32 value); - status_t ReplaceUInt32(const char *name, int32 index, uint32 value); - status_t ReplaceInt64(const char *name, int64 value); - status_t ReplaceInt64(const char *name, int32 index, int64 value); - status_t ReplaceUInt64(const char *name, uint64 value); - status_t ReplaceUInt64(const char *name, int32 index, uint64 value); - status_t ReplaceBool(const char *name, bool aBoolean); - status_t ReplaceBool(const char *name, int32 index, bool aBoolean); - status_t ReplaceFloat(const char *name, float aFloat); - status_t ReplaceFloat(const char *name, int32 index, float aFloat); - status_t ReplaceDouble(const char *name, double aDouble); - status_t ReplaceDouble(const char *name, int32 index, double aDouble); - status_t ReplacePointer(const char *name, const void *pointer); - status_t ReplacePointer(const char *name,int32 index,const void *pointer); - status_t ReplaceMessenger(const char *name, BMessenger messenger); - status_t ReplaceMessenger(const char *name, int32 index, BMessenger messenger); - status_t ReplaceRef( const char *name,const entry_ref *ref); - status_t ReplaceRef( const char *name, int32 index, const entry_ref *ref); - status_t ReplaceMessage(const char *name, const BMessage *message); - status_t ReplaceMessage(const char *name, int32 index, const BMessage *message); - status_t ReplaceFlat(const char *name, BFlattenable *object); - status_t ReplaceFlat(const char *name, int32 index, BFlattenable *object); - status_t ReplaceData(const char *name, type_code type, - const void *data, ssize_t numBytes); - status_t ReplaceData(const char *name, type_code type, int32 index, - const void *data, ssize_t numBytes); + status_t ReplaceString(const char* name, + const char* string); + status_t ReplaceString(const char* name, int32 index, + const char* string); + status_t ReplaceString(const char* name, + const BString& string); + status_t ReplaceString(const char* name, int32 index, + const BString& string); + status_t ReplaceInt8(const char* name, int8 value); + status_t ReplaceInt8(const char* name, int32 index, + int8 value); + status_t ReplaceUInt8(const char* name, uint8 value); + status_t ReplaceUInt8(const char* name, int32 index, + uint8 value); + status_t ReplaceInt16(const char* name, int16 value); + status_t ReplaceInt16(const char* name, int32 index, + int16 value); + status_t ReplaceUInt16(const char* name, uint16 value); + status_t ReplaceUInt16(const char* name, int32 index, + uint16 value); + status_t ReplaceInt32(const char* name, int32 value); + status_t ReplaceInt32(const char* name, int32 index, + int32 value); + status_t ReplaceUInt32(const char* name, uint32 value); + status_t ReplaceUInt32(const char* name, int32 index, + uint32 value); + status_t ReplaceInt64(const char* name, int64 value); + status_t ReplaceInt64(const char* name, int32 index, + int64 value); + status_t ReplaceUInt64(const char* name, uint64 value); + status_t ReplaceUInt64(const char* name, int32 index, + uint64 value); + status_t ReplaceBool(const char* name, bool aBoolean); + status_t ReplaceBool(const char* name, int32 index, + bool value); + status_t ReplaceFloat(const char* name, float value); + status_t ReplaceFloat(const char* name, int32 index, + float value); + status_t ReplaceDouble(const char* name, double value); + status_t ReplaceDouble(const char* name, int32 index, + double value); + status_t ReplacePointer(const char* name, + const void* pointer); + status_t ReplacePointer(const char* name, int32 index, + const void* pointer); + status_t ReplaceMessenger(const char* name, + BMessenger messenger); + status_t ReplaceMessenger(const char* name, int32 index, + BMessenger messenger); + status_t ReplaceRef(const char* name, + const entry_ref* ref); + status_t ReplaceRef(const char* name, int32 index, + const entry_ref* ref); + status_t ReplaceMessage(const char* name, + const BMessage* message); + status_t ReplaceMessage(const char* name, int32 index, + const BMessage* message); + status_t ReplaceFlat(const char* name, + BFlattenable* object); + status_t ReplaceFlat(const char* name, int32 index, + BFlattenable* object); + status_t ReplaceData(const char* name, type_code type, + const void* data, ssize_t numBytes); + status_t ReplaceData(const char* name, type_code type, + int32 index, const void* data, + ssize_t numBytes); - // Comparing data - Haiku experimental API - bool HasSameData(const BMessage &other, - bool ignoreFieldOrder = true, bool deep = false) const; + // Comparing data - Haiku experimental API + bool HasSameData(const BMessage& other, + bool ignoreFieldOrder = true, + bool deep = false) const; - void *operator new(size_t size); - void *operator new(size_t, void *pointer); - void *operator new(size_t, const std::nothrow_t &noThrow); - void operator delete(void *pointer, size_t size); + void* operator new(size_t size); + void* operator new(size_t, void* pointer); + void* operator new(size_t, + const std::nothrow_t& noThrow); + void operator delete(void* pointer, size_t size); - // Private, reserved, or obsolete - bool HasAlignment(const char*, int32 n = 0) const; - bool HasRect(const char *, int32 n = 0) const; - bool HasPoint(const char *, int32 n = 0) const; - bool HasSize(const char*, int32 n = 0) const; - bool HasString(const char *, int32 n = 0) const; - bool HasInt8(const char *, int32 n = 0) const; - bool HasUInt8(const char *, int32 n = 0) const; - bool HasInt16(const char *, int32 n = 0) const; - bool HasUInt16(const char *, int32 n = 0) const; - bool HasInt32(const char *, int32 n = 0) const; - bool HasUInt32(const char *, int32 n = 0) const; - bool HasInt64(const char *, int32 n = 0) const; - bool HasUInt64(const char *, int32 n = 0) const; - bool HasBool(const char *, int32 n = 0) const; - bool HasFloat(const char *, int32 n = 0) const; - bool HasDouble(const char *, int32 n = 0) const; - bool HasPointer(const char *, int32 n = 0) const; - bool HasMessenger(const char *, int32 n = 0) const; - bool HasRef(const char *, int32 n = 0) const; - bool HasMessage(const char *, int32 n = 0) const; - bool HasFlat(const char *, const BFlattenable *) const; - bool HasFlat(const char *, int32 n, const BFlattenable *) const; - bool HasData(const char *, type_code , int32 n = 0) const; - BRect FindRect(const char *, int32 n = 0) const; - BPoint FindPoint(const char *, int32 n = 0) const; - const char *FindString(const char *, int32 n = 0) const; - int8 FindInt8(const char *, int32 n = 0) const; - int16 FindInt16(const char *, int32 n = 0) const; - int32 FindInt32(const char *, int32 n = 0) const; - int64 FindInt64(const char *, int32 n = 0) const; - bool FindBool(const char *, int32 n = 0) const; - float FindFloat(const char *, int32 n = 0) const; - double FindDouble(const char *, int32 n = 0) const; + // Private, reserved, or obsolete + bool HasAlignment(const char* name, + int32 n = 0) const; + bool HasRect(const char* name, int32 n = 0) const; + bool HasPoint(const char* name, int32 n = 0) const; + bool HasSize(const char* name, int32 n = 0) const; + bool HasString(const char* name, int32 n = 0) const; + bool HasInt8(const char* name, int32 n = 0) const; + bool HasUInt8(const char* name, int32 n = 0) const; + bool HasInt16(const char* name, int32 n = 0) const; + bool HasUInt16(const char* name, int32 n = 0) const; + bool HasInt32(const char* name, int32 n = 0) const; + bool HasUInt32(const char* name, int32 n = 0) const; + bool HasInt64(const char* name, int32 n = 0) const; + bool HasUInt64(const char* name, int32 n = 0) const; + bool HasBool(const char* name, int32 n = 0) const; + bool HasFloat(const char* name, int32 n = 0) const; + bool HasDouble(const char* name, int32 n = 0) const; + bool HasPointer(const char* name, int32 n = 0) const; + bool HasMessenger(const char* name, + int32 n = 0) const; + bool HasRef(const char* name, int32 n = 0) const; + bool HasMessage(const char* name, int32 n = 0) const; + bool HasFlat(const char* name, + const BFlattenable* ) const; + bool HasFlat(const char* name, int32 n, + const BFlattenable* ) const; + bool HasData(const char* name, type_code , + int32 n = 0) const; + BRect FindRect(const char* name, int32 n = 0) const; + BPoint FindPoint(const char* name, int32 n = 0) const; + const char* FindString(const char* name, int32 n = 0) const; + int8 FindInt8(const char* name, int32 n = 0) const; + int16 FindInt16(const char* name, int32 n = 0) const; + int32 FindInt32(const char* name, int32 n = 0) const; + int64 FindInt64(const char* name, int32 n = 0) const; + bool FindBool(const char* name, int32 n = 0) const; + float FindFloat(const char* name, int32 n = 0) const; + double FindDouble(const char* name, int32 n = 0) const; - class Private; - struct message_header; - struct field_header; + class Private; + struct message_header; + struct field_header; - private: - friend class Private; - friend class BMessageQueue; +private: + friend class Private; + friend class BMessageQueue; - status_t _InitCommon(bool initHeader); - status_t _InitHeader(); - status_t _Clear(); + status_t _InitCommon(bool initHeader); + status_t _InitHeader(); + status_t _Clear(); - status_t _FlattenToArea(message_header **_header) const; - status_t _CopyForWrite(); - status_t _Reference(); - status_t _Dereference(); + status_t _FlattenToArea(message_header** _header) const; + status_t _CopyForWrite(); + status_t _Reference(); + status_t _Dereference(); - status_t _ValidateMessage(); + status_t _ValidateMessage(); - status_t _ResizeData(uint32 offset, int32 change); + status_t _ResizeData(uint32 offset, int32 change); - uint32 _HashName(const char* name) const; - status_t _FindField(const char* name, type_code type, - field_header** _result) const; - status_t _AddField(const char* name, type_code type, - bool isFixedSize, field_header** _result); - status_t _RemoveField(field_header* field); + uint32 _HashName(const char* name) const; + status_t _FindField(const char* name, type_code type, + field_header** _result) const; + status_t _AddField(const char* name, type_code type, + bool isFixedSize, field_header** _result); + status_t _RemoveField(field_header* field); - void _PrintToStream(const char* indent) const; + void _PrintToStream(const char* indent) const; - private: - message_header* fHeader; - field_header* fFields; - uint8* fData; +private: + BMessage(BMessage* message); + // deprecated - uint32 fFieldsAvailable; - size_t fDataAvailable; + virtual void _ReservedMessage1(); + virtual void _ReservedMessage2(); + virtual void _ReservedMessage3(); - mutable BMessage* fOriginal; + status_t _SendMessage(port_id port, team_id portOwner, + int32 token, bigtime_t timeout, + bool replyRequired, + BMessenger& replyTo) const; + status_t _SendMessage(port_id port, team_id portOwner, + int32 token, BMessage* reply, + bigtime_t sendTimeout, + bigtime_t replyTimeout) const; + static status_t _SendFlattenedMessage(void* data, int32 size, + port_id port, int32 token, + bigtime_t timeout); - BMessage* fQueueLink; - // fQueueLink is used by BMessageQueue to build a linked list + static void _StaticInit(); + static void _StaticReInitForkedChild(); + static void _StaticCleanup(); + static void _StaticCacheCleanup(); + static int32 _StaticGetCachedReplyPort(); - void* fArchivingPointer; +private: + message_header* fHeader; + field_header* fFields; + uint8* fData; - uint32 fReserved[8]; + uint32 fFieldsAvailable; + size_t fDataAvailable; - // deprecated - BMessage(BMessage *message); + mutable BMessage* fOriginal; - virtual void _ReservedMessage1(); - virtual void _ReservedMessage2(); - virtual void _ReservedMessage3(); + BMessage* fQueueLink; + // fQueueLink is used by BMessageQueue to build a linked list - status_t _SendMessage(port_id port, team_id portOwner, int32 token, - bigtime_t timeout, bool replyRequired, - BMessenger &replyTo) const; - status_t _SendMessage(port_id port, team_id portOwner, - int32 token, BMessage *reply, bigtime_t sendTimeout, - bigtime_t replyTimeout) const; - static status_t _SendFlattenedMessage(void *data, int32 size, - port_id port, int32 token, bigtime_t timeout); + void* fArchivingPointer; - static void _StaticInit(); - static void _StaticReInitForkedChild(); - static void _StaticCleanup(); - static void _StaticCacheCleanup(); - static int32 _StaticGetCachedReplyPort(); + uint32 fReserved[8]; - enum { sNumReplyPorts = 3 }; - static port_id sReplyPorts[sNumReplyPorts]; - static int32 sReplyPortInUse[sNumReplyPorts]; - static int32 sGetCachedReplyPort(); + enum { sNumReplyPorts = 3 }; + static port_id sReplyPorts[sNumReplyPorts]; + static int32 sReplyPortInUse[sNumReplyPorts]; + static int32 sGetCachedReplyPort(); - static BBlockCache* sMsgCache; + static BBlockCache* sMsgCache; }; + #endif // _MESSAGE_H From dfa8cf8c05bd7173fa5f25170bc297757175daab Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 18:43:25 -0400 Subject: [PATCH 15/19] Change SCROLL_KNOB_* constants to B_SCROLL_KNOB_* --- headers/os/interface/ScrollBar.h | 7 ++-- src/kits/interface/ScrollBar.cpp | 4 +-- src/preferences/appearance/FakeScrollBar.cpp | 4 +-- .../appearance/LookAndFeelSettingsView.cpp | 32 +++++++++---------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/headers/os/interface/ScrollBar.h b/headers/os/interface/ScrollBar.h index d9e709ebd5..2549122ba4 100644 --- a/headers/os/interface/ScrollBar.h +++ b/headers/os/interface/ScrollBar.h @@ -20,11 +20,12 @@ enum { - KNOB_STYLE_NONE = 0, - KNOB_STYLE_DOTS, - KNOB_STYLE_LINES + B_KNOB_STYLE_NONE = 0, + B_KNOB_STYLE_DOTS, + B_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 56fab7ba38..75a6248737 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -1154,11 +1154,11 @@ BScrollBar::Draw(BRect updateRect) } } - if (fPrivateData->fScrollBarInfo.knob == KNOB_STYLE_NONE) + if (fPrivateData->fScrollBarInfo.knob == B_KNOB_STYLE_NONE) return; // draw the scrollbar thumb knobs - bool square = fPrivateData->fScrollBarInfo.knob == KNOB_STYLE_DOTS; + bool square = fPrivateData->fScrollBarInfo.knob == B_KNOB_STYLE_DOTS; int32 hextent = 0; int32 vextent = 0; diff --git a/src/preferences/appearance/FakeScrollBar.cpp b/src/preferences/appearance/FakeScrollBar.cpp index cd791ccf79..95e5696d85 100644 --- a/src/preferences/appearance/FakeScrollBar.cpp +++ b/src/preferences/appearance/FakeScrollBar.cpp @@ -143,11 +143,11 @@ FakeScrollBar::Draw(BRect updateRect) be_control_look->DrawButtonBackground(this, bgRect, updateRect, normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); - if (fKnobStyle == KNOB_STYLE_NONE) + if (fKnobStyle == B_KNOB_STYLE_NONE) return; // draw the scrollbar thumb knobs - bool square = fKnobStyle == KNOB_STYLE_DOTS; + bool square = fKnobStyle == B_KNOB_STYLE_DOTS; int32 hextent = 0; int32 vextent = 0; diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index 6a2e57fcae..b63bd3934e 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.cpp +++ b/src/preferences/appearance/LookAndFeelSettingsView.cpp @@ -85,9 +85,9 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name) fSavedDoubleArrowsValue = _DoubleScrollBarArrows(); - fArrowStyleSingle = new FakeScrollBar(true, false, KNOB_STYLE_LINES, + fArrowStyleSingle = new FakeScrollBar(true, false, B_KNOB_STYLE_LINES, new BMessage(kMsgArrowStyleSingle)); - fArrowStyleDouble = new FakeScrollBar(true, true, KNOB_STYLE_LINES, + fArrowStyleDouble = new FakeScrollBar(true, true, B_KNOB_STYLE_LINES, new BMessage(kMsgArrowStyleDouble)); BView* arrowStyleView; @@ -111,11 +111,11 @@ LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name) BBox* knobStyleBox = new BBox("knob style"); knobStyleBox->SetLabel(B_TRANSLATE("Knob style")); - fKnobStyleNone = new FakeScrollBar(false, false, KNOB_STYLE_NONE, + fKnobStyleNone = new FakeScrollBar(false, false, B_KNOB_STYLE_NONE, new BMessage(kMsgKnobStyleNone)); - fKnobStyleDots = new FakeScrollBar(false, false, KNOB_STYLE_DOTS, + fKnobStyleDots = new FakeScrollBar(false, false, B_KNOB_STYLE_DOTS, new BMessage(kMsgKnobStyleDots)); - fKnobStyleLines = new FakeScrollBar(false, false, KNOB_STYLE_LINES, + fKnobStyleLines = new FakeScrollBar(false, false, B_KNOB_STYLE_LINES, new BMessage(kMsgKnobStyleLines)); BView* knobStyleView; @@ -184,15 +184,15 @@ LookAndFeelSettingsView::AttachedToWindow() fArrowStyleSingle->SetValue(B_CONTROL_ON); switch (fSavedKnobStyleValue) { - case KNOB_STYLE_NONE: + case B_KNOB_STYLE_NONE: fKnobStyleNone->SetValue(B_CONTROL_ON); break; - case KNOB_STYLE_DOTS: + case B_KNOB_STYLE_DOTS: fKnobStyleDots->SetValue(B_CONTROL_ON); break; - case KNOB_STYLE_LINES: + case B_KNOB_STYLE_LINES: fKnobStyleLines->SetValue(B_CONTROL_ON); break; } @@ -249,15 +249,15 @@ LookAndFeelSettingsView::MessageReceived(BMessage *msg) break; case kMsgKnobStyleNone: - _SetScrollBarKnobStyle(KNOB_STYLE_NONE); + _SetScrollBarKnobStyle(B_KNOB_STYLE_NONE); break; case kMsgKnobStyleDots: - _SetScrollBarKnobStyle(KNOB_STYLE_DOTS); + _SetScrollBarKnobStyle(B_KNOB_STYLE_DOTS); break; case kMsgKnobStyleLines: - _SetScrollBarKnobStyle(KNOB_STYLE_LINES); + _SetScrollBarKnobStyle(B_KNOB_STYLE_LINES); break; default: @@ -379,15 +379,15 @@ LookAndFeelSettingsView::_SetScrollBarKnobStyle(int32 knobStyle) set_scroll_bar_info(&info); switch (knobStyle) { - case KNOB_STYLE_NONE: + case B_KNOB_STYLE_NONE: fKnobStyleNone->SetValue(B_CONTROL_ON); break; - case KNOB_STYLE_DOTS: + case B_KNOB_STYLE_DOTS: fKnobStyleDots->SetValue(B_CONTROL_ON); break; - case KNOB_STYLE_LINES: + case B_KNOB_STYLE_LINES: fKnobStyleLines->SetValue(B_CONTROL_ON); break; } @@ -401,7 +401,7 @@ LookAndFeelSettingsView::IsDefaultable() { return fCurrentDecor != fDecorUtility.DefaultDecorator()->Name() || _DoubleScrollBarArrows() != false - || _ScrollBarKnobStyle() != KNOB_STYLE_DOTS; + || _ScrollBarKnobStyle() != B_KNOB_STYLE_DOTS; } @@ -410,7 +410,7 @@ LookAndFeelSettingsView::SetDefaults() { _SetDecor(fDecorUtility.DefaultDecorator()); _SetDoubleScrollBarArrows(false); - _SetScrollBarKnobStyle(KNOB_STYLE_DOTS); + _SetScrollBarKnobStyle(B_KNOB_STYLE_DOTS); } From 0dead7ddb6f5eee8ae882c7fd548be9d0e5a53fc Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 18:44:24 -0400 Subject: [PATCH 16/19] No reason to check to see if the scrollbar knobs will fit for the fake scrollbar, just assume they will --- src/preferences/appearance/FakeScrollBar.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/preferences/appearance/FakeScrollBar.cpp b/src/preferences/appearance/FakeScrollBar.cpp index 95e5696d85..77c4ddf21f 100644 --- a/src/preferences/appearance/FakeScrollBar.cpp +++ b/src/preferences/appearance/FakeScrollBar.cpp @@ -168,16 +168,12 @@ FakeScrollBar::Draw(BRect updateRect) 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); - } + 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); - } + 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, From a4f0328efe7fe56e8e49575eb31a0ac18b676c0b Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 18:52:36 -0400 Subject: [PATCH 17/19] Rename hextent and vextent to knobWidth and knobHeight --- src/kits/interface/ScrollBar.cpp | 36 ++++++++++---------- src/preferences/appearance/FakeScrollBar.cpp | 24 ++++++------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index 75a6248737..48cd1da978 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -1159,15 +1159,15 @@ BScrollBar::Draw(BRect updateRect) // draw the scrollbar thumb knobs bool square = fPrivateData->fScrollBarInfo.knob == B_KNOB_STYLE_DOTS; - int32 hextent = 0; - int32 vextent = 0; + int32 knobWidth = 0; + int32 knobHeight = 0; if (square) { - hextent = 2; - vextent = 2; + knobWidth = 2; + knobHeight = 2; } else { - hextent = 1; - vextent = 3; + knobWidth = 1; + knobHeight = 3; } int32 flags = 0; @@ -1179,35 +1179,35 @@ BScrollBar::Draw(BRect updateRect) BRect middleKnob = BRect( rect.left + hmiddle - - (fOrientation == B_HORIZONTAL ? hextent : vextent), + - (fOrientation == B_HORIZONTAL ? knobWidth : knobHeight), rect.top + vmiddle - - (fOrientation == B_HORIZONTAL ? vextent : hextent), + - (fOrientation == B_HORIZONTAL ? knobHeight : knobWidth), rect.left + hmiddle - + (fOrientation == B_HORIZONTAL ? hextent : vextent), + + (fOrientation == B_HORIZONTAL ? knobWidth : knobHeight), rect.top + vmiddle - + (fOrientation == B_HORIZONTAL ? vextent : hextent)); + + (fOrientation == B_HORIZONTAL ? knobHeight : knobWidth)); if (fOrientation == B_HORIZONTAL) { - BRect leftKnob = middleKnob.OffsetByCopy(hextent * -4, 0); - if (leftKnob.left > rect.left + hextent) { + BRect leftKnob = middleKnob.OffsetByCopy(knobWidth * -4, 0); + if (leftKnob.left > rect.left + knobWidth) { be_control_look->DrawButtonBackground(this, leftKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } - BRect rightKnob = middleKnob.OffsetByCopy(hextent * 4, 0); - if (rightKnob.right < rect.right - hextent) { + BRect rightKnob = middleKnob.OffsetByCopy(knobWidth * 4, 0); + if (rightKnob.right < rect.right - knobWidth) { be_control_look->DrawButtonBackground(this, rightKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } } else { - BRect topKnob = middleKnob.OffsetByCopy(0, hextent * -4); - if (topKnob.top > rect.top + vextent) { + BRect topKnob = middleKnob.OffsetByCopy(0, knobWidth * -4); + if (topKnob.top > rect.top + knobHeight) { be_control_look->DrawButtonBackground(this, topKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } - BRect bottomKnob = middleKnob.OffsetByCopy(0, hextent * 4); - if (bottomKnob.bottom < rect.bottom - vextent) { + BRect bottomKnob = middleKnob.OffsetByCopy(0, knobWidth * 4); + if (bottomKnob.bottom < rect.bottom - knobHeight) { be_control_look->DrawButtonBackground(this, bottomKnob, updateRect, normal, flags, BControlLook::B_ALL_BORDERS, fOrientation); } diff --git a/src/preferences/appearance/FakeScrollBar.cpp b/src/preferences/appearance/FakeScrollBar.cpp index 77c4ddf21f..8ca3de1737 100644 --- a/src/preferences/appearance/FakeScrollBar.cpp +++ b/src/preferences/appearance/FakeScrollBar.cpp @@ -148,30 +148,30 @@ FakeScrollBar::Draw(BRect updateRect) // draw the scrollbar thumb knobs bool square = fKnobStyle == B_KNOB_STYLE_DOTS; - int32 hextent = 0; - int32 vextent = 0; + int32 knobWidth = 0; + int32 knobHeight = 0; if (square) { - hextent = 2; - vextent = 2; + knobWidth = 2; + knobHeight = 2; } else { - hextent = 1; - vextent = 3; + knobWidth = 1; + knobHeight = 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 middleKnob = BRect(bgRect.left + hmiddle - knobWidth, + bgRect.top + vmiddle - knobHeight, + bgRect.left + hmiddle + knobWidth, + bgRect.top + vmiddle + knobHeight); - BRect leftKnob = middleKnob.OffsetByCopy(hextent * -4, 0); + BRect leftKnob = middleKnob.OffsetByCopy(knobWidth * -4, 0); be_control_look->DrawButtonBackground(this, leftKnob, updateRect, normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); - BRect rightKnob = middleKnob.OffsetByCopy(hextent * 4, 0); + BRect rightKnob = middleKnob.OffsetByCopy(knobWidth * 4, 0); be_control_look->DrawButtonBackground(this, rightKnob, updateRect, normal, 0, BControlLook::B_ALL_BORDERS, B_HORIZONTAL); From 68c70f9b6dc96d50f677862c579a65085dd7d300 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 2 Nov 2012 19:07:18 -0400 Subject: [PATCH 18/19] Variable name cleanup --- src/preferences/appearance/FakeScrollBar.cpp | 8 ++++---- src/preferences/appearance/FakeScrollBar.h | 4 ++-- src/preferences/appearance/LookAndFeelSettingsView.cpp | 6 +++--- src/preferences/appearance/LookAndFeelSettingsView.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/preferences/appearance/FakeScrollBar.cpp b/src/preferences/appearance/FakeScrollBar.cpp index 8ca3de1737..aa8ee8b7fa 100644 --- a/src/preferences/appearance/FakeScrollBar.cpp +++ b/src/preferences/appearance/FakeScrollBar.cpp @@ -270,17 +270,17 @@ FakeScrollBar::SetValue(int32 value) void -FakeScrollBar::SetDoubleArrows(bool doublearrows) +FakeScrollBar::SetDoubleArrows(bool doubleArrows) { - fDoubleArrows = doublearrows; + fDoubleArrows = doubleArrows; Invalidate(); } void -FakeScrollBar::SetKnobStyle(uint32 style) +FakeScrollBar::SetKnobStyle(uint32 knobStyle) { - fKnobStyle = style; + fKnobStyle = knobStyle; Invalidate(); } diff --git a/src/preferences/appearance/FakeScrollBar.h b/src/preferences/appearance/FakeScrollBar.h index 383b3bcbfd..7f96f613d1 100644 --- a/src/preferences/appearance/FakeScrollBar.h +++ b/src/preferences/appearance/FakeScrollBar.h @@ -28,8 +28,8 @@ public: virtual void SetValue(int32 value); - void SetDoubleArrows(bool doublearrows); - void SetKnobStyle(uint32 style); + void SetDoubleArrows(bool doubleArrows); + void SetKnobStyle(uint32 knobStyle); void SetFromScrollBarInfo(const scroll_bar_info &info); diff --git a/src/preferences/appearance/LookAndFeelSettingsView.cpp b/src/preferences/appearance/LookAndFeelSettingsView.cpp index b63bd3934e..4ac5f43fdd 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.cpp +++ b/src/preferences/appearance/LookAndFeelSettingsView.cpp @@ -342,15 +342,15 @@ LookAndFeelSettingsView::_DoubleScrollBarArrows() void -LookAndFeelSettingsView::_SetDoubleScrollBarArrows(bool on) +LookAndFeelSettingsView::_SetDoubleScrollBarArrows(bool doubleArrows) { scroll_bar_info info; get_scroll_bar_info(&info); - info.double_arrows = on; + info.double_arrows = doubleArrows; set_scroll_bar_info(&info); - if (on) + if (doubleArrows) fArrowStyleDouble->SetValue(B_CONTROL_ON); else fArrowStyleSingle->SetValue(B_CONTROL_ON); diff --git a/src/preferences/appearance/LookAndFeelSettingsView.h b/src/preferences/appearance/LookAndFeelSettingsView.h index db2b5bddea..bc06657544 100644 --- a/src/preferences/appearance/LookAndFeelSettingsView.h +++ b/src/preferences/appearance/LookAndFeelSettingsView.h @@ -46,7 +46,7 @@ private: void _AdoptInterfaceToCurrentDecor(); bool _DoubleScrollBarArrows(); - void _SetDoubleScrollBarArrows(bool on); + void _SetDoubleScrollBarArrows(bool doubleArrows); int32 _ScrollBarKnobStyle(); void _SetScrollBarKnobStyle(int32 knobStyle); From 4373e37dd8d9e3b6f1c7b303c74dde27c3e282db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Fri, 2 Nov 2012 23:44:23 +0100 Subject: [PATCH 19/19] Hide error when cd-ing out of the git tree --- 3rdparty/mmu_man/scripts/dev-perso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/mmu_man/scripts/dev-perso b/3rdparty/mmu_man/scripts/dev-perso index 2fb05836b6..bd9ecad908 100755 --- a/3rdparty/mmu_man/scripts/dev-perso +++ b/3rdparty/mmu_man/scripts/dev-perso @@ -164,7 +164,7 @@ dev() { test -n "$DEVUPCMD" && history -s "$DEVUPCMD" # spice up terminal window title for git, add current branch name - test -d .git && PROMPT_COMMAND='echo -en "\033]0;['$DEVPROJ':`git branch | sed "/^[^*]/d;s/^\*\s//"`:${PWD##*/}]\a"' + test -d .git && PROMPT_COMMAND='echo -en "\033]0;['$DEVPROJ':`git branch 2>/dev/null | sed "/^[^*]/d;s/^\*\s//"`:${PWD##*/}]\a"' } complete -W complete -W "$(dev)" dev