DataTranslations: use layout, standard format.

* Fix gif, hvif, png, psd, tga.
* Partialy fixes #11999.
This commit is contained in:
Janus 2015-04-22 23:19:00 +00:00
parent 037bc75e7f
commit c2751c41b7
6 changed files with 63 additions and 95 deletions

View File

@ -40,8 +40,8 @@ BMPView::BMPView(const BRect &frame, const char *name, uint32 resizeMode,
int(B_TRANSLATION_MINOR_VERSION(BMP_TRANSLATOR_VERSION)),
int(B_TRANSLATION_REVISION_VERSION(BMP_TRANSLATOR_VERSION)),
__DATE__);
BStringView *versionView = new BStringView("version", version);
BStringView *copyrightView = new BStringView("Copyright", B_UTF8_COPYRIGHT "2002-2010 Haiku Inc.");
BStringView *versionView = new BStringView("version", version);
BStringView *copyrightView = new BStringView("Copyright", B_UTF8_COPYRIGHT "2002-2010 Haiku Inc.");
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)

View File

@ -155,29 +155,21 @@ GIFView::GIFView(TranslatorSettings* settings)
}
}
BLayoutBuilder::Group<>(this, B_VERTICAL, 10.0f)
.SetInsets(10.0f)
.AddGrid(10.0f, 5.0f)
.Add(fTitle, 0, 0)
.Add(fVersion, 1, 0)
.Add(fCopyright, 0, 1, 2, 1)
.End()
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(fTitle)
.Add(fVersion)
.Add(fCopyright)
.AddGlue()
.AddGrid(10.0f, 5.0f)
.Add(fPaletteMF->CreateLabelLayoutItem(), 0, 0)
.Add(fPaletteMF->CreateMenuBarLayoutItem(), 1, 0)
.Add(fColorCountMF->CreateLabelLayoutItem(), 0, 1)
.Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1)
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10.0f), 1, 2)
.End()
.Add(fDitheringBox)
.Add(fInterlacedBox)
.Add(fTransparentBox)
.AddGlue()
.End();

View File

@ -62,12 +62,12 @@ HVIFView::HVIFView(const char* name, uint32 flags, TranslatorSettings *settings)
new BMessage(HVIF_SETTING_RENDER_SIZE_CHANGED));
fRenderSize->SetExplicitAlignment(labelAlignment);
float padding = 5.0f;
BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
.SetInsets(padding)
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(title)
.Add(version)
.Add(copyright)
.AddGlue()
.Add(fRenderSize)
.AddGlue();

View File

