Implemented a new look for the Haiku interface controls. It was

overheard that they looked too ninety-ish.
TODO: The code behind this is work in progress. The basic idea
is to extract all drawing code into a new class BControlLook,
of which there is a global instance be_control_look, instantiated
in InterfaceDefs.cpp. At the moment, all the old drawing code is
still there, and the usage of be_control_look is inside if-bodies
checking the instance against NULL. In another words, by not
instanitating be_control_look, you can revert back to the old look.
BControlLook's job is to provide reusable methods for drawing
certain types of frames, backgrounds and labels, so that application
developers can make controls that re-use the same drawing code
as built-in controls and adopt to changes made there. I have added
the notion of "borders". Each of the frame drawing methods can be
made to draw certain borders only, which is supposed to help when
controls shall visually attach. This feature is not fully explored
at all ATM.
TODO: Update BColumnListView header view and BStringItem text
spacing. Update other apps where it makes sense to use BControlLook.
For the moment, only Tracker and LaunchBox are updated. More...
NOTE: The new look is not very radically different, so that existing
apps do not immediately look too ugly or out of place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29221 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-02-15 18:23:19 +00:00
parent 700ab492a9
commit 2f86ba4557
35 changed files with 3478 additions and 408 deletions
+50 -41
View File
@@ -17,58 +17,67 @@
#include <ChannelControl.h>
class BChannelSlider : public BChannelControl
{
class BChannelSlider : public BChannelControl {
public:
BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message,
int32 channels = 1,
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message,
orientation o, int32 channels = 1,
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(BMessage* archive);
virtual ~BChannelSlider();
BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message,
int32 channels = 1,
uint32 resizeMode
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message,
enum orientation orientation,
int32 channels = 1,
uint32 resizeMode
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(const char* name,
const char* label, BMessage* message,
enum orientation orientation,
int32 channels = 1,
uint32 flags = B_WILL_DRAW);
BChannelSlider(BMessage* archive);
virtual ~BChannelSlider();
static BArchivable* Instantiate(BMessage* from);
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* from);
virtual status_t Archive(BMessage* into, bool deep = true) const;
virtual orientation Orientation() const;
void SetOrientation(orientation o);
virtual orientation Orientation() const;
void SetOrientation(enum orientation orientation);
virtual int32 MaxChannelCount() const;
virtual bool SupportsIndividualLimits() const;
virtual int32 MaxChannelCount() const;
virtual bool SupportsIndividualLimits() const;
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void DetachedFromWindow();
virtual void AllDetached();
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void DetachedFromWindow();
virtual void AllDetached();
virtual void MessageReceived(BMessage* msg);
virtual void MessageReceived(BMessage* message);
virtual void Draw(BRect area);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt,uint32 code,
const BMessage* message);
virtual void WindowActivated(bool state);
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void KeyUp(const char* bytes, int32 numBytes);
virtual void FrameResized(float width, float height);
virtual void Draw(BRect area);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage);
virtual void WindowActivated(bool state);
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void KeyUp(const char* bytes, int32 numBytes);
virtual void FrameResized(float width, float height);
virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL);
virtual void MakeFocus(bool focusState = true);
virtual void SetFont(const BFont* font,
uint32 mask = B_FONT_ALL);
virtual void MakeFocus(bool focusState = true);
virtual void SetEnabled(bool on);
virtual void SetEnabled(bool on);
virtual void GetPreferredSize(float* width, float* height);
virtual void GetPreferredSize(float* _width, float* _height);
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
BMessage* specifier, int32 form, const char* p);
virtual status_t GetSupportedSuites(BMessage* data);
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form,
const char* p);
virtual status_t GetSupportedSuites(BMessage* data);
// Perform rendering for an entire slider channel.
virtual void DrawChannel(BView* into, int32 channel, BRect area,
+297
View File
@@ -0,0 +1,297 @@
/*
* Copyright 2009, Stephan Aßmus <[email protected]>
* Distributed under the terms of the MIT License.
*/
#ifndef _CONTROL_LOOK_H
#define _CONTROL_LOOK_H
#include <Alignment.h>
#include <Font.h>
#include <Rect.h>
#include <Slider.h>
class BControl;
class BGradientLinear;
class BView;
namespace BPrivate {
class BControlLook {
public:
BControlLook();
virtual ~BControlLook();
enum frame_type {
B_BUTTON_FRAME,
B_MENU_FRAME,
B_LISTVIEW_FRAME,
B_INPUT_FRAME
};
enum background_type {
B_BUTTON_BACKGROUND,
B_MENU_BACKGROUND,
B_LISTVIEW_BACKGROUND,
B_INPUT_BACKGROUND
};
enum {
B_LEFT_BORDER = 1 << 0,
B_RIGHT_BORDER = 1 << 1,
B_TOP_BORDER = 1 << 2,
B_BOTTOM_BORDER = 1 << 3,
B_ALL_BORDERS = B_LEFT_BORDER | B_RIGHT_BORDER
| B_TOP_BORDER | B_BOTTOM_BORDER
};
enum {
B_FOCUSED = 1 << 0,
B_CLICKED = 1 << 1, // some controls activate on mouse up
B_ACTIVATED = 1 << 2,
B_HOVER = 1 << 3,
B_DISABLED = 1 << 4,
B_DEFAULT_BUTTON = 1 << 5
};
virtual BAlignment DefaultLabelAlignment() const;
virtual float DefaultLabelSpacing() const;
uint32 Flags(BControl* control) const;
virtual void DrawButtonFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
virtual void DrawButtonBackground(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0,
uint32 borders = B_ALL_BORDERS,
enum orientation orientation
= B_HORIZONTAL);
virtual void DrawMenuBarBackground(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 borders = B_ALL_BORDERS);
virtual void DrawMenuFieldBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, bool popupIndicator,
uint32 flags = 0);
virtual void DrawMenuFieldBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
virtual void DrawMenuBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
virtual void DrawMenuItemBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
virtual void DrawStatusBar(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
const rgb_color& barColor,
float progressPosition);
virtual void DrawCheckBox(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0);
virtual void DrawRadioButton(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 flags = 0);
virtual void DrawScrollBarBackground(BView* view,
BRect& rect1, BRect& rect2,
const BRect& updateRect,
const rgb_color& base, uint32 flags,
enum orientation orientation);
virtual void DrawScrollBarBackground(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
enum orientation orientation);
virtual rgb_color SliderBarColor(const rgb_color& base);
virtual void DrawSliderBar(BView* view, BRect rect,
const BRect& updateRect,
const rgb_color& base,
rgb_color leftFillColor,
rgb_color rightFillColor,
float sliderScale, uint32 flags,
enum orientation orientation);
virtual void DrawSliderBar(BView* view, BRect rect,
const BRect& updateRect,
const rgb_color& base, rgb_color fillColor,
uint32 flags, enum orientation orientation);
virtual void DrawSliderThumb(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags,
enum orientation orientation);
virtual void DrawSliderTriangle(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags,
enum orientation orientation);
virtual void DrawSliderHashMarks(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, int32 count,
hash_mark_location location,
uint32 flags, enum orientation orientation);
virtual void DrawActiveTab(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
virtual void DrawInctiveTab(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
// various borders
virtual void DrawBorder(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
border_style border, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
virtual void DrawRaisedBorder(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
virtual void DrawGroupFrame(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base,
uint32 borders = B_ALL_BORDERS);
virtual void DrawTextControlBorder(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& base, uint32 flags = 0,
uint32 borders = B_ALL_BORDERS);
// aligned labels
void DrawLabel(BView* view, const char* label,
BRect rect, const BRect& updateRect,
const rgb_color& base, uint32 flags);
virtual void DrawLabel(BView* view, const char* label,
BRect rect, const BRect& updateRect,
const rgb_color& base, uint32 flags,
const BAlignment& alignment);
protected:
void _DrawOuterResessedFrame(BView* view,
BRect& rect, const rgb_color& base,
float contrast = 1.0f,
float brightness = 1.0f,
uint32 borders = B_ALL_BORDERS);
void _DrawFrame(BView* view, BRect& rect,
const rgb_color& left,
const rgb_color& top,
const rgb_color& right,
const rgb_color& bottom,
uint32 borders = B_ALL_BORDERS);
void _DrawFrame(BView* view, BRect& rect,
const rgb_color& left,
const rgb_color& top,
const rgb_color& right,
const rgb_color& bottom,
const rgb_color& rightTop,
const rgb_color& leftBottom,
uint32 borders = B_ALL_BORDERS);
void _FillGradient(BView* view, const BRect& rect,
const rgb_color& base, float topTint,
float bottomTint,
enum orientation orientation
= B_HORIZONTAL);
void _FillGlossyGradient(BView* view,
const BRect& rect, const rgb_color& base,
float topTint, float middle1Tint,
float middle2Tint, float bottomTint,
enum orientation orientation
= B_HORIZONTAL);
void _MakeGradient(BGradientLinear& gradient,
const BRect& rect, const rgb_color& base,
float topTint, float bottomTint,
enum orientation orientation
= B_HORIZONTAL) const;
void _MakeGlossyGradient(BGradientLinear& gradient,
const BRect& rect, const rgb_color& base,
float topTint, float middle1Tint,
float middle2Tint, float bottomTint,
enum orientation orientation
= B_HORIZONTAL) const;
bool _RadioButtonAndCheckBoxMarkColor(
const rgb_color& base, rgb_color& color,
uint32 flags) const;
void _DrawRoundBarCorner(BView* view, BRect& rect,
const BRect& updateRect,
const rgb_color& edgeLightColor,
const rgb_color& edgeShadowColor,
const rgb_color& frameLightColor,
const rgb_color& frameShadowColor,
const rgb_color& fillLightColor,
const rgb_color& fillShadowColor,
float leftInset, float topInset,
float rightInset, float bottomInset,
enum orientation orientation);
void _DrawRoundCornerLeftTop(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base,
const rgb_color& edgeColor,
const rgb_color& frameColor,
const rgb_color& bevelColor,
const BGradientLinear& fillGradient);
void _DrawRoundCornerRightTop(BView* view,
BRect& rect, const BRect& updateRect,
const rgb_color& base,
const rgb_color& edgeTopColor,
const rgb_color& edgeRightColor,
const rgb_color& frameTopColor,
const rgb_color& frameRightColor,
const rgb_color& bevelTopColor,
const rgb_color& bevelRightColor,
const BGradientLinear& fillGradient);
};
extern BControlLook* be_control_look;
} // namespace BPrivate
using BPrivate::BControlLook;
using BPrivate::be_control_look;
#endif // _CONTROL_LOOK_H
+2
View File
@@ -206,8 +206,10 @@ private:
BRect _CalcFrame(BPoint where, bool* scrollOn);
protected:
void _DrawItems(BRect updateRect);
private:
bool _OverSuper(BPoint loc);
bool _OverSubmenu(BMenuItem* item, BPoint loc);
BPrivate::BMenuWindow* _MenuWindow();
+7
View File
@@ -56,6 +56,13 @@ public:
void SetOrientation(enum orientation orientation);
orientation Orientation() const;
// TODO: make this a virtual method, it should be one,
// but it's not important right now. This is supposed
// to be used in case the BScrollBar should draw part of
// the focus indication of the target view for aesthetical
// reasons. BScrollView will forward this method.
status_t SetBorderHighlighted(bool state);
virtual void MessageReceived(BMessage* message);
virtual void MouseDown(BPoint pt);
virtual void MouseUp(BPoint pt);
+1
View File
@@ -177,6 +177,7 @@ class BSlider : public BControl {
BSlider& operator=(const BSlider &);
void _InitBarColor();
void _InitObject();
private: