Skip to content

Commit

Permalink
Turbobadger Widget updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JimMarlowe authored and JoshEngebretson committed Jun 27, 2017
1 parent f1fb3ae commit 3f922d8
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Script/Packages/Atomic/UI.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"UISkinImage", "UITabContainer", "UISceneView", "UIPreferredSize", "UIDragObject",
"UIContainer", "UISection", "UIInlineSelect", "UITextureWidget", "UIColorWidget", "UIColorWheel",
"UIScrollContainer", "UISeparator", "UIDimmer", "UISelectDropdown", "UISlider", "UIBargraph",
"UIPromptWindow", "UIFinderWindow", "UIPulldownMenu"],
"UIPromptWindow", "UIFinderWindow", "UIPulldownMenu", "UIRadioButton", "UIScrollBar"],
"overloads" : {
},
"typescript_decl" : {
Expand Down
30 changes: 24 additions & 6 deletions Source/Atomic/UI/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ using namespace tb;
#include "UIFinderWindow.h"
#include "UIPulldownMenu.h"
#include "UIComponent.h"
#include "UIRadioButton.h"
#include "UIScrollBar.h"

#include "SystemUI/SystemUI.h"
#include "SystemUI/SystemUIEvents.h"
Expand Down Expand Up @@ -150,12 +152,12 @@ UI::~UI()

TBFile::SetReaderFunction(0);
TBID::tbidRegisterCallback = 0;

tb::TBWidgetsAnimationManager::Shutdown();

delete rootWidget_;
widgetWrap_.Clear();

// leak
//delete TBUIRenderer::renderer_;

Expand Down Expand Up @@ -355,7 +357,7 @@ void UI::SetFocusedView(UIView* uiView)
while (itr != uiViews_.End())
{
if ((*itr)->GetAutoFocus())
{
{
SetFocusedView(*itr);
return;
}
Expand Down Expand Up @@ -476,7 +478,7 @@ void UI::HandleUpdate(StringHash eventType, VariantMap& eventData)
exitRequested_ = false;
return;
}

tooltipHoverTime_ += eventData[Update::P_TIMESTEP].GetFloat();

if (tooltipHoverTime_ >= 0.5f)
Expand Down Expand Up @@ -504,7 +506,7 @@ void UI::HandleUpdate(StringHash eventType, VariantMap& eventData)
tooltip_->Show(mousePosition.x_ + 8, mousePosition.y_ + 8);
}
}
else
else
{
if (tooltip_) tooltip_->Close();
}
Expand Down Expand Up @@ -619,6 +621,14 @@ UIWidget* UI::WrapWidget(tb::TBWidget* widget)
return slider;
}

if (widget->IsOfType<TBScrollBar>())
{
UIScrollBar* slider = new UIScrollBar(context_, false);
slider->SetWidget(widget);
WrapWidget(slider, widget);
return slider;
}

if (widget->IsOfType<TBColorWidget>())
{
UIColorWidget* colorWidget = new UIColorWidget(context_, false);
Expand Down Expand Up @@ -734,6 +744,14 @@ UIWidget* UI::WrapWidget(tb::TBWidget* widget)
return nwidget;
}

if (widget->IsOfType<TBRadioButton>())
{
UIRadioButton* nwidget = new UIRadioButton(context_, false);
nwidget->SetWidget(widget);
WrapWidget(nwidget, widget);
return nwidget;
}

if (widget->IsOfType<TBBarGraph>())
{
UIBargraph* nwidget = new UIBargraph(context_, false);
Expand All @@ -757,7 +775,7 @@ UIWidget* UI::WrapWidget(tb::TBWidget* widget)
WrapWidget(nwidget, widget);
return nwidget;
}

if (widget->IsOfType<TBPromptWindow>())
{
UIPromptWindow* nwidget = new UIPromptWindow(context_, NULL, "", false);
Expand Down
16 changes: 16 additions & 0 deletions Source/Atomic/UI/UIInlineSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ void UIInlineSelect::SetLimits(double minimum, double maximum)

}

// set the inc, dec step size
void UIInlineSelect::SetStepSize(double step)
{
if (!widget_)
return;
((TBInlineSelect*) widget_)->SetStepSize(step);
}

// get the inc, dec step size
double UIInlineSelect::GetStepSize()
{
if (!widget_)
return 0.0;
return ((TBInlineSelect*) widget_)->GetStepSize();
}

