Now BSeparatorItem's Draw() checks the separator type. Implemented separator type "1". Please, someone with a better "artistic" skill than me, feel free to implement separator type "2" and check if the drawing of the others is correct :)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10554 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Copyright (c) 2001-2002, OpenBeOS
|
// Copyright (c) 2001-2004, Haiku, Inc.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -22,11 +22,13 @@
|
|||||||
// File Name: SeparatorItem.cpp
|
// File Name: SeparatorItem.cpp
|
||||||
// Author: Marc Flerackers ([email protected])
|
// Author: Marc Flerackers ([email protected])
|
||||||
// Bill Hayden ([email protected])
|
// Bill Hayden ([email protected])
|
||||||
|
// Stefano Ceccherini ([email protected])
|
||||||
// Description: Display separator item for BMenu class
|
// Description: Display separator item for BMenu class
|
||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Message.h>
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
BSeparatorItem::BSeparatorItem()
|
BSeparatorItem::BSeparatorItem()
|
||||||
@@ -66,15 +68,16 @@ BSeparatorItem::Instantiate(BMessage *data)
|
|||||||
void
|
void
|
||||||
BSeparatorItem::SetEnabled(bool state)
|
BSeparatorItem::SetEnabled(bool state)
|
||||||
{
|
{
|
||||||
|
// Don't do anything
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BSeparatorItem::GetContentSize(float *width, float *height)
|
BSeparatorItem::GetContentSize(float *width, float *height)
|
||||||
{
|
{
|
||||||
if (width)
|
if (width != NULL)
|
||||||
*width = 2.0f;
|
*width = 2.0f;
|
||||||
if (height)
|
if (height != NULL)
|
||||||
*height = 8.0f;
|
*height = 8.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,18 +85,47 @@ BSeparatorItem::GetContentSize(float *width, float *height)
|
|||||||
void
|
void
|
||||||
BSeparatorItem::Draw()
|
BSeparatorItem::Draw()
|
||||||
{
|
{
|
||||||
|
BMenu *menu = Menu();
|
||||||
|
if (menu == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
BRect bounds = Frame();
|
BRect bounds = Frame();
|
||||||
|
|
||||||
Menu()->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
// TODO: Calling this on every Draw() doesn't seem nice.
|
||||||
B_DARKEN_2_TINT));
|
menu_info menuInfo;
|
||||||
Menu()->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f),
|
get_menu_info(&menuInfo);
|
||||||
BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
|
switch (menuInfo.separator) {
|
||||||
Menu()->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
case 0:
|
||||||
B_LIGHTEN_2_TINT));
|
// TODO: Check if drawing is pixel perfect
|
||||||
Menu()->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f),
|
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||||
BPoint(bounds.right - 1.0f, bounds.top + 5.0f));
|
B_DARKEN_2_TINT));
|
||||||
|
menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 4.0f),
|
||||||
Menu()->SetHighColor(0, 0, 0);
|
BPoint(bounds.right - 1.0f, bounds.top + 4.0f));
|
||||||
|
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||||
|
B_LIGHTEN_2_TINT));
|
||||||
|
menu->StrokeLine(BPoint(bounds.left + 1.0f, bounds.top + 5.0f),
|
||||||
|
BPoint(bounds.right - 1.0f, bounds.top + 5.0f));
|
||||||
|
menu->SetHighColor(0, 0, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// TODO: Check if drawing is pixel perfect
|
||||||
|
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||||
|
B_DARKEN_2_TINT));
|
||||||
|
menu->StrokeLine(BPoint(bounds.left + 9.0f, bounds.top + 4.0f),
|
||||||
|
BPoint(bounds.right - 9.0f, bounds.top + 4.0f));
|
||||||
|
menu->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||||
|
B_LIGHTEN_2_TINT));
|
||||||
|
menu->StrokeLine(BPoint(bounds.left + 9.0f, bounds.top + 5.0f),
|
||||||
|
BPoint(bounds.right - 9.0f, bounds.top + 5.0f));
|
||||||
|
menu->SetHighColor(0, 0, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // TODO: Implement "type 2" look
|
||||||
|
default:
|
||||||
|
printf("BSeparatorItem::Draw(): Separator item look not supported yet\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user