MCPcopy Create free account
hub / github.com/SpartanJ/eepp / NewModal

Method NewModal

src/eepp/ui/tools/uicolorpicker.cpp:89–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87)css";
88
89UIColorPicker* UIColorPicker::NewModal( Node* nodeCreator,
90 const UIColorPicker::ColorPickedCb& colorPickedCb,
91 const Uint8& modalAlpha, const Uint32& winFlags,
92 const Sizef& winSize ) {
93 UIColorPicker* colorPicker = NewWindow( colorPickedCb, winFlags, winSize, modalAlpha );
94 UIWindow* pickerWin = colorPicker->getUIWindow();
95 Sizef windowSize( pickerWin->getSceneNode()->getSize() );
96 Sizef nodeSize( nodeCreator->getSize() );
97 Vector2f nodePos( nodeCreator->getPosition() );
98 nodeCreator->getParent()->nodeToWorld( nodePos );
99 nodePos = PixelDensity::pxToDp( nodePos ).ceil();
100
101 if ( nodePos.y + nodeSize.getHeight() + winSize.getHeight() <= windowSize.getHeight() &&
102 nodePos.x + winSize.getWidth() <= windowSize.getWidth() ) {
103 pickerWin->setPosition( nodePos.x, nodePos.y + nodeSize.getHeight() );
104 } else if ( nodePos.y - winSize.getHeight() >= 0.f &&
105 nodePos.x + winSize.getWidth() <= windowSize.getWidth() ) {
106 pickerWin->setPosition( nodePos.x, nodePos.y - winSize.getHeight() );
107 } else if ( nodePos.y + nodeSize.getHeight() / 2 - winSize.getHeight() / 2 >= 0 &&
108 nodePos.y + nodeSize.getHeight() / 2 - winSize.getHeight() / 2 +
109 winSize.getHeight() <=
110 windowSize.getHeight() ) {
111 if ( nodePos.x - winSize.getWidth() >= 0 ) {
112 pickerWin->setPosition( nodePos.x - winSize.getWidth(), nodePos.y +
113 nodeSize.getHeight() / 2 -
114 winSize.getHeight() / 2 );
115 } else if ( nodePos.x + nodeSize.getWidth() + winSize.getWidth() <=
116 windowSize.getWidth() ) {
117 pickerWin->setPosition( nodePos.x + nodeSize.getWidth(), nodePos.y +
118 nodeSize.getHeight() / 2 -
119 winSize.getHeight() / 2 );
120 } else {
121 pickerWin->center();
122 }
123 } else {
124 pickerWin->center();
125 }
126
127 return colorPicker;
128}
129
130UIColorPicker* UIColorPicker::NewWindow( const ColorPickedCb& colorPickedCb, const Uint32& winFlags,
131 const Sizef& winSize, const Uint8& modalAlpha ) {

Callers

nothing calls this directly

Calls 11

getUIWindowMethod · 0.80
centerMethod · 0.80
getSizeMethod · 0.45
getSceneNodeMethod · 0.45
getPositionMethod · 0.45
nodeToWorldMethod · 0.45
getParentMethod · 0.45
ceilMethod · 0.45
getHeightMethod · 0.45
getWidthMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected