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)
|
GIFView::GIFView(TranslatorSettings* settings)
|
||||||
:
|
:
|
||||||
BView("GIFView", B_WILL_DRAW),
|
BGroupView("GIFView", B_VERTICAL),
|
||||||
fSettings(settings)
|
fSettings(settings)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -172,19 +172,17 @@ GIFView::GIFView(TranslatorSettings* settings)
|
|||||||
.Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1)
|
.Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1)
|
||||||
|
|
||||||
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10.0f), 1, 2)
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10.0f), 1, 2)
|
||||||
|
.End()
|
||||||
|
|
||||||
.Add(fDitheringBox, 1, 3)
|
.Add(fDitheringBox)
|
||||||
.Add(fInterlacedBox, 1, 4)
|
.Add(fInterlacedBox)
|
||||||
.Add(fTransparentBox, 1, 5)
|
.Add(fTransparentBox)
|
||||||
|
|
||||||
.End()
|
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.End();
|
.End();
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
SetExplicitPreferredSize(BSize((font.Size() * 400) / 12,
|
|
||||||
(font.Size() * 300) / 12));
|
|
||||||
|
|
||||||
fSettings->Acquire();
|
fSettings->Acquire();
|
||||||
|
|
||||||
@@ -315,6 +313,11 @@ GIFView::AllAttached()
|
|||||||
fColorCountM->SetTargetForItems(messenger);
|
fColorCountM->SetTargetForItems(messenger);
|
||||||
|
|
||||||
BView::AllAttached();
|
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
|
#define GIF_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <GroupView.h>
|
||||||
#include "TranslatorSettings.h"
|
#include "TranslatorSettings.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ class BTextControl;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GIFView : public BView {
|
class GIFView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
GIFView(TranslatorSettings* settings);
|
GIFView(TranslatorSettings* settings);
|
||||||
virtual ~GIFView();
|
virtual ~GIFView();
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ static const struct preset_name {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ConfigView::ConfigView(TranslatorSettings* settings, uint32 flags)
|
ConfigView::ConfigView(TranslatorSettings* settings)
|
||||||
: BView(B_TRANSLATE("WebPTranslator Settings"), flags),
|
: BGroupView(B_TRANSLATE("WebPTranslator Settings"), B_VERTICAL),
|
||||||
fSettings(settings)
|
fSettings(settings)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -120,7 +120,8 @@ ConfigView::ConfigView(TranslatorSettings* settings, uint32 flags)
|
|||||||
fPreprocessingCheckBox->SetValue(B_CONTROL_ON);
|
fPreprocessingCheckBox->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
// Build the layout
|
// Build the layout
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<> builder(GroupLayout());
|
||||||
|
builder
|
||||||
.SetInsets(5)
|
.SetInsets(5)
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.Add(title)
|
.Add(title)
|
||||||
@@ -130,13 +131,11 @@ ConfigView::ConfigView(TranslatorSettings* settings, uint32 flags)
|
|||||||
.Add(copyrights)
|
.Add(copyrights)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
|
|
||||||
.AddGrid()
|
.Add(presetsField)
|
||||||
.Add(presetsField->CreateLabelLayoutItem(), 0, 0)
|
|
||||||
.Add(presetsField->CreateMenuBarLayoutItem(), 1, 0)
|
|
||||||
.End()
|
|
||||||
.Add(fQualitySlider)
|
.Add(fQualitySlider)
|
||||||
.Add(fMethodSlider)
|
.Add(fMethodSlider)
|
||||||
.Add(fPreprocessingCheckBox);
|
.Add(fPreprocessingCheckBox);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -149,13 +148,18 @@ ConfigView::~ConfigView()
|
|||||||
void
|
void
|
||||||
ConfigView::AttachedToWindow()
|
ConfigView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
BView::AttachedToWindow();
|
BGroupView::AttachedToWindow();
|
||||||
|
|
||||||
fPresetsMenu->SetTargetForItems(this);
|
fPresetsMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
fQualitySlider->SetTarget(this);
|
fQualitySlider->SetTarget(this);
|
||||||
fMethodSlider->SetTarget(this);
|
fMethodSlider->SetTarget(this);
|
||||||
fPreprocessingCheckBox->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) {
|
if (maps[i].name == NULL) {
|
||||||
BView::MessageReceived(message);
|
BGroupView::MessageReceived(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,17 +9,16 @@
|
|||||||
#define CONFIG_VIEW_H
|
#define CONFIG_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <GroupView.h>
|
||||||
|
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BSlider;
|
class BSlider;
|
||||||
class TranslatorSettings;
|
class TranslatorSettings;
|
||||||
|
|
||||||
class ConfigView : public BView {
|
class ConfigView : public BGroupView {
|
||||||
public:
|
public:
|
||||||
ConfigView(TranslatorSettings* settings,
|
ConfigView(TranslatorSettings* settings);
|
||||||
uint32 flags = B_WILL_DRAW);
|
|
||||||
virtual ~ConfigView();
|
virtual ~ConfigView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
|
|||||||
Reference in New Issue
Block a user