DebugWindow: improve layout

Fixes #15155.
This commit is contained in:
Adrien Destugues
2019-08-31 18:26:23 +02:00
parent 5f996be3c6
commit b4e2eff2f6
3 changed files with 24 additions and 12 deletions
+1 -1
View File
@@ -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));
}
+13 -4
View File
@@ -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);
}
+10 -7
View File
@@ -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;
};