RETextField::RETextField() : RELabel(), REMainLoopUpdatable(), _cursorView(NULL), _cursorBlinkTime(0.6), _lastBlinkTime(0.0), _maximumInputedTextLength(0), _isHasMaximumInputedTextLength(false), _isClearPreviousTextInputText(false), _isShowCursor(false), _isActualShowCursor(false) { REView * cursorView = REView::create(); if (cursorView) { if (this->addSubview(cursorView)) { _cursorView = cursorView; _cursorView->setColor(REColor(0.0f, 0.0f, 0.0f, 1.0f)); } else { REObject::deleteObject(cursorView); } } RETextInputRespondersManager * m = RETextInputRespondersManager::getDefaultManager(); if (m) { m->registerResponder(this); } this->setShowCursor(true); this->setRespondsForUserAction(true); }
void RESlurManipulator::Draw(REPainter& painter) const { REHandle* start = _handles.find("start")->second; REHandle* start_cp = _handles.find("start_cp")->second; REHandle* end_cp = _handles.find("end_cp")->second; REHandle* end = _handles.find("end")->second; REHandle* start_anchor = _handles.find("start_anchor")->second; REHandle* end_anchor = _handles.find("end_anchor")->second; REPoint p_start = PointFromSceneToLocal(start->ScenePosition()); REPoint p_start_cp = PointFromSceneToLocal(start_cp->ScenePosition()); REPoint p_end_cp = PointFromSceneToLocal(end_cp->ScenePosition()); REPoint p_end = PointFromSceneToLocal(end->ScenePosition()); REPoint p_start_anchor = PointFromSceneToLocal(start_anchor->ScenePosition()); REPoint p_end_anchor = PointFromSceneToLocal(end_anchor->ScenePosition()); // Anchor Points if(_focusedHandle) { painter.SetStrokeColor(REColor::Red); REReal lengths[] = {1.0f, 1.0f}; painter.SetLineDash(lengths, 2, 0.0); painter.StrokeLine(p_start_anchor, p_start); painter.StrokeLine(p_end_anchor, p_end); } // Gray borders { painter.SetStrokeColor(REColor::LightGray); REReal lengths[] = {2.0f, 1.0f}; painter.SetLineDash(lengths, 2, 0.0); REBezierPath p; p.MoveToPoint(p_start); p.LineToPoint(p_start_cp); p.LineToPoint(p_end_cp); p.LineToPoint(p_end); p.LineToPoint(p_start); painter.StrokePath(p); painter.SetLineDash(NULL, 0, 0.0f); painter.SetStrokeColor(REColor::DarkGray); } // Draw Handles for(auto h : _handles) { REHandle* handle = h.second; if(!handle->IsDraggable()) continue; RERect rc = handle->SceneFrame(); rc = RectFromSceneToLocal(rc); rc.origin.x += 0.5; rc.origin.y += 0.5; rc.size.w -= 1.0; rc.size.h -= 1.0; painter.StrokeRect(rc); } // Draw Slur { REPoint deltaThickness = REPoint(0, 5.0f); REBezierPath slurPath; slurPath.MoveToPoint(p_start); slurPath.CurveToPoint(p_end, p_start_cp, p_end_cp); slurPath.CurveToPoint(p_start, p_end_cp + deltaThickness, p_start_cp + deltaThickness); slurPath.Close(); if(_focusedHandle) { painter.SetFillColor(REColor(0.20, 0.25, 0.85)); } else { painter.SetFillColor(REColor::Black); } painter.FillPath(slurPath); } }