@ -13,6 +13,7 @@
#include <Alert.h>
#include <Catalog.h>
#include <LayoutBuilder.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
@ -33,41 +34,20 @@ PNGView::PNGView(const BRect &frame, const char *name, uint32 resizeMode,
fSettings = settings;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
font_height fontHeight;
be_bold_font->GetHeight(&fontHeight);
float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
BRect rect(10, 10, 200, 10 + height);
BStringView *stringView = new BStringView(rect, "title",
BStringView *titleView = new BStringView("title",
B_TRANSLATE("PNG image translator"));
stringView->SetFont(be_bold_font);
stringView->ResizeToPreferred();
AddChild(stringView);
titleView->SetFont(be_bold_font);
float maxWidth = stringView->Bounds().Width();
rect.OffsetBy(0, height + 10);
char version[256];
snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"),
int(B_TRANSLATION_MAJOR_VERSION(PNG_TRANSLATOR_VERSION)),
int(B_TRANSLATION_MINOR_VERSION(PNG_TRANSLATOR_VERSION)),
int(B_TRANSLATION_REVISION_VERSION(PNG_TRANSLATOR_VERSION)),
__DATE__);
stringView = new BStringView(rect, "version", version);
stringView->ResizeToPreferred();
AddChild(stringView);
BStringView *versionView = new BStringView("version", version);
if (stringView->Bounds().Width() > maxWidth)
maxWidth = stringView->Bounds().Width();
GetFontHeight(&fontHeight);
height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
rect.OffsetBy(0, height + 5);
stringView = new BStringView(rect,
BStringView *copyrightView = new BStringView(
"Copyright", B_UTF8_COPYRIGHT "2003-2006 Haiku Inc.");
stringView->ResizeToPreferred();
AddChild(stringView);
// setup PNG interlace options
@ -83,37 +63,47 @@ PNGView::PNGView(const BRect &frame, const char *name, uint32 resizeMode,
item->SetMarked(true);
fInterlaceMenu->AddItem(item);
rect.OffsetBy(0, stringView->Frame().Height() + 20.0f);
BMenuField* menuField = new BMenuField(rect,
BMenuField* menuField = new BMenuField(
B_TRANSLATE("PNG Interlace Menu"),
B_TRANSLATE("Interlacing type:"), fInterlaceMenu);
menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 7.0f);
menuField->ResizeToPreferred();
AddChild(menuField);
rect.OffsetBy(0, height + 15);
rect.right = Bounds().right;
rect.bottom = Bounds().bottom;
fCopyrightView = new BTextView(rect, "PNG copyright",
rect.OffsetToCopy(B_ORIGIN),
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
fCopyrightView = new BTextView("PNG copyright");
fCopyrightView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fCopyrightView->SetLowColor(fCopyrightView->ViewColor());
fCopyrightView->MakeEditable(false);
fCopyrightView->SetWordWrap(false);
fCopyrightView->MakeResizable(true);
fCopyrightView->SetText(png_get_copyright(NULL));
BFont font;
font.SetSize(font.Size() * 0.8);
fCopyrightView->SetFontAndColor(&font, B_FONT_SIZE, NULL);
AddChild(fCopyrightView);
//font.SetSize(font.Size() * 0.8);
//fCopyrightView->SetFontAndColor(&font, B_FONT_SIZE, NULL);
if (maxWidth + 20 > Bounds().Width())
ResizeTo(maxWidth + 20, Bounds().Height());
if (Bounds().Height() < rect.top + stringView->Bounds().Height()
* 3.0f + 8.0f)
ResizeTo(Bounds().Width(), rect.top + height * 3.0f + 8.0f);
fCopyrightView->SetTextRect(fCopyrightView->Bounds());
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(titleView)
.Add(versionView)
.Add(copyrightView)
.AddGlue()
.Add(menuField)
.AddGlue()
.Add(fCopyrightView);
GetFont(&font);
SetExplicitPreferredSize(BSize((font.Size() * 390) / 12,
(font.Size() * 180) / 12));
// TODO: remove this workaround for ticket #4217
fCopyrightView->SetExplicitPreferredSize(
BSize(fCopyrightView->LineWidth(4), fCopyrightView->TextHeight(0, 80)));
fCopyrightView->SetExplicitMaxSize(fCopyrightView->ExplicitPreferredSize());
fCopyrightView->SetExplicitMinSize(fCopyrightView->ExplicitPreferredSize());
}

View File

@ -6,10 +6,9 @@
#include "ConfigView.h"
#include <Catalog.h>
#include <ControlLook.h>
#include <LayoutBuilder.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
#include <SpaceLayoutItem.h>
#include <StringView.h>
#include <stdio.h>
@ -54,16 +53,9 @@ ConfigView::ConfigView(TranslatorSettings *settings)
fVersionField = new BMenuField("version",
B_TRANSLATE("Format: "), versionPopupMenu);
BAlignment leftAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);
BStringView *stringView = new BStringView("title",
BStringView *titleView = new BStringView("title",
B_TRANSLATE("Photoshop image translator"));
stringView->SetFont(be_bold_font);
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);
float spacing = be_control_look->DefaultItemSpacing();
AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
titleView->SetFont(be_bold_font);
char version[256];
sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
@ -71,29 +63,26 @@ ConfigView::ConfigView(TranslatorSettings *settings)
int(B_TRANSLATION_MINOR_VERSION(PSD_TRANSLATOR_VERSION)),
int(B_TRANSLATION_REVISION_VERSION(PSD_TRANSLATOR_VERSION)),
__DATE__);
stringView = new BStringView("version", version);
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);
stringView = new BStringView("copyright",
BStringView *versionView = new BStringView("version", version);
BStringView *copyrightView = new BStringView("copyright",
B_UTF8_COPYRIGHT "2005-2013 Haiku Inc.");
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);
stringView = new BStringView("my_copyright",
BStringView *copyright2View = new BStringView("my_copyright",
B_UTF8_COPYRIGHT "2012-2013 Gerasim Troeglazov <3dEyes@gmail.com>");
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);
AddChild(fVersionField);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(titleView)
.Add(versionView)
.Add(copyrightView)
.AddGlue()
.Add(fVersionField)
.Add(fCompressionField)
.AddGlue()
.Add(copyright2View);
AddChild(fCompressionField);
AddChild(BSpaceLayoutItem::CreateGlue());
GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
SetExplicitPreferredSize(GroupLayout()->MinSize());
//SetExplicitPreferredSize(GroupLayout()->MinSize());
}

View File

@ -31,7 +31,6 @@
#include <Catalog.h>
#include <LayoutBuilder.h>
#include <SpaceLayoutItem.h>
#include <stdio.h>
#include <string.h>
@ -49,7 +48,6 @@ TGAView::TGAView(const char *name, uint32 flags, TranslatorSettings *settings)
fSettings(settings)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetLowColor(ViewColor());
fTitle = new BStringView("title", B_TRANSLATE("TGA image translator"));
fTitle->SetFont(be_bold_font);
@ -77,16 +75,15 @@ TGAView::TGAView(const char *name, uint32 flags, TranslatorSettings *settings)
fpchkRLE->SetViewColor(ViewColor());
// Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL, 7)
.SetInsets(5)
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(fTitle)
.Add(fDetail)
.AddGlue()
.Add(fpchkIgnoreAlpha)
.Add(fpchkRLE)
.AddGlue()
.Add(fWrittenBy)
.AddGlue();
.Add(fWrittenBy);
BFont font;
GetFont(&font);