Hidden windows?

This commit is contained in:
Jordan Eldredge 2018-07-08 21:56:09 -07:00
parent 0e8d264efe
commit b0b9ddd441
6 changed files with 49 additions and 5 deletions

View file

@ -5,6 +5,7 @@ export {
toggleEqualizerShadeMode,
togglePlaylistShadeMode,
closeWindow,
hideWindow,
setWindowSize,
toggleWindow,
updateWindowPositions,

View file

@ -11,7 +11,8 @@ import {
WINDOW_SIZE_CHANGED,
TOGGLE_WINDOW,
CLOSE_WINDOW,
TOGGLE_WINDOW_SHADE_MODE
TOGGLE_WINDOW_SHADE_MODE,
HIDE_WINDOW
} from "../actionTypes";
import { getPositionDiff } from "../resizeUtils";
@ -82,6 +83,9 @@ export function closeWindow(windowId) {
return { type: CLOSE_WINDOW, windowId };
}
export function hideWindow(windowId) {
return { type: HIDE_WINDOW, windowId };
}
export function setWindowSize(windowId, size) {
return { type: WINDOW_SIZE_CHANGED, windowId, size };
}

View file

@ -1,7 +1,9 @@
import React from "react";
import { connect } from "react-redux";
import screenfull from "screenfull";
import ContextMenuWrapper from "../ContextMenuWrapper";
import GenWindow from "../GenWindow";
import { hideWindow } from "../../actionCreators";
import MilkdropContextMenu from "./MilkdropContextMenu";
import Desktop from "./Desktop";
@ -14,7 +16,7 @@ import "../../../css/milkdrop-window.css";
// This component is just responsible for loading dependencies.
// This simplifies the inner <Milkdrop /> component, by allowing
// it to alwasy assume that it has its dependencies.
export default class PresetsLoader extends React.Component {
class PresetsLoader extends React.Component {
constructor() {
super();
this.state = {
@ -28,6 +30,10 @@ export default class PresetsLoader extends React.Component {
this._enableDesktop = this._enableDesktop.bind(this);
}
isHidden() {
return this.state.desktop;
}
async componentDidMount() {
const {
butterchurn,
@ -55,6 +61,7 @@ export default class PresetsLoader extends React.Component {
}
_enableDesktop() {
this.props.hideWindow(this.props.windowId);
this.setState({ desktop: true });
}
@ -159,3 +166,13 @@ async function loadNonMinimalPresets() {
);
});
}
const mapStateToProps = () => ({});
const mapDispatchProps = {
hideWindow
};
export default connect(
mapStateToProps,
mapDispatchProps
)(PresetsLoader);

View file

@ -11,7 +11,7 @@ import {
applyDiff,
applyMultipleDiffs
} from "../snapUtils";
import { getWindowsInfo } from "../selectors";
import { getWindowsInfo, getWindowHidden } from "../selectors";
import { updateWindowPositions } from "../actionCreators";
import { WINDOW_HEIGHT, WINDOW_WIDTH } from "../constants";
import { calculateBoundingBox } from "../utils";
@ -84,7 +84,8 @@ class WindowManager extends React.Component {
movingAndStationaryNodes(key) {
const windows = this.props.windowsInfo.filter(
w => this.props.windows[w.key] != null
w =>
this.props.windows[w.key] != null && !this.props.getWindowHidden(w.key)
);
const targetNode = windows.find(node => node.key === key);
@ -214,7 +215,8 @@ WindowManager.propTypes = {
};
const mapStateToProps = state => ({
windowsInfo: getWindowsInfo(state)
windowsInfo: getWindowsInfo(state),
getWindowHidden: getWindowHidden(state)
});
const mapDispatchToProps = {

View file

@ -3,6 +3,7 @@ import {
SET_FOCUSED_WINDOW,
TOGGLE_WINDOW,
CLOSE_WINDOW,
HIDE_WINDOW,
ADD_GEN_WINDOW,
UPDATE_WINDOW_POSITIONS,
WINDOW_SIZE_CHANGED,
@ -17,6 +18,7 @@ const defaultWindowsState = {
title: "Main Window",
size: [0, 0],
open: true,
hidden: false,
shade: false,
canResize: false,
canShade: true,
@ -28,6 +30,7 @@ const defaultWindowsState = {
title: "Equalizer",
size: [0, 0],
open: true,
hidden: false,
shade: false,
canResize: false,
canShade: true,
@ -39,6 +42,7 @@ const defaultWindowsState = {
title: "Playlist Editor",
size: [0, 0],
open: true,
hidden: false,
shade: false,
canResize: true,
canShade: true,
@ -94,6 +98,17 @@ const windows = (state = defaultWindowsState, action) => {
}
}
};
case HIDE_WINDOW:
return {
...state,
genWindows: {
...state.genWindows,
[action.windowId]: {
...state.genWindows[action.windowId],
hidden: true
}
}
};
case ADD_GEN_WINDOW:
return {
...state,
@ -102,6 +117,7 @@ const windows = (state = defaultWindowsState, action) => {
[action.windowId]: {
title: action.title,
open: true,
hidden: false,
size: [0, 0],
canShade: false,
canResize: true,

View file

@ -279,6 +279,10 @@ export function getWindowShade(state, windowId) {
return state.windows.genWindows[windowId].shade;
}
export function getWindowHidden(state) {
return windowId => state.windows.genWindows[windowId].hidden;
}
export const getGenWindows = state => {
return state.windows.genWindows;
};