xref: /haiku/src/tests/kits/opengl/glinfo/OpenGLView.cpp (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
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 
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 	glView->UnlockGL();
56 
57 	GroupLayout()->SetSpacing(0);
58 	BLayoutBuilder::Group<>(this)
59 		.AddGroup(B_HORIZONTAL, 0)
60 			.Add(new GearsView())
61 			.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
62 				.SetInsets(0, B_USE_DEFAULT_SPACING,
63 					B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
64 				.Add(new InfoView())
65 				.Add(tabView)
66 				.End()
67 			.AddGlue()
68 			.End();
69 }
70 
71 OpenGLView::~OpenGLView()
72 {
73 }
74