Transform Capabilites into a ColumnListView. Make window shorter.

* Transform Capabilities to show a ColumnListView like Extensions.
* Make the window 250px tall, much shorter than before.
* Refactor both capabilities and extensions views.
* This eliminated the need for ExtensionsList which has been deleted.
* Move the gears image up.
* Take GearsView.cpp out of the Catalog since there are no strings
  there and there most likely never will be.
* Add OpenGLWindow.cpp to Catalog the window title counts.
* Update the Jamfile.
* Update copyright adding my name to several files.
* Rename Available column to Available extensions
This commit is contained in:
John Scipione 2012-04-12 02:39:49 -04:00
parent e5c6459e60
commit a73b93fb03
10 changed files with 145 additions and 191 deletions

View File

@ -1,8 +1,9 @@
/*
* Copyright 2009-2010 Haiku Inc. All rights reserved.
* Copyright 2009-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* John Scipione <jscipione@gmail.com>
* Alex Wilson <yourpalal2@gmail.com>
* Artur Wyszynski <harakash@gmail.com>
*/
@ -14,117 +15,129 @@
#include <Catalog.h>
#include <ControlLook.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <LayoutBuilder.h>
#include <Locale.h>
#include <Message.h>
#include <String.h>
#include <StringView.h>
#include <GL/glu.h>
#include <GL/glut.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Capabilities"
const BAlignment kNameAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);
const BAlignment kValueAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET);
CapabilitiesView::CapabilitiesView()
:
BGridView(B_TRANSLATE("Capabilities"))
BGroupView(B_TRANSLATE("Capabilities"), B_VERTICAL),
fCapabilitiesList(new BColumnListView("CapabilitiesList", B_FOLLOW_ALL))
{
_AddCapability(GL_AUX_BUFFERS, B_TRANSLATE("Auxiliary buffer(s):"));
// add the columns
_AddCapability(GL_MAX_MODELVIEW_STACK_DEPTH,
B_TRANSLATE("Model stack size:"));
fCapabilityColumn = new BStringColumn(B_TRANSLATE("Capability"),
240, 240, 240, B_TRUNCATE_MIDDLE);
fCapabilitiesList->AddColumn(fCapabilityColumn, 0);
fCapabilitiesList->SetSortingEnabled(true);
fCapabilitiesList->SetSortColumn(fCapabilityColumn, true, true);
_AddCapability(GL_MAX_PROJECTION_STACK_DEPTH,
B_TRANSLATE("Projection stack size:"));
fValueColumn = new BStringColumn(B_TRANSLATE("Value"), 60, 60, 60,
B_TRUNCATE_MIDDLE);
fCapabilitiesList->AddColumn(fValueColumn, 1);
_AddCapability(GL_MAX_TEXTURE_STACK_DEPTH,
B_TRANSLATE("Texture stack size:"));
// add the rows
_AddCapability(GL_MAX_NAME_STACK_DEPTH, B_TRANSLATE("Name stack size:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_AUX_BUFFERS,
"Auxiliary buffer(s)"));
_AddCapability(GL_MAX_LIST_NESTING, B_TRANSLATE("List stack size:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(
GL_MAX_MODELVIEW_STACK_DEPTH, "Model stack size"));
_AddCapability(GL_MAX_ATTRIB_STACK_DEPTH,
B_TRANSLATE("Attributes stack size:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(
GL_MAX_PROJECTION_STACK_DEPTH, "Projection stack size"));
_AddCapability(GL_MAX_TEXTURE_SIZE, B_TRANSLATE("Max. 2D texture size:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(
GL_MAX_TEXTURE_STACK_DEPTH, "Texture stack size"));
_AddCapability(GL_MAX_3D_TEXTURE_SIZE,
B_TRANSLATE("Max. 3D texture size:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(
GL_MAX_NAME_STACK_DEPTH, "Name stack size"));
_AddCapability(GL_MAX_TEXTURE_UNITS_ARB,
B_TRANSLATE("Max. texture units:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_LIST_NESTING,
"List stack size"));
_AddCapability(GL_MAX_LIGHTS, B_TRANSLATE("Max. lights:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(
GL_MAX_ATTRIB_STACK_DEPTH, "Attributes stack size"));
_AddCapability(GL_MAX_CLIP_PLANES, B_TRANSLATE("Max. clipping planes:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_TEXTURE_SIZE,
"Maximum 2D texture size"));
_AddCapability(GL_MAX_EVAL_ORDER,
B_TRANSLATE("Max. evaluators equation order:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_3D_TEXTURE_SIZE,
"Maximum 3D texture size"));
_AddConvolutionCapability();
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_TEXTURE_UNITS_ARB,
"Maximum texture units"));
_AddCapability(GL_MAX_ELEMENTS_INDICES,
B_TRANSLATE("Max. recommended index elements:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_LIGHTS,
"Maximum lights"));
_AddCapability(GL_MAX_ELEMENTS_VERTICES,
B_TRANSLATE("Max. recommended vertex elements:"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_CLIP_PLANES,
"Maximum clipping planes"));
BGridLayout* layout = GridLayout();
layout->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_EVAL_ORDER,
"Maximum evaluators equation order"));
fCapabilitiesList->AddRow(_CreateConvolutionCapabilitiesRow());
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_ELEMENTS_INDICES,
"Max. recommended index elements"));
fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_ELEMENTS_VERTICES,
"Max. recommended vertex elements"));
// add the list
AddChild(fCapabilitiesList);
GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
layout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, layout->CountRows(),
layout->CountColumns(), 1);
// Set horizontal spacing to 0, and use the middle column as
// variable-width spacing (like layout 'glue').
layout->SetHorizontalSpacing(0);
layout->SetMinColumnWidth(1, be_control_look->DefaultLabelSpacing());
layout->SetMaxColumnWidth(1, B_SIZE_UNLIMITED);
}
CapabilitiesView::~CapabilitiesView()
{
BRow *row;
while ((row = fCapabilitiesList->RowAt((int32)0, NULL)) != NULL) {
fCapabilitiesList->RemoveRow(row);
delete row;
}
delete fCapabilityColumn;
delete fValueColumn;
delete fCapabilitiesList;
}
void
CapabilitiesView::_AddCapability(GLenum capability, const char* name)
// #pragma mark -
BRow*
CapabilitiesView::_CreateCapabilitiesRow(GLenum capability, const char* name)
{
BRow* row = new BRow();
row->SetField(new BStringField(B_TRANSLATE(name)), 0);
int value = 0;
glGetIntegerv(capability, &value);
_AddCapabilityView(name, BString() << (int32)value);
row->SetField(new BStringField(BString() << (int32)value), 1);
return row;
}
void
CapabilitiesView::_AddCapabilityView(const char* name, const char* value)
BRow*
CapabilitiesView::_CreateConvolutionCapabilitiesRow()
{
BStringView *nameView = new BStringView(NULL, name);
nameView->SetExplicitAlignment(kNameAlignment);
BRow* row = new BRow();
row->SetField(new BStringField(B_TRANSLATE("Maximum convolution")), 0);
BStringView *valueView = new BStringView(NULL, value);
valueView->SetExplicitAlignment(kValueAlignment);
// Add the items at the bottom of our grid with a column inbetween
int32 row = GridLayout()->CountRows();
BLayoutBuilder::Grid<>(this)
.Add(nameView, 0, row)
.Add(valueView, 2, row);
}
void
CapabilitiesView::_AddConvolutionCapability()
{
int width = 0;
glGetConvolutionParameteriv(GL_CONVOLUTION_2D,
GL_MAX_CONVOLUTION_WIDTH, &width);
@ -135,5 +148,7 @@ CapabilitiesView::_AddConvolutionCapability()
BString convolution;
convolution << (int32)width << 'x' << (int32)height;
_AddCapabilityView(B_TRANSLATE("Max. convolution:"), convolution);
row->SetField(new BStringField(convolution), 1);
return row;
}

