<commit_before>"
Create a slider on a view. A callback may be set when it is moved

[ [ [ 
	| v label slider |
	v := RTView new.
	label := RTLabel elementOn: 0.
	v add: label.
	
	slider := RTSlider new.
	slider view: v.
	slider labelled.
	slider callback: [ :aValue | label model: aValue * 100. label updateShape ].
	slider moveBelow.
	slider build.
	
	v
 ] ] ]
"
Class {
	#name : #RTSlider,
	#superclass : #RTBuilder,
	#instVars : [
		'callback',
		'labelled',
		'position',
		'sliderElements',
		'min',
		'max',
		'useIntegerLabel',
		'value',
		'orientation',
		'size'
	],
	#category : #'Roassal2-Builder-UI-Slider'
}

{ #category : #public }
RTSlider >> build [
	| allElements res |
	allElements := view elements.
	res := super build.
	TRConstraint move: sliderElements to: position and: allElements.
	^ res
]

{ #category : #accessing }
RTSlider >> callback [
	^ callback
]

{ #category : #accessing }
RTSlider >> callback: aOneArgBlock [
	"At each movement of the slider, the argument aOneArgBlock will be evaluated. The bloc takes as argument a float value, ranging between 0.0 and 1.0"
	callback := aOneArgBlock
]

{ #category : #hooks }
RTSlider >> createShapeBuilder [
	"RTBox new color: (Color red alpha: 0.5); width: 15; height: 20"
	^ super createShapeBuilder
		rectangle;
		color: (Color red alpha: 0.5);
		width: 15;
		height: 20;
		yourself
]

{ #category : #examples }
RTSlider >> example01 [

	| v label slider |
	v := RTView new.
	label := RTLabel elementOn: 0.
	v add: label.
	slider := RTSlider new.
	slider view: v.
	slider labeled.
	slider callback: [ :aValue | label model: aValue * 100. label updateShape ].
	slider move: #above.
	slider build.
	
	v
	 
]

{ #category : #accessing }
RTSlider >> horizontal [
	orientation := #horizontal
]

{ #category : #initialization }
RTSlider >> initialize [
	super initialize.<commit_msg>Removed example, because they are already in the distribution.<commit_after>"
Create a slider on a view. A callback may be set when it is moved

[ [ [ 
	| v label slider |
	v := RTView new.
	label := RTLabel elementOn: 0.
	v add: label.
	
	slider := RTSlider new.
	slider view: v.
	slider labelled.
	slider callback: [ :aValue | label model: aValue * 100. label updateShape ].
	slider moveBelow.
	slider build.
	
	v
 ] ] ]
"
Class {
	#name : #RTSlider,
	#superclass : #RTBuilder,
	#instVars : [
		'callback',
		'labelled',
		'position',
		'sliderElements',
		'min',
		'max',
		'useIntegerLabel',
		'value',
		'orientation',
		'size'
	],
	#category : #'Roassal2-Builder-UI-Slider'
}

{ #category : #public }
RTSlider >> build [
	| allElements res |
	allElements := view elements.
	res := super build.
	TRConstraint move: sliderElements to: position and: allElements.
	^ res
]

{ #category : #accessing }
RTSlider >> callback [
	^ callback
]

{ #category : #accessing }
RTSlider >> callback: aOneArgBlock [
	"At each movement of the slider, the argument aOneArgBlock will be evaluated. The bloc takes as argument a float value, ranging between 0.0 and 1.0"
	callback := aOneArgBlock
]

{ #category : #hooks }
RTSlider >> createShapeBuilder [
	"RTBox new color: (Color red alpha: 0.5); width: 15; height: 20"
	^ super createShapeBuilder
		rectangle;
		color: (Color red alpha: 0.5);
		width: 15;
		height: 20;
		yourself
]

{ #category : #accessing }
RTSlider >> horizontal [
	orientation := #horizontal
]

{ #category : #initialization }
RTSlider >> initialize [
	super initialize.
{'fraction_non_alphanumeric': 0.1262390670553936, 'fraction_numerical': 0.013994169096209912, 'mean_word_length': 3.5930388219544844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7034262', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1173, 'n_words': 379}