SaturationBrightnessSquare

Package: Libraries.Interface.Controls · Inherits from: Libraries.Interface.Item, Libraries.Interface.Controls.Control, Libraries.Interface.Events.SliderListener, Libraries.Interface.Item2D, Libraries.Language.Object

A SaturationBrightnessSquare chooses the saturation and brightness of a color whose hue is set by a program, usually a HueRing around it. Across the square, from left to right, the color goes from gray to the purest color of the hue; from bottom to top it goes from black to full brightness. A marker shows the chosen spot. It takes the focus as one control. Left and Right change the saturation, Up and Down the brightness, one percent at a time, or a tenth of a percent with Shift. A click or a drag sets both from the place of the pointer. Inside, it holds two Sliders, "Saturation" and "Brightness", from 0 to 100 percent. They are see-through and not in the Tab order, but screen readers can find and adjust each one, since no platform has a role for a control with two values. Each says its value with the resulting color, such as "20 percent, dim gray". The square itself is a group, and its description says both values and the color, such as "Saturation 20 percent, brightness 43 percent, #4A5A6E, dim gray". Listeners added to either slider (GetSaturationSlider, GetBrightnessSlider) are told of the user's changes, whether they come from the keys, the pointer or a screen reader.

Example Code

use Libraries.Game.Game
use Libraries.Interface.Controls.SaturationBrightnessSquare

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        SaturationBrightnessSquare square
        square:SetHue(213)
        square:SetSaturationAndBrightness(33, 43)
        Add(square)
    end
end

Actions

DecreaseBrightness(boolean fine)

This action lowers the brightness, as Down does: one percent, or a tenth of a percent when fine.

Parameters

  • fine boolean: True for a tenth of a step, as with Shift.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:DecreaseBrightness(false)

DecreaseSaturation(boolean fine)

This action lowers the saturation, as Left does: one percent, or a tenth of a percent when fine.

Parameters

  • fine boolean: True for a tenth of a step, as with Shift.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:DecreaseSaturation(false)

GainedFocus(Libraries.Interface.Events.FocusEvent event)

This action is called when the square gains the focus: its edge and marker show the focus.

Parameters

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
use Libraries.Interface.Events.FocusEvent
SaturationBrightnessSquare square
FocusEvent event
square:GainedFocus(event)

GetActiveDescendant()

This action returns the slider screen readers are pointed at while the square has the focus: the one the keys, the pointer or a screen reader last changed. Left and Right change the saturation, and Up and Down the brightness; before any change, it is the saturation. Its value says the percent and the color, such as "20 percent, dim gray".

Returns

Libraries.Interface.Item: The saturation or brightness slider.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
use Libraries.Interface.Item
SaturationBrightnessSquare square
Item active = square:GetActiveDescendant()

GetBrightness()

This action returns the brightness, in percent.

Returns

number: The brightness, from 0 to 100.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
number brightness = square:GetBrightness()

GetBrightnessSlider()

This action returns the hidden slider for the brightness, which screen readers adjust. Listeners added to it are told of every change the user makes to the brightness.

Returns

Libraries.Interface.Controls.Slider: The brightness slider.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
use Libraries.Interface.Controls.Slider
SaturationBrightnessSquare square
Slider brightness = square:GetBrightnessSlider()

GetColor()

This action returns the color at the chosen spot, from the hue, the saturation and the brightness, fully opaque.

Returns

Libraries.Game.Graphics.Color: The color.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
use Libraries.Game.Graphics.Color
SaturationBrightnessSquare square
Color color = square:GetColor()

GetHue()

This action returns the hue the square shows, in degrees.

Returns

number: The hue, from 0 to 360.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
number hue = square:GetHue()

GetSaturation()

This action returns the saturation, in percent.

Returns

number: The saturation, from 0 to 100.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
number saturation = square:GetSaturation()

GetSaturationSlider()

This action returns the hidden slider for the saturation, which screen readers adjust. Listeners added to it are told of every change the user makes to the saturation.

Returns

Libraries.Interface.Controls.Slider: The saturation slider.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
use Libraries.Interface.Controls.Slider
SaturationBrightnessSquare square
Slider saturation = square:GetSaturationSlider()

IncreaseBrightness(boolean fine)

This action raises the brightness, as Up does: one percent, or a tenth of a percent when fine.

Parameters

  • fine boolean: True for a tenth of a step, as with Shift.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:IncreaseBrightness(false)

IncreaseSaturation(boolean fine)

This action raises the saturation, as Right does: one percent, or a tenth of a percent when fine.

Parameters

  • fine boolean: True for a tenth of a step, as with Shift.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:IncreaseSaturation(false)

IsAccessibleParent()

This action tells accessibility tools, such as screen readers, that the square holds its two sliders, so each can be found and adjusted inside it.

Returns

boolean: true, because the square contains its sliders for accessibility.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
boolean holds = square:IsAccessibleParent()

LoadGraphics(Libraries.Interface.Layouts.LayoutProperties properties)

This action loads the views of the square's layers and its marker the first time, then sets their colors. The square itself draws nothing, so its own theme colors never cover the layers. The game engine calls this as needed, so most users won't need to call it directly.

Parameters

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:LoadGraphics(square:GetDefaultLayoutProperties())

LostFocus(Libraries.Interface.Events.FocusEvent event)

This action is called when the square loses the focus: its edge and marker go back to their usual look.

Parameters

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
use Libraries.Interface.Events.FocusEvent
SaturationBrightnessSquare square
FocusEvent event
square:LostFocus(event)

MovePointerTo(number x, number y)

This action sets the saturation and brightness from a place on the screen, as a click or a drag does: the saturation from how far across the square it is, and the brightness from how far up. The square takes the focus, and listeners are told.

Parameters

  • x number: Where the pointer is, across the screen.
  • y number: Where the pointer is, up the screen.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:MovePointerTo(40, 60)

SetHue(number newHue)

This action sets the hue the square shows, in degrees, as a program does: the colors and the words change, but listeners aren't told.

Parameters

  • newHue number: The hue, from 0 to 360.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:SetHue(120)

SetSaturationAndBrightness(number saturation, number brightness)

This action sets the saturation and brightness, in percent, as a program does: the marker and the words change, and screen readers are told, but listeners aren't.

Parameters

  • saturation number: The saturation, from 0 to 100.
  • brightness number: The brightness, from 0 to 100.

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
SaturationBrightnessSquare square
square:SetSaturationAndBrightness(33, 43)

SliderChanged(Libraries.Interface.Events.SliderChangedEvent event)

This action is called when either slider's value is changed by the user, with a key, the pointer or a screen reader: the marker moves and the words are updated.

Parameters

Example

use Libraries.Interface.Controls.SaturationBrightnessSquare
use Libraries.Interface.Events.SliderChangedEvent
SaturationBrightnessSquare square
SliderChangedEvent event
event:SetSlider(square:GetSaturationSlider())
square:SliderChanged(event)

Inherited Actions

261 actions from Libraries.Interface.Controls.Control
59 actions from Libraries.Interface.Item
202 actions from Libraries.Interface.Item2D
3 actions from Libraries.Language.Object