View File

@ -1,27 +1,31 @@
/*
* Copyright 2009-2010 Haiku Inc. All rights reserved.
* Copyright 2009-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef CAPABILITIES_VIEW_H
#define CAPABILITIES_VIEW_H
#include <GridView.h>
#include <ColumnListView.h>
#include <ColumnTypes.h>
#include <GroupView.h>
#include <GL/gl.h>
class CapabilitiesView : public BGridView {
class CapabilitiesView : public BGroupView {
public:
CapabilitiesView();
virtual ~CapabilitiesView();
private:
void _AddCapability(GLenum capability,
BRow* _CreateCapabilitiesRow(GLenum capability,
const char* name);
void _AddCapabilityView(const char* name,
const char* value);
void _AddConvolutionCapability();
BRow* _CreateConvolutionCapabilitiesRow();
BColumnListView* fCapabilitiesList;
BStringColumn* fCapabilityColumn;
BStringColumn* fValueColumn;
};

View File

@ -1,55 +0,0 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Artur Wyszynski <harakash@gmail.com>
*/
#include "ExtensionsList.h"
#include <Catalog.h>
#include <ColumnTypes.h>
#include <Locale.h>
#include <String.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Extensions"
ExtensionRow::ExtensionRow(const char* extensionName)
:
BRow(),
fExtensionName(extensionName)
{
SetField(new BStringField(extensionName), 0);
}
ExtensionRow::~ExtensionRow()
{
}
ExtensionsList::ExtensionsList()
:
BColumnListView("ExtensionsList", B_FOLLOW_ALL)
{
BStringColumn* column = new BStringColumn(B_TRANSLATE("Available"),
280, 280, 280, B_TRUNCATE_MIDDLE);
AddColumn(column, 0);
SetSortingEnabled(true);
SetSortColumn(column, true, true);
}
ExtensionsList::~ExtensionsList()
{
BRow *row;
while ((row = RowAt((int32)0, NULL)) != NULL) {
RemoveRow(row);
delete row;
}
}

