xref: /haiku/src/tests/kits/opengl/glinfo/OpenGLView.cpp (revision 9293eadbdac802eba0aa782c08d5dd9972e5b4c1)
1 /*
2  * Copyright 2009-2012 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Alex Wilson <yourpalal2@gmail.com>
7  *		Artur Wyszynski <harakash@gmail.com>
8  */
9 
10 
11 #include "OpenGLView.h"
12 
13 #include <stdio.h>
14 
15 #include <Catalog.h>
16 #include <GLView.h>
17 #include <LayoutBuilder.h>
18 #include <Locale.h>
19 #include <MenuField.h>
20 #include <PopUpMenu.h>
21 #include <Size.h>
22 #include <SpaceLayoutItem.h>
23 #include <TabView.h>
24 
25 #include "CapabilitiesView.h"
26 #include "ExtensionsView.h"
27 #include "InfoView.h"
28 #include "GearsView.h"
29 
30 
31 #undef B_TRANSLATION_CONTEXT
32 #define B_TRANSLATION_CONTEXT "OpenGLView"
33 
34 
OpenGLView()35 OpenGLView::OpenGLView()
36 	:
37 	BGroupView("OpenGLView", B_VERTICAL)
38 {
39 
40 	BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0,
41 		BGL_RGB | BGL_DOUBLE);
42 	glView->Hide();
43 	AddChild(glView);
44 
45 	glView->LockGL();
46 
47 	float tabViewWidth = this->StringWidth("M") * 42;
48 	float tabViewHeight = this->StringWidth("M") * 16;
49 
50 	BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
51 	tabView->SetExplicitMinSize(BSize(tabViewWidth, tabViewHeight));
52 	tabView->AddTab(new CapabilitiesView());
53 	tabView->AddTab(new ExtensionsView());
54 
55 	GroupLayout()->SetSpacing(0);
56 	BLayoutBuilder::Group<>(this)
57 		.AddGroup(B_HORIZONTAL, 0)
58 			.Add(new GearsView())
59 			.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
60 				.SetInsets(0, B_USE_DEFAULT_SPACING,
61 					B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
62 				.Add(new InfoView())
63 				.Add(tabView)
64 				.End()
65 			.AddGlue()
66 			.End();
67 
68 	glView->UnlockGL();
69 }
70 
~OpenGLView()71 OpenGLView::~OpenGLView()
72 {
73 }
74