Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: use buttons for commands with a fixed set of values #790

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/components/DDCCISliders.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,26 @@ export default function DDCCISliders(props) {
// Default
icon = (<span className="icon vfix">&#xe897;</span>)
}
extraHTML.push(
<div className="feature-row feature-volume" key={monitor.key + "_" + vcp}>
<div className="feature-icon">{ icon }</div>
<Slider type="custom" monitorID={monitor.id} level={values[vcp]} monitorName={monitor.name} monitortype={monitor.type} onChange={val => { setValues({ [vcp]: val }); setVCP(monitor.id, parseInt(vcp), val * (monitor.features[vcp][1] / 100)) }} />
</div>
)
if(Array.isArray(settings?.fixedValues) && settings?.fixedValues.length > 0)
{
extraHTML.push(
<div className="feature-row" key={monitor.key + "_" + vcp}>
<div className="feature-icon">{ icon }</div>
<div className="icons-row">
{settings.fixedValues.map((value) => {
return (<button className="icon-option" data-active={feature[0] == value} onClick={() => { setValues({ [vcp]: value }); setVCP(monitor.id, parseInt(vcp), value) }} key={monitor.key + "_" + vcp + "_" + value}>{value}</button>)
})}
</div>
</div>
)
} else {
extraHTML.push(
<div className="feature-row feature-volume" key={monitor.key + "_" + vcp}>
<div className="feature-icon">{ icon }</div>
<Slider type="custom" monitorID={monitor.id} level={values[vcp]} monitorName={monitor.name} monitortype={monitor.type} onChange={val => { setValues({ [vcp]: val }); setVCP(monitor.id, parseInt(vcp), val * (monitor.features[vcp][1] / 100)) }} />
</div>
)
}
}
}

