Skip to content

Commit

Permalink
normal commit
Browse files Browse the repository at this point in the history
 - add new debug config LUI_DEBUG_WINDOW_MEMLEAK
 - improve SetText interface
 - bug fixed
dustpg committed Jun 1, 2020
1 parent e45f381 commit 3fc0148
Showing 38 changed files with 476 additions and 243 deletions.
8 changes: 6 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
控件创建使用折半查找 MAX_CONTROL_TYPE_COUNT
UIXxxxx::Private::SetText

m_oBox.xxx = { a ,b ,c d } 移动到NativeStyleInit

控件创建使用折半查找 MAX_CONTROL_TYPE_COUNT

MinSizeChange [针对文本] 测试

@@ -20,7 +24,7 @@ CUIWaiter单独测试?

Node 继承 偏移量调整

超过大部分(比如90%)渲染面积应该全渲染
超过大部分(比如90%)渲染面积应该全渲染?

Event_Initialize 时构造对象?

2 changes: 2 additions & 0 deletions include/control/ui_button.h
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ namespace LongUI {
class UIButton : public UIBoxLayout {
// super class
using Super = UIBoxLayout;
// private impl
struct Private;
public:
// min button width
//enum { MIN_BUTTON_WIDTH = 175 };
7 changes: 7 additions & 0 deletions include/control/ui_caption.h
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@

// ui namespace
namespace LongUI {
// UIGroupBox
class UIGroupBox;
// caption
class UICaption : public UILabel {
// super class
@@ -48,9 +50,14 @@ namespace LongUI {
~UICaption() noexcept;
// ctor
explicit UICaption(UIControl* parent = nullptr) noexcept : UICaption(UICaption::s_meta) { this->final_ctor(parent); }
// link
void Link(UIGroupBox& box) noexcept { m_pGroupBox = &box; }
protected:
// add attribute
void add_attribute(uint32_t key, U8View value) noexcept override;
protected:
// group box
UIGroupBox* m_pGroupBox = nullptr;
};
// get meta info for UICaption
LUI_DECLARE_METAINFO(UICaption);
2 changes: 2 additions & 0 deletions include/control/ui_checkbox.h
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@ namespace LongUI {
class UICheckBox : public UIBoxLayout {
// super class
using Super = UIBoxLayout;
// private impl
struct Private;
public:
// on commnad event
static constexpr auto _onCommand() noexcept { return GuiEvent::Event_OnCommand; }
2 changes: 2 additions & 0 deletions include/control/ui_groupbox.h
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@ namespace LongUI {
~UIGroupBox() noexcept;
// ctor
explicit UIGroupBox(UIControl* parent = nullptr) noexcept : UIGroupBox(UIGroupBox::s_meta) { this->final_ctor(parent); }
// caption removed
void CaptionRemoved(UICaption& c) noexcept;
public:
//update this
//void Update() noexcept override;
2 changes: 2 additions & 0 deletions include/control/ui_label.h
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ namespace LongUI {
class UILabel : public UIControl {
// super class
using Super = UIControl;
// private impl
struct Private;
protected:
// ctor
UILabel(const MetaControl&) noexcept;
2 changes: 2 additions & 0 deletions include/control/ui_listheader.h
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ namespace LongUI {
class UIListHeader : public UIBoxLayout {
// super class
using Super = UIBoxLayout;
// private impl
struct Private;
public:
// class meta
static const MetaControl s_meta;
2 changes: 2 additions & 0 deletions include/control/ui_listitem.h
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ namespace LongUI {
class UIListItem : public UIBoxLayout {
// super class
using Super = UIBoxLayout;
// private impl
struct Private;
public:
// class meta
static const MetaControl s_meta;
4 changes: 4 additions & 0 deletions include/control/ui_menuitem.h
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ namespace LongUI {
class UIMenuItem : public UIBoxLayout {
// super class
using Super = UIBoxLayout;
// private impl
struct Private;
// init menuitem
void init_menuitem() noexcept;
protected:
@@ -58,6 +60,8 @@ namespace LongUI {
void SetText(CUIString&&) noexcept;
// set text
void SetText(U16View) noexcept;
// set text
void SetText(const CUIString&) noexcept;
public:
// ICON WIDTH
enum : uint32_t { ICON_WIDTH = 28 };
6 changes: 4 additions & 2 deletions include/control/ui_menulist.h
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ namespace LongUI {
class UIMenuList : public UIBoxLayout {
// super class
using Super = UIBoxLayout;
// private impl
struct Private;
// menu list
void init_menulist();
public:
@@ -71,10 +73,10 @@ namespace LongUI {
void SetText(CUIString&& text) noexcept;
// set text
void SetText(U16View text) noexcept;
// set selected index
//void SetSelectedIndex(long) noexcept;
// get selected index
long GetSelectedIndex() const noexcept { return m_iSelected; }
// set selected index
//void SetSelectedIndex(long) noexcept;
public:
// update
void Update(UpdateReason) noexcept override;
2 changes: 2 additions & 0 deletions include/control/ui_radio.h
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ namespace LongUI {
class UIRadio : public UIBoxLayout {
// super class
using Super = UIBoxLayout;
// private impl
struct Private;
// init radio
void init_radio() noexcept;
public:
2 changes: 2 additions & 0 deletions include/control/ui_textbox.h
Original file line number Diff line number Diff line change
@@ -185,6 +185,8 @@ namespace LongUI {
// set text
void SetText(CUIString&& text) noexcept;
// set text
void SetText(const CUIString& text) noexcept;
// set text
void SetText(U16View view) noexcept;
// request text, not const method
auto RequestText() noexcept -> const CUIString&;
2 changes: 2 additions & 0 deletions include/control/ui_tree.h
Original file line number Diff line number Diff line change
@@ -97,6 +97,8 @@ namespace LongUI {
void select_item(UITreeItem&, UITreeCell* cell) noexcept;
// is item in displaying
bool is_item_in_displaying(const UITreeItem&) const noexcept;
// write items
void write_item_appearance() noexcept;
protected:
// cols
UITreeCols* m_pCols = nullptr;
3 changes: 3 additions & 0 deletions include/luiconf.h
Original file line number Diff line number Diff line change
@@ -37,6 +37,9 @@
// using ctor locker to avoid blocking the rendering-thread
//#define LUI_USING_CTOR_LOCKER

// using _CrtMemState under MS's crtdbg.h chekc memleak between 2-points
//#define LUI_DEBUG_WINDOW_MEMLEAK

// ----------------------------------------------------------------------------

// LongUI Need Win7-PlatformUpdate
30 changes: 23 additions & 7 deletions src/control/gapi/ui_textbox_g.cpp
Original file line number Diff line number Diff line change
@@ -20,10 +20,9 @@

// uinamespace
namespace LongUI {
// private text box
// UITextBox类 私有实现
struct UITextBox::Private {
// doc type
//using doc_t = TextBC::CBCTextDocument;
using doc_t = RichED::CEDTextDocument;
// longui -> riched
static void ToRichED(const TextFont& tf, RichED::RichData& rd) noexcept;
@@ -61,6 +60,17 @@ namespace LongUI {
bool created = false;
// cached
bool cached = false;
// 设置新的字符串
template<typename T> static auto SetText(UITextBox& tbox, T && text) noexcept {
auto& cached = tbox.pimpl()->text_cached;
if (cached == text) return false;
cached = std::forward<T>(text);
tbox.NeedUpdate(Reason_ValueTextChanged);
#ifdef LUI_ACCESSIBLE
// TODO: ACCESSIBLE
#endif
return true;
}
};
/// <summary>
/// Privates the text box.
@@ -737,10 +747,16 @@ void LongUI::UITextBox::private_set_text() noexcept {
/// <param name="text">The text.</param>
/// <returns></returns>
void LongUI::UITextBox::SetText(CUIString&& text) noexcept {
//this->SetText(text.view());
auto& cached = pimpl()->text_cached;
cached = std::move(text);
this->NeedUpdate(Reason_ValueTextChanged);
Private::SetText(*this, std::move(text));
}

/// <summary>
/// Sets the text.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
void LongUI::UITextBox::SetText(const CUIString & text) noexcept {
return this->SetText(text.view());
}

/// <summary>
@@ -749,7 +765,7 @@ void LongUI::UITextBox::SetText(CUIString&& text) noexcept {
/// <param name="view">The view.</param>
/// <returns></returns>
void LongUI::UITextBox::SetText(U16View view) noexcept {
this->SetText(CUIString(view));
Private::SetText(*this, view);
}


6 changes: 3 additions & 3 deletions src/control/ui_box.cpp
Original file line number Diff line number Diff line change
@@ -277,10 +277,10 @@ void LongUI::UIBoxLayout::relayout_this() noexcept {
if (this->GetChildrenCount()) {
// 更新布局
const auto ishor = m_state.orient == Orient_Horizontal;
return ishor ? this->relayout_h() : this->relayout_v();
ishor ? this->relayout_h() : this->relayout_v();
// 更新子控件
for (auto& child : *this)
child.NeedUpdate(Reason_NonChanged);
//for (auto& child : *this) child.NeedUpdate(Reason_NonChanged);

}
}

57 changes: 34 additions & 23 deletions src/control/ui_button.cpp
Original file line number Diff line number Diff line change
@@ -17,12 +17,35 @@
#include <core/ui_unsafe.h>
#include "../private/ui_private_control.h"


#ifdef LUI_ACCESSIBLE
#include <accessible/ui_accessible_callback.h>
#include <accessible/ui_accessible_event.h>
#include <accessible/ui_accessible_type.h>
#include <core/ui_string.h>
#endif


// ui namespace
namespace LongUI {
// UIButton类 元信息
LUI_CONTROL_META_INFO(UIButton, "button");
// UIButton私有实现
struct UIButton::Private {
// 设置新的文本
template<typename T> static auto SetText(UIButton& cbox, T && text) noexcept {
cbox.add_private_child();
if (cbox.m_oLabel.SetText(std::forward<T>(text))) {
cbox.mark_window_minsize_changed();
#ifdef LUI_ACCESSIBLE
LongUI::Accessible(cbox.m_pAccessible, Callback_PropertyChanged);
#endif
}
}
};
}


/// <summary>
/// Gets the text.
/// </summary>
@@ -125,17 +148,9 @@ void LongUI::UIButton::set_label_flex(float f) noexcept {
/// <param name="text">The text.</param>
/// <returns></returns>
void LongUI::UIButton::SetText(const CUIString& text) noexcept {
this->SetText(CUIString{ text });
this->SetText(text.view());
}

/// <summary>
/// Sets the text.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
void LongUI::UIButton::SetText(U16View text) noexcept {
this->SetText(CUIString(text));
}


/// <summary>
@@ -179,27 +194,23 @@ auto LongUI::UIButton::DoInputEvent(InputEventArg e) noexcept -> EventAccept {
}


#ifdef LUI_ACCESSIBLE
#include <accessible/ui_accessible_callback.h>
#include <accessible/ui_accessible_event.h>
#include <accessible/ui_accessible_type.h>
#include <core/ui_string.h>
#endif


/// <summary>
/// Sets the text.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
void LongUI::UIButton::SetText(CUIString&& text) noexcept {
this->add_private_child();
if (m_oLabel.SetText(std::move(text))) {
this->mark_window_minsize_changed();
#ifdef LUI_ACCESSIBLE
LongUI::Accessible(m_pAccessible, Callback_PropertyChanged);
#endif
}
Private::SetText(*this, std::move(text));
}

/// <summary>
/// Sets the text.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
void LongUI::UIButton::SetText(U16View text) noexcept {
Private::SetText(*this, text);
}

/// <summary>
8 changes: 3 additions & 5 deletions src/control/ui_caption.cpp
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ namespace LongUI {
/// </summary>
/// <param name="meta">The meta.</param>
LongUI::UICaption::UICaption(const MetaControl& meta) noexcept : Super(meta) {
m_oStyle.appearance = Appearance_Caption;
m_oStyle.appearance = Appearance_WeakApp | Appearance_Caption;
//this->SetBgColor({ RGBA_White });
}

@@ -28,10 +28,8 @@ LongUI::UICaption::UICaption(const MetaControl& meta) noexcept : Super(meta) {
/// </summary>
/// <returns></returns>
LongUI::UICaption::~UICaption() noexcept {
// TODO: 取消groupbox引用
//if (m_pParent && !m_pParent->m_state.destructing) {

//}
// 取消groupbox引用
if (m_pGroupBox) m_pGroupBox->CaptionRemoved(*this);
}

/// <summary>
Loading

0 comments on commit 3fc0148

Please sign in to comment.