//============================================================================ // NUnicodeParser::GetChar : Get a character. //---------------------------------------------------------------------------- utf32_t NUnicodeParser::GetChar(NIndex theIndex, bool toLower) const { NStringEncoder theEncoder; NRange theRange; const uint8_t *srcPtr; utf32_t theChar; // Validate our parameters NN_ASSERT(theIndex >= 0 && theIndex < GetSize()); // Get the state we need theRange = GetRange(theIndex); srcPtr = mData.GetData(theRange.GetLocation()); // Convert the character theChar = theEncoder.ConvertToUTF32(mEncoding, theRange.GetSize(), srcPtr); NN_ASSERT(theChar != 0); if (toLower) theChar = GetLower(theChar); return(theChar); }
const sf::FloatRect Scale::GetSliderRect() const { auto slider_length = Context::Get().GetEngine().GetProperty<float>( "SliderLength", shared_from_this() ); auto slider_width = (GetOrientation() == Orientation::HORIZONTAL) ? GetAllocation().height : GetAllocation().width; auto adjustment = GetAdjustment(); auto current_value = adjustment->GetValue(); auto value_range = adjustment->GetUpper() - adjustment->GetLower() - adjustment->GetPageSize(); if( GetOrientation() == Orientation::HORIZONTAL ) { auto slider_x = (GetAllocation().width - slider_length) * (current_value - adjustment->GetLower()) / value_range; auto slider_y = (GetAllocation().height - slider_width) / 2.f; return sf::FloatRect( slider_x, slider_y, slider_length, slider_width ); } auto slider_x = (GetAllocation().width - slider_width) / 2.f; auto slider_y = (GetAllocation().height - slider_length) * (1 - ((current_value - adjustment->GetLower()) / value_range)); return sf::FloatRect( slider_x, slider_y, slider_width, slider_length ); }