Expand Down
65 changes: 40 additions & 25 deletions src/components/MonitorFeatures.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ export default function MonitorFeatures(props) {
const enabled = monitorFeatures?.[vcp];
const name = (settings?.iconType === "text" && settings?.iconText?.length ? settings.iconText : "Custom Feature")
const icon = (settings?.iconType === "windows" && settings?.icon ? settings.icon : "E9E9")
const fixedValues = monitor?.vcpCodes ? monitor.vcpCodes[vcp] : [];
extraHTML.push(
<SettingsOption className="monitor-feature-item" key={vcp} icon={icon} title={`${name} (${vcp})`} expandable={true} input={
<div className="input-row"><div style={{cursor: "pointer"}} onClick={() => deleteFeature(vcp)}>{deleteIcon}</div><div className="inputToggle-generic"><input onChange={() => {props?.toggleFeature(monitor.hwid[1], vcp)}} checked={(enabled ? true : false)} data-checked={(enabled ? true : false)} type="checkbox" /></div></div>
}>
<SettingsChild>
<MonitorFeaturesSettings onChange={onChange} key={vcp + "_settings"} enabled={enabled} settings={settings} hwid={monitor?.hwid?.[1]} vcp={vcp} />
<MonitorFeaturesSettings onChange={onChange} key={vcp + "_settings"} enabled={enabled} settings={settings} hwid={monitor?.hwid?.[1]} vcp={vcp} fixedValues={fixedValues} />
</SettingsChild>
</SettingsOption>
)
Expand Down Expand Up @@ -136,7 +137,7 @@ export default function MonitorFeatures(props) {
}

function MonitorFeaturesSettings(props) {
const { enabled, settings, hwid, vcp, onChange } = props
const { enabled, settings, hwid, vcp, fixedValues, onChange } = props
//if(!enabled) return (<></>);

const [settingsObj, updateSettings] = useObject(Object.assign({
Expand All @@ -147,7 +148,8 @@ function MonitorFeaturesSettings(props) {
min: 0,
max: 100,
maxVisual: 100,
linked: false
linked: false,
fixedValues: fixedValues
}, settings))

const onChangeHandler = (settingName, value) => {
Expand All @@ -166,9 +168,11 @@ function MonitorFeaturesSettings(props) {
}
}

const labelPrefix = (fixedValues && fixedValues.length > 0) ? "" : "Slider";

const iconType = (
<div className="field">
<label>Slider Indicator Type</label>
<label>{labelPrefix} Indicator Type</label>
<select value={settingsObj.iconType} onChange={e => onChangeHandler("iconType", e.target.value)} style={{flex: "0.65"}}>
<option value="windows">Icon</option>
<option value="text">Text</option>
Expand All @@ -178,7 +182,7 @@ function MonitorFeaturesSettings(props) {

const icon = (
<div className="field">
<label>Slider Icon</label>
<label>{labelPrefix} Icon</label>
<select style={{fontFamily: `"Segoe Fluent Icons", "Segoe MDL2 Assets"`}} value={settingsObj.icon} onChange={e => onChangeHandler("icon", e.target.value)}>
<WindowsIconsOptions />
</select>
Expand All @@ -187,7 +191,7 @@ function MonitorFeaturesSettings(props) {

const iconText = (
<div className="field">
<label>Slider Text</label>
<label>{labelPrefix} Text</label>
<input type="text" value={settingsObj.iconText} onChange={e => onChangeHandler("iconText", e.target.value)} placeholder={"Enter name for slider"} />
</div>
)
Expand All @@ -200,25 +204,36 @@ function MonitorFeaturesSettings(props) {
</div>
)

return(
<div className="feature-toggle-settings">
{ ignoreCodes.indexOf(vcp) === -1 ? iconSettings : null }
<div className="input-row">
<Slider min={0} max={100} name={"Min"} onChange={value => onChangeHandler("min", value)} level={settingsObj.min} scrolling={false} height={"short"} icon={false} />
<Slider min={0} max={100} name={"Max"} onChange={value => onChangeHandler("max", value)} level={settingsObj.max} scrolling={false} height={"short"} icon={false} />
</div>
<div className="input-row">
<div className="feature-toggle-row">
<input onChange={e => onChangeHandler("linked", e.target.checked)} checked={(settingsObj.linked ? true : false)} data-checked={(settingsObj.linked ? true : false)} type="checkbox" />
<div className="feature-toggle-label"><span>Linked to brightness</span></div>
</div>
</div>
<div style={{display: (settingsObj.linked ? "block" : "none")}}>
<br />
<Slider min={0} max={100} name={"Stop after this brightness level"} onChange={value => onChangeHandler("maxVisual", value)} level={settingsObj.maxVisual ?? 100} scrolling={false} height={"short"} icon={false} />
</div>
</div>
)
if (fixedValues && fixedValues.length > 0)
{
return(
<div className="feature-toggle-settings">
{ ignoreCodes.indexOf(vcp) === -1 ? iconSettings : null }
</div>
)
}
else
{
return(
<div className="feature-toggle-settings">
{ ignoreCodes.indexOf(vcp) === -1 ? iconSettings : null }
<div className="input-row">
<Slider min={0} max={100} name={"Min"} onChange={value => onChangeHandler("min", value)} level={settingsObj.min} scrolling={false} height={"short"} icon={false} />
<Slider min={0} max={100} name={"Max"} onChange={value => onChangeHandler("max", value)} level={settingsObj.max} scrolling={false} height={"short"} icon={false} />
</div>
<div className="input-row">
<div className="feature-toggle-row">
<input onChange={e => onChangeHandler("linked", e.target.checked)} checked={(settingsObj.linked ? true : false)} data-checked={(settingsObj.linked ? true : false)} type="checkbox" />
<div className="feature-toggle-label"><span>Linked to brightness</span></div>
</div>
</div>
<div style={{display: (settingsObj.linked ? "block" : "none")}}>
<br />
<Slider min={0} max={100} name={"Stop after this brightness level"} onChange={value => onChangeHandler("maxVisual", value)} level={settingsObj.maxVisual ?? 100} scrolling={false} height={"short"} icon={false} />
</div>
</div>
)
}
}

const windowsIcons = [
Expand Down
8 changes: 7 additions & 1 deletion src/css/panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,13 @@ body[data-is-win11="false"] #root {
font-family: "Segoe MDL2 Assets", "Segoe Fluent Icons"; // Old icon works better at small sizes
}
}

.icon-option[data-active=true] {
background: var(--system-accent-medium);
border-color: var(--system-accent-medium-dark);
background-color: var(--system-accent-dark1);
border-color: var(--system-accent-light2);
color: var(--system-accent-light2);
}

.monitor-sliders.extended {
& + .monitor-sliders.extended {
Expand Down
3 changes: 2 additions & 1 deletion src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ function processSettings(newSettings = {}, sendUpdate = true) {
min: 0,
max: 100,
maxVisual: 100,
linked: false
linked: false,
fixedValues: []
}
}
}
Expand Down
Loading