Input preferences: Use BControlLook::ComposeIconSize().
And do some other cleanup while at it. Fixes #17919.
This commit is contained in:
@@ -103,7 +103,8 @@ struct DeviceListItemView::Renderer {
|
|||||||
float ItemWidth()
|
float ItemWidth()
|
||||||
{
|
{
|
||||||
float width = 4.0f;
|
float width = 4.0f;
|
||||||
width += be_plain_font->StringWidth(fTitle) + 16.0f;
|
width += be_plain_font->StringWidth(fTitle) +
|
||||||
|
(fPrimaryIcon != NULL ? fPrimaryIcon->Bounds().Width() : 16.0f);
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ DeviceListItemView::Update(BView* owner, const BFont* font)
|
|||||||
renderer.SetTitle(fTitle);
|
renderer.SetTitle(fTitle);
|
||||||
SetRenderParameters(renderer);
|
SetRenderParameters(renderer);
|
||||||
SetWidth(renderer.ItemWidth());
|
SetWidth(renderer.ItemWidth());
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -140,18 +141,18 @@ DeviceListItemView::DrawItem(BView* owner, BRect frame, bool complete)
|
|||||||
renderer.SetTitle(Label());
|
renderer.SetTitle(Label());
|
||||||
SetRenderParameters(renderer);
|
SetRenderParameters(renderer);
|
||||||
renderer.Render(owner, frame, complete);
|
renderer.Render(owner, frame, complete);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DeviceListItemView::SetRenderParameters(Renderer& renderer)
|
DeviceListItemView::SetRenderParameters(Renderer& renderer)
|
||||||
{
|
{
|
||||||
if (fInputType == MOUSE_TYPE)
|
if (Icons() != NULL) {
|
||||||
renderer.AddIcon(&Icons()->mouseIcon);
|
if (fInputType == MOUSE_TYPE)
|
||||||
|
renderer.AddIcon(&Icons()->mouseIcon);
|
||||||
else if (fInputType == TOUCHPAD_TYPE)
|
else if (fInputType == TOUCHPAD_TYPE)
|
||||||
renderer.AddIcon(&Icons()->touchpadIcon);
|
renderer.AddIcon(&Icons()->touchpadIcon);
|
||||||
|
else if (fInputType == KEYBOARD_TYPE)
|
||||||
else if (fInputType == KEYBOARD_TYPE)
|
renderer.AddIcon(&Icons()->keyboardIcon);
|
||||||
renderer.AddIcon(&Icons()->keyboardIcon);
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ public:
|
|||||||
const char* Label() { return fTitle.String();}
|
const char* Label() { return fTitle.String();}
|
||||||
|
|
||||||
|
|
||||||
static InputIcons* Icons() {return sIcons;}
|
static InputIcons* Icons() { return sIcons; }
|
||||||
static void SetIcons(InputIcons* icons) {sIcons = icons;}
|
static void SetIcons(InputIcons* icons) { sIcons = icons; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct Renderer;
|
struct Renderer;
|
||||||
@@ -61,7 +61,6 @@ protected:
|
|||||||
void SetRenderParameters(Renderer& renderer);
|
void SetRenderParameters(Renderer& renderer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static InputIcons* sIcons;
|
static InputIcons* sIcons;
|
||||||
BString fTitle;
|
BString fTitle;
|
||||||
input_type fInputType;
|
input_type fInputType;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "InputIcons.h"
|
#include "InputIcons.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <IconUtils.h>
|
#include <IconUtils.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
@@ -14,17 +15,20 @@
|
|||||||
#include "IconHandles.h"
|
#include "IconHandles.h"
|
||||||
|
|
||||||
|
|
||||||
#define ICON_SIZE 15
|
const BRect InputIcons::sBounds;
|
||||||
|
|
||||||
const BRect InputIcons::sBounds(0, 0, ICON_SIZE, ICON_SIZE);
|
|
||||||
|
|
||||||
|
|
||||||
InputIcons::InputIcons()
|
InputIcons::InputIcons()
|
||||||
:
|
:
|
||||||
mouseIcon(sBounds, B_CMAP8),
|
mouseIcon(NULL, false),
|
||||||
touchpadIcon(sBounds, B_CMAP8),
|
touchpadIcon(NULL, false),
|
||||||
keyboardIcon(sBounds, B_CMAP8)
|
keyboardIcon(NULL, false)
|
||||||
{
|
{
|
||||||
|
if (!sBounds.IsValid()) {
|
||||||
|
*const_cast<BRect*>(&sBounds) = BRect(BPoint(0, 0),
|
||||||
|
be_control_look->ComposeIconSize(B_MINI_ICON));
|
||||||
|
}
|
||||||
|
|
||||||
app_info info;
|
app_info info;
|
||||||
be_app->GetAppInfo(&info);
|
be_app->GetAppInfo(&info);
|
||||||
BFile executableFile(&info.ref, B_READ_ONLY);
|
BFile executableFile(&info.ref, B_READ_ONLY);
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ InputWindow::InputWindow(BRect rect)
|
|||||||
fDeviceListView = new BListView(B_TRANSLATE("Device List"));
|
fDeviceListView = new BListView(B_TRANSLATE("Device List"));
|
||||||
fDeviceListView->SetSelectionMessage(new BMessage(ITEM_SELECTED));
|
fDeviceListView->SetSelectionMessage(new BMessage(ITEM_SELECTED));
|
||||||
fDeviceListView->SetExplicitMinSize(
|
fDeviceListView->SetExplicitMinSize(
|
||||||
BSize(32 + fDeviceListView->StringWidth("Extended PS/2 Mouse 1"),
|
BSize(be_control_look->ComposeIconSize(32).Width()
|
||||||
|
+ fDeviceListView->StringWidth("Extended PS/2 Mouse 1"),
|
||||||
B_SIZE_UNSET));
|
B_SIZE_UNSET));
|
||||||
|
|
||||||
BScrollView* scrollView = new BScrollView(
|
BScrollView* scrollView = new BScrollView(
|
||||||
|
|||||||
Reference in New Issue
Block a user