Skip to content

Commit

Permalink
Improving visual display of complex fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Nov 12, 2024
1 parent a1fe143 commit 1be9b1f
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 51 deletions.
1 change: 1 addition & 0 deletions app/cc_view/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function (bin_cc_view)
ui/EnumValueFieldWidget.ui
ui/StringFieldWidget.ui
ui/BitfieldFieldWidget.ui
ui/BundleFieldWidget.ui
ui/OptionalFieldWidget.ui
ui/ArrayListRawDataFieldWidget.ui
ui/ArrayListFieldWidget.ui
Expand Down
52 changes: 34 additions & 18 deletions app/cc_view/src/ui/BitfieldFieldWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>305</width>
<height>27</height>
<width>346</width>
<height>65</height>
</rect>
</property>
<property name="windowTitle">
<string>Bitfield Field</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,1">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,1">
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -29,9 +29,6 @@
<item>
<widget class="QWidget" name="m_valueWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -45,14 +42,36 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_nameLabel">
<property name="text">
<string>Bitfield</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="m_nameLabel">
<property name="text">
<string>Bitfield</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="m_membersLayout"/>
<widget class="QGroupBox" name="m_membersGroupBox">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="m_membersLayout"/>
</widget>
</item>
</layout>
</widget>
Expand All @@ -66,10 +85,7 @@
</item>
<item>
<widget class="QWidget" name="m_serValueWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
Expand Down Expand Up @@ -106,8 +122,8 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>98</width>
<height>20</height>
<width>95</width>
<height>22</height>
</size>
</property>
</spacer>
Expand Down
36 changes: 17 additions & 19 deletions app/cc_view/src/ui/BitmaskValueFieldWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>283</width>
<height>29</height>
<width>263</width>
<height>65</height>
</rect>
</property>
<property name="windowTitle">
<string>Bitmask Value Field</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="1,0,1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -28,10 +28,7 @@
</property>
<item>
<widget class="QWidget" name="m_valueWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>6</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
Expand All @@ -47,18 +44,11 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="m_nameLabel">
<property name="text">
<string>Bits:</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="m_checkboxesLayout"/>
</item>
</layout>
<widget class="QLabel" name="m_nameLabel">
<property name="text">
<string>Bits:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
Expand All @@ -75,6 +65,14 @@
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="m_checkboxesGroupBox">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="m_checkboxesLayout"/>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
83 changes: 83 additions & 0 deletions app/cc_view/src/ui/BundleFieldWidget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BundleFieldWidget</class>
<widget class="QWidget" name="BundleFieldWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>346</width>
<height>65</height>
</rect>
</property>
<property name="windowTitle">
<string>Bundle Field</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="m_valueWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="m_nameLabel">
<property name="text">
<string>Bundle</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="m_membersGroupBox">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="m_membersLayout"/>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
19 changes: 8 additions & 11 deletions app/cc_view/src/widget/field/BundleFieldWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ BundleFieldWidget::BundleFieldWidget(
FieldPtr fieldPtr,
QWidget* parentObj)
: Base(parentObj),
m_fieldPtr(std::move(fieldPtr)),
m_membersLayout(new QVBoxLayout),
m_label(new QLabel)
m_fieldPtr(std::move(fieldPtr))
{
m_label->hide();
m_membersLayout->addWidget(m_label);
setLayout(m_membersLayout);
setNameLabelWidget(m_label);
m_ui.setupUi(this);
setNameLabelWidget(m_ui.m_nameLabel);
setValueWidget(m_ui.m_valueWidget);

commonConstruct();
}
Expand All @@ -49,16 +46,16 @@ void BundleFieldWidget::addMemberField(FieldWidget* memberFieldWidget)
{
m_members.push_back(memberFieldWidget);

if (1 < m_membersLayout->count()) {
if (0 < m_ui.m_membersLayout->count()) {
auto* line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);

m_membersLayout->addWidget(line);
m_ui.m_membersLayout->addWidget(line);
}

m_membersLayout->addWidget(memberFieldWidget);
assert(static_cast<std::size_t>(m_membersLayout->count()) == (m_members.size() * 2));
m_ui.m_membersLayout->addWidget(memberFieldWidget);
assert(static_cast<std::size_t>(m_ui.m_membersLayout->count()) == ((m_members.size() * 2) - 1));

connect(
memberFieldWidget, SIGNAL(sigFieldUpdated()),
Expand Down
5 changes: 2 additions & 3 deletions app/cc_view/src/widget/field/BundleFieldWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "cc_tools_qt/field/ToolsBundleField.h"
#include "FieldWidget.h"
#include "ui_BundleFieldWidget.h"

namespace cc_tools_qt
{
Expand Down Expand Up @@ -55,10 +56,8 @@ private slots:
void memberFieldUpdated();

private:

Ui::BundleFieldWidget m_ui;
FieldPtr m_fieldPtr;
QVBoxLayout* m_membersLayout = nullptr;
QLabel* m_label = nullptr;
std::vector<FieldWidget*> m_members;
};

Expand Down

0 comments on commit 1be9b1f

Please sign in to comment.