bool UIInlineSelect::OnEvent(const tb::TBWidgetEvent &ev)
{
if (ev.type == EVENT_TYPE_CUSTOM && ev.ref_id == TBIDC("edit_complete"))
Expand Down
4 changes: 4 additions & 0 deletions Source/Atomic/UI/UIInlineSelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class ATOMIC_API UIInlineSelect : public UIWidget

void SetLimits(double minimum, double maximum);

/// set and get the inc, dec step size
void SetStepSize(double step);
double GetStepSize();

void SetEditFieldLayoutParams(UILayoutParams* params);

protected:
Expand Down
56 changes: 56 additions & 0 deletions Source/Atomic/UI/UIRadioButton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#include <TurboBadger/tb_widgets.h>
#include <TurboBadger/tb_widgets_common.h>

#include <Atomic/IO/Log.h>

#include "UIEvents.h"
#include "UI.h"
#include "UIRadioButton.h"

using namespace tb;

namespace Atomic
{

UIRadioButton::UIRadioButton(Context* context, bool createWidget) : UIWidget(context, false)
{
if (createWidget)
{
widget_ = new TBRadioButton();
widget_->SetDelegate(this);
GetSubsystem<UI>()->WrapWidget(this, widget_);
}
}

UIRadioButton::~UIRadioButton()
{
}

bool UIRadioButton::OnEvent(const tb::TBWidgetEvent &ev)
{
return UIWidget::OnEvent(ev);
}

}
48 changes: 48 additions & 0 deletions Source/Atomic/UI/UIRadioButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#pragma once

#include "UIWidget.h"

namespace Atomic
{


class ATOMIC_API UIRadioButton : public UIWidget
{
ATOMIC_OBJECT(UIRadioButton, UIWidget)

public:

UIRadioButton(Context* context, bool createWidget = true);
virtual ~UIRadioButton();

protected:

virtual bool OnEvent(const tb::TBWidgetEvent &ev);

private:

};

}
101 changes: 101 additions & 0 deletions Source/Atomic/UI/UIScrollBar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//
// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#include <TurboBadger/tb_widgets.h>
#include <TurboBadger/tb_widgets_common.h>

#include <Atomic/IO/Log.h>

#include "UIEvents.h"
#include "UI.h"
#include "UILayout.h"
#include "UIScrollBar.h"

using namespace tb;

namespace Atomic
{

UIScrollBar::UIScrollBar(Context* context, bool createWidget) : UIWidget(context, false)
{
if (createWidget)
{
widget_ = new TBScrollBar();
widget_->SetDelegate(this);
GetSubsystem<UI>()->WrapWidget(this, widget_);
}
}

UIScrollBar::~UIScrollBar()
{

}

void UIScrollBar::SetLimits(double minimum, double maximum, double visible)
{
if (!widget_)
return;
((TBScrollBar*) widget_)->SetLimits(minimum, maximum, visible);

}

double UIScrollBar::GetMinValue() const
{
if (!widget_)
return 0.0;

return ((TBScrollBar*) widget_)->GetMinValue();

}

double UIScrollBar::GetMaxValue() const
{
if (!widget_)
return 0.0;

return ((TBScrollBar*) widget_)->GetMaxValue();

}

double UIScrollBar::GetVisible() const
{
if (!widget_)
return 0.0;

return ((TBScrollBar*) widget_)->GetVisible();

}

bool UIScrollBar::OnEvent(const tb::TBWidgetEvent &ev)
{
if (ev.type == EVENT_TYPE_CUSTOM && ev.ref_id == TBIDC("edit_complete"))
{
VariantMap eventData;
eventData[UIWidgetEditComplete::P_WIDGET] = this;
SendEvent(E_UIWIDGETEDITCOMPLETE, eventData);

return true;
}
return UIWidget::OnEvent(ev);
}

}
53 changes: 53 additions & 0 deletions Source/Atomic/UI/UIScrollBar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#pragma once

#include "UIWidget.h"

namespace Atomic
{


class ATOMIC_API UIScrollBar : public UIWidget
{
ATOMIC_OBJECT(UIScrollBar, UIWidget)

public:

UIScrollBar(Context* context, bool createWidget = true);
virtual ~UIScrollBar();

void SetLimits(double minimum, double maximum, double visible);
double GetMinValue() const;
double GetMaxValue() const;
double GetVisible() const;

protected:

virtual bool OnEvent(const tb::TBWidgetEvent &ev);

private:

};

}
Loading

0 comments on commit 3f922d8

Please sign in to comment.