* Made it look better when running under Haiku. Restricts the maximal font size to

12 points to make sure it'll look acceptable.
* Fixed direct window rendering by disabling moving the animation area around
  (would have to be changed in DirectConnected() as well).
* Refresh and density sliders now ResizeToPreferred().
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16206 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-02-02 18:14:38 +00:00
parent eefde19a76
commit f2c54a03a6
3 changed files with 511 additions and 452 deletions

View File

@ -29,7 +29,7 @@ main()
ChartApp::ChartApp() : BApplication("application/x-vnd.Be.ChartDemo") ChartApp::ChartApp() : BApplication("application/x-vnd.Be.ChartDemo")
{ {
fWindow = new ChartWindow(BRect(120, 150, 629, 557), "Charts"); fWindow = new ChartWindow(BRect(120, 150, 629, 589), "Charts");
// showing the window will also start the direct connection. If you // showing the window will also start the direct connection. If you
// Sync() after the show, the direct connection will be established // Sync() after the show, the direct connection will be established

View File

@ -10,27 +10,28 @@
#include "ChartWindow.h" #include "ChartWindow.h"
#include <Box.h>
#include <Menu.h>
#include <PopUpMenu.h>
#include <File.h>
#include <Path.h>
#include <Entry.h>
#include <Button.h>
#include <Slider.h>
#include <MenuItem.h>
#include <CheckBox.h>
#include <Directory.h>
#include <PlaySound.h>
#include <MenuField.h>
#include <TextControl.h>
#include <RadioButton.h>
#include <AppFileInfo.h> #include <AppFileInfo.h>
#include <Application.h> #include <Application.h>
#include <FindDirectory.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Screen.h> #include <Box.h>
#include <Button.h>
#include <ByteOrder.h> #include <ByteOrder.h>
#include <CheckBox.h>
#include <Directory.h>
#include <Entry.h>
#include <File.h>
#include <FindDirectory.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <Path.h>
#include <PlaySound.h>
#include <PopUpMenu.h>
#include <RadioButton.h>
#include <Screen.h>
#include <Slider.h>
#include <TextControl.h>
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
@ -44,6 +45,8 @@ enum {
CRC_KEY = 0x1789feb3 CRC_KEY = 0x1789feb3
}; };
#define MAX_FONT_SIZE 12.0f
/* various offse, width, height and position used to align and /* various offse, width, height and position used to align and
set the various UI elements. */ set the various UI elements. */
enum { enum {
@ -59,7 +62,7 @@ enum {
SPACE_LABEL = 40, SPACE_LABEL = 40,
SPACE_POPUP = 53, SPACE_POPUP = 53,
INSTANT_LOAD = 205, INSTANT_LOAD = 205,
LEFT_WIDTH = 72, LEFT_WIDTH = 90,
LEFT_OFFSET = 2, LEFT_OFFSET = 2,
STATUS_BOX = 96, STATUS_BOX = 96,
STATUS_LABEL = 12, STATUS_LABEL = 12,
@ -70,11 +73,11 @@ enum {
FULL_SCREEN = 16, FULL_SCREEN = 16,
AUTO_DEMO = 22, AUTO_DEMO = 22,
SECOND_THREAD = 16, SECOND_THREAD = 16,
COLORS_BOX = 145, COLORS_BOX = 146,
COLORS_LABEL = 16, COLORS_LABEL = 16,
COLORS_OFFSET = 2, COLORS_OFFSET = 2,
COLOR_CELL = 8, COLOR_CELL = 8,
SPECIAL_BOX = 90, SPECIAL_BOX = 92,
SPECIAL_LABEL = 16, SPECIAL_LABEL = 16,
SPECIAL_OFFSET = 2, SPECIAL_OFFSET = 2,
STAR_DENSITY_H = 160, STAR_DENSITY_H = 160,
@ -163,15 +166,13 @@ static int32 light_gradient[8] = {
}; };
// #pragma mark helper classes
/*****************************************************
** **
** Implementation of various helper classes **
** **
*****************************************************/
/* multiply a vector by a constant */ /* multiply a vector by a constant */
TPoint TPoint::operator* (const float k) const { TPoint
TPoint::operator* (const float k) const
{
TPoint v; TPoint v;
v.x = x*k; v.x = x*k;
@ -181,7 +182,9 @@ TPoint TPoint::operator* (const float k) const {
} }
/* substract 2 vectors */ /* substract 2 vectors */
TPoint TPoint::operator- (const TPoint& v2) const { TPoint
TPoint::operator- (const TPoint& v2) const
{
TPoint v; TPoint v;
v.x = x-v2.x; v.x = x-v2.x;
@ -201,7 +204,9 @@ TPoint TPoint::operator+ (const TPoint& v2) const {
} }
/* vectorial product of 2 vectors */ /* vectorial product of 2 vectors */
TPoint TPoint::operator^ (const TPoint& v2) const { TPoint
TPoint::operator^ (const TPoint& v2) const
{
TPoint v; TPoint v;
v.x = y*v2.z - z*v2.y; v.x = y*v2.z - z*v2.y;
@ -211,12 +216,16 @@ TPoint TPoint::operator^ (const TPoint& v2) const {
} }
/* length of a vector */ /* length of a vector */
float TPoint::Length() const { float
TPoint::Length() const
{
return sqrt(x*x + y*y + z*z); return sqrt(x*x + y*y + z*z);
} }
/* product of a vector by a matrix */ /* product of a vector by a matrix */
TPoint TMatrix::operator* (const TPoint& v) const { TPoint
TMatrix::operator* (const TPoint& v) const
{
TPoint res; TPoint res;
res.x = m[0][0]*v.x + m[1][0]*v.y + m[2][0]*v.z; res.x = m[0][0]*v.x + m[1][0]*v.y + m[2][0]*v.z;
@ -226,7 +235,8 @@ TPoint TMatrix::operator* (const TPoint& v) const {
} }
/* extract the Nth vector/column of a matrix. */ /* extract the Nth vector/column of a matrix. */
TPoint TMatrix::Axis(int32 index) TPoint
TMatrix::Axis(int32 index)
{ {
TPoint v; TPoint v;
@ -238,7 +248,9 @@ TPoint TMatrix::Axis(int32 index)
/* as we use rotation matrix, the invert of the matrix /* as we use rotation matrix, the invert of the matrix
is equal to the transpose */ is equal to the transpose */
TMatrix TMatrix::Transpose() const { TMatrix
TMatrix::Transpose() const
{
TMatrix inv; TMatrix inv;
inv.m[0][0] = m[0][0]; inv.m[0][0] = m[0][0];
@ -254,7 +266,9 @@ TMatrix TMatrix::Transpose() const {
} }
/* set a spherical rotation matrix */ /* set a spherical rotation matrix */
void TMatrix::Set(const float alpha, const float theta, const float phi) { void
TMatrix::Set(const float alpha, const float theta, const float phi)
{
float cD,sD,cI,sI,cA,sA; float cD,sD,cI,sI,cA,sA;
/* trigonometry */ /* trigonometry */
@ -277,25 +291,16 @@ void TMatrix::Set(const float alpha, const float theta, const float phi) {
m[2][2] = cD*cI; m[2][2] = cD*cI;
} }
/* copy a setting into another */
void ChartWindow::setting::Set(setting *master)
{
memcpy(this, master, sizeof(setting));
}
// #pragma mark -
/*****************************************************
** **
** A couple global functions... **
** **
*****************************************************/
/* this function will play a wav sound file, with the specified /* this function will play a wav sound file, with the specified
following name, in the application folder. This is activated following name, in the application folder. This is activated
when you press the button "Auto demo". */ when you press the button "Auto demo". */
void LaunchSound() { void
LaunchSound()
{
/* /*
BEntry soundFile; BEntry soundFile;
app_info info; app_info info;
@ -319,9 +324,10 @@ void LaunchSound() {
/* return the version_info of a file, described by its name /* return the version_info of a file, described by its name
and its generic folder (in find_directory syntax). */ and its generic folder (in find_directory syntax). */
status_t get_file_version_info( directory_which dir, status_t
char *filename, get_file_version_info(directory_which dir,
version_info *info) { char *filename, version_info *info)
{
BPath path; BPath path;
BFile file; BFile file;
status_t res; status_t res;
@ -344,14 +350,9 @@ status_t get_file_version_info( directory_which dir,
} }
// #pragma mark -
/*****************************************************
** **
** Standard constructor and destructor. **
** **
*****************************************************/
ChartWindow::ChartWindow(BRect frame, const char *name) ChartWindow::ChartWindow(BRect frame, const char *name)
: BDirectWindow(frame, name, B_TITLED_WINDOW, 0) : BDirectWindow(frame, name, B_TITLED_WINDOW, 0)
{ {
@ -366,6 +367,14 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
BStringView *string; BStringView *string;
BRadioButton *radio; BRadioButton *radio;
// we're not font-sensitive, so we make sure we don't look too ugly
BFont font;
if (font.Size() > MAX_FONT_SIZE)
font.SetSize(MAX_FONT_SIZE);
BFont boldFont(be_bold_font);
if (boldFont.Size() > MAX_FONT_SIZE)
boldFont.SetSize(MAX_FONT_SIZE);
/* Check to see if we need the work-around for the case where /* Check to see if we need the work-around for the case where
DirectConnected is called back with B_BUFFER_RESET not set DirectConnected is called back with B_BUFFER_RESET not set
properly. This happens only with version 1.3.0 of the properly. This happens only with version 1.3.0 of the
@ -377,7 +386,6 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
&& (vi.major == 1) && (vi.middle == 3) && (vi.minor == 0)) && (vi.major == 1) && (vi.middle == 3) && (vi.minor == 0))
need_r3_buffer_reset_work_around = true; need_r3_buffer_reset_work_around = true;
/* offset the content area frame in window relative coordinate */ /* offset the content area frame in window relative coordinate */
frame.OffsetTo(0.0, 0.0); frame.OffsetTo(0.0, 0.0);
@ -471,6 +479,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
fDirectConnected = false; fDirectConnected = false;
/* build the UI content of the window */ /* build the UI content of the window */
/* top line background */ /* top line background */
r.Set(0.0, 0.0, frame.right, TOP_LEFT_LIMIT - 1); r.Set(0.0, 0.0, frame.right, TOP_LEFT_LIMIT - 1);
fTopView = new BView(r, "top view", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW); fTopView = new BView(r, "top view", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
@ -508,8 +517,11 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+ANIM_LABEL+ANIM_POPUP-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); r.Set(h, v, h+ANIM_LABEL+ANIM_POPUP-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER));
popup = new BMenuField(r, "", "Animation:", menu); popup = new BMenuField(r, "", "Animation:", menu);
popup->SetFont(&font);
popup->MenuBar()->SetFont(&font);
popup->Menu()->SetFont(&font);
popup->ResizeToPreferred(); popup->ResizeToPreferred();
popup->SetDivider(popup->StringWidth(popup->Label())); popup->SetDivider(popup->StringWidth(popup->Label()) + 4.0f);
fTopView->AddChild(popup); fTopView->AddChild(popup);
h += ANIM_LABEL+ANIM_POPUP+H_BORDER; h += ANIM_LABEL+ANIM_POPUP+H_BORDER;
@ -533,8 +545,11 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+DISP_LABEL+DISP_POPUP-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); r.Set(h, v, h+DISP_LABEL+DISP_POPUP-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER));
popup = new BMenuField(r, "", "Display:", menu); popup = new BMenuField(r, "", "Display:", menu);
popup->SetFont(&font);
popup->MenuBar()->SetFont(&font);
popup->Menu()->SetFont(&font);
popup->ResizeToPreferred(); popup->ResizeToPreferred();
popup->SetDivider(popup->StringWidth(popup->Label())); popup->SetDivider(popup->StringWidth(popup->Label()) + 4.0f);
fTopView->AddChild(popup); fTopView->AddChild(popup);
h += DISP_LABEL+DISP_POPUP+H_BORDER; h += DISP_LABEL+DISP_POPUP+H_BORDER;
@ -570,7 +585,6 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
color_button->ResizeToPreferred(); color_button->ResizeToPreferred();
fTopView->AddChild(color_button); fTopView->AddChild(color_button);
h += BUTTON_WIDTH+2*H_BORDER; h += BUTTON_WIDTH+2*H_BORDER;
/* star density button */ /* star density button */
@ -599,14 +613,17 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+SPACE_LABEL+SPACE_POPUP-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); r.Set(h, v, h+SPACE_LABEL+SPACE_POPUP-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER));
popup = new BMenuField(r, "", "Space:", menu); popup = new BMenuField(r, "", "Space:", menu);
popup->SetFont(&font);
popup->MenuBar()->SetFont(&font);
popup->Menu()->SetFont(&font);
popup->ResizeToPreferred(); popup->ResizeToPreferred();
popup->SetDivider(SPACE_LABEL); popup->SetDivider(popup->StringWidth(popup->Label()) + 4.0f);
fTopView->AddChild(popup); fTopView->AddChild(popup);
h += SPACE_LABEL+SPACE_POPUP+2*H_BORDER; h += SPACE_LABEL+SPACE_POPUP+2*H_BORDER;
/* left column gray background */ /* left column gray background */
r.Set(0.0, TOP_LEFT_LIMIT, LEFT_WIDTH-1, frame.bottom-1); r.Set(0.0, TOP_LEFT_LIMIT, LEFT_WIDTH-1, frame.bottom);
fLeftView = new BView(r, "top view", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW); fLeftView = new BView(r, "top view", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW);
fLeftView->SetViewColor(background_color); fLeftView->SetViewColor(background_color);
AddChild(fLeftView); AddChild(fLeftView);
@ -617,8 +634,9 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
v = v2; v = v2;
/* status box */ /* status box */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+STATUS_BOX-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2, v+STATUS_BOX-1);
fStatusBox = new BBox(r); fStatusBox = new BBox(r);
fStatusBox->SetFont(&boldFont);
fStatusBox->SetLabel("Status"); fStatusBox->SetLabel("Status");
fLeftView->AddChild(fStatusBox); fLeftView->AddChild(fStatusBox);
float boxWidth, boxHeight; float boxWidth, boxHeight;
@ -631,8 +649,8 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* frames per second title string */ /* frames per second title string */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+STATUS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+STATUS_LABEL-1);
string = new BStringView(r, "", "Frames/s"); string = new BStringView(r, "", "Frames/s");
string->SetFont(&font);
string->SetAlignment(B_ALIGN_CENTER); string->SetAlignment(B_ALIGN_CENTER);
string->ResizeToPreferred();
fStatusBox->AddChild(string); fStatusBox->AddChild(string);
v += STATUS_LABEL+STATUS_OFFSET; v += STATUS_LABEL+STATUS_OFFSET;
@ -644,7 +662,6 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
frames->SetFont(be_bold_font); frames->SetFont(be_bold_font);
frames->SetFontSize(24.0); frames->SetFontSize(24.0);
frames->SetViewColor(B_TRANSPARENT_32_BIT); frames->SetViewColor(B_TRANSPARENT_32_BIT);
frames->ResizeToPreferred();
fStatusBox->AddChild(frames); fStatusBox->AddChild(frames);
v += STATUS_EDIT+STATUS_OFFSET; v += STATUS_EDIT+STATUS_OFFSET;
@ -653,7 +670,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+STATUS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+STATUS_LABEL-1);
string = new BStringView(r, "", "CPU load"); string = new BStringView(r, "", "CPU load");
string->SetAlignment(B_ALIGN_CENTER); string->SetAlignment(B_ALIGN_CENTER);
string->ResizeToPreferred(); string->SetFont(&font);
fStatusBox->AddChild(string); fStatusBox->AddChild(string);
v += STATUS_LABEL+STATUS_OFFSET; v += STATUS_LABEL+STATUS_OFFSET;
@ -665,7 +682,6 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
cpu_load->SetFont(be_bold_font); cpu_load->SetFont(be_bold_font);
cpu_load->SetFontSize(24.0); cpu_load->SetFontSize(24.0);
cpu_load->SetViewColor(B_TRANSPARENT_32_BIT); cpu_load->SetViewColor(B_TRANSPARENT_32_BIT);
cpu_load->ResizeToPreferred();
fStatusBox->AddChild(cpu_load); fStatusBox->AddChild(cpu_load);
v2 += STATUS_BOX+LEFT_OFFSET*2; v2 += STATUS_BOX+LEFT_OFFSET*2;
@ -676,6 +692,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+FULL_SCREEN-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+FULL_SCREEN-1);
full_screen = new BCheckBox(r, "", "Full Screen", new BMessage(FULL_SCREEN_MSG)); full_screen = new BCheckBox(r, "", "Full Screen", new BMessage(FULL_SCREEN_MSG));
full_screen->SetTarget(this); full_screen->SetTarget(this);
full_screen->SetFont(&font);
full_screen->ResizeToPreferred(); full_screen->ResizeToPreferred();
float width, height; float width, height;
@ -704,17 +721,19 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+SECOND_THREAD-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+SECOND_THREAD-1);
check_box = new BCheckBox(r, "", "2 Threads", new BMessage(SECOND_THREAD_MSG)); check_box = new BCheckBox(r, "", "2 Threads", new BMessage(SECOND_THREAD_MSG));
check_box->SetTarget(this); check_box->SetTarget(this);
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fLeftView->AddChild(check_box); fLeftView->AddChild(check_box);
v2 += SECOND_THREAD+LEFT_OFFSET*2; v2 += SECOND_THREAD+LEFT_OFFSET*2 + 2;
h = h2; h = h2;
v = v2; v = v2;
/* Star color selection box */ /* Star color selection box */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+COLORS_BOX-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2, v+COLORS_BOX-1);
fColorsBox = new BBox(r); fColorsBox = new BBox(r);
fColorsBox->SetLabel("Colors"); fColorsBox->SetLabel("Colors");
fColorsBox->SetFont(&boldFont);
fLeftView->AddChild(fColorsBox); fLeftView->AddChild(fColorsBox);
h = BOX_H_OFFSET; h = BOX_H_OFFSET;
@ -723,6 +742,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* star color red check box */ /* star color red check box */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
check_box = new BCheckBox(r, "", "Red", new BMessage(COLORS_RED_MSG)); check_box = new BCheckBox(r, "", "Red", new BMessage(COLORS_RED_MSG));
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fColorsBox->AddChild(check_box); fColorsBox->AddChild(check_box);
@ -732,6 +752,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
check_box = new BCheckBox(r, "", "Green", new BMessage(COLORS_GREEN_MSG)); check_box = new BCheckBox(r, "", "Green", new BMessage(COLORS_GREEN_MSG));
check_box->SetValue(1); check_box->SetValue(1);
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fColorsBox->AddChild(check_box); fColorsBox->AddChild(check_box);
@ -741,6 +762,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
check_box = new BCheckBox(r, "", "Blue", new BMessage(COLORS_BLUE_MSG)); check_box = new BCheckBox(r, "", "Blue", new BMessage(COLORS_BLUE_MSG));
check_box->SetValue(1); check_box->SetValue(1);
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fColorsBox->AddChild(check_box); fColorsBox->AddChild(check_box);
@ -750,6 +772,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
check_box = new BCheckBox(r, "", "Yellow", new BMessage(COLORS_YELLOW_MSG)); check_box = new BCheckBox(r, "", "Yellow", new BMessage(COLORS_YELLOW_MSG));
check_box->SetValue(1); check_box->SetValue(1);
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fColorsBox->AddChild(check_box); fColorsBox->AddChild(check_box);
@ -758,6 +781,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* star color orange check box */ /* star color orange check box */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
check_box = new BCheckBox(r, "", "Orange", new BMessage(COLORS_ORANGE_MSG)); check_box = new BCheckBox(r, "", "Orange", new BMessage(COLORS_ORANGE_MSG));
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fColorsBox->AddChild(check_box); fColorsBox->AddChild(check_box);
@ -766,6 +790,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* star color pink check box */ /* star color pink check box */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
check_box = new BCheckBox(r, "", "Pink", new BMessage(COLORS_PINK_MSG)); check_box = new BCheckBox(r, "", "Pink", new BMessage(COLORS_PINK_MSG));
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fColorsBox->AddChild(check_box); fColorsBox->AddChild(check_box);
@ -774,6 +799,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* star color white check box */ /* star color white check box */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
check_box = new BCheckBox(r, "", "White", new BMessage(COLORS_WHITE_MSG)); check_box = new BCheckBox(r, "", "White", new BMessage(COLORS_WHITE_MSG));
check_box->SetFont(&font);
check_box->ResizeToPreferred(); check_box->ResizeToPreferred();
fColorsBox->AddChild(check_box); fColorsBox->AddChild(check_box);
@ -782,8 +808,9 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
v = v2; v = v2;
/* Special type selection box */ /* Special type selection box */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+SPECIAL_BOX-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2, v+SPECIAL_BOX-1);
fSpecialBox = new BBox(r); fSpecialBox = new BBox(r);
fSpecialBox->SetFont(&boldFont);
fSpecialBox->SetLabel("Special"); fSpecialBox->SetLabel("Special");
fLeftView->AddChild(fSpecialBox); fLeftView->AddChild(fSpecialBox);
@ -794,6 +821,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
radio = new BRadioButton(r, "", "None", new BMessage(SPECIAL_NONE_MSG)); radio = new BRadioButton(r, "", "None", new BMessage(SPECIAL_NONE_MSG));
radio->SetValue(1); radio->SetValue(1);
radio->SetFont(&font);
radio->ResizeToPreferred(); radio->ResizeToPreferred();
fSpecialBox->AddChild(radio); fSpecialBox->AddChild(radio);
@ -802,6 +830,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* comet special animation radio button */ /* comet special animation radio button */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
radio = new BRadioButton(r, "", "Comet", new BMessage(SPECIAL_COMET_MSG)); radio = new BRadioButton(r, "", "Comet", new BMessage(SPECIAL_COMET_MSG));
radio->SetFont(&font);
radio->ResizeToPreferred(); radio->ResizeToPreferred();
fSpecialBox->AddChild(radio); fSpecialBox->AddChild(radio);
@ -810,6 +839,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
/* novas special animation radio button */ /* novas special animation radio button */
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
radio = new BRadioButton(r, "", "Novas", new BMessage(SPECIAL_NOVAS_MSG)); radio = new BRadioButton(r, "", "Novas", new BMessage(SPECIAL_NOVAS_MSG));
radio->SetFont(&font);
radio->ResizeToPreferred(); radio->ResizeToPreferred();
fSpecialBox->AddChild(radio); fSpecialBox->AddChild(radio);
@ -819,10 +849,12 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1);
radio = new BRadioButton(r, "", "Battle", new BMessage(SPECIAL_BATTLE_MSG)); radio = new BRadioButton(r, "", "Battle", new BMessage(SPECIAL_BATTLE_MSG));
radio->SetEnabled(false); radio->SetEnabled(false);
radio->SetFont(&font);
radio->ResizeToPreferred(); radio->ResizeToPreferred();
fSpecialBox->AddChild(radio); fSpecialBox->AddChild(radio);
fLeftView->ResizeTo(max_c(boxWidth + 2, fLeftView->Bounds().Width()), fLeftView->Bounds().Height()); // Note: direct window mode uses LEFT_WIDTH
//fLeftView->ResizeTo(max_c(boxWidth + 2, fLeftView->Bounds().Width()), fLeftView->Bounds().Height());
/* animation area */ /* animation area */
r.Set(fLeftView->Frame().right, TOP_LEFT_LIMIT, frame.right, frame.bottom); r.Set(fLeftView->Frame().right, TOP_LEFT_LIMIT, frame.right, frame.bottom);
@ -848,6 +880,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name)
resume_thread(fAnimationThread); resume_thread(fAnimationThread);
} }
ChartWindow::~ChartWindow() ChartWindow::~ChartWindow()
{ {
int32 result; int32 result;
@ -874,21 +907,19 @@ ChartWindow::~ChartWindow()
} }
// #pragma mark Standard window members
/***************************************************** bool
** ** ChartWindow::QuitRequested()
** Standard window members **
** **
*****************************************************/
bool ChartWindow::QuitRequested()
{ {
be_app->PostMessage(B_QUIT_REQUESTED); be_app->PostMessage(B_QUIT_REQUESTED);
return(TRUE); return(TRUE);
} }
void ChartWindow::MessageReceived(BMessage *message)
void
ChartWindow::MessageReceived(BMessage *message)
{ {
int32 index, color; int32 index, color;
BHandler *handler; BHandler *handler;
@ -1005,7 +1036,9 @@ void ChartWindow::MessageReceived(BMessage *message)
} }
} }
void ChartWindow::ScreenChanged(BRect screen_size, color_space depth)
void
ChartWindow::ScreenChanged(BRect screen_size, color_space depth)
{ {
BScreen my_screen(this); BScreen my_screen(this);
@ -1016,7 +1049,9 @@ void ChartWindow::ScreenChanged(BRect screen_size, color_space depth)
next_set.depth = my_screen.ColorSpace(); next_set.depth = my_screen.ColorSpace();
} }
void ChartWindow::FrameResized(float new_width, float new_height)
void
ChartWindow::FrameResized(float new_width, float new_height)
{ {
/* this is the same principle than the one described for /* this is the same principle than the one described for
MessageReceived, to inform the engine that the window MessageReceived, to inform the engine that the window
@ -1027,17 +1062,13 @@ void ChartWindow::FrameResized(float new_width, float new_height)
} }
// #pragma mark User Interface related stuff...
/*****************************************************
** **
** User Interface related stuff... **
** **
*****************************************************/
/* loop through the window list of the application, looking for /* loop through the window list of the application, looking for
a window with a specified name. */ a window with a specified name. */
BWindow *ChartWindow::GetAppWindow(char *name) BWindow *
ChartWindow::GetAppWindow(char *name)
{ {
int32 index; int32 index;
BWindow *window; BWindow *window;
@ -1060,7 +1091,8 @@ BWindow *ChartWindow::GetAppWindow(char *name)
/* this function return a picture (in active or inactive state) of /* this function return a picture (in active or inactive state) of
a standard BButton with some specific content draw in the middle. a standard BButton with some specific content draw in the middle.
button_type indicate what special content should be used. */ button_type indicate what special content should be used. */
BPicture *ChartWindow::ButtonPicture(bool active, int32 button_type) BPicture *
ChartWindow::ButtonPicture(bool active, int32 button_type)
{ {
char word[6]; char word[6];
int32 value; int32 value;
@ -1114,14 +1146,13 @@ BPicture *ChartWindow::ButtonPicture(bool active, int32 button_type)
BColorControl, ChartColorControl, that will return live feedback BColorControl, ChartColorControl, that will return live feedback
as the same time the user will change the color setting of the as the same time the user will change the color setting of the
background. */ background. */
void ChartWindow::OpenColorPalette(BPoint here) void
ChartWindow::OpenColorPalette(BPoint here)
{ {
BRect frame; BRect frame;
BPoint point; BPoint point;
BWindow *window;
BColorControl *color_ctrl;
window = GetAppWindow("Space color"); BWindow *window = GetAppWindow("Space color");
if (window == NULL) { if (window == NULL) {
frame.Set(here.x, here.y, here.x + 199.0, here.y + 99.0); frame.Set(here.x, here.y, here.x + 199.0, here.y + 99.0);
window = new BWindow(frame, "Space color", window = new BWindow(frame, "Space color",
@ -1129,14 +1160,14 @@ void ChartWindow::OpenColorPalette(BPoint here)
B_FLOATING_APP_WINDOW_FEEL, B_FLOATING_APP_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_NOT_RESIZABLE); B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_NOT_RESIZABLE);
point.Set(0, 0); point.Set(0, 0);
color_ctrl = new ChartColorControl(point, new BMessage(COLOR_PALETTE_MSG)); BColorControl *colorControl = new ChartColorControl(point,
window->AddChild(color_ctrl); new BMessage(COLOR_PALETTE_MSG));
color_ctrl->SetViewColor(background_color); colorControl->SetViewColor(background_color);
color_ctrl->SetTarget(NULL, this); colorControl->SetTarget(NULL, this);
color_ctrl->SetValue(fCurrentSettings.back_color); colorControl->SetValue(fCurrentSettings.back_color);
window->ResizeTo(color_ctrl->Bounds().Width(), color_ctrl->Bounds().Height()); colorControl->ResizeToPreferred();
window->SetSizeLimits(frame.Width(), frame.Width(), frame.Height(), frame.Height()); window->ResizeTo(colorControl->Bounds().Width(), colorControl->Bounds().Height());
window->SetZoomLimits(frame.Width(), frame.Height()); window->AddChild(colorControl);
window->Show(); window->Show();
} }
window->Activate(); window->Activate();
@ -1145,7 +1176,8 @@ void ChartWindow::OpenColorPalette(BPoint here)
/* Create a floating window including a BSlider, that will return /* Create a floating window including a BSlider, that will return
live feedback when the user will change the star density of the live feedback when the user will change the star density of the
starfield */ starfield */
void ChartWindow::OpenStarDensity(BPoint here) void
ChartWindow::OpenStarDensity(BPoint here)
{ {
BRect frame; BRect frame;
BSlider *slider; BSlider *slider;
@ -1158,9 +1190,6 @@ void ChartWindow::OpenStarDensity(BPoint here)
B_FLOATING_WINDOW_LOOK, B_FLOATING_WINDOW_LOOK,
B_FLOATING_APP_WINDOW_FEEL, B_FLOATING_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK); B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK);
window->SetSizeLimits(frame.Width(), frame.Width(),
frame.Height(), frame.Height());
window->SetZoomLimits(frame.Width(), frame.Height());
frame.OffsetTo(0.0, 0.0); frame.OffsetTo(0.0, 0.0);
slider = new BSlider(frame, "", NULL, new BMessage(STAR_DENSITY_MSG), slider = new BSlider(frame, "", NULL, new BMessage(STAR_DENSITY_MSG),
STAR_DENSITY_MIN, STAR_DENSITY_MAX); STAR_DENSITY_MIN, STAR_DENSITY_MAX);
@ -1169,6 +1198,8 @@ void ChartWindow::OpenStarDensity(BPoint here)
slider->SetValue(fCurrentSettings.star_density); slider->SetValue(fCurrentSettings.star_density);
slider->SetModificationMessage(new BMessage(STAR_DENSITY_MSG)); slider->SetModificationMessage(new BMessage(STAR_DENSITY_MSG));
slider->SetLimitLabels(" 5% (low)", "(high) 100% "); slider->SetLimitLabels(" 5% (low)", "(high) 100% ");
slider->ResizeToPreferred();
window->ResizeTo(slider->Bounds().Width(), slider->Bounds().Height());
window->AddChild(slider); window->AddChild(slider);
window->Show(); window->Show();
} }
@ -1178,7 +1209,8 @@ void ChartWindow::OpenStarDensity(BPoint here)
/* Create a floating window including a BSlider, that will return /* Create a floating window including a BSlider, that will return
live feedback when the user will change the target refresh rate live feedback when the user will change the target refresh rate
of the animation */ of the animation */
void ChartWindow::OpenRefresh(BPoint here) void
ChartWindow::OpenRefresh(BPoint here)
{ {
BRect frame; BRect frame;
BSlider *slider; BSlider *slider;
@ -1191,9 +1223,6 @@ void ChartWindow::OpenRefresh(BPoint here)
B_FLOATING_WINDOW_LOOK, B_FLOATING_WINDOW_LOOK,
B_FLOATING_APP_WINDOW_FEEL, B_FLOATING_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK); B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK);
window->SetSizeLimits(frame.Width(), frame.Width(),
frame.Height(), frame.Height());
window->SetZoomLimits(frame.Width(), frame.Height());
frame.OffsetTo(0.0, 0.0); frame.OffsetTo(0.0, 0.0);
slider = new BSlider(frame, "", NULL, new BMessage(REFRESH_RATE_MSG), 0.0, 1000.0); slider = new BSlider(frame, "", NULL, new BMessage(REFRESH_RATE_MSG), 0.0, 1000.0);
slider->SetViewColor(background_color); slider->SetViewColor(background_color);
@ -1201,6 +1230,8 @@ void ChartWindow::OpenRefresh(BPoint here)
slider->SetValue(1000.0*log(fCurrentSettings.refresh_rate/REFRESH_RATE_MIN)/log(REFRESH_RATE_MAX/REFRESH_RATE_MIN)); slider->SetValue(1000.0*log(fCurrentSettings.refresh_rate/REFRESH_RATE_MIN)/log(REFRESH_RATE_MAX/REFRESH_RATE_MIN));
slider->SetModificationMessage(new BMessage(REFRESH_RATE_MSG)); slider->SetModificationMessage(new BMessage(REFRESH_RATE_MSG));
slider->SetLimitLabels(" 0.6 f/s (logarythmic scale)", "600.0 f/s"); slider->SetLimitLabels(" 0.6 f/s (logarythmic scale)", "600.0 f/s");
slider->ResizeToPreferred();
window->ResizeTo(slider->Bounds().Width(), slider->Bounds().Height());
window->AddChild(slider); window->AddChild(slider);
window->Show(); window->Show();
} }
@ -1208,7 +1239,8 @@ void ChartWindow::OpenRefresh(BPoint here)
} }
/* This update the state of the frames per second vue-meter in a lazy way. */ /* This update the state of the frames per second vue-meter in a lazy way. */
void ChartWindow::DrawInstantLoad(float frame_per_second) void
ChartWindow::DrawInstantLoad(float frame_per_second)
{ {
int32 level, i; int32 level, i;
bigtime_t timeout; bigtime_t timeout;
@ -1257,7 +1289,9 @@ void ChartWindow::DrawInstantLoad(float frame_per_second)
Unlock(); Unlock();
} }
void ChartWindow::PrintStatNumbers(float fps)
void
ChartWindow::PrintStatNumbers(float fps)
{ {
char text_frames[6]; char text_frames[6];
char text_cpu_load[6]; char text_cpu_load[6];
@ -1299,15 +1333,11 @@ void ChartWindow::PrintStatNumbers(float fps)
} }
// #pragma mark Engine setting related functions.
/***************************************************** void
** ** ChartWindow::InitGeometry()
** Engine setting related functions. **
** **
*****************************************************/
void ChartWindow::InitGeometry()
{ {
float dz; float dz;
@ -1339,7 +1369,9 @@ void ChartWindow::InitGeometry()
because the structure of the animation engine loop guarantees because the structure of the animation engine loop guarantees
that DirectConnected can not stay blocked at the same time that that DirectConnected can not stay blocked at the same time that
this method is executed. */ this method is executed. */
void ChartWindow::ChangeSetting(setting new_set) { void
ChartWindow::ChangeSetting(setting new_set)
{
//star *s; //star *s;
int32 i, color_count, old_step; int32 i, color_count, old_step;
int32 color_index[7]; int32 color_index[7];
@ -1538,7 +1570,8 @@ void ChartWindow::ChangeSetting(setting new_set) {
} }
/* Initialise the starfield in the different modes */ /* Initialise the starfield in the different modes */
void ChartWindow::InitStars(int32 space_model) void
ChartWindow::InitStars(int32 space_model)
{ {
star *s; star *s;
int32 step; int32 step;
@ -1724,7 +1757,8 @@ void ChartWindow::InitStars(int32 space_model)
} }
/* Fill a list of star with random position in the [0-1]x[0-1]x[0-1] cube */ /* Fill a list of star with random position in the [0-1]x[0-1]x[0-1] cube */
void ChartWindow::FillStarList(star *list, int32 count) void
ChartWindow::FillStarList(star *list, int32 count)
{ {
int32 i; int32 i;
@ -1743,7 +1777,8 @@ void ChartWindow::FillStarList(star *list, int32 count)
} }
/* initialise anything needed to enable a specific special animation */ /* initialise anything needed to enable a specific special animation */
void ChartWindow::InitSpecials(int32 code) void
ChartWindow::InitSpecials(int32 code)
{ {
int i, j; int i, j;
float alpha, ksin, kcos, coeff; float alpha, ksin, kcos, coeff;
@ -1834,7 +1869,8 @@ void ChartWindow::InitSpecials(int32 code)
/* select a color for each star (and special animation point) by /* select a color for each star (and special animation point) by
looping through the color index list. */ looping through the color index list. */
void ChartWindow::SetStarColors(int32 *color_list, int32 color_count) void
ChartWindow::SetStarColors(int32 *color_list, int32 color_count)
{ {
int32 i, index; int32 i, index;
@ -1853,7 +1889,9 @@ void ChartWindow::SetStarColors(int32 *color_list, int32 color_count)
} }
} }
void ChartWindow::SetGeometry(int32 dh, int32 dv)
void
ChartWindow::SetGeometry(int32 dh, int32 dv)
{ {
float zoom; float zoom;
@ -1873,19 +1911,17 @@ void ChartWindow::SetGeometry(int32 dh, int32 dv)
geo.offset_v = geo.offset_v * 2.0 - 1.0; geo.offset_v = geo.offset_v * 2.0 - 1.0;
} }
void ChartWindow::SetColorSpace(buffer *buf, color_space depth)
void
ChartWindow::SetColorSpace(buffer *buf, color_space depth)
{ {
bool swap_needed; bool swap_needed;
int32 red_shift = 0, int32 red_shift = 0, green_shift = 0;
green_shift = 0, int32 blue_shift = 0, alpha_shift = 0;
blue_shift = 0, int32 step_doubling = 0;
alpha_shift = 0,
step_doubling = 0;
int32 red_divide_shift = 0, int32 red_divide_shift = 0, green_divide_shift = 0;
green_divide_shift = 0, int32 blue_divide_shift = 0, alpha_divide_shift = 0;
blue_divide_shift = 0,
alpha_divide_shift = 0;
int32 i; int32 i;
uint32 color; uint32 color;
uint32 *col; uint32 *col;
@ -2018,18 +2054,23 @@ void ChartWindow::SetColorSpace(buffer *buf, color_space depth)
/* do the endianess swap if needed */ /* do the endianess swap if needed */
if (swap_needed) { if (swap_needed) {
col = buf->colors[0]; col = buf->colors[0];
for (i=0; i<7*8; i++) for (i = 0; i < 7*8; i++) {
B_SWAP_INT32(col[i]); B_SWAP_INT32(col[i]);
}
B_SWAP_INT32(buf->back_color); B_SWAP_INT32(buf->back_color);
} }
} }
/* For each different offset used to access a pixel of the star matrix,
/*!
For each different offset used to access a pixel of the star matrix,
create a buffer pointer based on the main buffer pointer offset by create a buffer pointer based on the main buffer pointer offset by
the pixel matrix offset. That way, any pixel of the matrix can be the pixel matrix offset. That way, any pixel of the matrix can be
address later by just picking the right pointer and indexing it by address later by just picking the right pointer and indexing it by
the global star offset */ the global star offset
void ChartWindow::SetPatternBits(buffer *buf) */
void
ChartWindow::SetPatternBits(buffer *buf)
{ {
for (int32 i=0; i<32; i++) { for (int32 i=0; i<32; i++) {
buf->pattern_bits[i] = (void*)((char*)buf->bits + buf->pattern_bits[i] = (void*)((char*)buf->bits +
@ -2039,17 +2080,16 @@ void ChartWindow::SetPatternBits(buffer *buf)
} }
// #pragma mark Engine processing related functions.
/***************************************************** /*!
** ** That's the main thread controling the animation and synchronising
** Engine processing related functions. ** the engine state with the changes coming from the UI.
** ** */
*****************************************************/ long
ChartWindow::Animation(void *data)
/* That's the main thread controling the animation and synchronising {
the engine state with the changes coming from the UI. */
long ChartWindow::Animation(void *data) {
int32 i, cur_4_frames_index, cur_last_fps, count_fps; int32 i, cur_4_frames_index, cur_last_fps, count_fps;
float time_factor = 0, total_fps; float time_factor = 0, total_fps;
float last_fps[4]; float last_fps[4];
@ -2162,7 +2202,9 @@ long ChartWindow::Animation(void *data) {
slave of the Animation thread. It's directly synchronised with its slave of the Animation thread. It's directly synchronised with its
master, and will only do some star animation processing whenever master, and will only do some star animation processing whenever
its master allows him to do so. */ its master allows him to do so. */
long ChartWindow::Animation2(void *data) { long
ChartWindow::Animation2(void *data)
{
bigtime_t before, after; bigtime_t before, after;
ChartWindow *w; ChartWindow *w;
@ -2189,7 +2231,9 @@ long ChartWindow::Animation2(void *data) {
return 0; return 0;
} }
void ChartWindow::SetCubeOffset()
void
ChartWindow::SetCubeOffset()
{ {
int32 i; int32 i;
TPoint min, max, dx, dy, dz, p1; TPoint min, max, dx, dy, dz, p1;
@ -2283,7 +2327,8 @@ void ChartWindow::SetCubeOffset()
/* move the camera around, as defined by the animation popup. /* move the camera around, as defined by the animation popup.
This is adjusted by a time factor to compensate for change This is adjusted by a time factor to compensate for change
in the framerate. */ in the framerate. */
void ChartWindow::CameraAnimation(float time_factor) void
ChartWindow::CameraAnimation(float time_factor)
{ {
TPoint move; TPoint move;
@ -2428,7 +2473,9 @@ void ChartWindow::CameraAnimation(float time_factor)
} }
} }
void ChartWindow::SelectNewTarget()
void
ChartWindow::SelectNewTarget()
{ {
float ratio, ratio_min; float ratio, ratio_min;
float dist, lateral, axial, ftmp; float dist, lateral, axial, ftmp;
@ -2486,7 +2533,8 @@ void ChartWindow::SelectNewTarget()
/* Try to change the angular acceleration to aim in direction /* Try to change the angular acceleration to aim in direction
of the current target. */ of the current target. */
void ChartWindow::FollowTarget() void
ChartWindow::FollowTarget()
{ {
float x0, y0, x, y, z, cphi, sphi; float x0, y0, x, y, z, cphi, sphi;
TPoint pt; TPoint pt;
@ -2548,7 +2596,8 @@ void ChartWindow::FollowTarget()
/* Do whatever special processing is required to do special /* Do whatever special processing is required to do special
animation. This used a time_step (or time_factor) to animation. This used a time_step (or time_factor) to
compensate for change in the framerate of the animation. */ compensate for change in the framerate of the animation. */
void ChartWindow::AnimSpecials(float time_step) void
ChartWindow::AnimSpecials(float time_step)
{ {
int i, j; int i, j;
star *s; star *s;
@ -2632,9 +2681,12 @@ void ChartWindow::AnimSpecials(float time_step)
} }
} }
/* Sync the embedded camera state with the window class camera /* Sync the embedded camera state with the window class camera
state (before calling the embedded C-engine in ChartRender.c */ state (before calling the embedded C-engine in ChartRender.c */
void ChartWindow::SyncGeo() { void
ChartWindow::SyncGeo()
{
geo.x = origin.x; geo.x = origin.x;
geo.y = origin.y; geo.y = origin.y;
geo.z = origin.z; geo.z = origin.z;
@ -2644,7 +2696,9 @@ void ChartWindow::SyncGeo() {
memcpy(geo.m, camera_invert.m, sizeof(float)*9); memcpy(geo.m, camera_invert.m, sizeof(float)*9);
} }
void ChartWindow::RefreshStars(buffer *buf, float time_step)
void
ChartWindow::RefreshStars(buffer *buf, float time_step)
{ {
float ratio; float ratio;
int32 star_threshold, special_threshold; int32 star_threshold, special_threshold;
@ -2727,15 +2781,11 @@ void ChartWindow::RefreshStars(buffer *buf, float time_step)
} }
// #pragma mark Offscreen bitmap configuration related functions.
/***************************************************** void
** ** ChartWindow::CheckBitmap(color_space depth, int32 width, int32 height)
** Offscreen bitmap configuration related functions.**
** **
*****************************************************/
void ChartWindow::CheckBitmap(color_space depth, int32 width, int32 height)
{ {
color_space cur_depth; color_space cur_depth;
@ -2787,7 +2837,9 @@ void ChartWindow::CheckBitmap(color_space depth, int32 width, int32 height)
Unlock(); Unlock();
} }
void ChartWindow::SetBitmapClipping(int32 width, int32 height)
void
ChartWindow::SetBitmapClipping(int32 width, int32 height)
{ {
/* Set the bitmap buffer clipping to the required size of /* Set the bitmap buffer clipping to the required size of
the buffer (even if the allocated buffer is larger) */ the buffer (even if the allocated buffer is larger) */
@ -2802,7 +2854,9 @@ void ChartWindow::SetBitmapClipping(int32 width, int32 height)
bitmap_buffer.clip_list[0].bottom = bitmap_buffer.clip_bounds.bottom; bitmap_buffer.clip_list[0].bottom = bitmap_buffer.clip_bounds.bottom;
} }
void ChartWindow::SetBitmapBackGround()
void
ChartWindow::SetBitmapBackGround()
{ {
int32 i, count; int32 i, count;
uint32 *bits; uint32 *bits;
@ -2818,15 +2872,11 @@ void ChartWindow::SetBitmapBackGround()
} }
// #pragma mark DirectWindow related functions.
/***************************************************** void
** ** ChartWindow::DirectConnected(direct_buffer_info *info)
** DirectWindow related functions. **
** **
*****************************************************/
void ChartWindow::DirectConnected(direct_buffer_info *info)
{ {
/* block the animation thread. */ /* block the animation thread. */
acquire_sem(fDrawingLock); acquire_sem(fDrawingLock);
@ -2843,7 +2893,8 @@ void ChartWindow::DirectConnected(direct_buffer_info *info)
in DirectConnected, it's a bad idea to do any heavy drawing (long) in DirectConnected, it's a bad idea to do any heavy drawing (long)
operation. But as we only update the stars (the background will be operation. But as we only update the stars (the background will be
update a little later by the view system), it's not a big deal. */ update a little later by the view system), it's not a big deal. */
void ChartWindow::SwitchContext(direct_buffer_info *info) void
ChartWindow::SwitchContext(direct_buffer_info *info)
{ {
//star *s; //star *s;
uint32 i, j; uint32 i, j;
@ -2986,15 +3037,17 @@ void ChartWindow::SwitchContext(direct_buffer_info *info)
} }
/*! copy a setting into another */
void
ChartWindow::setting::Set(setting *master)
{
memcpy(this, master, sizeof(setting));
}
/***************************************************** /*! Pseudo-random generator increment function. */
** ** void
** Pseudo-random generator increment function. ** ChartWindow::CrcStep()
** **
*****************************************************/
void ChartWindow::CrcStep()
{ {
crc_alea <<= 1; crc_alea <<= 1;
if (crc_alea < 0) if (crc_alea < 0)

View File

@ -1,12 +1,18 @@
SubDir HAIKU_TOP src tests kits game chart ; SubDir HAIKU_TOP src tests kits game chart ;
SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ;
Application Chart : Application Chart :
Chart.cpp Chart.cpp
ChartRender.cpp ChartRender.cpp
ChartView.cpp ChartView.cpp
ChartWindow.cpp ChartWindow.cpp
: libbe.so libgame.so libroot.so : be game
: Chart.rdef : Chart.rdef
; ;
if $(TARGET_PLATFORM) = libbe_test {
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : Chart
: tests!apps ;
}