From a73b93fb03e9615bd9deca9c32efd2aa1df87918 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 12 Apr 2012 02:39:49 -0400 Subject: [PATCH] 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 --- .../3drendering/CapabilitiesView.cpp | 147 ++++++++++-------- .../3drendering/CapabilitiesView.h | 18 ++- .../3drendering/ExtensionsList.cpp | 55 ------- src/preferences/3drendering/ExtensionsList.h | 30 ---- .../3drendering/ExtensionsView.cpp | 48 ++++-- src/preferences/3drendering/ExtensionsView.h | 12 +- src/preferences/3drendering/GearsView.cpp | 9 +- src/preferences/3drendering/Jamfile | 6 +- src/preferences/3drendering/OpenGLView.cpp | 2 +- src/preferences/3drendering/OpenGLWindow.cpp | 9 +- 10 files changed, 145 insertions(+), 191 deletions(-) delete mode 100644 src/preferences/3drendering/ExtensionsList.cpp delete mode 100644 src/preferences/3drendering/ExtensionsList.h diff --git a/src/preferences/3drendering/CapabilitiesView.cpp b/src/preferences/3drendering/CapabilitiesView.cpp index 548a0c53e2..abc6038e0d 100644 --- a/src/preferences/3drendering/CapabilitiesView.cpp +++ b/src/preferences/3drendering/CapabilitiesView.cpp @@ -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 * Alex Wilson * Artur Wyszynski */ @@ -14,117 +15,129 @@ #include #include +#include +#include #include #include #include #include #include -#include -#include #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, - B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING); + fCapabilitiesList->AddRow(_CreateCapabilitiesRow(GL_MAX_EVAL_ORDER, + "Maximum evaluators equation order")); - layout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, layout->CountRows(), - layout->CountColumns(), 1); + fCapabilitiesList->AddRow(_CreateConvolutionCapabilitiesRow()); - // 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); + 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); } 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); @@ -134,6 +147,8 @@ CapabilitiesView::_AddConvolutionCapability() GL_MAX_CONVOLUTION_HEIGHT, &height); BString convolution; - convolution << (int32) width << 'x' << (int32) height; - _AddCapabilityView(B_TRANSLATE("Max. convolution:"), convolution); + convolution << (int32)width << 'x' << (int32)height; + row->SetField(new BStringField(convolution), 1); + + return row; } diff --git a/src/preferences/3drendering/CapabilitiesView.h b/src/preferences/3drendering/CapabilitiesView.h index 3b2e6ff6cc..6e84c53f21 100644 --- a/src/preferences/3drendering/CapabilitiesView.h +++ b/src/preferences/3drendering/CapabilitiesView.h @@ -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 +#include +#include +#include #include -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; }; diff --git a/src/preferences/3drendering/ExtensionsList.cpp b/src/preferences/3drendering/ExtensionsList.cpp deleted file mode 100644 index c4e826007a..0000000000 --- a/src/preferences/3drendering/ExtensionsList.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2009 Haiku Inc. All rights reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * Artur Wyszynski - */ - - -#include "ExtensionsList.h" - -#include -#include -#include -#include - - -#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; - } -} diff --git a/src/preferences/3drendering/ExtensionsList.h b/src/preferences/3drendering/ExtensionsList.h deleted file mode 100644 index 1c16374135..0000000000 --- a/src/preferences/3drendering/ExtensionsList.h +++ /dev/null @@ -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 -#include - - -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 */ diff --git a/src/preferences/3drendering/ExtensionsView.cpp b/src/preferences/3drendering/ExtensionsView.cpp index e7bcffc1e0..6dfb7a6761 100644 --- a/src/preferences/3drendering/ExtensionsView.cpp +++ b/src/preferences/3drendering/ExtensionsView.cpp @@ -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 * Alex Wilson * Artur Wyszynski */ @@ -11,16 +12,14 @@ #include "ExtensionsView.h" #include +#include +#include #include #include #include #include #include #include -#include -#include - -#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); diff --git a/src/preferences/3drendering/ExtensionsView.h b/src/preferences/3drendering/ExtensionsView.h index e19dee6c88..e08aabd90c 100644 --- a/src/preferences/3drendering/ExtensionsView.h +++ b/src/preferences/3drendering/ExtensionsView.h @@ -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 +#include #include -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; }; diff --git a/src/preferences/3drendering/GearsView.cpp b/src/preferences/3drendering/GearsView.cpp index 6ea027a548..39a1a2c2d3 100644 --- a/src/preferences/3drendering/GearsView.cpp +++ b/src/preferences/3drendering/GearsView.cpp @@ -10,17 +10,12 @@ #include "GearsView.h" #include -#include #include #include #include #include -#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)); } diff --git a/src/preferences/3drendering/Jamfile b/src/preferences/3drendering/Jamfile index 444c4d6169..f9afae571f 100644 --- a/src/preferences/3drendering/Jamfile +++ b/src/preferences/3drendering/Jamfile @@ -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 -; + ; diff --git a/src/preferences/3drendering/OpenGLView.cpp b/src/preferences/3drendering/OpenGLView.cpp index 445b3f95b7..5db0c4b92e 100644 --- a/src/preferences/3drendering/OpenGLView.cpp +++ b/src/preferences/3drendering/OpenGLView.cpp @@ -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: diff --git a/src/preferences/3drendering/OpenGLWindow.cpp b/src/preferences/3drendering/OpenGLWindow.cpp index e9fd0f0134..ca16a963b5 100644 --- a/src/preferences/3drendering/OpenGLWindow.cpp +++ b/src/preferences/3drendering/OpenGLWindow.cpp @@ -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 * Artur Wyszynski */ @@ -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)