43 typedef typename CC::ATOM_TYPE T;
56 SLIDER_WIDTH_BIG = 300,
57 SLIDER_HEIGHT_BIG = 64,
59 SLIDER_HALF_HEIGHT = (SLIDER_HEIGHT / 2),
60 SLIDER_HALF_HEIGHT_BIG = (SLIDER_HEIGHT_BIG / 2)
69 inline u32 GetSliderWidth()
const
74 inline u32 GetSliderHeight()
const
79 inline u32 GetSliderHalfHeight()
const
84 inline FontAsset GetRenderFont()
const
87 FONT_ASSET_HELPPANEL_SMALL;
92 Panel::SetDimensions(GetSliderWidth() * 2, GetSliderHeight());
93 Panel::SetDesiredSize(10000, GetSliderHeight());
101 MFM_API_ASSERT_NONNULL(this->m_parameter);
102 MFM_API_ASSERT_NONNULL(this->m_patom);
103 return this->m_parameter->GetBitsAsS32(*this->m_patom);
106 void SetValue(s32 val)
108 MFM_API_ASSERT_NONNULL(this->m_parameter);
109 MFM_API_ASSERT_NONNULL(this->m_patom);
110 return this->m_parameter->SetBitsAsS32(*this->m_patom, val);
115 if (!parameter && !patom)
117 this->m_parameter = NULL;
118 this->m_patom = NULL;
122 if (!parameter || !patom)
124 FAIL(ILLEGAL_ARGUMENT);
127 this->m_parameter = parameter;
128 this->m_patom = patom;
136 if(event.m_event.button.type == SDL_MOUSEBUTTONDOWN)
138 if(event.m_event.button.button == SDL_BUTTON_LEFT)
142 if(this->m_parameter)
145 m_dragStartX =
event.GetAt().GetX();
146 m_preDragVal = GetValue();
163 if(m_dragging && this->m_parameter)
165 s32 delta =
event.m_event.motion.x - m_dragStartX;
166 s32 valDelta = delta * ((double)this->m_parameter->GetMax() / GetSliderWidth());
175 if (this->m_parameter)
177 SetValue(m_preDragVal + valDelta);
190 if (!this->m_parameter)
197 d.
SetFont(AssetManager::Get(GetRenderFont()));
199 d.
DrawHLine(16, 7, GetSliderWidth() - 7);
202 d.
DrawVLine(GetSliderWidth() - 7, 16, 20);
205 numBuffer.Printf(
"%d", this->m_parameter->GetMin());
211 numBuffer.Printf(
"%d", this->m_parameter->GetMax());
213 UPoint(GetSliderWidth() - 32, GetSliderHalfHeight()),
214 UPoint(48, GetSliderHalfHeight()));
217 this->m_parameter->PrintValue(numBuffer, *this->m_patom);
222 UPoint(GetSliderWidth() / 2 - 16, GetSliderHalfHeight()),
223 UPoint(48, GetSliderHalfHeight()));
225 Rect sliderRect = GetSliderRect();
231 UPoint(GetSliderWidth(), 7),
232 UPoint(GetSliderWidth(), GetSliderHalfHeight()));
237 inline Rect GetSliderRect()
const
240 if (this->m_parameter)
242 s32 val = GetValue();
243 xpos = this->m_parameter->MapValue((GetSliderWidth() - 7), val) - 7;
245 return Rect(xpos > 0 ? xpos : 0, 0, 17, GetSliderHalfHeight());
const SPoint & GetPosition() const
Definition: Rect.h:137
void BlitAsset(Asset asset, UPoint loc, UPoint maxSize) const
Definition: Drawing.cpp:167
virtual void PaintBorder(Drawing &d)
Definition: Slider.h:131
u32 SetForeground(const u32 color)
Definition: Drawing.h:188
virtual bool Handle(MouseButtonEvent &event)
Definition: Slider.h:134
Definition: ParameterController.h:40
virtual void PaintComponent(Drawing &d)
Definition: Slider.h:188
SPoint GetAbsoluteLocation()
Definition: Panel.cpp:173
void BlitBackedText(const char *message, UPoint loc, UPoint size)
Definition: Drawing.cpp:233
const UPoint & GetSize() const
Definition: Rect.h:199
void Reset()
Definition: CharBufferByteSink.h:144
u32 SetBackground(const u32 color)
Definition: Drawing.h:170
virtual void OnMouseExit()
Definition: Slider.h:183
void DrawHLine(int y, int startX, int endX) const
Definition: Drawing.cpp:96
Definition: CharBufferByteSink.h:44
void DrawVLine(int x, int startY, int endY) const
Definition: Drawing.cpp:101
Definition: Parameter.h:51
const char * GetZString()
Definition: CharBufferByteSink.h:112
virtual bool Handle(MouseMotionEvent &event)
Definition: Slider.h:161
TTF_Font * SetFont(TTF_Font *newFont)
Definition: Drawing.h:209
void BlitText(const char *message, UPoint loc, UPoint size) const
Definition: Drawing.cpp:172