Some cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22568 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,13 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2003-2007, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef DEFAULT_MEDIA_THEME_H
|
#ifndef DEFAULT_MEDIA_THEME_H
|
||||||
#define DEFAULT_MEDIA_THEME_H
|
#define DEFAULT_MEDIA_THEME_H
|
||||||
|
|
||||||
|
|
||||||
#include <MediaTheme.h>
|
#include <MediaTheme.h>
|
||||||
|
|
||||||
|
class BParameterGroup;
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
@@ -15,18 +17,18 @@ class DefaultMediaTheme : public BMediaTheme {
|
|||||||
public:
|
public:
|
||||||
DefaultMediaTheme();
|
DefaultMediaTheme();
|
||||||
|
|
||||||
virtual BControl *MakeControlFor(BParameter *parameter);
|
virtual BControl* MakeControlFor(BParameter* parameter);
|
||||||
|
|
||||||
static BControl *MakeViewFor(BParameter *parameter, const BRect *hintRect = NULL);
|
static BControl* MakeViewFor(BParameter* parameter, const BRect* hintRect = NULL);
|
||||||
// this is also called by the BMediaTheme::MakeFallbackViewFor()
|
// this is also called by the BMediaTheme::MakeFallbackViewFor()
|
||||||
// method - that's why it's a static.
|
// method - that's why it's a static.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual BView *MakeViewFor(BParameterWeb *web, const BRect *hintRect = NULL);
|
virtual BView* MakeViewFor(BParameterWeb* web, const BRect* hintRect = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BView *MakeViewFor(BParameterGroup &group, const BRect &hintRect);
|
BView* MakeViewFor(BParameterGroup& group, const BRect* hintRect);
|
||||||
BView *MakeSelfHostingViewFor(BParameter ¶meter, const BRect &hintRect);
|
BView* MakeSelfHostingViewFor(BParameter& parameter, const BRect* hintRect);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2003-2004, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2003-2007, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the OpenBeOS License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "DefaultMediaTheme.h"
|
#include "DefaultMediaTheme.h"
|
||||||
@@ -108,7 +108,8 @@ class MessageFilter : public BMessageFilter {
|
|||||||
|
|
||||||
class ContinuousMessageFilter : public MessageFilter {
|
class ContinuousMessageFilter : public MessageFilter {
|
||||||
public:
|
public:
|
||||||
ContinuousMessageFilter(BControl *control, BContinuousParameter ¶meter);
|
ContinuousMessageFilter(BControl *control,
|
||||||
|
BContinuousParameter ¶meter);
|
||||||
virtual ~ContinuousMessageFilter();
|
virtual ~ContinuousMessageFilter();
|
||||||
|
|
||||||
virtual filter_result Filter(BMessage *message, BHandler **target);
|
virtual filter_result Filter(BMessage *message, BHandler **target);
|
||||||
@@ -254,7 +255,8 @@ DynamicScrollView::UpdateBars()
|
|||||||
if (vertical || fIsDocumentScroller)
|
if (vertical || fIsDocumentScroller)
|
||||||
rect.right -= B_V_SCROLL_BAR_WIDTH;
|
rect.right -= B_V_SCROLL_BAR_WIDTH;
|
||||||
|
|
||||||
fHorizontalScrollBar = new BScrollBar(rect, "horizontal", fTarget, 0, width, B_HORIZONTAL);
|
fHorizontalScrollBar = new BScrollBar(rect, "horizontal", fTarget, 0,
|
||||||
|
width, B_HORIZONTAL);
|
||||||
fTarget->ResizeBy(0, -B_H_SCROLL_BAR_HEIGHT);
|
fTarget->ResizeBy(0, -B_H_SCROLL_BAR_HEIGHT);
|
||||||
AddChild(fHorizontalScrollBar);
|
AddChild(fHorizontalScrollBar);
|
||||||
horizontalChanged = true;
|
horizontalChanged = true;
|
||||||
@@ -266,7 +268,8 @@ DynamicScrollView::UpdateBars()
|
|||||||
if (horizontal || fIsDocumentScroller)
|
if (horizontal || fIsDocumentScroller)
|
||||||
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
fVerticalScrollBar = new BScrollBar(rect, "vertical", fTarget, 0, height, B_VERTICAL);
|
fVerticalScrollBar = new BScrollBar(rect, "vertical", fTarget, 0,
|
||||||
|
height, B_VERTICAL);
|
||||||
fTarget->ResizeBy(-B_V_SCROLL_BAR_WIDTH, 0);
|
fTarget->ResizeBy(-B_V_SCROLL_BAR_WIDTH, 0);
|
||||||
AddChild(fVerticalScrollBar);
|
AddChild(fVerticalScrollBar);
|
||||||
verticalChanged = true;
|
verticalChanged = true;
|
||||||
@@ -274,10 +277,14 @@ DynamicScrollView::UpdateBars()
|
|||||||
|
|
||||||
// adapt the scroll bars, so that they don't overlap each other
|
// adapt the scroll bars, so that they don't overlap each other
|
||||||
if (!fIsDocumentScroller) {
|
if (!fIsDocumentScroller) {
|
||||||
if (horizontalChanged && !verticalChanged && vertical)
|
if (horizontalChanged && !verticalChanged && vertical) {
|
||||||
fVerticalScrollBar->ResizeBy(0, (horizontal ? -1 : 1) * B_H_SCROLL_BAR_HEIGHT);
|
fVerticalScrollBar->ResizeBy(0, (horizontal ? -1 : 1)
|
||||||
if (verticalChanged && !horizontalChanged && horizontal)
|
* B_H_SCROLL_BAR_HEIGHT);
|
||||||
fHorizontalScrollBar->ResizeBy((vertical ? -1 : 1) * B_V_SCROLL_BAR_WIDTH, 0);
|
}
|
||||||
|
if (verticalChanged && !horizontalChanged && horizontal) {
|
||||||
|
fHorizontalScrollBar->ResizeBy((vertical ? -1 : 1)
|
||||||
|
* B_V_SCROLL_BAR_WIDTH, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the scroll bar range & proportions
|
// update the scroll bar range & proportions
|
||||||
@@ -481,7 +488,8 @@ TitleView::GetPreferredSize(float *_width, float *_height)
|
|||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
GetFontHeight(&fontHeight);
|
GetFontHeight(&fontHeight);
|
||||||
|
|
||||||
*_height = fontHeight.ascent + fontHeight.descent + fontHeight.leading + 8;
|
*_height = fontHeight.ascent + fontHeight.descent + fontHeight.leading
|
||||||
|
+ 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,11 +512,13 @@ MessageFilter::FilterFor(BView *view, BParameter ¶meter)
|
|||||||
|
|
||||||
switch (parameter.Type()) {
|
switch (parameter.Type()) {
|
||||||
case BParameter::B_CONTINUOUS_PARAMETER:
|
case BParameter::B_CONTINUOUS_PARAMETER:
|
||||||
return new ContinuousMessageFilter(control, static_cast<BContinuousParameter &>(parameter));
|
return new ContinuousMessageFilter(control,
|
||||||
|
static_cast<BContinuousParameter &>(parameter));
|
||||||
|
|
||||||
case BParameter::B_DISCRETE_PARAMETER:
|
case BParameter::B_DISCRETE_PARAMETER:
|
||||||
return new DiscreteMessageFilter(control, static_cast<BDiscreteParameter &>(parameter));
|
return new DiscreteMessageFilter(control,
|
||||||
|
static_cast<BDiscreteParameter &>(parameter));
|
||||||
|
|
||||||
case BParameter::B_NULL_PARAMETER: /* fall through */
|
case BParameter::B_NULL_PARAMETER: /* fall through */
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -519,7 +529,8 @@ MessageFilter::FilterFor(BView *view, BParameter ¶meter)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
ContinuousMessageFilter::ContinuousMessageFilter(BControl *control, BContinuousParameter ¶meter)
|
ContinuousMessageFilter::ContinuousMessageFilter(BControl *control,
|
||||||
|
BContinuousParameter ¶meter)
|
||||||
: MessageFilter(),
|
: MessageFilter(),
|
||||||
fParameter(parameter)
|
fParameter(parameter)
|
||||||
{
|
{
|
||||||
@@ -589,7 +600,8 @@ ContinuousMessageFilter::Filter(BMessage *message, BHandler **target)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
DiscreteMessageFilter::DiscreteMessageFilter(BControl *control, BDiscreteParameter ¶meter)
|
DiscreteMessageFilter::DiscreteMessageFilter(BControl *control,
|
||||||
|
BDiscreteParameter ¶meter)
|
||||||
: MessageFilter(),
|
: MessageFilter(),
|
||||||
fParameter(parameter)
|
fParameter(parameter)
|
||||||
{
|
{
|
||||||
@@ -653,7 +665,7 @@ DiscreteMessageFilter::Filter(BMessage *message, BHandler **target)
|
|||||||
|
|
||||||
|
|
||||||
DefaultMediaTheme::DefaultMediaTheme()
|
DefaultMediaTheme::DefaultMediaTheme()
|
||||||
: BMediaTheme("BeOS Theme", "BeOS built-in theme version 0.1")
|
: BMediaTheme("Haiku Theme", "Haiku built-in theme version 0.1")
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
}
|
}
|
||||||
@@ -698,7 +710,7 @@ DefaultMediaTheme::MakeViewFor(BParameterWeb *web, const BRect *hintRect)
|
|||||||
if (group == NULL)
|
if (group == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BView *groupView = MakeViewFor(*group, rect);
|
BView *groupView = MakeViewFor(*group, hintRect ? &rect : NULL);
|
||||||
if (groupView == NULL)
|
if (groupView == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -706,7 +718,8 @@ DefaultMediaTheme::MakeViewFor(BParameterWeb *web, const BRect *hintRect)
|
|||||||
// the top-level group views must not be larger than their hintRect,
|
// the top-level group views must not be larger than their hintRect,
|
||||||
// but unlike their children, they should follow all sides when
|
// but unlike their children, they should follow all sides when
|
||||||
// their parent is resized
|
// their parent is resized
|
||||||
view->ResizeTo(rect.Width() - 10, rect.Height() - 10);
|
if (hintRect != NULL)
|
||||||
|
view->ResizeTo(rect.Width() - 10, rect.Height() - 10);
|
||||||
view->SetResizingMode(B_FOLLOW_ALL);
|
view->SetResizingMode(B_FOLLOW_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,14 +741,17 @@ DefaultMediaTheme::MakeViewFor(BParameterWeb *web, const BRect *hintRect)
|
|||||||
|
|
||||||
|
|
||||||
BView *
|
BView *
|
||||||
DefaultMediaTheme::MakeViewFor(BParameterGroup &group, const BRect &hintRect)
|
DefaultMediaTheme::MakeViewFor(BParameterGroup& group, const BRect* hintRect)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
if (group.Flags() & B_HIDDEN_PARAMETER)
|
if (group.Flags() & B_HIDDEN_PARAMETER)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BRect rect(hintRect);
|
BRect rect;
|
||||||
|
if (hintRect != NULL)
|
||||||
|
rect = *hintRect;
|
||||||
|
|
||||||
GroupView *view = new GroupView(rect, group.Name());
|
GroupView *view = new GroupView(rect, group.Name());
|
||||||
|
|
||||||
// Create the parameter views - but don't add them yet
|
// Create the parameter views - but don't add them yet
|
||||||
@@ -749,7 +765,8 @@ DefaultMediaTheme::MakeViewFor(BParameterGroup &group, const BRect &hintRect)
|
|||||||
if (parameter == NULL)
|
if (parameter == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BView *parameterView = MakeSelfHostingViewFor(*parameter, rect);
|
BView *parameterView = MakeSelfHostingViewFor(*parameter,
|
||||||
|
hintRect ? &rect : NULL);
|
||||||
if (parameterView == NULL)
|
if (parameterView == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -779,7 +796,7 @@ DefaultMediaTheme::MakeViewFor(BParameterGroup &group, const BRect &hintRect)
|
|||||||
if (subGroup == NULL)
|
if (subGroup == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BView *groupView = MakeViewFor(*subGroup, rect);
|
BView *groupView = MakeViewFor(*subGroup, &rect);
|
||||||
if (groupView == NULL)
|
if (groupView == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -864,18 +881,18 @@ DefaultMediaTheme::MakeViewFor(BParameterGroup &group, const BRect &hintRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** This creates a view that handles all incoming messages itself - that's
|
/*! This creates a view that handles all incoming messages itself - that's
|
||||||
* what is meant with self-hosting.
|
what is meant with self-hosting.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BView *
|
BView *
|
||||||
DefaultMediaTheme::MakeSelfHostingViewFor(BParameter ¶meter, const BRect &hintRect)
|
DefaultMediaTheme::MakeSelfHostingViewFor(BParameter& parameter,
|
||||||
|
const BRect* hintRect)
|
||||||
{
|
{
|
||||||
if (parameter.Flags() & B_HIDDEN_PARAMETER
|
if (parameter.Flags() & B_HIDDEN_PARAMETER
|
||||||
|| parameter_should_be_hidden(parameter))
|
|| parameter_should_be_hidden(parameter))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BView *view = MakeViewFor(¶meter, &hintRect);
|
BView *view = MakeViewFor(¶meter, hintRect);
|
||||||
if (view == NULL) {
|
if (view == NULL) {
|
||||||
// The MakeViewFor() method above returns a BControl - which we
|
// The MakeViewFor() method above returns a BControl - which we
|
||||||
// don't need for a null parameter; that's why it returns NULL.
|
// don't need for a null parameter; that's why it returns NULL.
|
||||||
@@ -886,12 +903,13 @@ DefaultMediaTheme::MakeSelfHostingViewFor(BParameter ¶meter, const BRect &hi
|
|||||||
// this is the first parameter in this group, so
|
// this is the first parameter in this group, so
|
||||||
// let's use a nice title view
|
// let's use a nice title view
|
||||||
|
|
||||||
TitleView *titleView = new TitleView(hintRect, parameter.Name());
|
TitleView *titleView = new TitleView(BRect(0, 0, 10, 10), parameter.Name());
|
||||||
titleView->ResizeToPreferred();
|
titleView->ResizeToPreferred();
|
||||||
|
|
||||||
return titleView;
|
return titleView;
|
||||||
}
|
}
|
||||||
BStringView *stringView = new BStringView(hintRect, parameter.Name(), parameter.Name());
|
BStringView *stringView = new BStringView(BRect(0, 0, 10, 10),
|
||||||
|
parameter.Name(), parameter.Name());
|
||||||
stringView->SetAlignment(B_ALIGN_CENTER);
|
stringView->SetAlignment(B_ALIGN_CENTER);
|
||||||
stringView->ResizeToPreferred();
|
stringView->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -932,14 +950,15 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
|
|||||||
|| discrete.CountItems() == 0) {
|
|| discrete.CountItems() == 0) {
|
||||||
// create a checkbox item
|
// create a checkbox item
|
||||||
|
|
||||||
BCheckBox *checkBox = new BCheckBox(rect, discrete.Name(), discrete.Name(), NULL);
|
BCheckBox *checkBox = new BCheckBox(rect, discrete.Name(),
|
||||||
|
discrete.Name(), NULL);
|
||||||
checkBox->ResizeToPreferred();
|
checkBox->ResizeToPreferred();
|
||||||
|
|
||||||
return checkBox;
|
return checkBox;
|
||||||
} else {
|
} else {
|
||||||
// create a pop up menu field
|
// create a pop up menu field
|
||||||
|
|
||||||
// ToDo: replace BOptionPopUp (or fix it in OpenBeOS...)
|
// ToDo: replace BOptionPopUp (or fix it in Haiku...)
|
||||||
// this is a workaround for a bug in BOptionPopUp - you need to
|
// this is a workaround for a bug in BOptionPopUp - you need to
|
||||||
// know the actual width before creating the object - very nice...
|
// know the actual width before creating the object - very nice...
|
||||||
|
|
||||||
@@ -953,7 +972,8 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
|
|||||||
width += font.StringWidth(discrete.Name()) + 55;
|
width += font.StringWidth(discrete.Name()) + 55;
|
||||||
rect.right = rect.left + width;
|
rect.right = rect.left + width;
|
||||||
|
|
||||||
BOptionPopUp *popUp = new BOptionPopUp(rect, discrete.Name(), discrete.Name(), NULL);
|
BOptionPopUp *popUp = new BOptionPopUp(rect, discrete.Name(),
|
||||||
|
discrete.Name(), NULL);
|
||||||
|
|
||||||
for (int32 i = 0; i < discrete.CountItems(); i++) {
|
for (int32 i = 0; i < discrete.CountItems(); i++) {
|
||||||
popUp->AddOption(discrete.ItemNameAt(i), discrete.ItemValueAt(i));
|
popUp->AddOption(discrete.ItemNameAt(i), discrete.ItemValueAt(i));
|
||||||
@@ -970,8 +990,7 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
|
|||||||
BContinuousParameter &continuous = static_cast<BContinuousParameter &>(*parameter);
|
BContinuousParameter &continuous = static_cast<BContinuousParameter &>(*parameter);
|
||||||
|
|
||||||
if (!strcmp(continuous.Kind(), B_MASTER_GAIN)
|
if (!strcmp(continuous.Kind(), B_MASTER_GAIN)
|
||||||
|| !strcmp(continuous.Kind(), B_GAIN))
|
|| !strcmp(continuous.Kind(), B_GAIN)) {
|
||||||
{
|
|
||||||
BChannelSlider *slider = new BChannelSlider(rect, continuous.Name(),
|
BChannelSlider *slider = new BChannelSlider(rect, continuous.Name(),
|
||||||
continuous.Name(), NULL, B_VERTICAL, continuous.CountChannels());
|
continuous.Name(), NULL, B_VERTICAL, continuous.CountChannels());
|
||||||
|
|
||||||
@@ -994,8 +1013,10 @@ DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
|
|||||||
|
|
||||||
// ToDo: take BContinuousParameter::GetResponse() & ValueStep() into account!
|
// ToDo: take BContinuousParameter::GetResponse() & ValueStep() into account!
|
||||||
|
|
||||||
for (int32 i = 0; i < continuous.CountChannels(); i++)
|
for (int32 i = 0; i < continuous.CountChannels(); i++) {
|
||||||
slider->SetLimitsFor(i, int32(continuous.MinValue() * 1000), int32(continuous.MaxValue() * 1000));
|
slider->SetLimitsFor(i, int32(continuous.MinValue() * 1000),
|
||||||
|
int32(continuous.MaxValue() * 1000));
|
||||||
|
}
|
||||||
|
|
||||||
return slider;
|
return slider;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user