Giter VIP home page Giter VIP logo

colorpickerui's Introduction

ColorPickerUI (Modified)

An ColorPicker for skin authors with a lot of options. Happy skinning!

2021-09-22_21-39-12.mp4

Changes from the original:

  • The color picker now shows the element's previous color on initialization.
  • A minor typo fix in functions.lua.

Usage Instructions:

Initialization

  • Creating a Measure:

    First in the config you want to use it create a script measure and include the ColorPickerUI.lua in the ColorPickerUI folder. So basically it should look like this:

    [ColorPicker]
    Measure=Script
    ScriptFile=#ROOTCONFIGPATH#ColorPickerUI\ColorPickerUI.lua
    ; The above file path should direct to where you have kept the folder.
  • Dependencies:

    Then include the SegoeIcons.ttf font file in @Resources\Fonts. You can find the file in resources folder of example skin or Fonts folder inside ColorPickerUI directory.

Options:

  • OnFinishAction:

    Bangs defined in this option are executed after user picks a color.

  • OnDismissAction:

    Bangs defined in this option are executed if the user chooses to dismiss the picker using dismiss button. Force unloading using skin context menu would not trigger this.

  • Theme:

    Which theme to use. In-built themes include Dark and Light. Follow tips and tricks in the end to know how to create and use new themes.

  • Animations:

    Whether to use initial animation.

Temporary Variables:

These variables would not persist after refresh or the addon config is used once again. These can be used in bangs defined in Actions defined inside the measure after color is chosen or addon is dismissed.

  • $color$:

    This is replaced by the last color choosen by an user. Not avaialable for OnDismissAction.

  • $option$:

    This option is replaced by the option, or variable name user chose to change.

  • $section$:

    This is replaced by the section where the option belongs to, "Variables" for a variable.

  • $filePath$:

    This is replaced by the file name where the color value is supposed to be written. Default value is the path to the current config's file path(#CURRENTPATH##CURRENTFILE#).

Custom Action:

This is an optional functionality, but very useful.

  • ColorChangeAction:

    Contrary to other options above in Options section, this option can be defined in any section, measure or meter. This action can be set when the function to activate the addon is called. The bangs defined in this option can also use temporary variables mentioned above. This action, if defined, will be executed before OnFinishAction.

Activation:

  • SetColor('option', 'section', 'format', 'fileName', 'actionSection'): This is the function which is to be called using "!CommandMeasure" to set a color. Argumaents described below:

    1. option:(required) The option which to change, variable_name for variables.
    2. section:(required) The section where the option is in. "Variables" for variables.
    3. format:(optional, default: rgb) In which format the color will be written. Available formats are:
      • rgb[a] - 255,255,255[,255]
      • hex[a] - FFFFFF[FF]
      • hsv[a]** - 0,0,1[,1]
      • hsl[a]** - 0,0,1[,1]
    • **Though available, not supported by Rainmeter. Using rgb, rgba, hex or hexa recommended.
    1. filePath:(optional, default: current filepath) The file where the section is in or where value is supposed to be written.
      • Important: You must use [[filePath]] to enclose file paths. For example [[#ROOTCONFIGPATH#Dependencies\Variables.inc]].
    2. actionSection:(optional, no default) The section where the ColorChangeAction is defined. The bangs will be executed after and only if a color is choosen, and before OnFinishAction.

    The arguments must be in order and optional arguments must not be skipped if the next argument is to be used. Only file name can be an empty string('') to use default value.

  • Example:

[SomeMeter]
SolidColor=0,0,0
LeftMouseUpAction=[!CommandMeasure ColorPicker "SetColor('SolidColor', 'SomeMeter')"]

; addon will write the value of SolidColor option under SomeMeter in rgb format.
[SomeOtherMeter]
FontColor=FEFEFEFF
LeftMouseUpAction=[!CommandMeasure ColorPicker "SetColor('FontColor', '#CURRENTSECTION#', 'hexa')"]

; addon will write the value of SolidColor option under SomeMeter in hexa format.
[AnotherMeter]
ImageTint="#ImageTint#"
LeftMouseUpAction=[!CommandMeasure ColorPicker "SetColor('ImageTint', 'Variables', 'rgba', [[#@#Variables.inc]])"]

; See that I enclosed #@#Variables.inc with `[[]]` and not `''`. It is important since lua considers `\` as escape sequence.
; addon will write the value of variable ImageTint in rgba format located in the file Variables.inc in @Resources
[FirstMeter]
FontColor=0,0,0,200
LeftMouseUpAction=[!CommandMeasure ColorPicker "SetColor('FontColor', 'FirstMeter', 'rgba', '', 'SecondMeter')"]
Group=Meters

[SecondMeter]
FontColor=0,0,0,200
ColorChangeAction=[!SetOptionGroup Meters $option$ "$color$"][!UpdateMeterGroup Meters][!Redraw][!WriteKeyValue SecondMeter $option$ "$color$"]
Group=Meters

; addon will first write the value of FontColor under FirstMeter.
; In the next step it will execute the bangs in the ColorChangeAction defined in 'SecondMeter' after replacing the temporary variables.
; Now it will SetOption and Redraw so you don't need to refresh. Then it will permanently write the value to "SecondMeter" too.
; Also notice that I used '' to skip the fileName parameter. This is only applicable in case of fileName.

Themes:

  • You can create a new inc file inside ColorPickerUI\Themes and name it what you want. Then copy the contents of existing themes and edit the color variables. In the measure, use Theme=your_theme_name.inc. That's all.

Tips and Tricks:

Using Windows theme to switch between Dark and Light theme:

[WindowTheme]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\Windows\CurrentVersion\Themes\Personalize
RegValue=AppsUseLightTheme
Substitute="1":"Light", "0":"Dark"

Credits:

  • JSMorely for CursorColor Plugin
  • NightHawkSLO for Mouse Plugin
  • Jax for the Preview

Bug Reports:

This being a new skin and a complex one, bugs might spring up. Please open an issue here and let me know. Thank you.๐Ÿ˜€

colorpickerui's People

Contributors

deathcrafter avatar undeadwanderer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.