forked from organicmaps/organicmaps
Fixed country status GUI
This commit is contained in:
parent
6fb8494c4c
commit
c5e72ee989
5 changed files with 31 additions and 20 deletions
|
@ -74,9 +74,12 @@ uint32_t BuildCorner(vector<Button::ButtonVertex> & vertices,
|
|||
|
||||
}
|
||||
|
||||
ButtonHandle::ButtonHandle(dp::Anchor anchor, m2::PointF const & size)
|
||||
ButtonHandle::ButtonHandle(dp::Anchor anchor, m2::PointF const & size,
|
||||
dp::Color const & color, dp::Color const & pressedColor)
|
||||
: TBase(anchor, m2::PointF::Zero(), size)
|
||||
, m_isInPressedState(false)
|
||||
, m_color(color)
|
||||
, m_pressedColor(pressedColor)
|
||||
{}
|
||||
|
||||
void ButtonHandle::OnTapBegin()
|
||||
|
@ -91,8 +94,7 @@ void ButtonHandle::OnTapEnd()
|
|||
|
||||
bool ButtonHandle::Update(ScreenBase const & screen)
|
||||
{
|
||||
glsl::vec4 color = glsl::ToVec4(m_isInPressedState ? dp::Color(0x0, 0x0, 0x0, 0xCC) :
|
||||
dp::Color(0x0, 0x0, 0x0, 0x99));
|
||||
glsl::vec4 color = glsl::ToVec4(m_isInPressedState ? m_pressedColor : m_color);
|
||||
m_uniforms.SetFloatValue("u_color", color.r, color.g, color.b, color.a);
|
||||
return TBase::Update(screen);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ class ButtonHandle : public TappableHandle
|
|||
typedef TappableHandle TBase;
|
||||
|
||||
public:
|
||||
ButtonHandle(dp::Anchor anchor, m2::PointF const & size);
|
||||
ButtonHandle(dp::Anchor anchor, m2::PointF const & size,
|
||||
dp::Color const & color, dp::Color const & pressedColor);
|
||||
|
||||
void OnTapBegin() override;
|
||||
void OnTapEnd() override;
|
||||
|
@ -21,6 +22,8 @@ public:
|
|||
|
||||
private:
|
||||
bool m_isInPressedState;
|
||||
dp::Color m_color;
|
||||
dp::Color m_pressedColor;
|
||||
};
|
||||
|
||||
class Button
|
||||
|
@ -54,6 +57,7 @@ public:
|
|||
float m_maxWidth = 0.0f;
|
||||
float m_margin = 0.0f;
|
||||
float m_facet = 0.0f;
|
||||
|
||||
THandleCreator m_bodyHandleCreator;
|
||||
THandleCreator m_labelHandleCreator;
|
||||
};
|
||||
|
|
|
@ -23,8 +23,9 @@ class CountryStatusButtonHandle : public ButtonHandle
|
|||
public:
|
||||
CountryStatusButtonHandle(CountryStatusHelper::ECountryState const state,
|
||||
Shape::TTapHandler const & tapHandler,
|
||||
dp::Anchor anchor, m2::PointF const & size)
|
||||
: TBase(anchor, size)
|
||||
dp::Anchor anchor, m2::PointF const & size,
|
||||
dp::Color const & color, dp::Color const & pressedColor)
|
||||
: TBase(anchor, size, color, pressedColor)
|
||||
, m_state(state)
|
||||
, m_tapHandler(tapHandler)
|
||||
{}
|
||||
|
@ -92,9 +93,10 @@ private:
|
|||
|
||||
drape_ptr<dp::OverlayHandle> CreateButtonHandle(CountryStatusHelper::ECountryState const state,
|
||||
Shape::TTapHandler const & tapHandler,
|
||||
dp::Color const & color, dp::Color const & pressedColor,
|
||||
dp::Anchor anchor, m2::PointF const & size)
|
||||
{
|
||||
return make_unique_dp<CountryStatusButtonHandle>(state, tapHandler, anchor, size);
|
||||
return make_unique_dp<CountryStatusButtonHandle>(state, tapHandler, anchor, size, color, pressedColor);
|
||||
}
|
||||
|
||||
drape_ptr<dp::OverlayHandle> CreateLabelHandle(CountryStatusHelper::ECountryState const state,
|
||||
|
@ -166,24 +168,30 @@ drape_ptr<ShapeRenderer> CountryStatus::Draw(ref_ptr<dp::TextureManager> tex,
|
|||
{
|
||||
case CountryStatusHelper::CONTROL_TYPE_BUTTON:
|
||||
{
|
||||
TButtonHandlers::const_iterator buttonHandlerIt = buttonHandlers.find(control.m_buttonType);
|
||||
Shape::TTapHandler buttonHandler = (buttonHandlerIt != buttonHandlers.end() ? buttonHandlerIt->second : nullptr);
|
||||
Button::THandleCreator buttonHandleCreator = bind(&CreateButtonHandle, state, buttonHandler, _1, _2);
|
||||
Button::THandleCreator labelHandleCreator = bind(&CreateLabelHandle, state, _1, _2);
|
||||
|
||||
float visualScale = df::VisualParams::Instance().GetVisualScale();
|
||||
float const visualScale = df::VisualParams::Instance().GetVisualScale();
|
||||
|
||||
ShapeControl shapeControl;
|
||||
Button::Params params;
|
||||
params.m_anchor = m_position.m_anchor;
|
||||
params.m_label = control.m_label;
|
||||
params.m_labelFont = dp::FontDecl(dp::Color::White(), 16);
|
||||
params.m_minWidth = 300;
|
||||
params.m_minWidth = 400;
|
||||
params.m_maxWidth = 600;
|
||||
params.m_margin = 5.0f * visualScale;
|
||||
params.m_facet = 8.0f * visualScale;
|
||||
params.m_bodyHandleCreator = buttonHandleCreator;
|
||||
params.m_labelHandleCreator = labelHandleCreator;
|
||||
|
||||
dp::Color color = dp::Color(0, 0, 0, 0.44 * 255);
|
||||
dp::Color pressedColor = dp::Color(0, 0, 0, 0.72 * 255);
|
||||
if (control.m_buttonType == CountryStatusHelper::BUTTON_TYPE_MAP_ROUTING)
|
||||
{
|
||||
color = dp::Color(32, 152, 82, 255);
|
||||
pressedColor = dp::Color(24, 128, 68, 255);
|
||||
}
|
||||
|
||||
TButtonHandlers::const_iterator buttonHandlerIt = buttonHandlers.find(control.m_buttonType);
|
||||
Shape::TTapHandler buttonHandler = (buttonHandlerIt != buttonHandlers.end() ? buttonHandlerIt->second : nullptr);
|
||||
params.m_bodyHandleCreator = bind(&CreateButtonHandle, state, buttonHandler, color, pressedColor, _1, _2);
|
||||
params.m_labelHandleCreator = bind(&CreateLabelHandle, state, _1, _2);
|
||||
|
||||
Button::Draw(params, shapeControl, tex);
|
||||
renderer->AddShapeControl(move(shapeControl));
|
||||
|
|
|
@ -134,7 +134,7 @@ CountryStatusHelper::Control const & CountryStatusHelper::GetControl(size_t inde
|
|||
|
||||
float CountryStatusHelper::GetControlMargin()
|
||||
{
|
||||
return 5.0f * df::VisualParams::Instance().GetVisualScale();
|
||||
return 20.0f * df::VisualParams::Instance().GetVisualScale();
|
||||
}
|
||||
|
||||
void CountryStatusHelper::GetProgressInfo(string & alphabet, size_t & maxLength)
|
||||
|
|
|
@ -150,10 +150,7 @@ ref_ptr<Handle> ShapeRenderer::ProcessTapEvent(m2::RectD const & touchArea)
|
|||
ForEachShapeInfo([&resultHandle, &touchArea](ShapeControl::ShapeInfo & shapeInfo)
|
||||
{
|
||||
if (shapeInfo.m_handle->IsTapped(touchArea))
|
||||
{
|
||||
ASSERT(resultHandle == nullptr, ("Overlays cannot be intersected"));
|
||||
resultHandle = make_ref(shapeInfo.m_handle);
|
||||
}
|
||||
});
|
||||
|
||||
return resultHandle;
|
||||
|
|
Loading…
Add table
Reference in a new issue