This commit is contained in:
Mirco Wittrien 2020-05-22 19:39:31 +02:00
parent ede9931cd1
commit 835a846c53
3 changed files with 44 additions and 30 deletions

View File

@ -6234,7 +6234,9 @@
InternalComponents.NativeSubComponents.FavButton = BDFDB.ModuleUtils.findByName("GIFFavButton");
InternalComponents.NativeSubComponents.KeybindRecorder = BDFDB.ModuleUtils.findByName("KeybindRecorder");
InternalComponents.NativeSubComponents.MenuCheckboxItem = BDFDB.ModuleUtils.findByName("MenuCheckboxItem");
InternalComponents.NativeSubComponents.MenuControlItem = BDFDB.ModuleUtils.findByName("MenuControlItem");
InternalComponents.NativeSubComponents.MenuItem = BDFDB.ModuleUtils.findByName("MenuItem");
InternalComponents.NativeSubComponents.MenuSlider = BDFDB.ModuleUtils.findByString("minValue", "maxValue", "sliderContainer");
InternalComponents.NativeSubComponents.PopoutContainer = BDFDB.ModuleUtils.findByName("Popout");
InternalComponents.NativeSubComponents.QuickSelect = BDFDB.ModuleUtils.findByName("QuickSelectWrapper");
InternalComponents.NativeSubComponents.RadioGroup = BDFDB.ModuleUtils.findByName("RadioGroup");
@ -7522,13 +7524,29 @@
}
};
// REMOVE
InternalComponents.LibraryComponents.ContextMenuItems = {};
InternalComponents.LibraryComponents.ContextMenuItems.Group = InternalComponents.LibraryComponents.MenuItems.MenuGroup;
InternalComponents.LibraryComponents.ContextMenuItems.Item = InternalComponents.LibraryComponents.MenuItems.MenuItem;
InternalComponents.LibraryComponents.ContextMenuItems.Slider = InternalComponents.LibraryComponents.MenuItems.MenuControlItem;
InternalComponents.LibraryComponents.ContextMenuItems.Sub = InternalComponents.LibraryComponents.MenuItems.MenuSeparator;
InternalComponents.LibraryComponents.ContextMenuItems.Toggle = InternalComponents.LibraryComponents.MenuItems.MenuItem;
InternalComponents.LibraryComponents.MenuItems.MenuSliderItem = InternalBDFDB.loadPatchedComp("MenuItems.MenuSliderItem") || reactInitialized && class BDFDB_MenuSliderItem extends LibraryModules.React.Component {
handleChange(value) {
if (this.props.state) {
this.props.state.value = Math.round(BDFDB.NumberUtils.mapRange([0, 100], [this.props.minValue, this.props.maxValue], value) * Math.pow(10, this.props.digits)) / Math.pow(10, this.props.digits);
if (typeof this.props.onChange == "function") this.props.onChange(this.props.state.value, this);
}
BDFDB.ReactUtils.forceUpdate(this);
}
render() {
let value = this.props.state && this.props.state.value || 0;
return BDFDB.ReactUtils.createElement(InternalComponents.NativeSubComponents.MenuControlItem, BDFDB.ObjectUtils.exclude(Object.assign({}, this.props, {
label: typeof this.props.renderLabel == "function" ? this.props.renderLabel(Math.round(value * Math.pow(10, this.props.digits)) / Math.pow(10, this.props.digits)) : this.props.label,
control: (menuItemProps, ref) => {
return BDFDB.ReactUtils.createElement(InternalComponents.NativeSubComponents.MenuSlider, Object.assign({}, menuItemProps, {
ref: ref,
value: Math.round(BDFDB.NumberUtils.mapRange([this.props.minValue, this.props.maxValue], [0, 100], value) * Math.pow(10, this.props.digits)) / Math.pow(10, this.props.digits),
onChange: this.handleChange.bind(this)
}));
}
}), "digits", "renderLabel"));
}
};
InternalBDFDB.setDefaultProps(InternalComponents.LibraryComponents.MenuItems.MenuSliderItem, {minValue:0, maxValue:100, digits:0});
InternalComponents.LibraryComponents.MessageGroup = BDFDB.ModuleUtils.findByName("ChannelMessage");
@ -8086,20 +8104,20 @@
InternalComponents.LibraryComponents.Slider = InternalBDFDB.loadPatchedComp("Slider") || reactInitialized && class BDFDB_Slider extends LibraryModules.React.Component {
handleValueChange(value) {
let newvalue = BDFDB.ArrayUtils.is(this.props.edges) && this.props.edges.length == 2 ? BDFDB.NumberUtils.mapRange([0, 100], this.props.edges, value) : value;
if (typeof this.props.digits == "number") newvalue = Math.round(newvalue * Math.pow(10, this.props.digits)) / Math.pow(10, this.props.digits);
this.props.defaultValue = newvalue;
if (typeof this.props.onValueChange == "function") this.props.onValueChange(newvalue, this);
let newValue = BDFDB.ArrayUtils.is(this.props.edges) && this.props.edges.length == 2 ? BDFDB.NumberUtils.mapRange([0, 100], this.props.edges, value) : value;
if (typeof this.props.digits == "number") newValue = Math.round(newValue * Math.pow(10, this.props.digits)) / Math.pow(10, this.props.digits);
this.props.defaultValue = newValue;
if (typeof this.props.onValueChange == "function") this.props.onValueChange(newValue, this);
BDFDB.ReactUtils.forceUpdate(this);
}
handleValueRender(value) {
let newvalue = BDFDB.ArrayUtils.is(this.props.edges) && this.props.edges.length == 2 ? BDFDB.NumberUtils.mapRange([0, 100], this.props.edges, value) : value;
if (typeof this.props.digits == "number") newvalue = Math.round(newvalue * Math.pow(10, this.props.digits)) / Math.pow(10, this.props.digits);
let newValue = BDFDB.ArrayUtils.is(this.props.edges) && this.props.edges.length == 2 ? BDFDB.NumberUtils.mapRange([0, 100], this.props.edges, value) : value;
if (typeof this.props.digits == "number") newValue = Math.round(newValue * Math.pow(10, this.props.digits)) / Math.pow(10, this.props.digits);
if (typeof this.props.onValueRender == "function") {
let tempReturn = this.props.onValueRender(newvalue, this);
if (tempReturn != undefined) newvalue = tempReturn;
let tempReturn = this.props.onValueRender(newValue, this);
if (tempReturn != undefined) newValue = tempReturn;
}
return newvalue;
return newValue;
}
render() {
let defaultValue = BDFDB.ArrayUtils.is(this.props.edges) && this.props.edges.length == 2 ? BDFDB.NumberUtils.mapRange(this.props.edges, [0, 100], this.props.defaultValue) : this.props.defaultValue;

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ var ImageZoom = (_ => {
return class ImageZoom {
getName () {return "ImageZoom";}
getVersion () {return "1.1.2";}
getVersion () {return "1.1.3";}
getAuthor () {return "DevilBro";}
@ -12,7 +12,7 @@ var ImageZoom = (_ => {
constructor () {
this.changelog = {
"fixed":[["Styling && Functionality","Fixed the style for the new image modal layout"]]
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
};
this.patchedModules = {
@ -41,8 +41,8 @@ var ImageZoom = (_ => {
this.defaults = {
settings: {
zoomlevel: {value:2, digits:1, edges:[1, 10], unit:"x", label:"ACCESSIBILITY_ZOOM_LEVEL_LABEL"},
lensesize: {value:200, digits:0, edges:[50, 1000], unit:"px", label:"context_lensesize_text"}
zoomlevel: {value:2, digits:1, minValue: 1, maxValue: 10, unit:"x", label:"ACCESSIBILITY_ZOOM_LEVEL_LABEL"},
lensesize: {value:200, digits:0, minValue: 50, maxValue: 1000, unit:"px", label:"context_lensesize_text"}
}
};
}
@ -101,20 +101,16 @@ var ImageZoom = (_ => {
let openContext = event => {
let settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: Object.keys(settings).map(type => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuControlItem, {
defaultValue: settings[type],
digits: this.defaults.settings[type].digits,
edges: this.defaults.settings[type].edges,
children: Object.keys(settings).map(type => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuSliderItem, Object.assign({
id: BDFDB.ContextMenuUtils.createItemId(this.name, type),
value: settings[type],
renderLabel: value => {
return (this.labels[this.defaults.settings[type].label] || BDFDB.LanguageUtils.LanguageStrings[this.defaults.settings[type].label]) + ": " + value + this.defaults.settings[type].unit;
},
onValueRender: value => {
return value + this.defaults.settings[type].unit;
},
onValueChange: value => {
onChange: value => {
BDFDB.DataUtils.save(value, this, "settings", type);
}
}))
}, BDFDB.ObjectUtils.extract(this.defaults.settings[type], "digits", "minValue", "maxValue"))))
}));
};
children[index] = BDFDB.ReactUtils.createElement("span", {