[haiku-commits] Change in haiku[master]: Bug_fix_#15738(Make Device list width is font sensitive)

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 3 Mar 2020 18:16:06 +0000

From Preetpal Kaur <preetpalok123@xxxxxxxxx>:

Preetpal Kaur has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2308 ;)


Change subject: Bug_fix_#15738(Make Device list width is font sensitive)
......................................................................

Bug_fix_#15738(Make Device list width is font sensitive)

Change-Id: I125c47f015c939acbd70c9509310ec3cdef7d2c5
---
M src/preferences/input/InputDeviceView.cpp
M src/preferences/input/InputDeviceView.h
M src/preferences/input/InputWindow.cpp
3 files changed, 16 insertions(+), 2 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/08/2308/1

diff --git a/src/preferences/input/InputDeviceView.cpp 
b/src/preferences/input/InputDeviceView.cpp
index 56309b9..033f46f 100644
--- a/src/preferences/input/InputDeviceView.cpp
+++ b/src/preferences/input/InputDeviceView.cpp
@@ -34,10 +34,8 @@
        fScrollView = new BScrollView("ScrollView",fDeviceList,
                                        0 , false, B_FANCY_BORDER);

-       SetExplicitMinSize(BSize(160, B_SIZE_UNSET));
        SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

-
        BLayoutBuilder::Group<>(this, B_VERTICAL)
                .Add(fScrollView)
                .End();
@@ -56,3 +54,17 @@
        fDeviceList->Select(0);
        SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
 }
+
+void
+DeviceListView::SetExplicitSize()
+{
+       float minWidth = 0;
+       for (int32 i = 0; i < fDeviceList->CountItems(); i++) {
+               BStringItem* item = (BStringItem*)fDeviceList->ItemAt(i);
+               float width = fDeviceList->StringWidth(item->Text());
+               if (width > minWidth){
+                       minWidth = width;
+               }
+       }
+       SetExplicitMinSize(BSize(minWidth + 40 , B_SIZE_UNSET));
+}
diff --git a/src/preferences/input/InputDeviceView.h 
b/src/preferences/input/InputDeviceView.h
index 2cc80aa..1de026d 100644
--- a/src/preferences/input/InputDeviceView.h
+++ b/src/preferences/input/InputDeviceView.h
@@ -33,6 +33,7 @@
                        DeviceListView(const char *name);
        virtual         ~DeviceListView();
        virtual void    AttachedToWindow();
+       void            SetExplicitSize();
        BListView*      fDeviceList;

 private:
diff --git a/src/preferences/input/InputWindow.cpp 
b/src/preferences/input/InputWindow.cpp
index cd24e0e..ba3e944 100644
--- a/src/preferences/input/InputWindow.cpp
+++ b/src/preferences/input/InputWindow.cpp
@@ -194,4 +194,5 @@
        } else {
                delete dev;
        }
+       fDeviceListView->SetExplicitSize();
 }

--
To view, visit https://review.haiku-os.org/c/haiku/+/2308
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I125c47f015c939acbd70c9509310ec3cdef7d2c5
Gerrit-Change-Number: 2308
Gerrit-PatchSet: 1
Gerrit-Owner: Preetpal Kaur <preetpalok123@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: Bug_fix_#15738(Make Device list width is font sensitive) - Gerrit