Skip to content

Commit

Permalink
chore: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Nov 18, 2023
1 parent 7d82ba4 commit c1764b1
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions lib/Controls/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class ControlsController extends CoreBase {
}

if (type) {
this.createBankControl(location, type)
this.createButtonControl(location, type)
}
}
)
Expand Down Expand Up @@ -1485,7 +1485,7 @@ class ControlsController extends CoreBase {
* @returns {string | null} controlId
* @access public
*/
createBankControl(location, newType) {
createButtonControl(location, newType) {
if (!this.page.isPageValid(location.pageNumber)) return null

const controlId = CreateBankControlId(nanoid())
Expand Down
8 changes: 4 additions & 4 deletions lib/Data/ImportExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class DataImportExport extends CoreBase {
const oldControlId = this.page.getControlIdAt(location)
if (oldControlId) this.controls.deleteControl(oldControlId)

this.controls.createBankControl(location, definition.type)
this.controls.createButtonControl(location, definition.type)
}
}
}
Expand Down Expand Up @@ -708,7 +708,7 @@ class DataImportExport extends CoreBase {
this.page.resetPage(pageNumber)

for (const { type, location } of default_nav_buttons_definitions) {
this.controls.createBankControl(
this.controls.createButtonControl(
{
pageNumber,
...location,
Expand All @@ -730,7 +730,7 @@ class DataImportExport extends CoreBase {
(pageNumber) => {
// make magical page buttons!
for (const { type, location } of default_nav_buttons_definitions) {
this.controls.createBankControl(
this.controls.createButtonControl(
{
pageNumber,
...location,
Expand Down Expand Up @@ -987,7 +987,7 @@ class DataImportExport extends CoreBase {

if (!skipNavButtons) {
for (const { type, location } of default_nav_buttons_definitions) {
this.controls.createBankControl(
this.controls.createButtonControl(
{
pageNumber,
...location,
Expand Down
6 changes: 3 additions & 3 deletions lib/Graphics/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class GraphicsController extends CoreBase {
render = this.#renderLRUCache.get(key)

if (!render) {
const { buffer, width, height, dataUrl, draw_style } = await this.#pool.exec('drawBankImage', [
const { buffer, width, height, dataUrl, draw_style } = await this.#pool.exec('drawButtonImage', [
this.#drawOptions,
buttonStyle,
location,
Expand Down Expand Up @@ -178,7 +178,7 @@ class GraphicsController extends CoreBase {
this.emit('button_drawn', location, render)
}
} catch (e) {
this.logger.warn(`drawBankImage failed: ${e}`)
this.logger.warn(`drawButtonImage failed: ${e}`)
}
},
5
Expand Down Expand Up @@ -240,7 +240,7 @@ class GraphicsController extends CoreBase {
size: buttonStyle.size === 'auto' ? 'auto' : Number(buttonStyle.size),
}

const { buffer, width, height, dataUrl, draw_style } = await this.#pool.exec('drawBankImage', [
const { buffer, width, height, dataUrl, draw_style } = await this.#pool.exec('drawButtonImage', [
this.#drawOptions,
drawStyle,
])
Expand Down
6 changes: 3 additions & 3 deletions lib/Graphics/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ export default class GraphicsRenderer {
* @returns {Promise<{ buffer: Buffer, width: number, height: number, dataUrl: string, draw_style: import('../Data/Model/StyleModel.js').DrawStyleModel['style'] | undefined}>} Image render object
*/
static async drawButtonImageUnwrapped(options, drawStyle, location, pagename) {
// console.log('starting drawBankImage '+ performance.now())
// console.time('drawBankImage')
// console.log('starting drawButtonImage '+ performance.now())
// console.time('drawButtonImage')
const img = new Image(72, 72, 4)

/** @type {import('../Data/Model/StyleModel.js').DrawStyleModel['style'] | undefined} */
Expand Down Expand Up @@ -180,7 +180,7 @@ export default class GraphicsRenderer {
await GraphicsRenderer.#drawButtonMain(img, options, drawStyle, location)
}

// console.timeEnd('drawBankImage')
// console.timeEnd('drawButtonImage')
return {
buffer: img.buffer(),
width: img.realwidth,
Expand Down
2 changes: 1 addition & 1 deletion lib/Graphics/Thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ import GraphicsRenderer from './Renderer.js'
import workerPool from 'workerpool'

workerPool.worker({
drawBankImage: GraphicsRenderer.drawButtonImageUnwrapped,
drawButtonImage: GraphicsRenderer.drawButtonImageUnwrapped,
})
2 changes: 1 addition & 1 deletion webui/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@import 'scss/tablet';

@import 'scss/action-recorder';
@import 'scss/bank';
@import 'scss/button-control';
@import 'scss/button-edit';
@import 'scss/button-grid';
@import 'scss/controls';
Expand Down
2 changes: 1 addition & 1 deletion webui/src/Buttons/ActionRecorder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ function ButtonPicker({ selectButton }) {

<ButtonGridHeader pageNumber={pageNumber} changePage={changePage} setPage={setPageNumber} />
</div>
<div className="bankgrid" ref={isInViewRef}>
<div className="buttongrid" ref={isInViewRef}>
{hasBeenInView && (
<ButtonInfiniteGrid
ref={gridRef}
Expand Down
4 changes: 2 additions & 2 deletions webui/src/Components/ButtonPreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const RedImage =

export const ButtonPreview = React.memo(function (props) {
const classes = {
bank: true,
'button-control': true,
fixed: !!props.fixedSize,
drophere: props.canDrop,
drophover: props.dropHover,
Expand Down Expand Up @@ -45,7 +45,7 @@ export const ButtonPreview = React.memo(function (props) {
}}
>
<div
className="bank-border"
className="button-border"
ref={props.dragRef}
style={{
backgroundImage: props.preview ? `url(${props.preview})` : undefined,
Expand Down
2 changes: 1 addition & 1 deletion webui/src/Controls/ActionSetEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function ActionTableRow({
<div className="cell-description">{actionSpec?.description || ''}</div>

{location && showButtonPreview && (
<div className="cell-bank-preview">
<div className="cell-button-preview">
<OptionButtonPreview location={location} options={action.options} />
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion webui/src/Controls/FeedbackEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ function FeedbackEditor({
<div className="cell-description">{feedbackSpec?.description || ''}</div>

{location && showButtonPreview && (
<div className="cell-bank-preview">
<div className="cell-button-preview">
<OptionButtonPreview location={location} options={feedback.options} />
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions webui/src/Emulator/Emulator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ function CyclePages({ imageCache, setKeyDown, columns, rows }) {
)} */}
{/* </h1> */}
</div>
<div className="bankgrid">
<div className="buttongrid">
{' '}
{Array(rows)
.fill(0)
.map((_, y) => {
return (
<CCol key={y} sm={12} className="pagebank-row">
<CCol key={y} sm={12} className="buttongrid-row">
{Array(columns)
.fill(0)
.map((_2, x) => {
Expand Down
4 changes: 2 additions & 2 deletions webui/src/ImportExport/Import/Page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function ImportPageWizard({ snapshot, instanceRemap, setInstanceRemap, do
setPage={isSinglePage ? null : setImportPageNumber}
/>
</CCol>
<div className="bankgrid" ref={hasBeenRenderedRef}>
<div className="buttongrid" ref={hasBeenRenderedRef}>
{hasBeenRendered && (
<ButtonInfiniteGrid
ref={sourceGridRef}
Expand Down Expand Up @@ -118,7 +118,7 @@ export function ImportPageWizard({ snapshot, instanceRemap, setInstanceRemap, do

<ButtonGridHeader pageNumber={pageNumber} changePage={changePage} setPage={setPageNumber} />
</CCol>
<div className="bankgrid">
<div className="buttongrid">
{hasBeenRendered && (
<ButtonInfiniteGrid
ref={destinationGridRef}
Expand Down
2 changes: 1 addition & 1 deletion webui/src/TabletView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function TabletView() {

<div className="button-zone">
<CRow>
<CCol sm={12} className="pagebank-row">
<CCol sm={12} className="buttongrid-row">
<div ref={elementSizeRef} className="buttons-holder">
{validPages.map((number, i) => (
<MyErrorBoundary key={i}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.bank {
.button-control {
-webkit-touch-callout: none !important;
-webkit-user-select: none !important;
user-select: none !important;
Expand All @@ -13,12 +13,12 @@
cursor: pointer;
}

&.selected .bank-border {
&.selected .button-border {
border: 1px solid #d50215 !important;
box-shadow: 0px 0px 0px 1px #d50215 inset;
}

&.fixed .bank-border {
&.fixed .button-border {
width: 72px;
height: 72px;
}
Expand All @@ -37,7 +37,7 @@
// -webkit-user-drag: inherit;
// }

.bank-border {
.button-border {
position: relative;
object-fit: contain;
display: block;
Expand Down
4 changes: 2 additions & 2 deletions webui/src/scss/_button-edit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ table.feedback-table {
grid-column: 1;
}

.cell-bank-preview {
.cell-button-preview {
grid-row: 2 / 5;
grid-column: 2;

.bank {
.button-control {
padding: 0;
}
}
Expand Down
10 changes: 5 additions & 5 deletions webui/src/scss/_button-grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
color: black;
}

.bankgrid {
.buttongrid {
-webkit-touch-callout: none !important;
-webkit-user-select: none !important;
user-select: none !important;
Expand All @@ -26,11 +26,11 @@
grid-auto-flow: row;
grid-auto-rows: 1fr;

&.bank-armed .pagebank-row {
&.button-armed .buttongrid-row {
background-color: rgba(255, 0, 0, 0.5);
}

.pagebank-row {
.buttongrid-row {
display: grid;
grid-auto-flow: column;
grid-auto-columns: 1fr;
Expand Down Expand Up @@ -96,7 +96,7 @@
border-radius: 5px;
overflow: scroll;

&.bank-armed {
&.button-armed {
background-color: #7f1111;
}

Expand Down Expand Up @@ -171,7 +171,7 @@
}
}

.bank {
.button-control {
position: absolute;
float: left;
}
Expand Down
8 changes: 4 additions & 4 deletions webui/src/scss/_tablet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,26 @@

width: 100%;

.bank {
.button-control {
border: none;
position: absolute;
float: left;
}

.bank img {
.button-control img {
max-width: 150px;
max-height: 150px;
}

&.bank-armed .pagebank-row {
&.button-armed .buttongrid-row {
background-color: rgba(255, 0, 0, 0.5);
}

.buttons-holder {
position: relative;
}

.pagebank-row {
.buttongrid-row {
display: grid;
// grid-auto-flow: column;
grid-auto-columns: 1fr;
Expand Down

0 comments on commit c1764b1

Please sign in to comment.