Skip to content

Commit

Permalink
Add ability to disable fullscreen titlebar control
Browse files Browse the repository at this point in the history
  • Loading branch information
davej committed Jul 8, 2018
1 parent 298e6b7 commit be2e87d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/mac-os/title-bar.md
Expand Up @@ -15,7 +15,8 @@ title | string | Sets the title of the title bar.
transparent | bool | Make the title bar background transparent.
disableClose | bool | Disable the close button.
disableMinimize | bool | Disable the minimize button.
disableReize | bool | Disable the resize button.
disableResize | bool | Disable the resize button.
disableFullscreen | bool | Disable fullscreen, will show the '+' maximize icon instead.

### Examples

Expand Down
8 changes: 5 additions & 3 deletions src/TitleBar/macOs/Controls/Resize.js
Expand Up @@ -10,7 +10,8 @@ class Resize extends Component {
static propTypes = {
isFullscreen: PropTypes.bool,
showIcon: PropTypes.bool,
disabled: PropTypes.bool
disabled: PropTypes.bool,
disableFullscreen: PropTypes.bool,
};

componentDidMount() {
Expand All @@ -34,6 +35,7 @@ class Resize extends Component {
isWindowFocused,
showIcon,
disabled,
disableFullscreen,
...props
} = this.props;

Expand All @@ -53,7 +55,7 @@ class Resize extends Component {
}

let icon;
if (this.props.isFullscreen) {
if (this.props.isFullscreen && !disableFullscreen) {
icon = window && window.devicePixelRatio > 1.5 ? (
<svg x="0px" y="0px" width="10px" height="10px" viewBox="0 0 20 20" style={iconStyle}>
<path fill="#006400" d="M8.7,10H1l9,8.8v-7.5C9.3,11.2,8.7,10.7,8.7,10z"/>
Expand All @@ -65,7 +67,7 @@ class Resize extends Component {
<path fill="#006400" d="M5,0c0,0 0,2.744 0,4.167c0,0.221 0.088,0.433 0.244,0.589c0.156,0.156 0.368,0.244 0.589,0.244c1.423,0 4.167,0 4.167,0l-5,-5Z" />
</svg>
);
} else if (this.state.altKey) {
} else if (this.state.altKey || disableFullscreen) {
onClick = onMaximizeClick;
icon = window && window.devicePixelRatio > 1.5 ? (
<svg x="0px" y="0px" width="10px" height="10px" viewBox="0 0 20 20" style={iconStyle}>
Expand Down
4 changes: 3 additions & 1 deletion src/TitleBar/macOs/Controls/index.js
Expand Up @@ -28,7 +28,8 @@ class Controls extends Component {
onResizeClick: PropTypes.func,
disableClose: PropTypes.bool,
disableMinimize: PropTypes.bool,
disableResize: PropTypes.bool
disableResize: PropTypes.bool,
disableFullscreen: PropTypes.bool
};

constructor() {
Expand Down Expand Up @@ -61,6 +62,7 @@ class Controls extends Component {
onMaximizeClick={this.props.onMaximizeClick}
showIcon={this.state.isOver}
disabled={this.props.disableResize}
disableFullscreen={this.props.disableFullscreen}
/>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/TitleBar/macOs/index.js
Expand Up @@ -21,7 +21,8 @@ class TitleBar extends Component {
onResizeClick: PropTypes.func,
disableClose: PropTypes.bool,
disableMinimize: PropTypes.bool,
disableResize: PropTypes.bool
disableResize: PropTypes.bool,
disableFullscreen: PropTypes.bool
};

static childContextTypes = {
Expand Down

0 comments on commit be2e87d

Please sign in to comment.