begin some documentation in styles
This commit is contained in:
parent
02c5e7b8ff
commit
44cf5e20d3
|
@ -0,0 +1,3 @@
|
|||
*.yardoc
|
||||
doc
|
||||
!.gitignore
|
|
@ -0,0 +1,222 @@
|
|||
# @title Style Tags Overview
|
||||
|
||||
## Style Overview
|
||||
This document describes how style tags can be specified, how they affect your
|
||||
widgets, and how to use specific built-in style tags in otclient, as well
|
||||
as how to define new custom style tags.
|
||||
|
||||
## Style Value Types
|
||||
|
||||
{valhead:Integer}
|
||||
Integer number, used by most of style proprieties
|
||||
|
||||
**Examples:**
|
||||
|
||||
* 1
|
||||
* 9
|
||||
* 5
|
||||
|
||||
{valhead:Float}
|
||||
Float number
|
||||
|
||||
**Examples:**
|
||||
|
||||
* 1.0
|
||||
* 9
|
||||
* 1.5
|
||||
|
||||
{valhead:String}
|
||||
String containing a text
|
||||
|
||||
|
||||
**Examples:**
|
||||
|
||||
* this is a string
|
||||
* it doesn't need quotes or escaping
|
||||
|
||||
{valhead:Boolean}
|
||||
Value with two states, **true** or **false**
|
||||
|
||||
**Examples:**
|
||||
|
||||
* true
|
||||
* false
|
||||
|
||||
{valhead:Size}
|
||||
Size type, defined by 2 integers, width followed by height
|
||||
|
||||
size: width height
|
||||
|
||||
|
||||
**Examples:**
|
||||
|
||||
* 10 20
|
||||
* 30 10
|
||||
|
||||
{valhead:Rect}
|
||||
|
||||
Rect type, defined by 4 integers
|
||||
|
||||
rect: x y width height
|
||||
|
||||
**Examples:**
|
||||
|
||||
* 0 0 32 32
|
||||
* 10 20 30 40
|
||||
|
||||
{valhead:Color}
|
||||
|
||||
{valhead:Image}
|
||||
|
||||
{valhead:Font}
|
||||
|
||||
|
||||
## UIWidget
|
||||
|
||||
{taghead:rect Rect}
|
||||
Defines widget's rect
|
||||
|
||||
**Examples:**
|
||||
|
||||
!!!plain
|
||||
rect: 32 32 32 32
|
||||
|
||||
**See also:** {tag:pos}, {tag:size}
|
||||
|
||||
{taghead:size Size}
|
||||
Defines size of a widget in pixels
|
||||
|
||||
**Examples:**
|
||||
|
||||
!!!plain
|
||||
size: 32 32
|
||||
|
||||
{taghead:width Integer}
|
||||
Defines width of a widget
|
||||
|
||||
{taghead:height Integer}
|
||||
Defines height of a widget
|
||||
|
||||
{taghead:pos Point}
|
||||
Defines absolute position of the widget relative to the window top left, this is generialy not used,
|
||||
if you want to position relative to parent widget, use anchors and margins
|
||||
|
||||
|
||||
**Examples:**
|
||||
|
||||
!!!plain
|
||||
pos: 32 32
|
||||
|
||||
{taghead:x Integer}
|
||||
Defines x absolute position
|
||||
|
||||
**See also:** {tag:pos}
|
||||
|
||||
{taghead:y Integer}
|
||||
Defines y absolute position
|
||||
|
||||
**See also:** {tag:pos}
|
||||
|
||||
|
||||
{taghead:color Color}
|
||||
Foreground color, mostly used for coloring texts
|
||||
|
||||
**Examples:**
|
||||
|
||||
!!!plain
|
||||
color: red
|
||||
color: #ff0000
|
||||
color: #ff000080
|
||||
|
||||
{taghead:background Color}
|
||||
Same as {tag:background-color}
|
||||
|
||||
{taghead:background-color Color}
|
||||
Defines background color
|
||||
|
||||
|
||||
{taghead:background-rect Rect}
|
||||
{taghead:background-offset Point}
|
||||
{taghead:background-offset-x Integer}
|
||||
{taghead:background-offset-y Integer}
|
||||
{taghead:background-size Size}
|
||||
{taghead:background-width Integer}
|
||||
{taghead:background-height Integer}
|
||||
|
||||
|
||||
{taghead:icon Image}
|
||||
{taghead:icon-source Image}
|
||||
{taghead:icon-color Color}
|
||||
{taghead:icon-offset-x Integer}
|
||||
{taghead:icon-offset-y Integer}
|
||||
{taghead:icon-offset Point}
|
||||
{taghead:icon-width Integer}
|
||||
{taghead:icon-height Integer}
|
||||
{taghead:icon-size Size}
|
||||
{taghead:icon-rect Rect}
|
||||
{taghead:opacity Float}
|
||||
{taghead:enabled Boolean}
|
||||
{taghead:visible Boolean}
|
||||
{taghead:checked Boolean}
|
||||
{taghead:dragable Boolean}
|
||||
{taghead:on Boolean}
|
||||
{taghead:focusable Boolean}
|
||||
{taghead:phantom Boolean}
|
||||
{taghead:fixed-size Boolean}
|
||||
{taghead:clipping Boolean}
|
||||
{taghead:border Integer}
|
||||
{taghead:border-width Integer}
|
||||
{taghead:border-width-top Integer}
|
||||
{taghead:border-width-right Integer}
|
||||
{taghead:border-width-bottom Integer}
|
||||
{taghead:border-width-left Integer}
|
||||
{taghead:border-color Color}
|
||||
{taghead:border-color-top Color}
|
||||
{taghead:border-color-right Color}
|
||||
{taghead:border-color-bottom Color}
|
||||
{taghead:border-color-left Color}
|
||||
{taghead:margin-top Integer}
|
||||
{taghead:margin-right Integer}
|
||||
{taghead:margin-bottom Integer}
|
||||
{taghead:margin-left Integer}
|
||||
{taghead:margin Integer}
|
||||
{taghead:padding-top Integer}
|
||||
{taghead:padding-right Integer}
|
||||
{taghead:padding-bottom Integer}
|
||||
{taghead:padding-left Integer}
|
||||
{taghead:padding Integer}
|
||||
{taghead:layout Layout}
|
||||
|
||||
{taghead:image-source}
|
||||
{taghead:image-offset-x Integer}
|
||||
{taghead:image-offset-y Integer}
|
||||
{taghead:image-offset Point}
|
||||
{taghead:image-width Integer}
|
||||
{taghead:image-height Integer}
|
||||
{taghead:image-size Size}
|
||||
{taghead:image-rect Rect}
|
||||
{taghead:image-clip Rect}
|
||||
{taghead:image-fixed-ratio Boolean}
|
||||
{taghead:image-repeated Boolean}
|
||||
{taghead:image-smooth Boolean}
|
||||
{taghead:image-color Color}
|
||||
{taghead:image-border-top Integer}
|
||||
{taghead:image-border-right Integer}
|
||||
{taghead:image-border-bottom Integer}
|
||||
{taghead:image-border-left Integer}
|
||||
{taghead:image-border Integer}
|
||||
|
||||
{taghead:text}
|
||||
{taghead:text-align Align}
|
||||
{taghead:text-offset Point}
|
||||
{taghead:text-wrap Boolean}
|
||||
{taghead:text-auto-resize Boolean}
|
||||
{taghead:font Font}
|
||||
|
||||
# UITextEdit
|
||||
{taghead:text-margin}
|
||||
{taghead:always-active}
|
||||
{taghead:shift-navigation}
|
||||
{taghead:multiline}
|
||||
{taghead:max-length}
|
||||
|
|
@ -1,4 +1,18 @@
|
|||
class UIWidget
|
||||
# Declares the API that the object belongs to. Does not display in
|
||||
# output, but useful for performing queries (+yardoc --query+). Any text is
|
||||
# allowable in this tag, and there are no predefined values.
|
||||
#
|
||||
# @!macro yard.tag.transitive
|
||||
# @note The special name +@api private+ does display a notice in
|
||||
# documentation if it is listed, letting users know that the
|
||||
# method is not to be used by external components.
|
||||
# @example
|
||||
# class Post
|
||||
# # @api private
|
||||
# def reset_table!; table.flush end
|
||||
# end
|
||||
define_tag "API Visibility", :api
|
||||
end
|
||||
|
||||
class g_game
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
include YARD
|
||||
include Templates
|
||||
|
||||
module MyTemplateHelper
|
||||
def linkify(*args)
|
||||
if args.first.is_a?(String)
|
||||
case args.first
|
||||
when /^taghead:(\S+)/
|
||||
tag_name = $1
|
||||
params = args[1]
|
||||
return "<h3 class=\"note\" id=\"#{tag_name}\" toc-title=\"#{tag_name}\"><strong>#{tag_name}:</strong> #{params}</h3>"
|
||||
when /^valhead:(\S+)/
|
||||
tag_name = $1
|
||||
return "<h3 class=\"note private\" id=\"#{tag_name}\" toc-title=\"#{tag_name}\"><strong>#{tag_name}</strong></h3>"
|
||||
when /^tag:(\S+)/
|
||||
tag_name = $1
|
||||
return "<a href=\"##{tag_name}\">#{tag_name}</a>"
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
Template.extra_includes << MyTemplateHelper
|
||||
Engine.register_template_path(File.dirname(__FILE__))
|
|
@ -492,7 +492,7 @@ function Console.sendCurrentMessage()
|
|||
g_game.talkPrivate(speaktype.speakType, name, message)
|
||||
|
||||
message = applyMessagePrefixies(player:getName(), player:getLevel(), message)
|
||||
Console.addPrivateText(message, speaktype, name, isPrivateCommand, g_game:getLocalPlayer():getName())
|
||||
Console.addPrivateText(message, speaktype, name, isPrivateCommand, g_game.getLocalPlayer():getName())
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -373,7 +373,6 @@ void Application::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UITextEdit>("setCursorPos", &UITextEdit::setCursorPos);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("setCursorEnabled", &UITextEdit::setCursorEnabled);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("setTextHidden", &UITextEdit::setTextHidden);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("setAlwaysActive", &UITextEdit::setAlwaysActive);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("setValidCharacters", &UITextEdit::setValidCharacters);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("setShiftNavigation", &UITextEdit::setShiftNavigation);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("setMultiline", &UITextEdit::setMultiline);
|
||||
|
@ -387,7 +386,6 @@ void Application::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<UITextEdit>("getCursorPos", &UITextEdit::getCursorPos);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("getMaxLength", &UITextEdit::getMaxLength);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("isCursorEnabled", &UITextEdit::isCursorEnabled);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("isAlwaysActive", &UITextEdit::isAlwaysActive);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("isTextHidden", &UITextEdit::isTextHidden);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("isShiftNavigation", &UITextEdit::isShiftNavigation);
|
||||
g_lua.bindClassMemberFunction<UITextEdit>("isMultiline", &UITextEdit::isMultiline);
|
||||
|
|
|
@ -34,7 +34,6 @@ UITextEdit::UITextEdit()
|
|||
m_startRenderPos = 0;
|
||||
m_textHorizontalMargin = 0;
|
||||
m_textHidden = false;
|
||||
m_alwaysActive = false;
|
||||
m_shiftNavigation = false;
|
||||
m_multiline = false;
|
||||
m_maxLength = 0;
|
||||
|
@ -58,7 +57,7 @@ void UITextEdit::drawSelf()
|
|||
g_painter->drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]);
|
||||
|
||||
// render cursor
|
||||
if(isExplicitlyEnabled() && (isActive() || m_alwaysActive) && m_cursorPos >= 0) {
|
||||
if(isExplicitlyEnabled() && isActive() && m_cursorPos >= 0) {
|
||||
assert(m_cursorPos <= textLength);
|
||||
// draw every 333ms
|
||||
const int delay = 333;
|
||||
|
@ -268,11 +267,6 @@ void UITextEdit::setTextHidden(bool hidden)
|
|||
update();
|
||||
}
|
||||
|
||||
void UITextEdit::setAlwaysActive(bool enable)
|
||||
{
|
||||
m_alwaysActive = enable;
|
||||
}
|
||||
|
||||
void UITextEdit::appendText(std::string text)
|
||||
{
|
||||
if(m_cursorPos >= 0) {
|
||||
|
@ -417,8 +411,6 @@ void UITextEdit::onStyleApply(const std::string& styleName, const OTMLNodePtr& s
|
|||
setTextHidden(node->value<bool>());
|
||||
else if(node->tag() == "text-margin")
|
||||
setTextHorizontalMargin(node->value<int>());
|
||||
else if(node->tag() == "always-active")
|
||||
setAlwaysActive(node->value<bool>());
|
||||
else if(node->tag() == "shift-navigation")
|
||||
setShiftNavigation(node->value<bool>());
|
||||
else if(node->tag() == "multiline")
|
||||
|
@ -436,7 +428,7 @@ void UITextEdit::onGeometryChange(const Rect& oldRect, const Rect& newRect)
|
|||
|
||||
void UITextEdit::onFocusChange(bool focused, Fw::FocusReason reason)
|
||||
{
|
||||
if(focused && !m_alwaysActive) {
|
||||
if(focused) {
|
||||
if(reason == Fw::KeyboardFocusReason)
|
||||
setCursorPos(m_text.length());
|
||||
else
|
||||
|
|
|
@ -40,7 +40,6 @@ public:
|
|||
void setCursorPos(int pos);
|
||||
void setCursorEnabled(bool enable);
|
||||
void setTextHidden(bool hidden);
|
||||
void setAlwaysActive(bool enable);
|
||||
void setValidCharacters(const std::string validCharacters) { m_validCharacters = validCharacters; }
|
||||
void setShiftNavigation(bool enable) { m_shiftNavigation = enable; }
|
||||
void setMultiline(bool enable) { m_multiline = enable; }
|
||||
|
@ -57,7 +56,6 @@ public:
|
|||
int getCursorPos() { return m_cursorPos; }
|
||||
uint getMaxLength() { return m_maxLength; }
|
||||
bool isCursorEnabled() { return m_cursorPos != -1; }
|
||||
bool isAlwaysActive() { return m_alwaysActive; }
|
||||
bool isTextHidden() { return m_textHidden; }
|
||||
bool isShiftNavigation() { return m_shiftNavigation; }
|
||||
bool isMultiline() { return m_multiline; }
|
||||
|
@ -82,7 +80,6 @@ private:
|
|||
ticks_t m_cursorTicks;
|
||||
int m_textHorizontalMargin;
|
||||
bool m_textHidden;
|
||||
bool m_alwaysActive;
|
||||
bool m_shiftNavigation;
|
||||
bool m_multiline;
|
||||
std::string m_validCharacters;
|
||||
|
|
Loading…
Reference in New Issue