GIF and WebP translators: force layout of parent window
Translators are now allowed to use the layout API, but this doesn't work well when they are used in a non-layout aware window (the view ends up with a size of 0x0 or some arbitrary size set with SetExplicitPreferredSize). To avoid this, detect the case where the translator settings are the single child of a non-layout window, and force the window to become layouted. Fixes #7754.
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
|
||||
GIFView::GIFView(TranslatorSettings* settings)
|
||||
:
|
||||
BView("GIFView", B_WILL_DRAW),
|
||||
BGroupView("GIFView", B_VERTICAL),
|
||||
fSettings(settings)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
@@ -172,19 +172,17 @@ GIFView::GIFView(TranslatorSettings* settings)
|
||||
.Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1)
|
||||
|
||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10.0f), 1, 2)
|
||||
.End()
|
||||
|
||||
.Add(fDitheringBox, 1, 3)
|
||||
.Add(fInterlacedBox, 1, 4)
|
||||
.Add(fTransparentBox, 1, 5)
|
||||
.Add(fDitheringBox)
|
||||
.Add(fInterlacedBox)
|
||||
.Add(fTransparentBox)
|
||||
|
||||
.End()
|
||||
.AddGlue()
|
||||
.End();
|
||||
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
SetExplicitPreferredSize(BSize((font.Size() * 400) / 12,
|
||||
(font.Size() * 300) / 12));
|
||||
|
||||
fSettings->Acquire();
|
||||
|
||||
@@ -315,6 +313,11 @@ GIFView::AllAttached()
|
||||
fColorCountM->SetTargetForItems(messenger);
|
||||
|
||||
BView::AllAttached();
|
||||
|
||||
if (Parent() == NULL && Window()->GetLayout() == NULL) {
|
||||
Window()->SetLayout(new BGroupLayout(B_VERTICAL));
|
||||
Window()->ResizeTo(PreferredSize().Width(), PreferredSize().Height());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define GIF_VIEW_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
#include <GroupView.h>
|
||||
#include "TranslatorSettings.h"
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class BTextControl;
|
||||
|
||||
|
||||
|
||||
class GIFView : public BView {
|
||||
class GIFView : public BGroupView {
|
||||
public:
|
||||
GIFView(TranslatorSettings* settings);
|
||||
virtual ~GIFView();
|
||||
|
||||
@@ -52,8 +52,8 @@ static const struct preset_name {
|
||||
};
|
||||
|
||||
|
||||
ConfigView::ConfigView(TranslatorSettings* settings, uint32 flags)
|
||||
: BView(B_TRANSLATE("WebPTranslator Settings"), flags),
|
||||
ConfigView::ConfigView(TranslatorSettings* settings)
|
||||
: BGroupView(B_TRANSLATE("WebPTranslator Settings"), B_VERTICAL),
|
||||
fSettings(settings)
|
||||
{
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
@@ -120,7 +120,8 @@ ConfigView::ConfigView(TranslatorSettings* settings, uint32 flags)
|
||||
fPreprocessingCheckBox->SetValue(B_CONTROL_ON);
|
||||
|
||||
// Build the layout
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||
BLayoutBuilder::Group<> builder(GroupLayout());
|
||||
builder
|
||||
.SetInsets(5)
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.Add(title)
|
||||
@@ -130,13 +131,11 @@ ConfigView::ConfigView(TranslatorSettings* settings, uint32 flags)
|
||||
.Add(copyrights)
|
||||
.AddGlue()
|
||||
|
||||
.AddGrid()
|
||||
.Add(presetsField->CreateLabelLayoutItem(), 0, 0)
|
||||
.Add(presetsField->CreateMenuBarLayoutItem(), 1, 0)
|
||||
.End()
|
||||
.Add(presetsField)
|
||||
.Add(fQualitySlider)
|
||||
.Add(fMethodSlider)
|
||||
.Add(fPreprocessingCheckBox);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -149,13 +148,18 @@ ConfigView::~ConfigView()
|
||||
void
|
||||
ConfigView::AttachedToWindow()
|
||||
{
|
||||
BView::AttachedToWindow();
|
||||
BGroupView::AttachedToWindow();
|
||||
|
||||
fPresetsMenu->SetTargetForItems(this);
|
||||
|
||||
fQualitySlider->SetTarget(this);
|
||||
fMethodSlider->SetTarget(this);
|
||||
fPreprocessingCheckBox->SetTarget(this);
|
||||
|
||||
if (Parent() == NULL && Window()->GetLayout() == NULL) {
|
||||
Window()->SetLayout(new BGroupLayout(B_VERTICAL));
|
||||
Window()->ResizeTo(PreferredSize().Width(), PreferredSize().Height());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +185,7 @@ ConfigView::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
if (maps[i].name == NULL) {
|
||||
BView::MessageReceived(message);
|
||||
BGroupView::MessageReceived(message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,17 +9,16 @@
|
||||
#define CONFIG_VIEW_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
#include <GroupView.h>
|
||||
|
||||
class BCheckBox;
|
||||
class BPopUpMenu;
|
||||
class BSlider;
|
||||
class TranslatorSettings;
|
||||
|
||||
class ConfigView : public BView {
|
||||
class ConfigView : public BGroupView {
|
||||
public:
|
||||
ConfigView(TranslatorSettings* settings,
|
||||
uint32 flags = B_WILL_DRAW);
|
||||
ConfigView(TranslatorSettings* settings);
|
||||
virtual ~ConfigView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
|
||||
Reference in New Issue
Block a user