Add a slider to the settings view to allow adjusting the rendering output size.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30799 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -44,6 +44,11 @@ static translation_format sOutputFormats[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static TranSetting sDefaultSettings[] = {
|
||||||
|
{ HVIF_SETTING_RENDER_SIZE, TRAN_SETTING_INT32, 64 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
BTranslator *
|
BTranslator *
|
||||||
make_nth_translator(int32 n, image_id image, uint32 flags, ...)
|
make_nth_translator(int32 n, image_id image, uint32 flags, ...)
|
||||||
{
|
{
|
||||||
@@ -58,8 +63,9 @@ HVIFTranslator::HVIFTranslator()
|
|||||||
HVIF_TRANSLATOR_VERSION, sInputFormats,
|
HVIF_TRANSLATOR_VERSION, sInputFormats,
|
||||||
sizeof(sInputFormats) / sizeof(sInputFormats[0]), sOutputFormats,
|
sizeof(sInputFormats) / sizeof(sInputFormats[0]), sOutputFormats,
|
||||||
sizeof(sOutputFormats) / sizeof(sOutputFormats[0]),
|
sizeof(sOutputFormats) / sizeof(sOutputFormats[0]),
|
||||||
"HVIFTranslator_Settings", NULL, 0, B_TRANSLATOR_BITMAP,
|
"HVIFTranslator_Settings", sDefaultSettings,
|
||||||
HVIF_FORMAT_CODE)
|
sizeof(sDefaultSettings) / sizeof(sDefaultSettings[0]),
|
||||||
|
B_TRANSLATOR_BITMAP, HVIF_FORMAT_CODE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +140,12 @@ HVIFTranslator::DerivedTranslate(BPositionIO *inSource,
|
|||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
BBitmap rendered(BRect(0, 0, 63, 63), B_BITMAP_NO_SERVER_LINK, B_RGBA32);
|
int32 renderSize = fSettings->SetGetInt32(HVIF_SETTING_RENDER_SIZE);
|
||||||
|
if (renderSize <= 0 || renderSize > 1024)
|
||||||
|
renderSize = 64;
|
||||||
|
|
||||||
|
BBitmap rendered(BRect(0, 0, renderSize - 1, renderSize - 1),
|
||||||
|
B_BITMAP_NO_SERVER_LINK, B_RGBA32);
|
||||||
if (BIconUtils::GetVectorIcon(buffer, size, &rendered) != B_OK) {
|
if (BIconUtils::GetVectorIcon(buffer, size, &rendered) != B_OK) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
@@ -158,5 +169,5 @@ BView *
|
|||||||
HVIFTranslator::NewConfigView(TranslatorSettings *settings)
|
HVIFTranslator::NewConfigView(TranslatorSettings *settings)
|
||||||
{
|
{
|
||||||
return new HVIFView(BRect(0, 0, 250, 150), "HVIFTranslator Settings",
|
return new HVIFView(BRect(0, 0, 250, 150), "HVIFTranslator Settings",
|
||||||
B_FOLLOW_ALL, B_WILL_DRAW);
|
B_FOLLOW_ALL, B_WILL_DRAW, settings);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "BaseTranslator.h"
|
#include "BaseTranslator.h"
|
||||||
|
|
||||||
#define HVIF_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(1, 0, 0)
|
#define HVIF_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(1, 0, 0)
|
||||||
|
#define HVIF_SETTING_RENDER_SIZE "hvif /renderSize"
|
||||||
|
|
||||||
class HVIFTranslator : public BaseTranslator {
|
class HVIFTranslator : public BaseTranslator {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -9,14 +9,18 @@
|
|||||||
#include "HVIFView.h"
|
#include "HVIFView.h"
|
||||||
#include "HVIFTranslator.h"
|
#include "HVIFTranslator.h"
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define HVIF_SETTING_RENDER_SIZE_CHANGED 'rsch'
|
||||||
|
|
||||||
|
|
||||||
HVIFView::HVIFView(const BRect &frame, const char *name, uint32 resizeMode,
|
HVIFView::HVIFView(const BRect &frame, const char *name, uint32 resizeMode,
|
||||||
uint32 flags)
|
uint32 flags, TranslatorSettings *settings)
|
||||||
: BView(frame, name, resizeMode, flags)
|
: BView(frame, name, resizeMode, flags),
|
||||||
|
fSettings(settings)
|
||||||
{
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
@@ -50,4 +54,50 @@ HVIFView::HVIFView(const BRect &frame, const char *name, uint32 resizeMode,
|
|||||||
B_UTF8_COPYRIGHT"2009 Haiku Inc.");
|
B_UTF8_COPYRIGHT"2009 Haiku Inc.");
|
||||||
stringView->ResizeToPreferred();
|
stringView->ResizeToPreferred();
|
||||||
AddChild(stringView);
|
AddChild(stringView);
|
||||||
|
|
||||||
|
rect.OffsetBy(0, height + 5);
|
||||||
|
int32 renderSize = fSettings->SetGetInt32(HVIF_SETTING_RENDER_SIZE);
|
||||||
|
BString label = "Render Size: ";
|
||||||
|
label << renderSize;
|
||||||
|
fRenderSize = new BSlider(rect, "renderSize", label.String(), NULL, 1, 32);
|
||||||
|
|
||||||
|
fRenderSize->ResizeToPreferred();
|
||||||
|
fRenderSize->SetValue(renderSize / 8);
|
||||||
|
fRenderSize->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||||
|
fRenderSize->SetHashMarkCount(16);
|
||||||
|
fRenderSize->SetModificationMessage(
|
||||||
|
new BMessage(HVIF_SETTING_RENDER_SIZE_CHANGED));
|
||||||
|
AddChild(fRenderSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
HVIFView::AttachedToWindow()
|
||||||
|
{
|
||||||
|
fRenderSize->SetTarget(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
HVIFView::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case HVIF_SETTING_RENDER_SIZE_CHANGED:
|
||||||
|
{
|
||||||
|
int32 value = fRenderSize->Value();
|
||||||
|
if (value <= 0 || value > 32)
|
||||||
|
break;
|
||||||
|
|
||||||
|
value *= 8;
|
||||||
|
fSettings->SetGetInt32(HVIF_SETTING_RENDER_SIZE, &value);
|
||||||
|
fSettings->SaveSettings();
|
||||||
|
|
||||||
|
BString newLabel = "Render Size: ";
|
||||||
|
newLabel << value;
|
||||||
|
fRenderSize->SetLabel(newLabel.String());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,23 @@
|
|||||||
#ifndef HVIF_VIEW_H
|
#ifndef HVIF_VIEW_H
|
||||||
#define HVIF_VIEW_H
|
#define HVIF_VIEW_H
|
||||||
|
|
||||||
|
#include "TranslatorSettings.h"
|
||||||
|
|
||||||
|
#include <Slider.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
class HVIFView : public BView {
|
class HVIFView : public BView {
|
||||||
public:
|
public:
|
||||||
HVIFView(const BRect &frame, const char *name,
|
HVIFView(const BRect &frame, const char *name,
|
||||||
uint32 resizeMode, uint32 flags);
|
uint32 resizeMode, uint32 flags,
|
||||||
|
TranslatorSettings *settings);
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BSlider * fRenderSize;
|
||||||
|
TranslatorSettings *fSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HVIF_VIEW_H
|
#endif // HVIF_VIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user