summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/button.cpp15
-rw-r--r--scene/gui/range.cpp10
-rw-r--r--scene/gui/spin_box.cpp2
-rw-r--r--scene/gui/text_edit.cpp17
-rw-r--r--scene/gui/text_edit.h1
-rw-r--r--scene/gui/texture_progress.cpp5
-rw-r--r--scene/gui/texture_rect.cpp2
-rw-r--r--scene/gui/tree.cpp30
-rw-r--r--scene/gui/tree.h5
-rw-r--r--scene/gui/video_player.cpp1
10 files changed, 61 insertions, 27 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index f28595b622..2d1d437668 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -74,17 +74,21 @@ void Button::_notification(int p_what) {
//print_line(get_text()+": "+itos(is_flat())+" hover "+itos(get_draw_mode()));
+ Ref<StyleBox> style = get_stylebox("normal");
+
switch( get_draw_mode() ) {
case DRAW_NORMAL: {
+ style = get_stylebox("normal");
if (!flat)
- get_stylebox("normal" )->draw( ci, Rect2(Point2(0,0), size) );
+ style->draw( ci, Rect2(Point2(0,0), size) );
color=get_color("font_color");
} break;
case DRAW_PRESSED: {
- get_stylebox("pressed" )->draw( ci, Rect2(Point2(0,0), size) );
+ style = get_stylebox("pressed");
+ style->draw( ci, Rect2(Point2(0,0), size) );
if (has_color("font_color_pressed"))
color=get_color("font_color_pressed");
else
@@ -93,13 +97,15 @@ void Button::_notification(int p_what) {
} break;
case DRAW_HOVER: {
- get_stylebox("hover" )->draw( ci, Rect2(Point2(0,0), size) );
+ style = get_stylebox("hover");
+ style->draw( ci, Rect2(Point2(0,0), size) );
color=get_color("font_color_hover");
} break;
case DRAW_DISABLED: {
- get_stylebox("disabled" )->draw( ci, Rect2(Point2(0,0), size) );
+ style = get_stylebox("disabled");
+ style->draw( ci, Rect2(Point2(0,0), size) );
color=get_color("font_color_disabled");
} break;
@@ -111,7 +117,6 @@ void Button::_notification(int p_what) {
style->draw(ci,Rect2(Point2(),size));
}
- Ref<StyleBox> style = get_stylebox("normal" );
Ref<Font> font=get_font("font");
Ref<Texture> _icon;
if (icon.is_null() && has_icon("icon"))
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index d5c1034c9c..5ecafccaca 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -141,8 +141,8 @@ void Range::set_as_ratio(double p_value) {
if (shared->exp_ratio && get_min()>0) {
- double exp_min = Math::log(get_min())/Math::log(2);
- double exp_max = Math::log(get_max())/Math::log(2);
+ double exp_min = Math::log(get_min())/Math::log((double)2);
+ double exp_max = Math::log(get_max())/Math::log((double)2);
v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
} else {
@@ -160,9 +160,9 @@ double Range::get_as_ratio() const {
if (shared->exp_ratio && get_min()>0) {
- double exp_min = Math::log(get_min())/Math::log(2);
- double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::log(get_value())/Math::log(2);
+ double exp_min = Math::log(get_min())/Math::log((double)2);
+ double exp_max = Math::log(get_max())/Math::log((double)2);
+ double v = Math::log(get_value())/Math::log((double)2);
return (v - exp_min) / (exp_max - exp_min);
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index ec6be0d19d..8920f8f056 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -162,7 +162,7 @@ void SpinBox::_gui_input(const InputEvent& p_event) {
if (drag.enabled) {
float diff_y = drag.mouse_pos.y - cpos.y;
- diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
+ diff_y=Math::pow(ABS(diff_y),1.8f)*SGN(diff_y);
diff_y*=0.1;
drag.mouse_pos=cpos;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index d1a8c458ba..6036b3f9df 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -482,14 +482,6 @@ void TextEdit::_notification(int p_what) {
Color color = cache.font_color;
int in_region=-1;
- if (line_length_guideline) {
- int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
- if (x>xmargin_beg && x<xmargin_end) {
- Color guideline_color(color.r,color.g,color.b,color.a*0.25f);
- VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),guideline_color);
- }
- }
-
if (syntax_coloring) {
if (cache.background_color.a>0.01) {
@@ -1080,6 +1072,14 @@ void TextEdit::_notification(int p_what) {
}
}
+ if (line_length_guideline) {
+ int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
+ if (x>xmargin_beg && x<xmargin_end) {
+ VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),cache.line_length_guideline_color);
+ }
+ }
+
+
bool completion_below = false;
if (completion_active) {
// code completion box
@@ -3484,6 +3484,7 @@ void TextEdit::_update_caches() {
cache.selection_color=get_color("selection_color");
cache.mark_color=get_color("mark_color");
cache.current_line_color=get_color("current_line_color");
+ cache.line_length_guideline_color=get_color("line_length_guideline_color");
cache.breakpoint_color=get_color("breakpoint_color");
cache.brace_mismatch_color=get_color("brace_mismatch_color");
cache.word_highlighted_color=get_color("word_highlighted_color");
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 6113fd72c2..437e22ca40 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -91,6 +91,7 @@ class TextEdit : public Control {
Color mark_color;
Color breakpoint_color;
Color current_line_color;
+ Color line_length_guideline_color;
Color brace_mismatch_color;
Color word_highlighted_color;
Color search_result_color;
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index f6a33b5643..7d8373976b 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -46,7 +46,9 @@ void TextureProgress::set_over_texture(const Ref<Texture>& p_texture) {
over=p_texture;
update();
- minimum_size_changed();
+ if (under.is_null()) {
+ minimum_size_changed();
+ }
}
Ref<Texture> TextureProgress::get_over_texture() const{
@@ -302,4 +304,5 @@ TextureProgress::TextureProgress()
rad_init_angle=0;
rad_center_off=Point2();
rad_max_degrees=360;
+ set_mouse_filter(MOUSE_FILTER_PASS);
}
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index cbb077ef5d..6a4b59c5ec 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -160,7 +160,7 @@ TextureRect::TextureRect() {
expand=false;
- set_mouse_filter(MOUSE_FILTER_IGNORE);
+ set_mouse_filter(MOUSE_FILTER_PASS);
stretch_mode=STRETCH_SCALE_ON_EXPAND;
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 2cfebb7c1e..1a7392f27e 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -943,7 +943,7 @@ void Tree::draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,cons
bmsize.width=p_cell.icon_max_w;
}
- p_cell.draw_icon(ci,rect.pos + Size2i(0,Math::floor((rect.size.y-bmsize.y)/2)),bmsize);
+ p_cell.draw_icon(ci,rect.pos + Size2i(0,Math::floor((real_t)(rect.size.y-bmsize.y)/2)),bmsize);
rect.pos.x+=bmsize.x+cache.hseparation;
rect.size.x-=bmsize.x+cache.hseparation;
@@ -1008,7 +1008,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
/* Draw label, if height fits */
- bool skip=(p_item==root && hide_root);
+ bool skip=(p_item==root && hide_root);
if (!skip && (p_pos.y+label_h-cache.offset.y)>0) {
@@ -1173,7 +1173,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
Ref<Texture> checked = cache.checked;
Ref<Texture> unchecked = cache.unchecked;
Point2i check_ofs=item_rect.pos;
- check_ofs.y+=Math::floor((item_rect.size.y-checked->get_height())/2);
+ check_ofs.y+=Math::floor((real_t)(item_rect.size.y-checked->get_height())/2);
if (p_item->cells[i].checked) {
@@ -1711,8 +1711,15 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
case TreeItem::CELL_MODE_CHECK: {
bring_up_editor=false; //checkboxes are not edited with editor
- p_item->set_checked(col, !c.checked);
- item_edited(col, p_item);
+ if (force_edit_checkbox_only_on_checkbox) {
+ if (x < cache.checked->get_width()) {
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ }
+ } else {
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ }
click_handled = true;
//p_item->edited_signal.call(col);
@@ -2321,7 +2328,7 @@ void Tree::_gui_input(InputEvent p_event) {
TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col];
float diff_y = -b.relative_y;
- diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y);
+ diff_y=Math::pow(ABS(diff_y),1.8f)*SGN(diff_y);
diff_y*=0.1;
range_drag_base=CLAMP(range_drag_base + c.step * diff_y, c.min, c.max);
popup_edited_item->set_range(popup_edited_item_col,range_drag_base);
@@ -3555,6 +3562,16 @@ bool Tree::get_single_select_cell_editing_only_when_already_selected() const {
return force_select_on_already_selected;
}
+void Tree::set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable) {
+
+ force_edit_checkbox_only_on_checkbox=p_enable;
+}
+
+bool Tree::get_edit_checkbox_cell_only_when_checkbox_is_pressed() const {
+
+ return force_edit_checkbox_only_on_checkbox;
+}
+
void Tree::set_allow_rmb_select(bool p_allow) {
@@ -3733,6 +3750,7 @@ Tree::Tree() {
force_select_on_already_selected=false;
allow_rmb_select=false;
+ force_edit_checkbox_only_on_checkbox=false;
set_clip_contents(true);
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index d715ff4772..351cc4cb50 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -452,6 +452,7 @@ friend class TreeItem;
bool scrolling;
bool force_select_on_already_selected;
+ bool force_edit_checkbox_only_on_checkbox;
bool hide_folding;
@@ -531,6 +532,10 @@ public:
void set_single_select_cell_editing_only_when_already_selected(bool p_enable);
bool get_single_select_cell_editing_only_when_already_selected() const;
+ void set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable);
+ bool get_edit_checkbox_cell_only_when_checkbox_is_pressed() const;
+
+
void set_allow_rmb_select(bool p_allow);
bool get_allow_rmb_select() const;
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 907b5a771f..46c0eeca65 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -28,6 +28,7 @@
/*************************************************************************/
#include "video_player.h"
#include "os/os.h"
+#include "servers/audio_server.h"
/*
int VideoPlayer::InternalStream::get_channel_count() const {