PPM translator: clang-format
Change-Id: I290f9b369af37d919308759b83c42122f7f309bc Reviewed-on: https://review.haiku-os.org/c/902 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
4bf8cf7a1b
commit
72c5a125f1
@@ -22,58 +22,61 @@
|
|||||||
BPoint get_window_origin();
|
BPoint get_window_origin();
|
||||||
void set_window_origin(BPoint pt);
|
void set_window_origin(BPoint pt);
|
||||||
|
|
||||||
class PPMWindow :
|
class PPMWindow : public BWindow
|
||||||
public BWindow
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PPMWindow(BRect area) :
|
PPMWindow(BRect area)
|
||||||
BWindow(area, B_TRANSLATE("PPM Settings"), B_TITLED_WINDOW,
|
: BWindow(area, B_TRANSLATE("PPM Settings"), B_TITLED_WINDOW,
|
||||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
{
|
{
|
||||||
BLayoutBuilder::Group<>(this, B_HORIZONTAL);
|
BLayoutBuilder::Group<>(this, B_HORIZONTAL);
|
||||||
}
|
}
|
||||||
~PPMWindow()
|
~PPMWindow()
|
||||||
{
|
{
|
||||||
BPoint pt(0,0);
|
BPoint pt(0, 0);
|
||||||
ConvertToScreen(&pt);
|
ConvertToScreen(&pt);
|
||||||
set_window_origin(pt);
|
set_window_origin(pt);
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
BApplication app("application/x-vnd.Haiku-PPMTranslator");
|
BApplication app("application/x-vnd.Haiku-PPMTranslator");
|
||||||
BView * v = NULL;
|
BView* v = NULL;
|
||||||
BRect r(0, 0, 1, 1);
|
BRect r(0, 0, 1, 1);
|
||||||
if (MakeConfig(NULL, &v, &r)) {
|
if (MakeConfig(NULL, &v, &r)) {
|
||||||
BAlert * err = new BAlert("Error",
|
BAlert* err = new BAlert("Error",
|
||||||
B_TRANSLATE("Something is wrong with the PPMTranslator!"),
|
B_TRANSLATE("Something is wrong with the PPMTranslator!"),
|
||||||
B_TRANSLATE("OK"));
|
B_TRANSLATE("OK"));
|
||||||
err->SetFlags(err->Flags() | B_CLOSE_ON_ESCAPE);
|
err->SetFlags(err->Flags() | B_CLOSE_ON_ESCAPE);
|
||||||
err->Go();
|
err->Go();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
PPMWindow *w = new PPMWindow(r);
|
PPMWindow* w = new PPMWindow(r);
|
||||||
v->ResizeTo(r.Width(), r.Height());
|
v->ResizeTo(r.Width(), r.Height());
|
||||||
w->AddChild(v);
|
w->AddChild(v);
|
||||||
BPoint o = get_window_origin();
|
BPoint o = get_window_origin();
|
||||||
{
|
{
|
||||||
BScreen scrn;
|
BScreen scrn;
|
||||||
BRect f = scrn.Frame();
|
BRect f = scrn.Frame();
|
||||||
f.InsetBy(10,23);
|
f.InsetBy(10, 23);
|
||||||
/* if not in a good place, start where the cursor is */
|
/* if not in a good place, start where the cursor is */
|
||||||
if (!f.Contains(o)) {
|
if (!f.Contains(o)) {
|
||||||
uint32 i;
|
uint32 i;
|
||||||
v->GetMouse(&o, &i, false);
|
v->GetMouse(&o, &i, false);
|
||||||
o.x -= r.Width()/2;
|
o.x -= r.Width() / 2;
|
||||||
o.y -= r.Height()/2;
|
o.y -= r.Height() / 2;
|
||||||
/* clamp location to screen */
|
/* clamp location to screen */
|
||||||
if (o.x < f.left) o.x = f.left;
|
if (o.x < f.left)
|
||||||
if (o.y < f.top) o.y = f.top;
|
o.x = f.left;
|
||||||
if (o.x > f.right) o.x = f.right;
|
if (o.y < f.top)
|
||||||
if (o.y > f.bottom) o.y = f.bottom;
|
o.y = f.top;
|
||||||
|
if (o.x > f.right)
|
||||||
|
o.x = f.right;
|
||||||
|
if (o.y > f.bottom)
|
||||||
|
o.y = f.bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w->MoveTo(o);
|
w->MoveTo(o);
|
||||||
@@ -81,4 +84,3 @@ main()
|
|||||||
app.Run();
|
app.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -12,18 +12,18 @@
|
|||||||
/* with rowbytes amount of pixel data into some other color space in */
|
/* with rowbytes amount of pixel data into some other color space in */
|
||||||
/* out_data, with enough memory assumed to be in out_data for the */
|
/* out_data, with enough memory assumed to be in out_data for the */
|
||||||
/* converted data. */
|
/* converted data. */
|
||||||
status_t convert_space(color_space in_space, color_space out_space,
|
status_t convert_space(color_space in_space, color_space out_space,
|
||||||
unsigned char * in_data, int rowbytes, unsigned char * out_data);
|
unsigned char* in_data, int rowbytes, unsigned char* out_data);
|
||||||
|
|
||||||
/* This function expands rowbytes amount of data from in_data into */
|
/* This function expands rowbytes amount of data from in_data into */
|
||||||
/* RGBA32 data in out_buf, which must be big enough. */
|
/* RGBA32 data in out_buf, which must be big enough. */
|
||||||
int expand_data(color_space from_space, unsigned char * in_data,
|
int expand_data(color_space from_space, unsigned char* in_data, int rowbytes,
|
||||||
int rowbytes, unsigned char * out_buf);
|
unsigned char* out_buf);
|
||||||
|
|
||||||
/* This function converts num_bytes bytes of RGBA32 data into some new */
|
/* This function converts num_bytes bytes of RGBA32 data into some new */
|
||||||
/* color space in out_buf, where out_buf must be big enough. */
|
/* color space in out_buf, where out_buf must be big enough. */
|
||||||
int collapse_data(unsigned char * in_buf, int num_bytes,
|
int collapse_data(unsigned char* in_buf, int num_bytes, color_space out_space,
|
||||||
color_space out_space, unsigned char * out_buf);
|
unsigned char* out_buf);
|
||||||
|
|
||||||
/* Given a specific number of pixels in width in the color space space */
|
/* Given a specific number of pixels in width in the color space space */
|
||||||
/* this function calculates what the row_bytes should be. */
|
/* this function calculates what the row_bytes should be. */
|
||||||
|
|||||||
Reference in New Issue
Block a user