* Color drops for the data source color are now only accepted on the colored
box, added a new method _LegendColorFrameAt() that returns that area, and is also used when drawing it. * Fixed changing the history background color; it accidently changed the color of the wrong view. This fixes bug #2115. * If the history gets too dark, it will now lighten up the scale, instead of drawing it even darker. * Changing the color of a data source now immediately redraws the colored box, too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25097 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
0970b97bed
commit
1201d52e6c
@ -400,7 +400,7 @@ ActivityView::_Init(const BMessage* settings)
|
|||||||
|
|
||||||
const char* name;
|
const char* name;
|
||||||
for (int32 i = 0; settings->FindString("source", i, &name) == B_OK; i++) {
|
for (int32 i = 0; settings->FindString("source", i, &name) == B_OK; i++) {
|
||||||
AddDataSource(DataSource::FindSource(name));
|
AddDataSource(DataSource::FindSource(name), settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,10 +760,10 @@ ActivityView::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
// if a color is dropped, use it as background
|
// if a color is dropped, use it as background
|
||||||
if (message->WasDropped()) {
|
if (message->WasDropped()) {
|
||||||
rgb_color *color;
|
rgb_color* color;
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
if ((message->FindData("RGBColor", B_RGB_COLOR_TYPE, 0,
|
if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, 0,
|
||||||
(const void **)&color, &size) == B_OK)
|
(const void**)&color, &size) == B_OK
|
||||||
&& size == sizeof(rgb_color)) {
|
&& size == sizeof(rgb_color)) {
|
||||||
BPoint dropPoint = message->DropPoint();
|
BPoint dropPoint = message->DropPoint();
|
||||||
ConvertFromScreen(&dropPoint);
|
ConvertFromScreen(&dropPoint);
|
||||||
@ -775,10 +775,11 @@ ActivityView::MessageReceived(BMessage* message)
|
|||||||
// check each legend color box
|
// check each legend color box
|
||||||
BRect legendFrame = _LegendFrame();
|
BRect legendFrame = _LegendFrame();
|
||||||
for (int32 i = 0; i < fSources.CountItems(); i++) {
|
for (int32 i = 0; i < fSources.CountItems(); i++) {
|
||||||
BRect frame = _LegendFrameAt(legendFrame, i);
|
BRect frame = _LegendColorFrameAt(legendFrame, i);
|
||||||
if (frame.Contains(dropPoint)) {
|
if (frame.Contains(dropPoint)) {
|
||||||
fSources.ItemAt(i)->SetColor(*color);
|
fSources.ItemAt(i)->SetColor(*color);
|
||||||
Invalidate(_HistoryFrame());
|
Invalidate(_HistoryFrame());
|
||||||
|
Invalidate(frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -786,6 +787,7 @@ ActivityView::MessageReceived(BMessage* message)
|
|||||||
if (dynamic_cast<ActivityMonitor*>(be_app) == NULL) {
|
if (dynamic_cast<ActivityMonitor*>(be_app) == NULL) {
|
||||||
// allow background color change in the replicant only
|
// allow background color change in the replicant only
|
||||||
fLegendBackgroundColor = *color;
|
fLegendBackgroundColor = *color;
|
||||||
|
SetLowColor(fLegendBackgroundColor);
|
||||||
Invalidate(legendFrame);
|
Invalidate(legendFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -941,6 +943,17 @@ ActivityView::_LegendFrameAt(BRect frame, int32 index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
ActivityView::_LegendColorFrameAt(BRect frame, int32 index) const
|
||||||
|
{
|
||||||
|
frame = _LegendFrameAt(frame, index);
|
||||||
|
frame.InsetBy(1, 1);
|
||||||
|
frame.right = frame.left + frame.Height();
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
ActivityView::_PositionForValue(DataSource* source, DataHistory* values,
|
ActivityView::_PositionForValue(DataSource* source, DataHistory* values,
|
||||||
int64 value)
|
int64 value)
|
||||||
@ -975,7 +988,7 @@ ActivityView::_DrawHistory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
BRect frame = _HistoryFrame();
|
BRect frame = _HistoryFrame();
|
||||||
SetLowColor(fHistoryBackgroundColor);
|
view->SetLowColor(fHistoryBackgroundColor);
|
||||||
view->FillRect(frame, B_SOLID_LOW);
|
view->FillRect(frame, B_SOLID_LOW);
|
||||||
|
|
||||||
uint32 step = 2;
|
uint32 step = 2;
|
||||||
@ -990,13 +1003,25 @@ ActivityView::_DrawHistory()
|
|||||||
bigtime_t timeStep = fRefreshInterval * resolution;
|
bigtime_t timeStep = fRefreshInterval * resolution;
|
||||||
bigtime_t now = system_time();
|
bigtime_t now = system_time();
|
||||||
|
|
||||||
|
// Draw scale
|
||||||
|
// TODO: add second markers?
|
||||||
|
|
||||||
view->SetPenSize(1);
|
view->SetPenSize(1);
|
||||||
|
|
||||||
view->SetHighColor(tint_color(view->ViewColor(), B_DARKEN_2_TINT));
|
rgb_color scaleColor = view->LowColor();
|
||||||
|
uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
|
||||||
|
if (average < 96)
|
||||||
|
scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
|
||||||
|
else
|
||||||
|
scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);
|
||||||
|
|
||||||
|
view->SetHighColor(scaleColor);
|
||||||
view->StrokeRect(frame);
|
view->StrokeRect(frame);
|
||||||
view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
|
view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
|
||||||
BPoint(frame.right, frame.top + frame.Height() / 2));
|
BPoint(frame.right, frame.top + frame.Height() / 2));
|
||||||
|
|
||||||
|
// Draw values
|
||||||
|
|
||||||
view->SetPenSize(2);
|
view->SetPenSize(2);
|
||||||
|
|
||||||
for (uint32 i = fSources.CountItems(); i-- > 0;) {
|
for (uint32 i = fSources.CountItems(); i-- > 0;) {
|
||||||
@ -1076,8 +1101,7 @@ ActivityView::Draw(BRect /*updateRect*/)
|
|||||||
BRect frame = _LegendFrameAt(legendFrame, i);
|
BRect frame = _LegendFrameAt(legendFrame, i);
|
||||||
|
|
||||||
// draw color box
|
// draw color box
|
||||||
BRect colorBox = frame.InsetByCopy(2, 2);
|
BRect colorBox = _LegendColorFrameAt(legendFrame, i);
|
||||||
colorBox.right = colorBox.left + colorBox.Height();
|
|
||||||
SetHighColor(tint_color(source->Color(), B_DARKEN_1_TINT));
|
SetHighColor(tint_color(source->Color(), B_DARKEN_1_TINT));
|
||||||
StrokeRect(colorBox);
|
StrokeRect(colorBox);
|
||||||
SetHighColor(source->Color());
|
SetHighColor(source->Color());
|
||||||
|
@ -94,6 +94,7 @@ private:
|
|||||||
float _LegendHeight() const;
|
float _LegendHeight() const;
|
||||||
BRect _LegendFrame() const;
|
BRect _LegendFrame() const;
|
||||||
BRect _LegendFrameAt(BRect frame, int32 index) const;
|
BRect _LegendFrameAt(BRect frame, int32 index) const;
|
||||||
|
BRect _LegendColorFrameAt(BRect frame, int32 index) const;
|
||||||
float _PositionForValue(DataSource* source,
|
float _PositionForValue(DataSource* source,
|
||||||
DataHistory* values, int64 value);
|
DataHistory* values, int64 value);
|
||||||
void _DrawHistory();
|
void _DrawHistory();
|
||||||
|
Loading…
Reference in New Issue
Block a user