Skip to content

Commit

Permalink
Add createSlider to UI module
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtcoolguy committed Jan 16, 2015
1 parent 8a23a35 commit c2d0788
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Source/TitaniumKit/include/Titanium/ApplicationBuilder.hpp
Expand Up @@ -43,6 +43,9 @@ namespace Titanium
JSObject LabelObject() const TITANIUM_NOEXCEPT;
ApplicationBuilder& LabelObject(const JSObject&) TITANIUM_NOEXCEPT;

JSObject SliderObject() const TITANIUM_NOEXCEPT;
ApplicationBuilder& SliderObject(const JSObject&) TITANIUM_NOEXCEPT;

JSObject ScrollViewObject() const TITANIUM_NOEXCEPT;
ApplicationBuilder& ScrollViewObject(const JSObject&) TITANIUM_NOEXCEPT;

Expand Down Expand Up @@ -88,6 +91,7 @@ namespace Titanium
JSObject button__;
JSObject imageview__;
JSObject label__;
JSObject slider__;
JSObject scrollview__;
JSObject platform__;
JSObject accelerometer__;
Expand All @@ -98,6 +102,6 @@ namespace Titanium
#pragma warning(pop)
};

} // namespace Titanium {
} // namespace Titanium

#endif // _TITANIUM_APPLICATIONBUILDER_HPP_
5 changes: 4 additions & 1 deletion Source/TitaniumKit/include/Titanium/UIModule.hpp
Expand Up @@ -16,6 +16,7 @@
#include "Titanium/UI/ScrollView.hpp"
#include "Titanium/UI/ImageView.hpp"
#include "Titanium/UI/Label.hpp"
#include "Titanium/UI/Slider.hpp"

namespace Titanium
{
Expand Down Expand Up @@ -113,6 +114,7 @@ namespace Titanium
JSObject createTab(const JSObject& parameters, JSObject& this_object) TITANIUM_NOEXCEPT;
JSObject createTabGroup(const JSObject& parameters, JSObject& this_object) TITANIUM_NOEXCEPT;
JSObject createScrollView(const JSObject& parameters, JSObject& this_object) TITANIUM_NOEXCEPT;
JSObject createSlider(const JSObject& parameters, JSObject& this_object) TITANIUM_NOEXCEPT;

virtual JSValue ANIMATION_CURVE_EASE_IN() const TITANIUM_NOEXCEPT final;
virtual JSValue ANIMATION_CURVE_EASE_IN_OUT() const TITANIUM_NOEXCEPT final;
Expand Down Expand Up @@ -241,6 +243,7 @@ namespace Titanium
JSValue js_createScrollView(const std::vector<JSValue>& arguments, JSObject& this_object);
JSValue js_createImageView(const std::vector<JSValue>& arguments, JSObject& this_object);
JSValue js_createLabel(const std::vector<JSValue>& arguments, JSObject& this_object);
JSValue js_createSlider(const std::vector<JSValue>& arguments, JSObject& this_object);
JSValue js_setBackgroundColor(const std::vector<JSValue>& arguments, JSObject& this_object);

private:
Expand Down Expand Up @@ -352,6 +355,6 @@ namespace Titanium
JSFunction createViewFunction(const JSContext& js_context, const std::string& viewClass) const TITANIUM_NOEXCEPT;
};

} // namespace Titanium {
} // namespace Titanium

#endif // _TITANIUM_UI_HPP_
15 changes: 14 additions & 1 deletion Source/TitaniumKit/src/ApplicationBuilder.cpp
Expand Up @@ -29,6 +29,7 @@ namespace Titanium
button__(js_context__.CreateObject<Titanium::UI::Button>()),
imageview__(js_context__.CreateObject<Titanium::UI::ImageView>()),
label__(js_context__.CreateObject<Titanium::UI::Label>()),
slider__(js_context__.CreateObject<Titanium::UI::Slider>()),
scrollview__(js_context__.CreateObject<Titanium::UI::ScrollView>()),
platform__(js_context__.CreateObject<Titanium::PlatformModule>()),
accelerometer__(js_context__.CreateObject<Titanium::Accelerometer>()),
Expand All @@ -47,6 +48,7 @@ namespace Titanium
ui.SetProperty("Button", button__);
ui.SetProperty("ImageView", imageview__);
ui.SetProperty("Label", label__);
ui.SetProperty("Slider", slider__);
ui.SetProperty("ScrollView", scrollview__);

