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:
@@ -2,12 +2,14 @@
|
||||
* Copyright 2004-2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#include <ScrollView.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ControlLook.h>
|
||||
#include <LayoutUtils.h>
|
||||
#include <ScrollView.h>
|
||||
#include <Message.h>
|
||||
#include <Region.h>
|
||||
#include <Window.h>
|
||||
|
||||
#include <binary_compatibility/Interface.h>
|
||||
@@ -90,6 +92,9 @@ BScrollView::_Init(bool horizontal, bool vertical)
|
||||
fVerticalScrollBar = NULL;
|
||||
fHighlighted = false;
|
||||
|
||||
if (be_control_look != NULL)
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
BRect targetFrame;
|
||||
if (fTarget) {
|
||||
// layout target and add it
|
||||
@@ -218,6 +223,43 @@ BScrollView::AllDetached()
|
||||
void
|
||||
BScrollView::Draw(BRect updateRect)
|
||||
{
|
||||
if (be_control_look != NULL) {
|
||||
uint32 flags = 0;
|
||||
if (fHighlighted && Window()->IsActive())
|
||||
flags |= BControlLook::B_FOCUSED;
|
||||
BRect rect(Bounds());
|
||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
if (fBorder == B_FANCY_BORDER
|
||||
&& fHorizontalScrollBar && fVerticalScrollBar) {
|
||||
BRect scrollCornerRect(rect);
|
||||
scrollCornerRect.left = fHorizontalScrollBar->Frame().right + 2;
|
||||
scrollCornerRect.top = fVerticalScrollBar->Frame().bottom + 2;
|
||||
BRegion region(rect);
|
||||
region.Exclude(scrollCornerRect);
|
||||
ConstrainClippingRegion(®ion);
|
||||
}
|
||||
|
||||
be_control_look->DrawBorder(this, rect, updateRect, base, fBorder,
|
||||
flags);
|
||||
|
||||
if (fBorder == B_FANCY_BORDER
|
||||
&& fHorizontalScrollBar && fVerticalScrollBar) {
|
||||
ConstrainClippingRegion(NULL);
|
||||
|
||||
rect = Bounds().InsetByCopy(1, 1);
|
||||
rect.right = fHorizontalScrollBar->Frame().right + 1;
|
||||
be_control_look->DrawBorder(this, rect, updateRect, base, fBorder,
|
||||
flags, BControlLook::B_RIGHT_BORDER);
|
||||
|
||||
rect = Bounds().InsetByCopy(1, 1);
|
||||
rect.bottom = fVerticalScrollBar->Frame().bottom + 1;
|
||||
be_control_look->DrawBorder(this, rect, updateRect, base, fBorder,
|
||||
flags, BControlLook::B_BOTTOM_BORDER);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (fBorder == B_PLAIN_BORDER) {
|
||||
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT));
|
||||
StrokeRect(Bounds());
|
||||
@@ -339,7 +381,15 @@ BScrollView::SetBorderHighlighted(bool state)
|
||||
|
||||
fHighlighted = state;
|
||||
|
||||
if (fHorizontalScrollBar != NULL)
|
||||
fHorizontalScrollBar->SetBorderHighlighted(state);
|
||||
if (fVerticalScrollBar != NULL)
|
||||
fVerticalScrollBar->SetBorderHighlighted(state);
|
||||
|
||||
BRect bounds = Bounds();
|
||||
if (be_control_look != NULL)
|
||||
bounds.InsetBy(1, 1);
|
||||
|
||||
Invalidate(BRect(bounds.left, bounds.top, bounds.right, bounds.top));
|
||||
Invalidate(BRect(bounds.left, bounds.top + 1, bounds.left,
|
||||
bounds.bottom - 1));
|
||||
@@ -444,11 +494,22 @@ BScrollView::FrameResized(float width, float height)
|
||||
if (fBorder == B_NO_BORDER)
|
||||
return;
|
||||
|
||||
// changes in width
|
||||
|
||||
BRect bounds = Bounds();
|
||||
float border = _BorderSize() - 1;
|
||||
|
||||
if (be_control_look && fHorizontalScrollBar && fVerticalScrollBar) {
|
||||
BRect scrollCorner(bounds);
|
||||
scrollCorner.left = min_c(
|
||||
fPreviousWidth - fVerticalScrollBar->Frame().Height(),
|
||||
fHorizontalScrollBar->Frame().right + 1);
|
||||
scrollCorner.top = min_c(
|
||||
fPreviousHeight - fHorizontalScrollBar->Frame().Width(),
|
||||
fVerticalScrollBar->Frame().bottom + 1);
|
||||
Invalidate(scrollCorner);
|
||||
}
|
||||
|
||||
// changes in width
|
||||
|
||||
if (bounds.Width() > fPreviousWidth) {
|
||||
// invalidate the region between the old and the new right border
|
||||
BRect rect = bounds;
|
||||
|
||||
Reference in New Issue
Block a user