mirror of
https://github.com/godotengine/godot.git
synced 2025-01-10 12:11:05 +00:00
add placeholder alpha property
This commit is contained in:
parent
081c400ac6
commit
c702981d57
@ -637,7 +637,7 @@ void LineEdit::_notification(int p_what) {
|
|||||||
const String& t = text.empty() ? placeholder : text;
|
const String& t = text.empty() ? placeholder : text;
|
||||||
// draw placeholder color
|
// draw placeholder color
|
||||||
if(text.empty())
|
if(text.empty())
|
||||||
font_color.a *= 0.6;
|
font_color.a *= placeholder_alpha;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
||||||
@ -954,6 +954,18 @@ String LineEdit::get_placeholder() const {
|
|||||||
return placeholder;
|
return placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LineEdit::set_placeholder_alpha(float p_alpha) {
|
||||||
|
|
||||||
|
placeholder_alpha = p_alpha;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
float LineEdit::get_placeholder_alpha() const {
|
||||||
|
|
||||||
|
return placeholder_alpha;
|
||||||
|
}
|
||||||
|
|
||||||
void LineEdit::set_cursor_pos(int p_pos) {
|
void LineEdit::set_cursor_pos(int p_pos) {
|
||||||
|
|
||||||
if (p_pos>(int)text.length())
|
if (p_pos>(int)text.length())
|
||||||
@ -1241,6 +1253,8 @@ void LineEdit::_bind_methods() {
|
|||||||
ObjectTypeDB::bind_method(_MD("get_text"),&LineEdit::get_text);
|
ObjectTypeDB::bind_method(_MD("get_text"),&LineEdit::get_text);
|
||||||
ObjectTypeDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
|
ObjectTypeDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
|
||||||
ObjectTypeDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
|
ObjectTypeDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
|
||||||
|
ObjectTypeDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
|
||||||
|
ObjectTypeDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
|
||||||
ObjectTypeDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
|
ObjectTypeDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
|
||||||
ObjectTypeDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
|
ObjectTypeDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
|
||||||
ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&LineEdit::cursor_set_blink_enabled);
|
ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&LineEdit::cursor_set_blink_enabled);
|
||||||
@ -1275,7 +1289,8 @@ void LineEdit::_bind_methods() {
|
|||||||
BIND_CONSTANT( MENU_MAX );
|
BIND_CONSTANT( MENU_MAX );
|
||||||
|
|
||||||
ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
|
ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
|
||||||
ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
|
ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder/text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
|
||||||
|
ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder/alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
|
||||||
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
|
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
|
||||||
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
|
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
|
||||||
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
|
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
|
||||||
@ -1294,6 +1309,7 @@ LineEdit::LineEdit() {
|
|||||||
window_has_focus=true;
|
window_has_focus=true;
|
||||||
max_length = 0;
|
max_length = 0;
|
||||||
pass=false;
|
pass=false;
|
||||||
|
placeholder_alpha=0.6;
|
||||||
|
|
||||||
selection_clear();
|
selection_clear();
|
||||||
set_focus_mode( FOCUS_ALL );
|
set_focus_mode( FOCUS_ALL );
|
||||||
|
@ -68,6 +68,7 @@ private:
|
|||||||
String undo_text;
|
String undo_text;
|
||||||
String text;
|
String text;
|
||||||
String placeholder;
|
String placeholder;
|
||||||
|
float placeholder_alpha;
|
||||||
|
|
||||||
PopupMenu *menu;
|
PopupMenu *menu;
|
||||||
|
|
||||||
@ -138,6 +139,8 @@ public:
|
|||||||
String get_text() const;
|
String get_text() const;
|
||||||
void set_placeholder(String p_text);
|
void set_placeholder(String p_text);
|
||||||
String get_placeholder() const;
|
String get_placeholder() const;
|
||||||
|
void set_placeholder_alpha(float p_alpha);
|
||||||
|
float get_placeholder_alpha() const;
|
||||||
void set_cursor_pos(int p_pos);
|
void set_cursor_pos(int p_pos);
|
||||||
int get_cursor_pos() const;
|
int get_cursor_pos() const;
|
||||||
void set_max_length(int p_max_length);
|
void set_max_length(int p_max_length);
|
||||||
|
Loading…
Reference in New Issue
Block a user