Skip to content

Commit 26edcb0

Browse files
authored
Merge pull request aframevr#173 from fernandojsg/transformsToolbar
Add transforms toolbar and make panel titles much smaller
2 parents 6be5f52 + a60ceaf commit 26edcb0

File tree

6 files changed

+163
-64
lines changed

6 files changed

+163
-64
lines changed

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"babel-plugin-transform-class-properties": "^6.10.2",
2525
"babel-preset-es2015": "^6.9.0",
2626
"babel-preset-react": "^6.5.0",
27+
"classnames": "^2.2.5",
2728
"css-loader": "^0.23.1",
2829
"eslint": "^2.9.x",
2930
"eslint-config-standard": "^5.3.1",

‎src/components/Main.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import AttributesSidebar from './attributes/AttributesSidebar';
77
import {MenuWidget} from './menu/Menu';
88
import ModalTextures from './modals/ModalTextures';
99
import SceneGraph from './SceneGraph';
10+
import ToolBar from './ToolBar';
1011

1112
import "../css/main.css";
1213
import "../css/dark.css";
@@ -76,9 +77,10 @@ export default class Main extends React.Component {
7677
<div>
7778
<div id="editor" className={this.state.editorEnabled ? '' : 'hidden'}>
7879
<ModalTextures ref="modaltextures" isOpen={textureDialogOpened} onClose={this.onModalTextureOnClose}/>
80+
<ToolBar/>
7981
<MenuWidget/>
8082
<div id="sidebar-left">
81-
<div className="tab">SCENEGRAPH</div>
83+
<div className="sidebar-title">scenegraph</div>
8284
<SceneGraph scene={scene}/>
8385
</div>
8486
<AttributesSidebar/>

‎src/components/ToolBar.js‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
var React = require('react');
2+
var Events = require('../lib/Events.js');
3+
var classNames = require('classnames');
4+
5+
var TransformButtons = [
6+
{value: 'translate', icon: 'fa-arrows'},
7+
{value: 'rotate', icon: 'fa-repeat'},
8+
{value: 'scale', icon: 'fa-expand'}
9+
];
10+
11+
export default class ToolBar extends React.Component {
12+
constructor (props) {
13+
super(props);
14+
this.state = {selectedTransform: 'translate', localSpace: false};
15+
}
16+
17+
changeTransformMode = mode => {
18+
this.setState({selectedTransform: mode});
19+
Events.emit('transformModeChanged', mode);
20+
}
21+
22+
onLocalChange = e => {
23+
var local = e.target.checked;
24+
this.setState({localSpace: local});
25+
Events.emit('spaceChanged', local ? 'local' : 'world');
26+
}
27+
28+
renderTransformButtons = () => {
29+
return TransformButtons.map(function (option) {
30+
var selected = option.value === this.state.selectedTransform;
31+
var classes = classNames({
32+
button: true,
33+
fa: true,
34+
[option.icon]: true,
35+
active: selected
36+
});
37+
38+
return <a href='#' title={option.value}
39+
onClick={this.changeTransformMode.bind(this, option.value)}
40+
className={classes}></a>;
41+
}.bind(this));
42+
}
43+
44+
render () {
45+
return (
46+
<div className='toolbar'>
47+
{this.renderTransformButtons()}
48+
<span className='local-transform'>
49+
<input id='local' type='checkbox'
50+
checked={this.state.localSpace || this.state.selectedTransform === 'scale'}
51+
disabled={this.state.selectedTransform === 'scale'}
52+
onChange={this.onLocalChange}/>
53+
<label htmlFor='local'>local</label>
54+
</span>
55+
</div>
56+
);
57+
}
58+
}

‎src/components/attributes/AttributesSidebar.js‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ export default class AttributesSidebar extends React.Component {
1515
render() {
1616
return (
1717
<div id="sidebar">
18-
<div className="tab collapsible">
19-
<span>ATTRIBUTES</span>
20-
<div className="dropdown menu hide">
21-
<div className="dropdown-content">
22-
<a href="#" onClick={this.deleteComponent}>Collapse all</a>
23-
</div>
24-
</div>
25-
</div>
18+
<div className="sidebar-title">attributes</div>
2619
<AttributesPanel/>
2720
</div>
2821
);

‎src/css/dark.css‎

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -235,29 +235,6 @@ input.number:focus {
235235
background-color: #111;
236236
}
237237

238-
#toolbar {
239-
position: absolute;
240-
left: 0;
241-
right: 330px;
242-
bottom: 0;
243-
height: 32px;
244-
background-color: #111;
245-
color: #333;
246-
}
247-
248-
#toolbar * {
249-
vertical-align: middle;
250-
}
251-
252-
#toolbar .Panel {
253-
padding: 4px;
254-
color: #888;
255-
}
256-
257-
#toolbar button {
258-
margin-right: 6px;
259-
}
260-
261238
.aframe-logo {
262239
background-color: #424242;
263240
margin-right: 10px;
@@ -768,6 +745,58 @@ code, pre {
768745
font-weight: 500;
769746
}
770747

748+
.sidebar-title {
749+
color: #1faaf2;
750+
text-align: center;
751+
background-color: #323232;
752+
padding: 2px;
753+
border-top: 2px solid #1faaf2;
754+
font-size: 10px;
755+
}
756+
757+
.toolbar {
758+
position: absolute;
759+
right: 330px;
760+
top: 34px;
761+
height: 32px;
762+
background-color: #262626;
763+
color: #333;
764+
}
765+
766+
.toolbar * {
767+
vertical-align: middle;
768+
padding: 8px;
769+
margin-left: 0px;
770+
/*margin-top: 7px;*/
771+
}
772+
773+
774+
.toolbar a.button {
775+
margin: 0 6px 0 0;
776+
}
777+
778+
.toolbar .active {
779+
background-color: #1faaf2;
780+
color: #fff;
781+
}
782+
783+
.toolbar .active:hover {
784+
color: #fff !important;
785+
}
786+
787+
.local-transform {
788+
padding-left: 10px;
789+
}
790+
791+
.local-transform label {
792+
color: #AAA;
793+
padding-left: 5px;
794+
}
795+
796+
.local-transform a.button {
797+
padding-top: 0px;
798+
}
799+
771800
.outliner {
772801
color: #868686;
773802
background: #2b2b2b;

0 commit comments

Comments
 (0)