View File

@ -1,30 +0,0 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef EXTENSIONS_LIST_H
#define EXTENSIONS_LIST_H
#include <ColumnListView.h>
#include <String.h>
class ExtensionRow : public BRow {
public:
ExtensionRow(const char* extensionName);
virtual ~ExtensionRow();
private:
BString fExtensionName;
};
class ExtensionsList : public BColumnListView {
public:
ExtensionsList();
virtual ~ExtensionsList();
};
#endif /* EXTENSIONS_LIST_H */

View File

@ -1,8 +1,9 @@
/*
* Copyright 2009-2010 Haiku Inc. All rights reserved.
* Copyright 2009-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* John Scipione <jscipione@gmail.com>
* Alex Wilson <yourpalal2@gmail.com>
* Artur Wyszynski <harakash@gmail.com>
*/
@ -11,16 +12,14 @@
#include "ExtensionsView.h"
#include <Catalog.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Locale.h>
#include <Message.h>
#include <SpaceLayoutItem.h>
#include <String.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ExtensionsList.h"
#undef B_TRANSLATE_CONTEXT
@ -29,13 +28,25 @@
ExtensionsView::ExtensionsView()
:
BGroupView(B_TRANSLATE("Extensions"), B_VERTICAL)
BGroupView(B_TRANSLATE("Extensions"), B_VERTICAL),
fExtensionsList(new BColumnListView("ExtensionsList", B_FOLLOW_ALL))
{
ExtensionsList *extList = new ExtensionsList();
_AddExtensionsList(extList, (char*) glGetString(GL_EXTENSIONS));
_AddExtensionsList(extList, (char*) gluGetString(GLU_EXTENSIONS));
// add the columns
AddChild(extList);
fAvailableColumn = new BStringColumn(B_TRANSLATE("Available extensions"),
280, 280, 280, B_TRUNCATE_MIDDLE);
fExtensionsList->AddColumn(fAvailableColumn, 0);
fExtensionsList->SetSortingEnabled(true);
fExtensionsList->SetSortColumn(fAvailableColumn, true, true);
// add the rows
_AddExtensionsList(fExtensionsList, (char*)glGetString(GL_EXTENSIONS));
_AddExtensionsList(fExtensionsList, (char*)gluGetString(GLU_EXTENSIONS));
// add the list
AddChild(fExtensionsList);
GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);
}
@ -43,6 +54,13 @@ ExtensionsView::ExtensionsView()
ExtensionsView::~ExtensionsView()
{
BRow *row;
while ((row = fExtensionsList->RowAt((int32)0, NULL)) != NULL) {
fExtensionsList->RemoveRow(row);
delete row;
}
delete fAvailableColumn;
delete fExtensionsList;
}
@ -50,18 +68,20 @@ ExtensionsView::~ExtensionsView()
void
ExtensionsView::_AddExtensionsList(ExtensionsList *extList, char* stringList)
ExtensionsView::_AddExtensionsList(BColumnListView* fExtensionsList, char* stringList)
{
if (!stringList)
if (stringList == NULL)
// empty extentions string
return;
while (*stringList) {
while (*stringList != NULL) {
char extName[255];
int n = strcspn(stringList, " ");
strncpy(extName, stringList, n);
extName[n] = 0;
extList->AddRow(new ExtensionRow(extName));
BRow* row = new BRow();
row->SetField(new BStringField(extName), 0);
fExtensionsList->AddRow(row);
if (!stringList[n])
break;
stringList += (n + 1);

View File

@ -1,24 +1,28 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Copyright 2009-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef EXTENSIONS_VIEW_H
#define EXTENSIONS_VIEW_H
#include <ColumnListView.h>
#include <ColumnTypes.h>
#include <GroupView.h>
class ExtensionsList;
class ExtensionsView : public BGroupView {
public:
ExtensionsView();
virtual ~ExtensionsView();
private:
void _AddExtensionsList(ExtensionsList *extList,
void _AddExtensionsList(
BColumnListView* fExtensionsList,
char* stringList);
BColumnListView* fExtensionsList;
BStringColumn* fAvailableColumn;
};

View File

@ -10,17 +10,12 @@
#include "GearsView.h"
#include <Bitmap.h>
#include <Catalog.h>
#include <Locale.h>
#include <Size.h>
#include <TranslationUtils.h>
#include <TranslatorFormats.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "GearsView"
static const float kStripeWidth = 30.0;
GearsView::GearsView()
@ -28,7 +23,7 @@ GearsView::GearsView()
BView("GearsView", B_WILL_DRAW),
fGears(NULL)
{
SetExplicitPreferredSize(BSize(64 + 5, B_SIZE_UNLIMITED));
SetExplicitPreferredSize(BSize(64.0 + 5.0, B_SIZE_UNLIMITED));
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
_InitGearsBitmap();
}
@ -56,7 +51,7 @@ GearsView::Draw(BRect updateRect)
SetDrawingMode(B_OP_ALPHA);
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
DrawBitmapAsync(fGears, BPoint(5, 70));
DrawBitmapAsync(fGears, BPoint(5.0, 30.0));
}

View File

@ -6,7 +6,6 @@ if $(HAIKU_GCC_VERSION[1]) < 3 {
SubDirC++Flags --no-warnings ;
}
UsePrivateHeaders interface ;
local sources =
@ -14,7 +13,6 @@ local sources =
OpenGLWindow.cpp
OpenGLView.cpp
CapabilitiesView.cpp
ExtensionsList.cpp
ExtensionsView.cpp
InfoView.cpp
GearsView.cpp
@ -35,10 +33,8 @@ DoCatalogs 3DRendering :
x-vnd.Haiku-3DRendering
:
CapabilitiesView.cpp
ExtensionsList.cpp
ExtensionsView.cpp
InfoView.cpp
GearsView.cpp
OpenGLWindow.cpp
;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2009-2010 Haiku Inc. All rights reserved.
* Copyright 2009-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:

View File

@ -1,8 +1,9 @@
/*
* Copyright 2009 Haiku Inc. All rights reserved.
* Copyright 2009-2012 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* John Scipione <jscipione@gmail.com>
* Artur Wyszynski <harakash@gmail.com>
*/
@ -15,9 +16,13 @@
#include "OpenGLView.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "OpenGLWindow"
OpenGLWindow::OpenGLWindow()
:
BWindow(BRect(50, 50, 450 + 64, 400),
BWindow(BRect(50, 50, 450 + 64, 300),
B_TRANSLATE_SYSTEM_NAME("3D Rendering"), B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS)