clean up calculations of ListViewItem positions in Interfaces add-on; remove delete profile option which doesn't make sense

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40311 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alexander von Gluck IV 2011-01-28 20:21:06 +00:00
parent c9f72f4333
commit f74b3ec2d0
5 changed files with 23 additions and 24 deletions

View File

@ -1,10 +1,11 @@
/*
* Copyright 2004-2009 Haiku Inc. All rights reserved.
* Copyright 2004-2011 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Philippe Houdoin
* Fredrik Modéen
* Alexander von Gluck IV, <kallisti5@unixzen.com>
*/
@ -78,8 +79,14 @@ InterfaceListItem::Update(BView* owner, const BFont* font)
font_height height;
font->GetHeight(&height);
// TODO: take into account icon height, if he's taller...
SetHeight((height.ascent+height.descent+height.leading) * 3.0 + 8);
float lineHeight = ceilf(height.ascent) + ceilf(height.descent)
+ ceilf(height.leading);
fFirstlineOffset = 2 + ceilf(height.ascent + height.leading / 2);
fSecondlineOffset = fFirstlineOffset + lineHeight;
fThirdlineOffset = fFirstlineOffset + (lineHeight * 2);
SetHeight(3 * lineHeight + 4);
}
@ -90,11 +97,7 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
if (!list)
return;
font_height height;
BFont font;
owner->GetFont(&font);
font.GetHeight(&height);
float fntheight = height.ascent+height.descent+height.leading;
owner->PushState();
BRect bounds = list->ItemFrame(list->IndexOf(this));
@ -116,9 +119,9 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
owner->SetHighColor( oldcolor );
BPoint iconPt = bounds.LeftTop() + BPoint(4,4);
BPoint namePt = iconPt + BPoint(32+8, fntheight);
BPoint driverPt = iconPt + BPoint(32+8, fntheight*2);
BPoint commentPt = iconPt + BPoint(32+8, fntheight*3);
BPoint namePt = BPoint(32+12, fFirstlineOffset);
BPoint driverPt = BPoint(32+12, fSecondlineOffset);
BPoint commentPt = BPoint(32+12, fThirdlineOffset);
drawing_mode mode = owner->DrawingMode();
if (fSettings->IsDisabled()) {
@ -151,6 +154,8 @@ InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete)
owner->SetHighColor(oldcolor);
owner->SetDrawingMode(mode);
owner->PopState();
}

View File

@ -44,6 +44,10 @@ private:
BBitmap* fIcon;
BNetworkInterface fInterface;
Settings* fSettings;
float fFirstlineOffset;
float fSecondlineOffset;
float fThirdlineOffset;
float fStateWidth;
};

View File

@ -1,11 +1,12 @@
SubDir HAIKU_TOP src tests kits net preflet ;
SimpleTest NetworkSetup :
Preference NetworkSetup :
NetworkSetup.cpp
NetworkSetupWindow.cpp
NetworkSetupProfile.cpp
NetworkSetupAddOn.cpp
: be root $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS)
: NetworkSetup.rdef
;
SubInclude HAIKU_TOP src tests kits net preflet InterfacesAddOn ;

View File

@ -8,7 +8,7 @@
#define SOFTWARE_EDITOR "Haiku"
#define NAME "NetworkSettings"
#define NAME "NetworkSetup"
#define SOFTWARE_VERSION_LABEL "0.1.0 alpha"
#define APPLICATION_SIGNATURE "application/x-vnd." SOFTWARE_EDITOR "-" NAME

View File

@ -27,9 +27,6 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
BWindow(BRect(100, 100, 300, 300), title, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
BBox *topDivider = new BBox(B_EMPTY_STRING);
topDivider->SetBorder(B_PLAIN_BORDER);
// ---- Profiles section
BMenu *profilesPopup = new BPopUpMenu("<none>");
_BuildProfilesMenu(profilesPopup, SELECT_PROFILE_MSG);
@ -74,7 +71,6 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
.AddGlue()
.Add(button)
.End()
.Add(topDivider)
.Add(fPanel)
.Add(bottomDivider)
.AddGroup(B_HORIZONTAL, 5)
@ -87,7 +83,6 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title)
_BuildShowTabView(SHOW_MSG);
topDivider->SetExplicitMaxSize(BSize(B_SIZE_UNSET, 1));
bottomDivider->SetExplicitMaxSize(BSize(B_SIZE_UNSET, 1));
fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(),
fMinAddonViewRect.Height()));
@ -119,10 +114,6 @@ NetworkSetupWindow::MessageReceived(BMessage* msg)
case NEW_PROFILE_MSG:
break;
case DELETE_PROFILE_MSG: {
break;
}
case SELECT_PROFILE_MSG: {
BPath name;
const char *path;
@ -206,8 +197,6 @@ NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 msg_what)
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("New" B_UTF8_ELLIPSIS),
new BMessage(NEW_PROFILE_MSG)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Delete"),
new BMessage(DELETE_PROFILE_MSG)));
if (strlen(current_profile)) {
item = menu->FindItem(current_profile);