filesystem__.SetProperty("File", file__);
Expand Down Expand Up @@ -130,6 +132,17 @@ namespace Titanium
return *this;
}

JSObject ApplicationBuilder::SliderObject() const TITANIUM_NOEXCEPT
{
return slider__;
}

ApplicationBuilder& ApplicationBuilder::SliderObject(const JSObject& slider) TITANIUM_NOEXCEPT
{
slider__ = slider;
return *this;
}

JSObject ApplicationBuilder::ImageViewObject() const TITANIUM_NOEXCEPT
{
return imageview__;
Expand Down Expand Up @@ -228,4 +241,4 @@ namespace Titanium
return *this;
}

} // namespace Titanium {
} // namespace Titanium
33 changes: 33 additions & 0 deletions Source/TitaniumKit/src/UIModule.cpp
Expand Up @@ -309,6 +309,27 @@ namespace Titanium
return button;
}

JSObject UIModule::createSlider(const JSObject& parameters, JSObject& this_object) TITANIUM_NOEXCEPT
{
TITANIUM_LOG_DEBUG("UI::createSlider");

JSValue Titanium_property = this_object.get_context().get_global_object().GetProperty("Titanium");
TITANIUM_ASSERT(Titanium_property.IsObject()); // precondition
JSObject Titanium = Titanium_property;

JSValue UI_property = Titanium.GetProperty("UI");
TITANIUM_ASSERT(UI_property.IsObject()); // precondition
JSObject UI = UI_property;

JSValue Slider_property = UI.GetProperty("Slider");
TITANIUM_ASSERT(Slider_property.IsObject()); // precondition
JSObject Slider = Slider_property;

auto slider = Slider.CallAsConstructor(parameters);
Titanium::applyProperties(slider, parameters);
return slider;
}

JSObject UIModule::createTab(const JSObject& parameters, JSObject& this_object) TITANIUM_NOEXCEPT
{
TITANIUM_LOG_DEBUG("UI::createTab");
Expand Down Expand Up @@ -955,6 +976,7 @@ namespace Titanium
JSExport<UIModule>::AddFunctionProperty("createScrollView", std::mem_fn(&UIModule::js_createScrollView));
JSExport<UIModule>::AddFunctionProperty("createImageView", std::mem_fn(&UIModule::js_createImageView));
JSExport<UIModule>::AddFunctionProperty("createLabel", std::mem_fn(&UIModule::js_createLabel));
JSExport<UIModule>::AddFunctionProperty("createSlider", std::mem_fn(&UIModule::js_createSlider));
JSExport<UIModule>::AddFunctionProperty("setBackgroundColor", std::mem_fn(&UIModule::js_setBackgroundColor));
JSExport<UIModule>::AddValueProperty("ANIMATION_CURVE_EASE_IN", std::mem_fn(&UIModule::ANIMATION_CURVE_EASE_IN));
JSExport<UIModule>::AddValueProperty("ANIMATION_CURVE_EASE_IN_OUT", std::mem_fn(&UIModule::ANIMATION_CURVE_EASE_IN_OUT));
Expand Down Expand Up @@ -1095,6 +1117,17 @@ namespace Titanium
return createButton(parameters, this_object);
}

JSValue UIModule::js_createSlider(const std::vector<JSValue>& arguments, JSObject& this_object)
{
JSObject parameters = get_context().CreateObject();
if (arguments.size() >= 1) {
const auto _0 = arguments.at(0);
TITANIUM_ASSERT(_0.IsObject());
parameters = _0;
}
return createSlider(parameters, this_object);
}

JSValue UIModule::js_createImageView(const std::vector<JSValue>& arguments, JSObject& this_object)
{
JSObject parameters = get_context().CreateObject();
Expand Down

0 comments on commit c2d0788

Please sign in to comment.