[haiku-commits] haiku: hrev53439 - in src: servers/debug kits/shared

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 31 Aug 2019 12:25:13 -0400 (EDT)

hrev53439 adds 1 changeset to branch 'master'
old head: 5f996be3c6f7aaec9bc4d4e35b3da46cae13d9f1
new head: b4e2eff2f63a9d4370194b28cdc1e58d22120487
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b4e2eff2f63a+%5E5f996be3c6f7

----------------------------------------------------------------------------

b4e2eff2f63a: DebugWindow: improve layout
  
  Fixes #15155.

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53439
Commit:      b4e2eff2f63a9d4370194b28cdc1e58d22120487
URL:         https://git.haiku-os.org/haiku/commit/?id=b4e2eff2f63a
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Sat Aug 31 16:26:23 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/15155

----------------------------------------------------------------------------

3 files changed, 24 insertions(+), 12 deletions(-)
src/kits/shared/StripeView.cpp    |  2 +-
src/servers/debug/DebugWindow.cpp | 17 +++++++++++++----
src/servers/debug/DebugWindow.h   | 17 ++++++++++-------

----------------------------------------------------------------------------

diff --git a/src/kits/shared/StripeView.cpp b/src/kits/shared/StripeView.cpp
index 00a113aae4..c4c9aa5bcf 100644
--- a/src/kits/shared/StripeView.cpp
+++ b/src/kits/shared/StripeView.cpp
@@ -55,7 +55,7 @@ BStripeView::Draw(BRect updateRect)
 
        SetDrawingMode(B_OP_ALPHA);
        SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
-       DrawBitmapAsync(&fIcon, BPoint(stripeRect.right - (fIconSize / 2.0),
+       DrawBitmapAsync(&fIcon, BPoint(18 * iconLayoutScale,
                6 * iconLayoutScale));
 }
 
diff --git a/src/servers/debug/DebugWindow.cpp 
b/src/servers/debug/DebugWindow.cpp
index cf2c00c6da..0dd295f3d6 100644
--- a/src/servers/debug/DebugWindow.cpp
+++ b/src/servers/debug/DebugWindow.cpp
@@ -5,6 +5,7 @@
 
 #include "DebugWindow.h"
 
+#include <algorithm>
 #include <stdio.h>
 
 #include <Button.h>
@@ -26,7 +27,7 @@ DebugWindow::DebugWindow(const char* appName)
        :
        BWindow(BRect(0, 0, 100, 50), "Crashed program", B_MODAL_WINDOW,
                B_CLOSE_ON_ESCAPE | B_NOT_RESIZABLE | 
B_AUTO_UPDATE_SIZE_LIMITS),
-       fBitmap(BRect(0, 0, 31, 31), B_RGBA32),
+       fBitmap(IconSize(), B_RGBA32),
        fSemaphore(create_sem(0, "DebugWindow")),
        fAction(kActionKillTeam)
 {
@@ -38,11 +39,9 @@ DebugWindow::DebugWindow(const char* appName)
 
        BResources resources;
        resources.SetToImage(B_TRANSLATION_CONTEXT);
-       printf("init %s\n", strerror(resources.InitCheck()));
        size_t size;
        const uint8* iconData = (const uint8*)resources.LoadResource('VICN', 2,
                &size);
-       printf("icon %p\n", iconData);
        BIconUtils::GetVectorIcon(iconData, size, &fBitmap);
        BStripeView *stripeView = new BStripeView(fBitmap);
 
@@ -55,7 +54,10 @@ DebugWindow::DebugWindow(const char* appName)
        message->SetWordWrap(true);
        message->SetText(buffer);
        message->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNSET));
-       message->SetExplicitMinSize(BSize(310, B_SIZE_UNSET));
+       float width = message->StringWidth(appName)
+               + message->StringWidth(" ") * 12;
+       width = std::max(width, message->StringWidth("W") * 30);
+       message->SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
 
        BRadioButton *terminate = new BRadioButton("terminate",
                B_TRANSLATE("Terminate"), new BMessage(kActionKillTeam));
@@ -134,3 +136,10 @@ DebugWindow::Go()
 }
 
 
+BRect
+DebugWindow::IconSize()
+{
+       int32 size = std::max((int32)1, ((int32)be_plain_font->Size() + 15) / 
16)
+               * 32 - 1;
+       return BRect(0, 0, size, size);
+}
diff --git a/src/servers/debug/DebugWindow.h b/src/servers/debug/DebugWindow.h
index 58929dcbd4..9a4fc40b5b 100644
--- a/src/servers/debug/DebugWindow.h
+++ b/src/servers/debug/DebugWindow.h
@@ -28,15 +28,18 @@ enum {
 
 class DebugWindow : public BWindow {
 public:
-                               DebugWindow(const char* appName);
-                               ~DebugWindow();
+                                       DebugWindow(const char* appName);
+                                       ~DebugWindow();
 
-       void            MessageReceived(BMessage* message);
-       int32           Go();
+       void                    MessageReceived(BMessage* message);
+       int32                   Go();
 private:
-       BBitmap         fBitmap;
-       sem_id          fSemaphore;
-       int32           fAction;
+       static  BRect   IconSize();
+
+private:
+       BBitmap                 fBitmap;
+       sem_id                  fSemaphore;
+       int32                   fAction;
 };
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev53439 - in src: servers/debug kits/shared - Adrien Destugues