| 14 | |
| 15 | template<typename E> |
| 16 | SEditResult<E> CEditor::DoPropertiesWithState(CUIRect *pToolBox, CProperty *pProps, int *pIds, int *pNewVal, const std::vector<ColorRGBA> &vColors) |
| 17 | { |
| 18 | int Change = -1; |
| 19 | EEditState State = EEditState::NONE; |
| 20 | |
| 21 | for(int i = 0; pProps[i].m_pName; i++) |
| 22 | { |
| 23 | const ColorRGBA *pColor = i >= (int)vColors.size() ? &ms_DefaultPropColor : &vColors[i]; |
| 24 | |
| 25 | CUIRect Slot; |
| 26 | pToolBox->HSplitTop(13.0f, &Slot, pToolBox); |
| 27 | CUIRect Label, Shifter; |
| 28 | Slot.VSplitMid(&Label, &Shifter); |
| 29 | Shifter.HMargin(1.0f, &Shifter); |
| 30 | Ui()->DoLabel(&Label, pProps[i].m_pName, 10.0f, TEXTALIGN_ML); |
| 31 | |
| 32 | if(pProps[i].m_Type == PROPTYPE_INT) |
| 33 | { |
| 34 | CUIRect Inc, Dec; |
| 35 | |
| 36 | Shifter.VSplitRight(10.0f, &Shifter, &Inc); |
| 37 | Shifter.VSplitLeft(10.0f, &Dec, &Shifter); |
| 38 | auto NewValueRes = UiDoValueSelector((char *)&pIds[i], &Shifter, "", pProps[i].m_Value, pProps[i].m_Min, pProps[i].m_Max, 1, 1.0f, "Use left mouse button to drag and change the value. Hold shift to be more precise. Right click to edit as text.", false, false, 0, pColor); |
| 39 | if(NewValueRes.m_Value != pProps[i].m_Value || (NewValueRes.m_State != EEditState::NONE && NewValueRes.m_State != EEditState::EDITING)) |
| 40 | { |
| 41 | *pNewVal = NewValueRes.m_Value; |
| 42 | if(NewValueRes.m_State != EEditState::NONE) |
| 43 | { |
| 44 | Change = i; |
| 45 | } |
| 46 | State = NewValueRes.m_State; |
| 47 | } |
| 48 | if(DoButton_FontIcon((char *)&pIds[i] + 1, FontIcon::MINUS, 0, &Dec, BUTTONFLAG_LEFT, "Decrease value.", IGraphics::CORNER_L, 7.0f)) |
| 49 | { |
| 50 | *pNewVal = std::clamp(pProps[i].m_Value - 1, pProps[i].m_Min, pProps[i].m_Max); |
| 51 | Change = i; |
| 52 | State = EEditState::ONE_GO; |
| 53 | } |
| 54 | if(DoButton_FontIcon(((char *)&pIds[i]) + 2, FontIcon::PLUS, 0, &Inc, BUTTONFLAG_LEFT, "Increase value.", IGraphics::CORNER_R, 7.0f)) |
| 55 | { |
| 56 | *pNewVal = std::clamp(pProps[i].m_Value + 1, pProps[i].m_Min, pProps[i].m_Max); |
| 57 | Change = i; |
| 58 | State = EEditState::ONE_GO; |
| 59 | } |
| 60 | } |
| 61 | else if(pProps[i].m_Type == PROPTYPE_BOOL) |
| 62 | { |
| 63 | CUIRect No, Yes; |
| 64 | Shifter.VSplitMid(&No, &Yes); |
| 65 | if(DoButton_Ex(&pIds[i], "No", !pProps[i].m_Value, &No, BUTTONFLAG_LEFT, nullptr, IGraphics::CORNER_L)) |
| 66 | { |
| 67 | *pNewVal = 0; |
| 68 | Change = i; |
| 69 | State = EEditState::ONE_GO; |
| 70 | } |
| 71 | if(DoButton_Ex(((char *)&pIds[i]) + 1, "Yes", pProps[i].m_Value, &Yes, BUTTONFLAG_LEFT, nullptr, IGraphics::CORNER_R)) |
| 72 | { |
| 73 | *pNewVal = 1; |
nothing calls this directly
no test coverage detected