Mercurial > wow > hansgar_and_franzok_assist
comparison Libs/DF/textentry.lua @ 22:dbd417f413a8
- framework update.
| author | Tercio |
|---|---|
| date | Tue, 08 Sep 2015 13:16:49 -0300 |
| parents | dc1c77254f80 |
| children | 5da06cb420d4 |
comparison
equal
deleted
inserted
replaced
| 21:7fef991992f6 | 22:dbd417f413a8 |
|---|---|
| 257 if (not self.editbox:IsEnabled()) then | 257 if (not self.editbox:IsEnabled()) then |
| 258 self.editbox:Enable() | 258 self.editbox:Enable() |
| 259 self.editbox:SetBackdropBorderColor (unpack (self.enabled_border_color)) | 259 self.editbox:SetBackdropBorderColor (unpack (self.enabled_border_color)) |
| 260 self.editbox:SetBackdropColor (unpack (self.enabled_backdrop_color)) | 260 self.editbox:SetBackdropColor (unpack (self.enabled_backdrop_color)) |
| 261 self.editbox:SetTextColor (unpack (self.enabled_text_color)) | 261 self.editbox:SetTextColor (unpack (self.enabled_text_color)) |
| 262 if (self.editbox.borderframe) then | |
| 263 self.editbox.borderframe:SetBackdropColor (unpack (self.editbox.borderframe.onleave_backdrop)) | |
| 264 end | |
| 262 end | 265 end |
| 263 end | 266 end |
| 264 | 267 |
| 265 function TextEntryMetaFunctions:Disable() | 268 function TextEntryMetaFunctions:Disable() |
| 266 if (self.editbox:IsEnabled()) then | 269 if (self.editbox:IsEnabled()) then |
| 271 self.editbox:Disable() | 274 self.editbox:Disable() |
| 272 | 275 |
| 273 self.editbox:SetBackdropBorderColor (.5, .5, .5, .5) | 276 self.editbox:SetBackdropBorderColor (.5, .5, .5, .5) |
| 274 self.editbox:SetBackdropColor (.5, .5, .5, .5) | 277 self.editbox:SetBackdropColor (.5, .5, .5, .5) |
| 275 self.editbox:SetTextColor (.5, .5, .5, .5) | 278 self.editbox:SetTextColor (.5, .5, .5, .5) |
| 279 | |
| 280 if (self.editbox.borderframe) then | |
| 281 self.editbox.borderframe:SetBackdropColor (.5, .5, .5, .5) | |
| 282 end | |
| 276 end | 283 end |
| 277 end | 284 end |
| 278 | 285 |
| 279 ------------------------------------------------------------------------------------------------------------ | 286 ------------------------------------------------------------------------------------------------------------ |
| 280 --> scripts | 287 --> scripts |
| 298 if (textentry:IsEnabled()) then | 305 if (textentry:IsEnabled()) then |
| 299 textentry.current_bordercolor = textentry.current_bordercolor or {textentry:GetBackdropBorderColor()} | 306 textentry.current_bordercolor = textentry.current_bordercolor or {textentry:GetBackdropBorderColor()} |
| 300 textentry:SetBackdropBorderColor (1, 1, 1, 1) | 307 textentry:SetBackdropBorderColor (1, 1, 1, 1) |
| 301 end | 308 end |
| 302 | 309 |
| 303 local parent = textentry:GetParent().MyObject | |
| 304 if (parent and parent.type == "panel") then | |
| 305 if (parent.GradientEnabled) then | |
| 306 parent:RunGradient() | |
| 307 end | |
| 308 end | |
| 309 | |
| 310 end | 310 end |
| 311 | 311 |
| 312 local OnLeave = function (textentry) | 312 local OnLeave = function (textentry) |
| 313 if (textentry.MyObject.OnLeaveHook) then | 313 if (textentry.MyObject.OnLeaveHook) then |
| 314 local interrupt = textentry.MyObject.OnLeaveHook (textentry) | 314 local interrupt = textentry.MyObject.OnLeaveHook (textentry) |
| 324 textentry.mouse_over = false | 324 textentry.mouse_over = false |
| 325 | 325 |
| 326 if (textentry:IsEnabled()) then | 326 if (textentry:IsEnabled()) then |
| 327 textentry:SetBackdropBorderColor (unpack (textentry.current_bordercolor)) | 327 textentry:SetBackdropBorderColor (unpack (textentry.current_bordercolor)) |
| 328 end | 328 end |
| 329 | 329 |
| 330 local parent = textentry:GetParent().MyObject | |
| 331 if (parent and parent.type == "panel") then | |
| 332 if (parent.GradientEnabled) then | |
| 333 parent:RunGradient (false) | |
| 334 end | |
| 335 end | |
| 336 end | 330 end |
| 337 | 331 |
| 338 local OnHide = function (textentry) | 332 local OnHide = function (textentry) |
| 339 if (textentry.MyObject.OnHideHook) then | 333 if (textentry.MyObject.OnHideHook) then |
| 340 local interrupt = textentry.MyObject.OnHideHook (textentry) | 334 local interrupt = textentry.MyObject.OnHideHook (textentry) |
| 471 function TextEntryMetaFunctions:PressEnter (byScript) | 465 function TextEntryMetaFunctions:PressEnter (byScript) |
| 472 OnEnterPressed (self.editbox, byScript) | 466 OnEnterPressed (self.editbox, byScript) |
| 473 end | 467 end |
| 474 | 468 |
| 475 ------------------------------------------------------------------------------------------------------------ | 469 ------------------------------------------------------------------------------------------------------------ |
| 470 | |
| 471 function TextEntryMetaFunctions:SetTemplate (template) | |
| 472 if (template.width) then | |
| 473 self:SetWidth (template.width) | |
| 474 end | |
| 475 if (template.height) then | |
| 476 self:SetHeight (template.height) | |
| 477 end | |
| 478 | |
| 479 if (template.backdrop) then | |
| 480 self:SetBackdrop (template.backdrop) | |
| 481 end | |
| 482 if (template.backdropcolor) then | |
| 483 local r, g, b, a = DF:ParseColors (template.backdropcolor) | |
| 484 self:SetBackdropColor (r, g, b, a) | |
| 485 self.onleave_backdrop = {r, g, b, a} | |
| 486 end | |
| 487 if (template.backdropbordercolor) then | |
| 488 local r, g, b, a = DF:ParseColors (template.backdropbordercolor) | |
| 489 self:SetBackdropBorderColor (r, g, b, a) | |
| 490 self.editbox.current_bordercolor[1] = r | |
| 491 self.editbox.current_bordercolor[2] = g | |
| 492 self.editbox.current_bordercolor[3] = b | |
| 493 self.editbox.current_bordercolor[4] = a | |
| 494 self.onleave_backdrop_border_color = {r, g, b, a} | |
| 495 end | |
| 496 end | |
| 497 | |
| 498 ------------------------------------------------------------------------------------------------------------ | |
| 476 --> object constructor | 499 --> object constructor |
| 477 | 500 |
| 478 function DF:CreateTextEntry (parent, func, w, h, member, name) | 501 function DF:CreateTextEntry (parent, func, w, h, member, name, with_label, entry_template, label_template) |
| 479 return DF:NewTextEntry (parent, parent, name, member, w, h, func) | 502 return DF:NewTextEntry (parent, parent, name, member, w, h, func, nil, nil, nil, with_label, entry_template, label_template) |
| 480 end | 503 end |
| 481 | 504 |
| 482 function DF:NewTextEntry (parent, container, name, member, w, h, func, param1, param2, space) | 505 function DF:NewTextEntry (parent, container, name, member, w, h, func, param1, param2, space, with_label, entry_template, label_template) |
| 483 | 506 |
| 484 if (not name) then | 507 if (not name) then |
| 485 name = "DetailsFrameworkTextEntryNumber" .. DF.TextEntryCounter | 508 name = "DetailsFrameworkTextEntryNumber" .. DF.TextEntryCounter |
| 486 DF.TextEntryCounter = DF.TextEntryCounter + 1 | 509 DF.TextEntryCounter = DF.TextEntryCounter + 1 |
| 487 | 510 |
| 569 TextEntryObject.editbox.current_bordercolor = {1, 1, 1, 0.7} | 592 TextEntryObject.editbox.current_bordercolor = {1, 1, 1, 0.7} |
| 570 TextEntryObject.editbox:SetBackdropBorderColor (1, 1, 1, 0.7) | 593 TextEntryObject.editbox:SetBackdropBorderColor (1, 1, 1, 0.7) |
| 571 TextEntryObject.enabled_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()} | 594 TextEntryObject.enabled_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()} |
| 572 TextEntryObject.enabled_backdrop_color = {TextEntryObject.editbox:GetBackdropColor()} | 595 TextEntryObject.enabled_backdrop_color = {TextEntryObject.editbox:GetBackdropColor()} |
| 573 TextEntryObject.enabled_text_color = {TextEntryObject.editbox:GetTextColor()} | 596 TextEntryObject.enabled_text_color = {TextEntryObject.editbox:GetTextColor()} |
| 597 TextEntryObject.onleave_backdrop = {TextEntryObject.editbox:GetBackdropColor()} | |
| 598 TextEntryObject.onleave_backdrop_border_color = {TextEntryObject.editbox:GetBackdropBorderColor()} | |
| 574 | 599 |
| 575 TextEntryObject.func = func | 600 TextEntryObject.func = func |
| 576 TextEntryObject.param1 = param1 | 601 TextEntryObject.param1 = param1 |
| 577 TextEntryObject.param2 = param2 | 602 TextEntryObject.param2 = param2 |
| 578 TextEntryObject.next = nil | 603 TextEntryObject.next = nil |
| 597 TextEntryObject.editbox:SetScript ("OnTextChanged", OnTextChanged) | 622 TextEntryObject.editbox:SetScript ("OnTextChanged", OnTextChanged) |
| 598 TextEntryObject.editbox:SetScript ("OnTabPressed", OnTabPressed) | 623 TextEntryObject.editbox:SetScript ("OnTabPressed", OnTabPressed) |
| 599 | 624 |
| 600 _setmetatable (TextEntryObject, TextEntryMetaFunctions) | 625 _setmetatable (TextEntryObject, TextEntryMetaFunctions) |
| 601 | 626 |
| 602 return TextEntryObject | 627 if (with_label) then |
| 603 | 628 local label = DF:CreateLabel (TextEntryObject.editbox, with_label, nil, nil, nil, "label", nil, "overlay") |
| 629 label.text = with_label | |
| 630 TextEntryObject.editbox:SetPoint ("left", label.widget, "right", 2, 0) | |
| 631 if (label_template) then | |
| 632 label:SetTemplate (label_template) | |
| 633 end | |
| 634 with_label = label | |
| 635 end | |
| 636 | |
| 637 if (entry_template) then | |
| 638 TextEntryObject:SetTemplate (entry_template) | |
| 639 end | |
| 640 | |
| 641 return TextEntryObject, with_label | |
| 642 | |
| 643 end | |
| 644 | |
| 645 function DF:NewSpellEntry (parent, func, w, h, param1, param2, member, name) | |
| 646 local editbox = DF:NewTextEntry (parent, parent, name, member, w, h, func, param1, param2) | |
| 647 | |
| 648 editbox:SetHook ("OnEditFocusGained", SpellEntryOnEditFocusGained) | |
| 649 editbox:SetHook ("OnTextChanged", SpellEntryOnTextChanged) | |
| 650 | |
| 651 return editbox | |
| 604 end | 652 end |
| 605 | 653 |
| 606 local function_gettext = function (self) | 654 local function_gettext = function (self) |
| 607 return self.editbox:GetText() | 655 return self.editbox:GetText() |
| 608 end | 656 end |
| 647 borderframe.GetText = function_gettext | 695 borderframe.GetText = function_gettext |
| 648 borderframe.SetText = function_settext | 696 borderframe.SetText = function_settext |
| 649 borderframe.ClearFocus = function_clearfocus | 697 borderframe.ClearFocus = function_clearfocus |
| 650 borderframe.SetFocus = function_setfocus | 698 borderframe.SetFocus = function_setfocus |
| 651 | 699 |
| 700 borderframe.Enable = TextEntryMetaFunctions.Enable | |
| 701 borderframe.Disable = TextEntryMetaFunctions.Disable | |
| 702 | |
| 703 borderframe.SetTemplate = TextEntryMetaFunctions.SetTemplate | |
| 704 | |
| 652 if (not nointent) then | 705 if (not nointent) then |
| 653 IndentationLib.enable (scrollframe.editbox, nil, 4) | 706 IndentationLib.enable (scrollframe.editbox, nil, 4) |
| 654 end | 707 end |
| 655 | 708 |
| 656 borderframe:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], | 709 borderframe:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], |
| 657 tile = 1, tileSize = 16, edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}}) | 710 tile = 1, tileSize = 16, edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}}) |
| 711 | |
| 712 scrollframe.editbox.current_bordercolor = {1, 1, 1, 0.7} | |
| 713 borderframe:SetBackdropBorderColor (1, 1, 1, 0.7) | |
| 658 borderframe:SetBackdropColor (0.090195, 0.090195, 0.188234, 1) | 714 borderframe:SetBackdropColor (0.090195, 0.090195, 0.188234, 1) |
| 659 borderframe:SetBackdropBorderColor (1, 1, 1, 1) | 715 |
| 716 borderframe.enabled_border_color = {borderframe:GetBackdropBorderColor()} | |
| 717 borderframe.enabled_backdrop_color = {borderframe:GetBackdropColor()} | |
| 718 borderframe.enabled_text_color = {scrollframe.editbox:GetTextColor()} | |
| 719 | |
| 720 borderframe.onleave_backdrop = {scrollframe.editbox:GetBackdropColor()} | |
| 721 borderframe.onleave_backdrop_border_color = {scrollframe.editbox:GetBackdropBorderColor()} | |
| 660 | 722 |
| 661 borderframe.scroll = scrollframe | 723 borderframe.scroll = scrollframe |
| 662 borderframe.editbox = scrollframe.editbox | 724 borderframe.editbox = scrollframe.editbox |
| 725 borderframe.editbox.borderframe = borderframe | |
| 663 | 726 |
| 664 return borderframe | 727 return borderframe |
| 665 end | 728 end |
