BMenuItem now also draws the trigger at the right position. There was a small visual glitch because the menu's lowcolor was not resetted: fixed. BMenuItem::Draw() needs a cleanup.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10828 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -347,21 +347,40 @@ void
|
|||||||
BMenuItem::DrawContent()
|
BMenuItem::DrawContent()
|
||||||
{
|
{
|
||||||
fSuper->MovePenBy(0, fSuper->fAscent);
|
fSuper->MovePenBy(0, fSuper->fAscent);
|
||||||
|
BPoint lineStart = fSuper->PenLocation();
|
||||||
|
|
||||||
fSuper->DrawString(fLabel);
|
fSuper->DrawString(fLabel);
|
||||||
|
|
||||||
// ToDo: label truncation is missing
|
// ToDo: label truncation is missing
|
||||||
// ToDo: draw trigger is missing!
|
|
||||||
|
if (fSuper->AreTriggersEnabled() && fTriggerIndex != -1) {
|
||||||
|
float escapements[128]; // TODO: this doesn't look nice
|
||||||
|
BFont font;
|
||||||
|
fSuper->GetFont(&font);
|
||||||
|
font.GetEscapements(fLabel, fTriggerIndex + 1, escapements);
|
||||||
|
for (int32 i = 0; i < fTriggerIndex; i++)
|
||||||
|
lineStart.x += escapements[i] * font.Size();
|
||||||
|
|
||||||
|
lineStart.x--;
|
||||||
|
lineStart.y++;
|
||||||
|
|
||||||
|
BPoint lineEnd(lineStart);
|
||||||
|
lineEnd.x += escapements[fTriggerIndex] * font.Size();
|
||||||
|
|
||||||
|
fSuper->StrokeLine(lineStart, lineEnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMenuItem::Draw()
|
BMenuItem::Draw()
|
||||||
{
|
{
|
||||||
|
// TODO: Cleanup
|
||||||
bool enabled = IsEnabled();
|
bool enabled = IsEnabled();
|
||||||
|
|
||||||
fSuper->CacheFontInfo();
|
fSuper->CacheFontInfo();
|
||||||
|
|
||||||
if (IsSelected() && (enabled || Submenu())/* && fSuper->fRedrawAfterSticky*/) {
|
if (IsSelected() && (enabled || Submenu()) /*&& fSuper->fRedrawAfterSticky*/) {
|
||||||
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
fSuper->SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||||
B_DARKEN_2_TINT));
|
B_DARKEN_2_TINT));
|
||||||
fSuper->SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
fSuper->SetLowColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR),
|
||||||
@@ -379,8 +398,11 @@ BMenuItem::Draw()
|
|||||||
B_DISABLED_LABEL_TINT));
|
B_DISABLED_LABEL_TINT));
|
||||||
|
|
||||||
fSuper->MovePenTo(ContentLocation());
|
fSuper->MovePenTo(ContentLocation());
|
||||||
|
|
||||||
DrawContent();
|
DrawContent();
|
||||||
|
|
||||||
|
fSuper->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));
|
||||||
|
|
||||||
if (fSuper->Layout() == B_ITEMS_IN_COLUMN) {
|
if (fSuper->Layout() == B_ITEMS_IN_COLUMN) {
|
||||||
if (IsMarked())
|
if (IsMarked())
|
||||||
DrawMarkSymbol();
|
DrawMarkSymbol();
|
||||||
@@ -459,10 +481,9 @@ BMenuItem::InitMenuData(BMenu *menu)
|
|||||||
fSubmenu = menu;
|
fSubmenu = menu;
|
||||||
fSubmenu->fSuperitem = this;
|
fSubmenu->fSuperitem = this;
|
||||||
|
|
||||||
BMenuItem *item;
|
BMenuItem *item = menu->FindMarked();
|
||||||
|
|
||||||
if (menu->IsRadioMode() && menu->IsLabelFromMarked() &&
|
if (menu->IsRadioMode() && menu->IsLabelFromMarked() && item != NULL)
|
||||||
(item = menu->FindMarked()) != NULL)
|
|
||||||
SetLabel(item->Label());
|
SetLabel(item->Label());
|
||||||
else
|
else
|
||||||
SetLabel(menu->Name());
|
SetLabel(menu->Name());
|
||||||
|
|||||||
Reference in New Issue
Block a user