haiku/src/kits/tracker/TitleView.h
Stephan Aßmus 2f86ba4557 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
2009-02-15 18:23:19 +00:00

212 lines
5.5 KiB
C++

/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _TITLE_VIEW_H
#define _TITLE_VIEW_H
#include <Cursor.h>
#include <DataIO.h>
#include <View.h>
#include "ObjectList.h"
namespace BPrivate {
class BPoseView;
class BColumn;
class BColumnTitle;
class ColumnTrackState;
class OffscreenBitmap;
const int32 kTitleViewHeight = 16;
const int32 kEdgeSize = 6;
const int32 kTitleColumnLeftExtraMargin = 11;
const int32 kTitleColumnRightExtraMargin = 5;
const int32 kTitleColumnExtraMargin = kTitleColumnLeftExtraMargin
+ kTitleColumnRightExtraMargin;
const int32 kMinColumnWidth = 20;
const int32 kRemoveTitleMargin = 10;
const int32 kColumnStart = 40;
class BTitleView : public BView {
public:
BTitleView(BRect, BPoseView *);
virtual ~BTitleView();
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual void Draw(BRect updateRect);
void Draw(BRect, bool useOffscreen = false,
bool updateOnly = true,
const BColumnTitle *pressedColumn = 0,
void (*trackRectBlitter)(BView *, BRect) = 0,
BRect passThru = BRect(0, 0, 0, 0));
void AddTitle(BColumn *, const BColumn *after = 0);
void RemoveTitle(BColumn *);
void Reset();
BPoseView *PoseView() const;
protected:
void MouseMoved(BPoint, uint32, const BMessage *);
private:
BColumnTitle *FindColumnTitle(BPoint) const;
BColumnTitle *InColumnResizeArea(BPoint) const;
BColumnTitle *FindColumnTitle(const BColumn *) const;
BPoseView *fPoseView;
BObjectList<BColumnTitle> fTitleList;
BCursor fHorizontalResizeCursor;
BColumnTitle *fPreviouslyClickedColumnTitle;
bigtime_t fPreviousLeftClickTime;
ColumnTrackState* fTrackingState;
static OffscreenBitmap *sOffscreen;
typedef BView _inherited;
friend class ColumnTrackState;
friend class ColumnDragState;
};
class BColumnTitle {
public:
BColumnTitle(BTitleView *, BColumn *);
virtual ~BColumnTitle() {}
virtual void Draw(BView *, bool pressed = false);
BColumn *Column() const;
BRect Bounds() const;
bool InColumnResizeArea(BPoint) const;
private:
BColumn *fColumn;
BTitleView *fParent;
friend class ColumnResizeState;
};
// Utility classes to handle dragging state
class ColumnTrackState {
public:
ColumnTrackState(BTitleView *titleView, BColumnTitle *columnTitle,
BPoint where, bigtime_t pastClickTime);
virtual ~ColumnTrackState() {}
void MouseMoved(BPoint where, uint32 buttons);
void MouseUp(BPoint where);
protected:
virtual void Moved(BPoint where, uint32 buttons) = 0;
virtual void Clicked(BPoint where) = 0;
virtual void Done(BPoint where) = 0;
virtual bool ValueChanged(BPoint where) = 0;
BTitleView *fTitleView;
BColumnTitle *fTitle;
BPoint fFirstClickPoint;
bigtime_t fPastClickTime;
bool fHasMoved;
};
class ColumnResizeState : public ColumnTrackState {
public:
ColumnResizeState(BTitleView* titleView, BColumnTitle* columnTitle,
BPoint where, bigtime_t pastClickTime);
protected:
virtual void Moved(BPoint where, uint32 buttons);
virtual void Done(BPoint where);
virtual void Clicked(BPoint where);
virtual bool ValueChanged(BPoint);
void DrawLine();
void UndrawLine();
private:
float fLastLineDrawPos;
float fInitialTrackOffset;
typedef ColumnTrackState _inherited;
};
class ColumnDragState : public ColumnTrackState {
public:
ColumnDragState(BTitleView* titleView, BColumnTitle* columnTitle,
BPoint where, bigtime_t pastClickTime);
protected:
virtual void Moved(BPoint where, uint32 buttons);
virtual void Done(BPoint where);
virtual void Clicked(BPoint where);
virtual bool ValueChanged(BPoint);
void DrawOutline(float);
void UndrawOutline();
void DrawPressNoOutline();
private:
float fInitialMouseTrackOffset;
bool fTrackingRemovedColumn;
BMallocIO fColumnArchive;
typedef ColumnTrackState _inherited;
};
inline BColumn *
BColumnTitle::Column() const
{
return fColumn;
}
inline BPoseView *
BTitleView::PoseView() const
{
return fPoseView;
}
} // namespace BPrivate
using namespace BPrivate;
#endif // _TITLE_VIEW_H