Class: PMXLBrightnessSlider

Inherits:
UISlider
  • Object
show all
Defined in:
lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#color_pickerObject

Returns the value of attribute color_picker.



128
129
130
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 128

def color_picker
  @color_picker
end

Instance Method Details

#drawRect(rect) ⇒ Object



159
160
161
162
163
164
165
166
167
168
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 159

def drawRect(rect)
  ctx = UIGraphicsGetCurrentContext()

  space = CGColorSpaceCreateDeviceGray()
  colors = [UIColor.blackColor, UIColor.whiteColor]

  gradient = CGGradientCreateWithColors(space, colors, nil)

  CGContextDrawLinearGradient(ctx, gradient, CGPointZero, [rect.size.width, 0], 0)
end

#init_routineObject



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 142

def init_routine
  self.minimumValue = 0.0
  self.maximumValue = 1.0
  self.continuous = true

  self.enabled = true
  self.userInteractionEnabled = true

  self.addTarget(self,
                action: 'slider_value_changed:',
                forControlEvents: UIControlEventValueChanged)
end

#initWithCoder(decoder) ⇒ Object



136
137
138
139
140
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 136

def initWithCoder(decoder)
  super.tap do
    init_routine
  end
end

#initWithFrame(frame) ⇒ Object



130
131
132
133
134
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 130

def initWithFrame(frame)
  super.tap do
    init_routine
  end
end

#slider_value_changed(_) ⇒ Object



155
156
157
# File 'lib/ProMotion/XLForm/cells/xl_form_color_selector_cell.rb', line 155

def slider_value_changed(_)
  color_picker.setBrightness(self.value)
end