[haiku-commits] haiku: hrev49092 - in src/add-ons/translators: png psd gif bmp tga

  • From: janus2@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 23 Apr 2015 01:20:52 +0200 (CEST)

hrev49092 adds 1 changeset to branch 'master'
old head: 037bc75e7f1a6c54dc8c0123ef242c4181537ddf
new head: c2751c41b7404c4e7b0b6ed723b92505a6cf332b
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=c2751c41b740+%5E037bc75e7f1a

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

c2751c41b740: DataTranslations: use layout, standard format.

* Fix gif, hvif, png, psd, tga.
* Partialy fixes #11999.

[ Janus <janus2@xxxxxxxxx> ]

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

Revision: hrev49092
Commit: c2751c41b7404c4e7b0b6ed723b92505a6cf332b
URL: http://cgit.haiku-os.org/haiku/commit/?id=c2751c41b740
Author: Janus <janus2@xxxxxxxxx>
Date: Wed Apr 22 23:19:00 2015 UTC

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

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

6 files changed, 68 insertions(+), 100 deletions(-)
src/add-ons/translators/bmp/BMPView.cpp | 4 +-
src/add-ons/translators/gif/GIFView.cpp | 18 ++----
src/add-ons/translators/hvif/HVIFView.cpp | 6 +-
src/add-ons/translators/png/PNGView.cpp | 82 +++++++++++---------------
src/add-ons/translators/psd/ConfigView.cpp | 49 ++++++---------
src/add-ons/translators/tga/TGAView.cpp | 9 +--

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

diff --git a/src/add-ons/translators/bmp/BMPView.cpp
b/src/add-ons/translators/bmp/BMPView.cpp
index c523cc5..a0881d3 100644
--- a/src/add-ons/translators/bmp/BMPView.cpp
+++ b/src/add-ons/translators/bmp/BMPView.cpp
@@ -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)
diff --git a/src/add-ons/translators/gif/GIFView.cpp
b/src/add-ons/translators/gif/GIFView.cpp
index 7c08a9a..88cfdb0 100644
--- a/src/add-ons/translators/gif/GIFView.cpp
+++ b/src/add-ons/translators/gif/GIFView.cpp
@@ -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();

diff --git a/src/add-ons/translators/hvif/HVIFView.cpp
b/src/add-ons/translators/hvif/HVIFView.cpp
index 5e21163..0eb3db6 100644
--- a/src/add-ons/translators/hvif/HVIFView.cpp
+++ b/src/add-ons/translators/hvif/HVIFView.cpp
@@ -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();

diff --git a/src/add-ons/translators/png/PNGView.cpp
b/src/add-ons/translators/png/PNGView.cpp
index bde700b..24acb88 100644
--- a/src/add-ons/translators/png/PNGView.cpp
+++ b/src/add-ons/translators/png/PNGView.cpp
@@ -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);
-
- float maxWidth = stringView->Bounds().Width();
+ titleView->SetFont(be_bold_font);

- 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);
-
- if (stringView->Bounds().Width() > maxWidth)
- maxWidth = stringView->Bounds().Width();
+ BStringView *versionView = new BStringView("version", version);

- 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);
-
- 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());
+ //font.SetSize(font.Size() * 0.8);
+ //fCopyrightView->SetFontAndColor(&font, B_FONT_SIZE, NULL);
+
+
+ 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());
}


diff --git a/src/add-ons/translators/psd/ConfigView.cpp
b/src/add-ons/translators/psd/ConfigView.cpp
index 92512f7..15508bf 100644
--- a/src/add-ons/translators/psd/ConfigView.cpp
+++ b/src/add-ons/translators/psd/ConfigView.cpp
@@ -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@xxxxxxxxx>");
- stringView->SetExplicitAlignment(leftAlignment);
- AddChild(stringView);

- AddChild(fVersionField);
-
- 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());
+ 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);
+
+
+ //SetExplicitPreferredSize(GroupLayout()->MinSize());
}


diff --git a/src/add-ons/translators/tga/TGAView.cpp
b/src/add-ons/translators/tga/TGAView.cpp
index 6005e90..e975449 100644
--- a/src/add-ons/translators/tga/TGAView.cpp
+++ b/src/add-ons/translators/tga/TGAView.cpp
@@ -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);


Other related posts:

  • » [haiku-commits] haiku: hrev49092 - in src/add-ons/translators: png psd gif bmp tga - janus2