MCPcopy Create free account
hub / github.com/MyGUI/mygui / updateFromPoint

Method updateFromPoint

Tools/EditorFramework/ColourPanel.cpp:145–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143 }
144
145 void ColourPanel::updateFromPoint(const MyGUI::IntPoint& _point)
146 {
147 // get colour by cursor position Altren 09.2008
148 float x = 1.0f * _point.left / mColourRect->getWidth();
149 float y = 1.0f * _point.top / mColourRect->getHeight();
150
151 if (x > 1)
152 x = 1;
153 else if (x < 0)
154 x = 0;
155
156 if (y > 1)
157 y = 1;
158 else if (y < 0)
159 y = 0;
160
161 mCurrentColour.red = (1 - y) * (mBaseColour.red * x + MyGUI::Colour::White.red * (1 - x));
162 mCurrentColour.green = (1 - y) * (mBaseColour.green * x + MyGUI::Colour::White.green * (1 - x));
163 mCurrentColour.blue = (1 - y) * (mBaseColour.blue * x + MyGUI::Colour::White.blue * (1 - x));
164
165 mColourView->setColour(mCurrentColour);
166 mAlphaSliderBack->setColour(mCurrentColour);
167
168 eventPreviewColour(mCurrentColour);
169
170 mEditRed->setCaption(MyGUI::utility::toString(static_cast<int>(mCurrentColour.red * 255)));
171 mEditGreen->setCaption(MyGUI::utility::toString(static_cast<int>(mCurrentColour.green * 255)));
172 mEditBlue->setCaption(MyGUI::utility::toString(static_cast<int>(mCurrentColour.blue * 255)));
173 }
174
175 void ColourPanel::notifyScrollChangePosition(MyGUI::ScrollBar* _sender, size_t _position)
176 {

Callers

nothing calls this directly

Calls 5

toStringFunction · 0.85
getWidthMethod · 0.45
getHeightMethod · 0.45
setColourMethod · 0.45
setCaptionMethod · 0.45

Tested by

no test coverage detected